Game Development Community

Blender LOD for animated shapes

by Gustavo Munoz · in Artist Corner · 11/19/2005 (10:10 am) · 13 replies

Hi everybody:

I saw a few old posts about people not getting the Levels Of Detail working when using an Armature to deform a shape.
I have tried some options and finally I got it working fine. I am currently using Blender 2.7a and the last version of the dts exporter.

First, I implemented some resource I found anywhere here. I don't remember who was the author, but it is not mine:

----------------------------
In tsStatic.cc near line 238 you need to change a true/false condition as shown below.

if (image->isTranslucent == true)
{
TSShapeInstance::smNoRenderNonTranslucent = true;
TSShapeInstance::smNoRenderTranslucent = false;
}
else
{
TSShapeInstance::smNoRenderNonTranslucent = false;
TSShapeInstance::smNoRenderTranslucent = false; // was true
}
Blender models now work perfectly giving all LOD's and transparent faces work too.
I also tested with the Max Orc and it still works fine as well.
--------------------------------

The next problem was getting the same armature to deform all the diferent meshes with the same action. My solution was to make an instance (a dependent copy) of the armature for the first LOD mesh, with alt+D inside Blender, and use it as the parent for the second LOD mesh. Here you have a blend file with a simple example:

http://www.gustavom.com/images/otros/LODs.zip

I have exported the model and it works ok in TSTpro, you see the 2 LOD with the same animation and working just right. I have also exported it as a player dts, and once in Torque it works also fine.

But when I try to get it inside Torque as a static shape I have some troubles:

-if I use just the dts, the simple cs and the dsq, and import it as a static shape, I got the LODs working, but no animation at all.

-And I have tried to make it a Misc. item, using a .cs script from another tuto (the radar one with videotuto, great material):
------------------------------
datablock StaticShapeData(Radar_part2)
{
category = "Misc";
shapeFile = "~/tuts/radar_part2.dts";
};

function Radar_part2::onAdd(%this,%obj)
{
%obj.playThread(0,"Action");
}

function StaticShapeData::create(%block)
{
%obj = new StaticShape()
{
dataBlock = %block;
};
return(%obj);
}
----------------------------
Changing names and paths, of course, and I got it running inside Torque as an animated shape from the misc. folder, but then the first LOD does not work at all, and I don't see the model untill I am very near it. But this way the animation is working...


So, I need to learn some more basic scripting for Torque, but Blender LODs are working right ;)

I hope it is usefull for somebody. Regards.

#1
11/20/2005 (2:53 am)
Thanks for the info and the sample .blend file. I'm not at the point where I am playing with LODs, but now I know where to look when I do.
#2
11/23/2005 (10:01 pm)
I am also currently trying to figure out LODs. I have an animated character already skinned etc, that can be used for testing.
PLease let me know how i can help. not a programmer but a 3D modeler.

correct me if im wrong but:
-each level of detail has its own Mesh AND armature/skeleton (copies of orig).

-only the 1st armature needs the animation sequences, as other skeletons will use the same node naming and there fore the same animations.

-each LOD is created by hand...? or do we have an automated LOD generator?

-also, does this mean we can use differnt materials for each LOD?
#3
11/26/2005 (4:41 am)
Ok, i got LODs to show up in Show tool pro, but the viewer is NOT detecting a pixel size for my figure.
any ideas?
Thanks.
#4
11/26/2005 (4:57 am)
Hi Alaric: I am also a 3D artist, not a programmer.

- Yes
- Yes
- Yes. We currently have just the decimator tool, not very usefull because it destroys UVs and it is not so good mantaining meaningfull shapes. I would better build them by hand.
- Yes, see the example.

The pixelsize is determined by the number in each LOD name.

Let me know any new feature you got working :)

Regards.
#5
11/26/2005 (5:19 am)
Got em all working.
I have characters in with full animations, skinned proper, correct LOS and collision detection.
Have multiple LODs...
only issue is that LODs "pixel size" is not being detected by Show Tool Pro. so its not changing the detail levels automatically. but if you use the slider, they are there.

suggestions?

My markers are named:
Detail200
Detail100
Detail60
...bla bla bla/ whatevery levels you want.

Only other issue seems to be in Torque, where the game is rendering ALL levels of detail together.
but there is readings around here on that issue too.

I got a great player.blend that I did in the last hour, if anyone wants to see the proper setup for meshs and nodes and LODs with animation. Email me.

if i can find someone to host a tutorial, I'll record one, or build it.
Blender is worth it.
So is this community.
maybe for a Xmax gift to everyone.
#6
11/26/2005 (5:29 am)
Maybe you are using the automatic Generate LOD option in the meshes tab? I think you should not if you have build your own ones... Other than that, I cannot figure out why aren't they showing for you... Please, send me the blend player so I can try it.
#7
11/26/2005 (10:26 am)
I would also be interested in seeing your player.blend

smlnjoe at yahoo.com

thank you for sharing your lessons/resources with the community.
#8
11/26/2005 (1:16 pm)
...
#9
11/27/2005 (12:00 am)
Thank you, Joseph, I will try it.
#10
11/27/2005 (5:57 am)
I just got a new install of 1.4.
I should be able to test it Sunday night.

when i get the LODs to change proper, ill send out the file.

@Gustavo- you got a reading for "Pixel Size" greater than 0???


im not familiar with:
(smNoRenderNonTranslucent), got a link to read up on it tho? maybe theres something in there of value.
#11
11/27/2005 (7:15 am)
About (smNoRenderNonTranslucent), take a look at the link provided by Joseph in this same thread.
#12
12/07/2005 (2:52 pm)
Gustavo and everyone else, the smNoRenderNonTranslucent issue was my original attempt at fixing the Blender LOD problem and I narrowed it down to a specific area before Joseph took over the investigation and did a great job of solving it completely. You should not be using the smNoRenderNonTranslucent version of the fix as Gustavo did, but use Joseph's final solution as it is 100% correct.

Joseph's fix is basically in TSShape::initMaterialList() find
S32 end = subShapeNumObjects[ss];
and change it to
S32 end = subShapeNumObjects[ss] + start;

Ben was supposed to put it in TGE 1.4 but never did.
Bad Ben, very bad ;)
#13
12/08/2005 (12:04 am)
Yes, I got it working, thanks Duncan.