Generic Object Mounting
by Michael Reino · in Torque 3D Professional · 06/19/2014 (10:03 pm) · 17 replies
I have created two branches for testing object mounting. The first, shape_mounting makes all classes that derive from ShapeBase mountable. It also modifies TSStatic to be mountable.
The second, mount_object_ex, expands on the first and enables mounting by node name and aligning a mountpoint node on the shape that's mounting. There are some usage instructions in the branch readme. There is also a demo script included that creates this:

All of the objects in the above image (except the terrain) are mounted to the base cheetah. The unnamed objects are TSStatics. The objects mounted to the rear hubs demonstrate mounting to animated nodes as well as mounting to nodes by name. The two Lurkers mounted to the front hubs demonstrate using an alignment node on the mounting object. The MuzzlePoint node on the Lurker is aligned to a Hub node with a displacement and rotation.
Any testing, debugging, feedback or suggestions that you can provide would be greatly appreciated.
The second, mount_object_ex, expands on the first and enables mounting by node name and aligning a mountpoint node on the shape that's mounting. There are some usage instructions in the branch readme. There is also a demo script included that creates this:

All of the objects in the above image (except the terrain) are mounted to the base cheetah. The unnamed objects are TSStatics. The objects mounted to the rear hubs demonstrate mounting to animated nodes as well as mounting to nodes by name. The two Lurkers mounted to the front hubs demonstrate using an alignment node on the mounting object. The MuzzlePoint node on the Lurker is aligned to a Hub node with a displacement and rotation.
Any testing, debugging, feedback or suggestions that you can provide would be greatly appreciated.
About the author
Recent Threads
#3

Pic related, its a knife with an optical sights attached to it.
06/20/2014 (8:32 pm)
Awesome work! Does this also allow attaching stuff to weapons, like optical sights, or lasers, or knives, or optical sights on a knife?
Pic related, its a knife with an optical sights attached to it.
#4
EDIT: I assume. Michael didn't mention any changes to SBI but I haven't looked at the code yet...
06/20/2014 (8:41 pm)
Nope, unfortunately a ShapeBaseImage is still not a real object :(.EDIT: I assume. Michael didn't mention any changes to SBI but I haven't looked at the code yet...
#6
@ Chris. Daniel is right, this does not include any changes to ShapeBaseImage. There have been resources for doing just that. I'm very familiar with this one, but it would need a complete overhaul to work with T3D. If you were looking for a purely visual effect that did not affect the weapon image behavior, you could mount the sight as an object to the same node that the 'weapon' is mounted to and offset it to the correct position. It will move with the weapon and look like it's mounted to it...
06/21/2014 (1:21 am)
@ Daniel and Azaezel, Thank you.@ Chris. Daniel is right, this does not include any changes to ShapeBaseImage. There have been resources for doing just that. I'm very familiar with this one, but it would need a complete overhaul to work with T3D. If you were looking for a purely visual effect that did not affect the weapon image behavior, you could mount the sight as an object to the same node that the 'weapon' is mounted to and offset it to the correct position. It will move with the weapon and look like it's mounted to it...
#7
06/21/2014 (7:13 am)
I guess I created something like this for IPS actually lol.. I was annoyed that I could only mount to the mountnodes which is not practical for particleemitters, so I did the whole "mount by name" thing as well :P
#8
Also for adding particle emitters as being able to mount to any node, and not just nodes where particle emitters are hard-coded.
06/21/2014 (9:48 am)
@Michael Well you should add that, and if you have a Patreon, I'd throw money at you for it.Also for adding particle emitters as being able to mount to any node, and not just nodes where particle emitters are hard-coded.
#9
06/21/2014 (2:39 pm)
The mountObjectEx() command works for all objects that were previously mountable as well as all of the newly mountable types. You can mount a ParticleEmitterNode to any named shape node. Example:%fireNode = new ParticleEmitterNode() {
datablock = TorchFireEmitterNode;
emitter = TorchFireEmitter;
active = true;
};
%obj.mountObjectEx(%fireNode, "Bip01_Head");
// or %obj.mountObjectEx(%fireNode, "Bip01_Head", "", "0 0 0.1 0 0 1 0");If you put that into PlayerData::onAdd(), you would have a player with a Torch emitter mounted to it's head.
#10
Also:
"If you put that into PlayerData::onAdd(), you would have a player with a Torch emitter mounted to it's head."
Excellent, now I can start work on my next game: Nicholas Cage - The Video Game!
06/21/2014 (11:53 pm)
@Michael Dang, you thought of everything, didn't you? Excellent work!Also:
"If you put that into PlayerData::onAdd(), you would have a player with a Torch emitter mounted to it's head."
Excellent, now I can start work on my next game: Nicholas Cage - The Video Game!
#12
06/22/2014 (8:49 am)
@Daniel yeah, sorry, I completely forgot :P I guess I was distracted by the possibility of mounting anything to anything. But it still works for 3.5.1?
#13
07/19/2015 (12:13 pm)
I merged it into current release (3.7) and works amazing well! Needed to be able to snap objects together like LEGOs and w/o this code it just defaulted to mounting the object at its center. So this was perfect!
#14
I spawn objects A,B and C with scale set to "2 2 2" ... then mount A to B.
A doubles in size.
Then mount B to C ... and B doubles and A doubles again (4x size now). and so on.
To get around it, I just reset everything to scale "1 1 1" -
07/19/2015 (12:36 pm)
Lol - I did notice (1) flaw in this system. I spawn objects A,B and C with scale set to "2 2 2" ... then mount A to B.
A doubles in size.
Then mount B to C ... and B doubles and A doubles again (4x size now). and so on.
To get around it, I just reset everything to scale "1 1 1" -
#15
07/19/2015 (4:07 pm)
That's actually expected behavior. Lets you do things like scale a player an it's gun without additional coding and the like, though I could see an mInheritScale flag...
#16
07/19/2015 (9:13 pm)
Well, I could live with "hey, create and mount everything at base scale then apply your desired scale to the parent object" as a sort of standard operating procedure. It only gets weird when you want to have a base object A at 1, a mounted object B at 2, and an object C mounted to B at 1....
#17
But wanted to remark that this is causing a significant drop in performance on this side. The fps decreased with 60%. Anyone experienced the same?
Really like the whole idea though and many thanks for sharing!
Again, sorry to bump this, older resources still are of use today.
09/15/2019 (9:19 pm)
I know, couple of years late and wrong forums,But wanted to remark that this is causing a significant drop in performance on this side. The fps decreased with 60%. Anyone experienced the same?
Really like the whole idea though and many thanks for sharing!
Again, sorry to bump this, older resources still are of use today.
Torque Owner Daniel Buckmaster
T3D Steering Committee