Game Development Community

Statice .setTransform() and transform orientation

by Daniel Hopkins · in Torque Game Engine · 09/10/2008 (9:12 pm) · 6 replies

EDIT: Sorry to post this again, but I accidentally hit the 'delete' button on my topic header, and want to make sure the thread remains

I have two questions:

1)This has to do with calling the '.setTransform()' function called from script on Static shapes while in the editor.

Let's say there's a static shape called "test." I turn on the editor, and call
"test.setTransform([some new transform])" When I do this, the bounding box of "test" moves, but the "test" mesh doesn't. Then, if I click on the bounding box, the mesh will "update" and move to where it's supposed to be. Is there a way I can get it to "update" in script, rather than having to manually update it by selecting the bounding box?

2)This has to do with applying the normals from the containerRayCast() method to objects.

Basically, if you cast a ray, the result will be, among other things, the collision position and surface normal. I'm wanting to move an object to that position and rotate it according to the normal. I assume you would use the .setTransform() to do this. However, I'm not sure how to incoporate the normals into the transform. Can someone show me how to do this?

Thanks

#1
09/11/2008 (1:40 am)
TSStatic's do not send changes in their transform to clients normally, they are designed to be "static". But if those changes are made by the editor (or you click on it) it will be updated for clients. Basically you just need to set the same maskbit the editor uses whenever TSStatic::setTransform is called, and you will get what you want I believe.
#2
09/11/2008 (5:18 pm)
@James: Thank you for the response. That sounds like just what I'm looking for, the only problem is I'm not sure how to do it. Which maskbit would I have to set?

To all in regards to question 2:
I got sort of what I want to do by passing this as the rotation transform:

%hitPointNormal SPC "360"

so the new .setTransform() function looks like:

[obj].setTransform(%hitPosition SPC %htPointNormal SPC "360")

Although it seems to work, there are times I wonder if that's not the way to go. Can anyone verify whether this is correct, or show me another way?

Thank you
#3
09/12/2008 (8:15 am)
In my case I only needed to set the position of the TSStatic and have it updated, so what I did was overload sceneObject::setPosition to this:
void TSStatic::setPosition( const Point3F &pos )
{
   Parent::setPosition( pos );
   setMaskBits( advancedStaticOptionsMask );
}

On the second question, that seems correct, if what you want is the object's up vector to be the collision normal. You could also change that to 0 degrees with the same result.
#4
09/12/2008 (9:13 am)
@James: Okay, thanks a lot! Is there a way to set the maskbit in script? I was kind of wanting to stay away from editing the source.
#5
09/12/2008 (9:29 am)
Nopes
#6
09/12/2008 (2:02 pm)
@James: Awww...oh well. Thank you for the information and timely responses!!