1 registered members (AbrahamR),
717
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
an emulated shadow for my models!?
#414729
01/07/13 09:41
01/07/13 09:41
|
Joined: Jan 2013
Posts: 23 France
Mo222
OP
Newbie
|
OP
Newbie
Joined: Jan 2013
Posts: 23
France
|
Hello,
I am trying to make a script to add shadows for my models. I am having big troubles with vectors and angles.
my biggest problem so far is my ignorance of the whole C-script.I know the basics of C-script , but when it comes to angles , it becomes illogic in my head.
I searched in the manual and i know that 3 angles affect the orientation of the model in the world : -pan -tilt -roll
While pan and roll are 0-360 , tilt is -90 to 0 to 90 ...... Why is tilt different from pan and roll? i can find a solution yet for my shadows.
Since A6 doesnt cast model shadow on another model, then i decided(as superku advised me) to create a homemade function for shadows to cast on any surface.
In order to do that , lets say there is a little toon running in levels made of cubes(cubes that are models).
-i made the script of the little toon(gravity, move,etc..) -i attach to the little toon his shadow (his shadow is the same model that i would shrink and make dark) -i let the toon perform a trace from him to the ground in the direction of the sun. -Where the trace hit the ground , i put the shadow there. -I animate the shadow like the little toon (my.frame=you.frame)
And now the problem. -Now i want the shadow to give the right face of the toon on the ground. For example : if the toon gives his side to the sun, then i want the shadow to show his side on the ground . If the toon gives his back to the sun, then the shadow is showing her back on the ground,etc...
I understood that it was not possible to change pan,tilt,roll directly , because A6 then confuses tilt and roll, and it doesnt work. After you tilted the shadow to make it horizontal on the ground, i cant make it turn like the pan of the toon with direct changes of pan,tilt,roll . 1 angle is blocked.
Then i tried with ang_add . And now i have the problem of the tilt range(-90,0,+90) which doesnt match with pan and roll range(0,360) , then how can i use that to make an instruction that would something like: shadow_toon.tilt=toon.pan; and the whole combination in an ang_add instruction.........
Somebody tried to make this kind of shadow?
|
|
|
Re: an emulated shadow for my models!?
[Re: Mo222]
#414740
01/07/13 11:08
01/07/13 11:08
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
The angles are not limited, you can keep pan/ roll between -180 and 180 and still describe the whole sphere (see spherical coordinates on Wikipedia)/ all angles.
Try something as follows:
// in the player function after c_move: c_trace(my.x,vector(my.x,my.y,my.z-2000),IGNORE_PASSABLE | IGNORE_ME); if(trace_hit) { vec_rotate(normal,vector(-my.pan,0,0)); my_shadow.tilt = -asin(normal.x); my_shadow.roll = -asin(normal.y); }
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
|