Difference between revisions of "LlGetSunDirection/ja"

From Second Life Wiki
Jump to navigation Jump to search
m (Undo revision 851012 by Mako Nozaki (Talk))
m (sync with english page)
Line 1: Line 1:
{{LSL_Function/ja
{{Issues/VWR-3717}}{{LSL_Function/ja
|func_id=177|func_sleep=0.0|func_energy=10.0
|func_id=177|func_sleep=0.0|func_energy=10.0
|func=llGetSunDirection|return_type=vector
|func=llGetSunDirection|return_type=vector
Line 93: Line 93:
|cat2=Time
|cat2=Time
|cat3=Light
|cat3=Light
|cat4
|cat4=Weather
|cat5
|cat5
|cat6
|cat6
}}
}}

Revision as of 02:42, 16 April 2010

要約

関数: vector llGetSunDirection( );

リージョンの太陽の方角を vector で返します。

太陽の位置はSimオーナの希望次第で動的あるいは固定にできます。

サンプル

これはスクリプトの動作により日中あるいは夜間(SL時間での短いもの)かどうかを素早く決定するのに用いることができます。返されるベクトルのZ要素が正の域の場合、太陽は地平線より上にあります。 <lsl>integer lightsOn = -1;//not TRUE or FALSE

CheckSun() {

   vector sun = llGetSunDirection();
   integer turnLightsOn = (sun.z < 0);
   if(turnLightsOn != lightsOn)
   {
       lightsOn = turnLightsOn;
       llSetPrimitiveParams([ PRIM_FULLBRIGHT, ALL_SIDES, lightsOn ]);
   }
}</lsl>

注意点

AVERAGE_SUN_TILT = -.25 * pi
SEASONAL_SUN_TILT = .03 * pi
SUN_NORMALIZED_OFFSET = .45

これはmSunOffsetがどのように計算されているかをあらわしています。 <cpp>F64 daily_phase = DAILY_OMEGA * U64_to_F64(local_time / USEC_PER_SEC); F32 sun_phase = (F32)fmod(daily_phase, 2.0*F_PI); sun_hour -= 6.0f; mSunOffset = HOURS_TO_RADIANS * sun_hour - (0.25f * F_PI) * cosf(HOURS_TO_RADIANS * sun_hour) - sun_phase;

//And here's how sun direction is calculated:

void LLRegion::calculateSunInfo(

      U64 current_time,
      LLVector3& directionp,
      LLVector3& ang_velocityp,
      F32& sun_phase)

{

  U64 local_time = current_time;
  if(getSunFixed())
  {
      local_time = 0;
  }
    // Sun moves (once a day) about a circle that lies on a tilted plane.
    // The angle of the plane cycles (once a year) a few radians about
    // some average.
    // These are F64's, otherwise we get rounding errors over time
  F64 daily_phase  = DAILY_OMEGA * U64_to_F64(local_time / USEC_PER_SEC) + mSunOffset;
  F64 yearly_phase = YEARLY_OMEGA * U64_to_F64(local_time / USEC_PER_SEC);
  F32 tilt = AVERAGE_SUN_TILT + SEASONAL_SUN_TILT_AMPLITUDE * (F32)sin(yearly_phase);
  sun_phase = (F32)fmod(daily_phase, 2.0*F_PI);
    // move sun around a circle
  directionp.setVec((F32)cos(-daily_phase), (F32)sin(-daily_phase), 0.0f);
    //tilt the circle about X-axis (due east)  
  directionp.rotVec(tilt, 1.0f, 0.0f, 0.0f);
    // calculate angular velocity (radians per second)
  ang_velocityp.setVec(0.0f, 0.0f, (F32)DAILY_OMEGA);
  ang_velocityp.rotVec((F32)tilt, 1.0f, 0.0f, 0.0f);
    // James wanted the night to be shorter than the day.
    // We can do this by offsetting the center of the sun's orbit in the positive
    // z-direction and normalizing the new vector.
  directionp.mV[VZ] += SUN_NORMALIZED_OFFSET;
  F32 R = directionp.normVec();
    // We also need to correct the angular velocity
    //
    // V = W % R
    // V has constant magnitude
    // As R goes up, W must go down
    // W and R are always perpendicular
    // ===>
    // W *= 1 /

関連項目

関数

•  llGetTimeOfDay

特記事項

All Issues

~ Search JIRA for related Issues
   llGetSunDirection not accurate

Signature

function vector llGetSunDirection();
この翻訳は 原文 と比べて古いですか?間違いがありますか?読みにくいですか?みんなで 修正 していきましょう! (手順はこちら)
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。