Static shape = no shadow ?
by Bendik Stang · in Torque Game Engine · 03/13/2002 (1:58 pm) · 17 replies
I have made some models in max and exported them to dts. Problem is that the objects does not cast a shadow on the ground. (trees and buildings) Is there an easy fix to this?
Also, the buildings shading gets a bit weird, depending on the sun's position. I have began looking at the map2dif. (As the interior objects do cast a nice shade.)
But I have found no documentation on going from dts2dif ...and I might no need the objects to have a unique lightmap on them.
...so what do I do?
Also, the buildings shading gets a bit weird, depending on the sun's position. I have began looking at the map2dif. (As the interior objects do cast a nice shade.)
But I have found no documentation on going from dts2dif ...and I might no need the objects to have a unique lightmap on them.
...so what do I do?
#2
Anyway... its that or make some engine modifications.
03/13/2002 (2:46 pm)
If you want shadows, you'll have to use the .dif format... For this you'll need World Craft or Quark. There is a tool available to covert models to the .map format wich can be read by Quark or WorldCarft, so you can try that (but I'm not sure if that works well)Anyway... its that or make some engine modifications.
#3
03/13/2002 (2:47 pm)
heheh... same post at the exact same time (ok, you beat me with a couple of seconds)
#4
The max2map does not work with max4...
Anyone made a compilation that runs with max4 ?
*begins to figure out worldcraft*
03/13/2002 (3:56 pm)
Thanks for the quick answers. :)The max2map does not work with max4...
Anyone made a compilation that runs with max4 ?
*begins to figure out worldcraft*
#5
03/13/2002 (4:46 pm)
It doesn't work with r3.1 either.
#6
Sheah! Not as difficult as you make it sound. I've only had Torque for two days and I have a solution. The solution doesn't add shadows to static shapes, but allows you to easily use DTS files as regular shapes and regular shapes have shadows. In fact it's so easy, I'll add my own little mini tutorial right now.
For my extensive tutorial, we'll assume that you want to use a sphere that you made in 3ds Max that happens to be called sphere.dts:
1. In your "server" folder, create a file and name it "shapes.cs" or something, then slap this code in it and save it:
datablock StaticShapeData(sphereItem)
{
category = "Items";
shapeFile = "~/data/shapes/sphere/sphere.dts";
};
2. In the same folder there is a file called game.cs. Open it and add the line:
exec("./shapes.cs");
to the function onServerCreated() where the other exec stuff is listed.
3. Go into the World Editor Creator, add the sphere shape and be happy.
NOTE: This worked with the shape I exported myself, however I did try using this with the tree that came with one of the tutorials and for some reason it isn't casting a shadow.
Yes, I'm aware that this will end up making a huge list of datablocks, but hey. You got shadows!
01/16/2007 (11:28 pm)
"Or hack the code to allow shadows on any shape!"Sheah! Not as difficult as you make it sound. I've only had Torque for two days and I have a solution. The solution doesn't add shadows to static shapes, but allows you to easily use DTS files as regular shapes and regular shapes have shadows. In fact it's so easy, I'll add my own little mini tutorial right now.
For my extensive tutorial, we'll assume that you want to use a sphere that you made in 3ds Max that happens to be called sphere.dts:
1. In your "server" folder, create a file and name it "shapes.cs" or something, then slap this code in it and save it:
datablock StaticShapeData(sphereItem)
{
category = "Items";
shapeFile = "~/data/shapes/sphere/sphere.dts";
};
2. In the same folder there is a file called game.cs. Open it and add the line:
exec("./shapes.cs");
to the function onServerCreated() where the other exec stuff is listed.
3. Go into the World Editor Creator, add the sphere shape and be happy.
NOTE: This worked with the shape I exported myself, however I did try using this with the tree that came with one of the tutorials and for some reason it isn't casting a shadow.
Yes, I'm aware that this will end up making a huge list of datablocks, but hey. You got shadows!
#7
To my ShapeBaseData-derived-object's constructor and shadows magically appeared.
Gary (-;
01/17/2007 (10:15 am)
I just addedgenericShadowLevel = 0.4f; noShadowLevel = 0.02f; shadowEnable = true; shadowCanMove = true; shadowCanAnimate = true;
To my ShapeBaseData-derived-object's constructor and shadows magically appeared.
Gary (-;
#8
The way I did it, I didn't have to add shadowEnable to anything... just creating the StaticShapeData itself worked fine. However, I did find out that it DID work with the tree, but the shadow just appears very lightly and blurry because the bounding box for the tree was so huge. For some reason that makes a huge difference in the shadow.
I can figure out how you were saying to do that if you tell me where exactly you put it... I'd appreciate it. :)
01/18/2007 (2:56 pm)
Gary, is that a better way of doing it? If so, I'd be interested in a specific example. Like if you just showed me where you put that code that you posted, I could take it from there.The way I did it, I didn't have to add shadowEnable to anything... just creating the StaticShapeData itself worked fine. However, I did find out that it DID work with the tree, but the shadow just appears very lightly and blurry because the bounding box for the tree was so huge. For some reason that makes a huge difference in the shadow.
I can figure out how you were saying to do that if you tell me where exactly you put it... I'd appreciate it. :)
#9
Honestly if shadows are there, then I'm not sure how to go about tweaking them. You could also just try adding to your datablock defn thusly and seeing if it helps:
Gary (-;
01/18/2007 (3:14 pm)
The stuff I listed there is for C++, assuming you have an object derived from a shapeBase... you're presumably only doing this in torquescript.Honestly if shadows are there, then I'm not sure how to go about tweaking them. You could also just try adding to your datablock defn thusly and seeing if it helps:
datablock StaticShapeData(sphereItem)
{
category = "Items";
shapeFile = "~/data/shapes/sphere/sphere.dts";
shadowEnable = true;
shadowCanMove = true;
shadowCanAnimate = true;
};Gary (-;
#10
So yeah, if you'd tell me where you put that on yours, or an example of where you put it (if you added it to multiple places), that'd help tremendously. I promise I won't follow up the answer with "how do u make a new game in c++???".
PS. I am having trouble with that tree again.... it's not casting a shadow like I thought, that's why I want to try it your way. :)
01/18/2007 (4:49 pm)
I'd prefer it if your C++ way made it so that I didn't have to create a datablock for every custom shape I put in, which is going to be a lot. I know that I'm pretty much a noob, but I know enough C++ to figure out where to add things and how to arrange things so that they will compile correctly, even if I don't really know what's going on... However, I do know how to recompile the engine to create a new torqueDemo.exe and have done it successfully using vs2005, which I'm pretty proud of myself for, heheh.So yeah, if you'd tell me where you put that on yours, or an example of where you put it (if you added it to multiple places), that'd help tremendously. I promise I won't follow up the answer with "how do u make a new game in c++???".
PS. I am having trouble with that tree again.... it's not casting a shadow like I thought, that's why I want to try it your way. :)
#11
01/18/2007 (6:20 pm)
This thread is nearly 5 years old.
#13
...which is why I find it strange that dts shapes still don't have shadows by default. Heh.
01/18/2007 (8:46 pm)
"This thread is nearly 5 years old."...which is why I find it strange that dts shapes still don't have shadows by default. Heh.
#14
The trees weren't casting shadows because the sun azimuth was 0. Upon changing it to 25, I had tree shadows. Neat huh? I don't know why trees need that and the other stuff I was playing with didn't, but eh, who cares?
01/20/2007 (6:29 pm)
Sorry for bumping the dusty old thread again (I know you vets hate that), but it's still relevant, so I thought I would post a finding:The trees weren't casting shadows because the sun azimuth was 0. Upon changing it to 25, I had tree shadows. Neat huh? I don't know why trees need that and the other stuff I was playing with didn't, but eh, who cares?
#15
I stopped by because I have the opposite problem. I want certain TSStatic objects to NOT cast shadows ;) Still looking.
04/20/2007 (8:10 am)
To clarify, TSStatic objects cast shadows these days, assuming the sun is not overhead as Charles mentioned. I stopped by because I have the opposite problem. I want certain TSStatic objects to NOT cast shadows ;) Still looking.
#16
shadowEnable = false;
in your datablock definition. Works for my RigidShape-derived objects.
04/20/2007 (11:25 am)
@Matthew: try shadowEnable = false;
in your datablock definition. Works for my RigidShape-derived objects.
#17
shadowCanMove should only be true for things like players and vehicles etc.
04/20/2007 (9:58 pm)
To add my 5 cents, setting shadowCanMove = true on a static is a bad idea because it tells the shadow class to re-run the buildPartition() method on every frame which will dent your frame rate for no usefull reason.shadowCanMove should only be true for things like players and vehicles etc.
Torque 3D Owner Phil Carlisle
Difs are made with worldcraft, they have shadows on em.
Either make your shapes with worldcraft, or give max2map a try..
Or hack the code to allow shadows on any shape!
Phil.