getting the sun direction
by Bendik Stang · in Torque Game Engine · 12/09/2002 (8:45 am) · 7 replies
Does anyone know how I can access the sun object?
I need the direction, the color and the ambient color.
(=> baked shadows in the fxGrassReplicator.)
-Bendik
I need the direction, the color and the ambient color.
(=> baked shadows in the fxGrassReplicator.)
-Bendik
#2
I don't use the ND patch yet.
I guess I will have to, but I wanted to write the code so that you could use it with the lates head, without adding all sorts of extra code.
*goes too look at the DN code*
Thanks for the tip Adam!
12/11/2002 (2:40 am)
oh, scary externs!I don't use the ND patch yet.
I guess I will have to, but I wanted to write the code so that you could use it with the lates head, without adding all sorts of extra code.
*goes too look at the DN code*
Thanks for the tip Adam!
#3
12/11/2002 (2:46 am)
I thought those variables were exposed on the sun object itself in the HEAD code..
#4
I'm not using the fancy Day/Night cycles either!
So, in that regard, hope this helps.
I named my sun "ScorchedSun" for the Scorched mission you get with Torque.
If you name a datablock when it's created, you can simply ask for its information, such as:
//The following is in the mission file
Hope this help :)
12/13/2002 (2:26 am)
Hey Bendik,I'm not using the fancy Day/Night cycles either!
So, in that regard, hope this helps.
I named my sun "ScorchedSun" for the Scorched mission you get with Torque.
If you name a datablock when it's created, you can simply ask for its information, such as:
ScorchedSun.dump();
%pos = ScorchedSun.position;
%rot = ScorchedSun.rotation;
%dir = ScorchedSun.direction;
%amb = ScorchedSun.ambient;
echo("Pos: " @ %pos @ " Rot: " @ %rot);
echo("Dir: " @ %dir @ " Amb: " @ %amb);Put that in a function, and name your sun something, such as://The following is in the mission file
new Sun(ScorchedSun) {
direction = "0 -0.941742 -0.336336";
color = "0.988000 0.980000 0.883000 1.000000";
ambient = "0.703000 0.844000 0.910000 1.000000";
position = "0 0 0";
rotation = "1 0 0 0";
locked = "true";
scale = "1 1 1";
};//End mission fileHope this help :)
#5
And this method can be applied to any other object in the game, I pressume!
A very nice tip indeed.
Thank you!
:)
Bendik
12/13/2002 (3:15 am)
Now that was exactly what I was looking for!And this method can be applied to any other object in the game, I pressume!
A very nice tip indeed.
Thank you!
:)
Bendik
#6
If you were dealing with something other than a Sun, for example a Wooden Crate, you may have several Wooden Crates sitting around, all with the same name, but each one would have a different object handle(a number).
There's a few ways you can get that object number, such as a raycast. In our sun example, if you used 1233(assuming 1233 is the object number for the sun), you could replace ScorchedSun with 1233 wherever you wanted.
Take a look in game, hit F11 and you'll see what I mean about the numbers. (Sorry if you already knew this )
:)
-Jared
12/13/2002 (11:51 am)
Yep, and I bet it would be trivial to make this a tad more dynamic.If you were dealing with something other than a Sun, for example a Wooden Crate, you may have several Wooden Crates sitting around, all with the same name, but each one would have a different object handle(a number).
There's a few ways you can get that object number, such as a raycast. In our sun example, if you used 1233(assuming 1233 is the object number for the sun), you could replace ScorchedSun with 1233 wherever you wanted.
Take a look in game, hit F11 and you'll see what I mean about the numbers. (Sorry if you already knew this )
:)
-Jared
#7
12/14/2002 (10:21 am)
If you're looking for the light direction, I'd suggest looking through the code where it generates the lightmap for the terrain - it needs to know where the light is, so copy-paste :)
Torque Owner Adam "OnO" Strzelecki
Isn't it in atgeDayNight.h:
Look at game/shapeBase.cc around line 2504 for shadow rendering too.
Cheers,
Adam
I'm thinking about making shadows for my trees too.