Game Development Community

Using mountObject .. Help Needed

by Seth Patchett · in Torque Game Engine · 11/29/2003 (5:34 am) · 7 replies

I had modeled my flying vehicle with a main body, left wing, right wing, and laser cannon. Each being there own DTS from 3DS Max.

I'm currently working with the main body and left wing. I want to mount the left wing to the main body. I defined mount0 on the main body, and I defined mountpoint on the left wing. Is this correct?

I noticed that the buggy vehicle example does it's mounts within the src code with defined functions, which don't exist for the flyingVehicle. So do I need to expand the flyingVehicle like the wheeledVehicle in order to mount objects to it?

I have also tried defining the ShapeBaseImageData for the wing as well. This didn't work, or I might have done it incorrectly.

I haven't come across any resources or threads which would help me, though it could be a lack of the incorrect term in my search.

Could someone either point me in the right direction to find the correct thread or supply some input on how to get this done.

All your help is appreciated. Thanks.

- Seth

#1
11/29/2003 (7:39 pm)
You do realize that if you make the wings as seperate objects and mount them as a shapeBaseImage that they will not collide, UNLESS you extend the collision mesh in the base vehicle to cover those areas, right?

In any case, the easy way to mount objects for your situation would be an onAdd script function for your vehicle (which would be called whenever an instance of the vehicle is created).....

function VehicleDataBlockName::onAdd(%data, %obj)
{
Parent::onAdd(%data, %obj);

// if you mount a static shape....
//%obj.mountObject( staticObjectDataBlockName, slot);
%obj.mountObject( leftWing, 0);

// if you mount a shapeBaseimage...
//%obj.mountImage( ImageDataBlockName, slot);
%obj.mountImage(leftWingImage, 0);
}

The way you describe doing the mount nodes in the dts objects is correct, but there is a nice feature I ran into that's worth knowing about.

In the image dataBlock you can define a variable of mountPoint = X;
That variable defines the node transform which will be used when the image is attached to the object.

A player/vehicle/staticShape has an array which can mount 8 images/objects. However the slot an object is mounted to does not have to use the same dts node transform as the slot number. I.E. you can mount a weapon image into slot 0, but use the mount5 transform for it by putting mountpoint =5; in the images datablock.

Gee I hope that's not confusing.
#2
11/30/2003 (1:17 pm)
Martin,

Thanks for the information. Yes I was aware about extending the collision mesh for the entire craft if I mount the wings as ShapeBaseImage. The game I'm working on will be utilizing a shield scenerio so a low poly sphere will engulf the entire craft.

You didn't confuse me or loose me. I had noticed the variable mountPoint and you cleared it all up for me. Much appreciated.

Now to apply what I have learned here to my game. Thanx

- Seth
#3
11/30/2003 (4:49 pm)
Martin,

Ok. For testing purposes I tried to mount my wing to the WarSparrow Content Pak, replacing the gun. The wing appears, though it is rendered above the WarSparrow model. Below is the schematic view I'm using for the left wing:
base01
 |-- dummy
 |-- start01
 |    |-- dummy
 |    |-- mountPoint
 |         |-- dummy
 |         |-- leftwing128
 |              |-- Contrail0
 |                   |-- dummy
 |-- detail128
      |-- dummy

Is the above correct?
#4
11/30/2003 (7:15 pm)
I don't think there would be any problems with that hierarchy, though it appears as if leftwing128 is a child of the mountpoint (it doesn't need to be, but I don't think it would cause a problem).

Check the wing datablock for the offset parameter, it is used to move the mounted image "x y z" meters away from the mount position.

I found on a couple occasions after working with the same file for a long time that some problem will develope with the bounds or the base and start dummies. (Scaling them tends to cause trouble). Deleting and making new versions of those objects has resolved odd transform problems with the dts in-game. I have also found that it is best to keep base and start at the center of the model, to ensure they are always within the bounds box.

Also it may have already occured to you, but in a player/vehicle model you can rotate the mountX dummies so that no rotation variable is needed in the image dataBlock in order to align it the way you want for the particular vehicle/player.
#5
11/30/2003 (7:52 pm)
Martin,

Thanks for responding. Yeah, the heirarchy is the setup similar to the WarSparrow machine gun and they have the gun being a child of the mountPoint. Thanks for the tip with the offset parameter. I didn't know exactly what it did now I do. That should come in handy. Also thanks for the tips with working with the models. I've been coming across the same issues today, been very aggravating at times.

Thanks again.

- Seth
#6
11/30/2003 (8:55 pm)
Awesome. A good question, a good answer, and then someone who profits from that answer. Way to go, guys! :)
#7
11/30/2003 (11:21 pm)
Ben,

You read my mind; I was reading down this thinking exactly the same thing, nice collaboration. :)

- Melv.