Game Development Community

DTS Object Problems

by Ian Dale · in Torque Game Engine · 01/10/2005 (1:16 am) · 16 replies

I'm using TGE 1.3, Lighting Pack 1.2 and Milkshape 1.7.

I've created a simple object, a door, and included animations for it to open and close.

I've placed the item into a DIF interior in my mission. When I click on the item it plays the animation correctly. However it's collision box doesn't change and as such even though the image has moved, I'm still colliding with it as though the object hasn't. Also, when the item has moved it begins to disappear into the DIF interior, even though there's no interior to disappear into.

I've defined the item as StaticShape.

Any ideas as to how I can fix these problems?

#1
01/10/2005 (1:20 am)
I think its better to have a nonanimated door and then open/close it with script, just set the pivotpoint where the hinge would be and then rotate it around its z axis.
#2
01/10/2005 (1:25 am)
How do you set a pivot point???
#3
01/10/2005 (1:51 am)
You do it in the modelingprogram, I have never used milkshape so I cant tell you how to do it there, but the pivotpoint is the center of the object, the center used when you rotate a model in milkshape, dont even know if its called pivot in milkshape, in 3dsmax it is.
#4
01/10/2005 (2:52 am)
The reason for the Collision to work is because you cant animate the collision box.
This is a know problem... There is a door resource somewhere... I'll try to find it... just search for it...

Here you are:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6780
#5
01/10/2005 (4:26 am)
Thanks very much for the info.
#6
01/13/2005 (9:38 am)
Does this problem of animating the collision box only exist for DTS's created in milkshape?

If I create it in 3ds max will it happen?

What about if I create a door out of a player class, will it still happen?

Regards,
#7
01/13/2005 (9:53 am)
Its not necisarily a problem, just a different of approach... your thinking to do it in the 3d program with a sequence... you need to be doing it in script/code... Much simpler that way, slightly less memory intensive too.

That door resource is great
#8
01/13/2005 (10:09 am)
I've used the principles of the door resource and made an animated door that swings open and closed. But I find the animation rather jerky. I felt that using proper animation looked better.
#9
01/13/2005 (10:32 am)
Ahh... hmm I guess its theoritically possible to run the animation and at the end of the sequence switch out the dts with an open door object with a different collision box
#10
01/15/2005 (3:30 pm)
You could always modify the collision code to support animated collision meshes...
#11
01/15/2005 (9:20 pm)
Ben,

I've found an alternate method simply using two animated DTS objects. But out of interest, what would be involved in modifying the collision code? My understanding is that it would be a enormous change as it would affect all animated DTS objects (players and static). Is that correct?
#12
01/15/2005 (9:50 pm)
There are 2 door resources. tried either of them yet?
#13
01/16/2005 (12:32 am)
It would be a "simple" matter of getting the collision meshes to move (that's not so hard) and getting displacement to work so they'd push stuff out of the way (probably harder). It's not a "follow instructions" fix but it's pretty feasible within the existing framework of Torque.
#14
01/16/2005 (12:11 pm)
Ian, I would be interested to know how you implemented two animated DTS objects. I agree that collision meshes should move with the animation as well.
#15
01/16/2005 (7:42 pm)
Ryan,

To implement switching dts objects I created a cs module called door.cs and called it from game.cs.

door.cs contains:

datablock StaticShapeData(DoorAClosed)
{
category = "Interactive";
itemselectable = true;
itemtype = 1;
// Door in closed position. Animation opens it.
shapefile = "~/data/shapes/doors/door1a.dts";
emap = FALSE;
// Name of other datablock containing opened door image.
otherblock = "DoorAOpen";
isdooropen = false;
};

datablock StaticShapeData(DoorAOpen)
{
category = "Interactive";
itemselectable = true;
itemtype = 1;
// Door in open position. Animation closes it.
shapefile = "~/data/shapes/doors/door1b.dts";
emap = FALSE;
// Name of datablock containing closed door image.
otherblock = "DoorAClosed";
isdooropen = true;
};

function Interact(%obj)
{
if (isobject(%obj))
{
switch (%obj.getdatablock().itemtype)
{
case 1: dooranimate(%obj);
}
}
}

function DoorAnimate(%obj)
{
if (isobject(%obj))
{
if (%obj.getdatablock().isdooropen)
{
// Play close animation
%obj.playthread(1,"close");
// Switch to closed door object
schedule(1500,0,"changeobject",%obj);
}
else
{
// Play open animation
%obj.playthread(2,"open");
// Switch to opened door object
schedule(1500,0,"changeobject",%obj);
}
}
}

function changeobject(%obj)
{
%location = %obj.gettransform();
%tx = getword(%location, 0);
%ty = getword(%location, 1);
%tz = getword(%location, 2);
%rx = getword(%location, 3);
%ry = getword(%location, 4);
%rz = getword(%location, 5);
%rd = getword(%location, 6);


%newdatablock = %obj.getdatablock().otherblock;
%scale = %obj.getscale();


new StaticShape() {
position = %tx SPC %ty SPC %tz;
rotation = %rx SPC %ry SPC %rz SPC %rd;
scale = %scale;
dataBlock = %newdatablock;
};
%obj.delete();

}

I will eventually release this as a resource but I'm still testing it. I also looked at switching just the datablocks, which does work, providing no animations have been played.

As for animated collision boxes, perhaps I'll look at implementing it when I understand a bit more about how the engine works.

Regards,
#16
01/16/2005 (7:44 pm)
Robert,

I examined and used both door resources but I didn't like them.