Getting Prims to Follow the Sun
|
|
Miriel Enfield
Prim Junkie
Join date: 12 Dec 2005
Posts: 389
|
02-21-2008 15:58
I want to make some prim sunbeams that follow the sun (and do other things, based on the time of day, but I'm not having trouble with those). I know I have to set a timer, manipulate the result from llGetSunDirection(), and tie the prim's rotation to that, but I'm not sure _how_. I'd been denormalizing (unnormalizing?) the vector from llGetSunDirection(), turning that into a rotation, and setting the prim's rotation to that, but (as I'm sure those of you that know what you're doing have realized) that isn't having the desired result.
Can anyone give me any tips, script snippets, or explanations about what I'm supposed to be doing and why? (The last would be awesome, if you can manage it -- I always like to learn how to catch my own fish, when possible.)
Thanks!
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
02-21-2008 17:10
because I've never played with this....
does the sun have a set distance? one that's relative to a single point on the sim?
what I'm getting at is, while the suns angle for the sim is a known, is it's position known?
because if you can't get a position, then your overlay of rays will only look right for one spot on the sim... change the angle of the person viewing it and it'll be off.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Miriel Enfield
Prim Junkie
Join date: 12 Dec 2005
Posts: 389
|
02-21-2008 17:26
Lslwiki.net says:
"For all intents and purposes, the sun can be considered infinitely far away compared to the scale of the world. That is, its direction (and light) is uniform not only over the entire simulator but over the entire world."
So the viewer changing position shouldn't be an issue.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
02-21-2008 18:09
The direction of the sun fixes two degrees of freedom. You need to figure out how to handle the third. You can picture this by pointing your index finger at something and then rotating your hand about an axis that is along your finger, while still pointing at your target. If you want, for example, to keep the y-axis level, you could do: vector localX = llGetSunDirection(); vector localY; if (localX.x == 0.0 && localX.y == 0.0) { // Arbitrary horizontal vector; point "south" (if you pitch down to level in the usual human-head fashion) localY = <1.0, 0.0, 0.0>; } else { localY = llVecNorm(<-localX.y, localX.x, 0.0>); // Same as <0.0, 0.0, 1.0>%localX cross product } // Already normalized, since localX and localY are orthonormal vector localZ = localX%localY;
rotation rot = llAxes2Rot(localX, localY, localZ);
|
|
gonkerplumb Flanagan
Landscape Designer
Join date: 6 Feb 2007
Posts: 20
|
02-22-2008 00:08
Hi,
I have played around with shadows in world, Drop me an IM inworld and I'll help out if I can!
Gonks
_____________________
You will be delighted and enchanted with your garden, when you garden with Gonks!
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
02-22-2008 03:22
From: Miriel Enfield Lslwiki.net says:
"For all intents and purposes, the sun can be considered infinitely far away compared to the scale of the world. That is, its direction (and light) is uniform not only over the entire simulator but over the entire world."
So the viewer changing position shouldn't be an issue. my point was how do you situate an object that must be within draw distance, and IS subject to parallax, between any two viewrs, at two different points, so that it aligns with the sun for both viewers? or put more simply, even if the sun is seen at the same angle from all spots on a sim, surely the object being placed won't. it'll be seen at different angles from different points.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
02-22-2008 09:14
From: Void Singer my point was how do you situate an object that must be within draw distance, and IS subject to parallax, between any two viewrs, at two different points, so that it aligns with the sun for both viewers?
or put more simply, even if the sun is seen at the same angle from all spots on a sim, surely the object being placed won't. it'll be seen at different angles from different points. How about the Sun in real life? To a human viewer, it might as well be infinitely far away, the distance is so large compared the scales on which we operate. And that's usually the way it is modeled in computer graphics as well: light rays from a "Sun" type lightsource are simply given a direction (and assumed to fill all space except where blocked from that direction by objects). So, if you point in the direction of the Sun, do other people around you see you as pointing at it? Does it matter where they stand?
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
02-22-2008 15:14
perhaps I misread OPs meaning...
after Heewee's question, it struck me that OP might have (probably?) meant local volumentric lighting (like sun filtering through the leaves) rather than the more literal picture of cartoon style rays attached to the actual sun. The latter would suffer the problem I was talking about... the former, very little at all (since it is the endpoint)...
apologies for the confusion.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Miriel Enfield
Prim Junkie
Join date: 12 Dec 2005
Posts: 389
|
02-22-2008 16:25
Thank you, Hewee and gonkerplumb. I have to admit I'm confused about Hewee's explanation, but I'll spend some more time trying to sort this all out in my head. From: Void Singer after Heewee's question, it struck me that OP might have (probably?) meant local volumentric lighting (like sun filtering through the leaves) rather than the more literal picture of cartoon style rays attached to the actual sun. The former is exactly what I meant. 
|