Game Development Community

Dynamically change the DTS object of a datablock.

by Cameron Aycock · in Torque Game Engine · 11/18/2004 (12:54 pm) · 6 replies

I'm pretty sure this has been asked MANY times but I can't find it.

Basically, is it possible to dynamically change the DTS file for a datablock? Is so, how?

#1
06/29/2006 (4:50 am)
The thread is very old, but i'd need a function like %obj.setshapefile(bla.dts) too...
does anyone know a solution for this problem?
#2
06/29/2006 (6:47 am)
Try to change datablock with the desired dts file.
use %obj.setDatablock(mynewdts)
#3
06/29/2006 (6:49 am)
Hi Felix,
It's my understanding that you can't/shouldn't change a datablock on the fly, you can only change what datablock an object looks to for its data.

You'd need to create a datablock for each shape, then set %obj.datablock=myNewShapeData .

If you need to share datablocks between multiple instances, but have different attributes for each one, you'll probably need to store those attributes in global variables and code some copy-and-swap routines for the changeover. Things get messy there, but sometimes, that's what it takes.

Hope that's helpful... I'd love to hear alternative approaches from the more savvy members!

-- JohnDopp
#4
01/23/2009 (2:22 am)
so, it is impossible if one datablock have multiple shape(dts file)

I have some chairs model with different style but the behavior is same
and I want to create just one datablock for all chairs
#5
01/23/2009 (8:16 am)
yadhi,
create a base datablock which implements the behaviour you want,
and create a derived datablock for each different DTS.

eg

// i may have the particular syntax and such wrong, but:

new shapeBaseData(chairBaseDB)
{
   myParam1 = "foo";
   myParam2 = "bar";
}

new shapeBaseData(comfyChairDB : chairBaseDB)
{
   shapeFile = "comfyChair.dts";
}

new shapeBaseData(royalChairDB : chairBaseDB)
{
   shapeFile = "royalChair.dts";
}

function chairBaseDB::playSits(%thisDB, %object, %player)
{
   // do stuff.
}
#6
01/26/2009 (9:00 pm)
Orion Elenzil, thanks for reply.

so, every shape (model) must have specific datablock.