Game Development Community

Can I do this in Scripts?

by Sam Guffey · in Torque Game Engine · 05/08/2005 (11:59 am) · 6 replies

This function is called in the engine for rotation of object in the WorldEditor, I need to use this in scripts, is there any way??

// get offset in obj space
      Point3F offset = pos - center;
      MatrixF wMat = ((SceneObject*)mObjectList[0])->getWorldTransform();
      wMat.mulV(offset);

      // 
      MatrixF transform(EulerF(0,0,0), -offset);
      transform.mul(MatrixF(rot));
      transform.mul(MatrixF(EulerF(0,0,0), offset));
      mat.mul(transform);

Thanks

#1
05/08/2005 (12:24 pm)
You already have console access methods for setting the transform (position + rotation) for game objects. The appropriate one in this case would be setTransform();.

Using the search capability here in the forums (top right corner of the screen, select "Forums" or "Resources" as the search group, and setTransform() as the keyword) brings up more than 8 pages worth of information on the topic.
#2
05/08/2005 (12:31 pm)
I am trying to set an objects transform based on the surfaceNormal of the terrain and the players Z rotation, simply setting the transform of the object does NOT take into effect the surfaceNormal which is why I need this function converted into scripts as there are no topics related to what I am tying to do..
#3
05/08/2005 (12:41 pm)
Then do your operations that you need to do prior to calling setTransform(). You can use getTransform() to grab the z-axis rotation, and IIRC there is an access method to get the surfaceNormal as well (if not, you can simply take that part of the code you are referencing above, abstract it, and create your own ConsoleMethod to call it from script), so you'd do your manipulations of the transform, and then finally call setTransform when you are finished.

You may want to take a look at some of the ConsoleMethods that implement script functions you are familiar with, see how they work, and simply write your own to expose the functionality you want to script.
#4
05/08/2005 (12:48 pm)
Thats just it Stephen, I am trying to improve my scripting by creating a mod with Tribes 2, thus I wouldnt be able to create a new console method for this.
#5
05/08/2005 (12:50 pm)
Well, you are kind of stuck with the console methods that are part of Tribes 2 if that is your restriction. I'd look for a console method that allows you to find the surfaceNormal (and as I said above I'm pretty sure something like that exists, just don't know it off the top of my head), do the matrix manipulation yourself in script, and then use setTransform() once your manipulations are finished.
#6
05/08/2005 (3:17 pm)
RayCast will get you the surface normal. Didn't Matt Fairfax spend a few hours helping out with this?