### A little question about mountObject

Expanding and utilizing the engine via C++.

#### A little question about mountObject

alierainy123
Posts: 2
Joined: Tue Mar 20, 2018 2:53 am
I've never done anything on my own with mountObject, but now I'm finding a pressing need to make it work. I've been testing on tsStatic, but ultimately I'm going to need to do it with PhysicsShape (or, GameBase if we want to go deeper, unless it's going to go all the way down to any SceneObject).

I just discovered PR #680 and I see it on the list for 3.8. Did it make it in? I'll have to DL and test it, hadn't gotten around to it, but am curious if anyone has any help for me on this issue anyway.

For example, do we still need nodes named "mount0" etc or can we just mount to any node now? And does the mounted shape still need a "mountpoint" node? Or is all that just the ShapeBase implementation?

#### Re: A little question about mountObject

alierainy123
Posts: 2
Joined: Tue Mar 20, 2018 2:53 am

#### Re: A little question about mountObject

Atomic Walrus
Posts: 6
Joined: Mon Feb 23, 2015 10:41 pm
Mounting was moved to the sceneObject quite a while back, so basically everything in the scene can be mounted to anything else.

Mount points in the models (mount0, mount1, etc) are still used, but not required; for example, if you mount an object to a mount slot that doesn't have a defined mount point will simply mount at the origin (center). You can use the offset coordinates in the mountObject command to put the mounted shape anywhere you want.

Keep in mind that while all SceneObjects can mount, not every object has a defined behavior when it mounts; Mounting is just a theoretical association, and the mounted object must use that association to place itself at the mount point. Take a look at how TSStatics handle mounting, as they are the simplest functional mountable object.

Open up TSStatic.cpp and search for "ismounted" (no quotes), you will find very basic code for making a mounted object actually visibly stick to its mount point. Depending on your object's inheritance, you may need to copy these bits of code into the relevant functions. If your object has a physics simulation, either stock or external, you'll probably want to pause it while the object is mounted.

#### Re: A little question about mountObject

Steve_Yorkshire
Posts: 239
Joined: Tue Feb 03, 2015 10:30 pm

FYI:
Mounted objects without a mountPoint will mount at origin of the model.

If you stick to mount0/1/2/etc you can't go wrong - but I do remember a "mount any node resource" but don't remember if it got added to the stock code.

A mountable object needs to be a StaticShape (which I've always found a confusing name cos it's actually a dynamic object which can be updated in realtime).

I wasn't aware TsStatic's were mountable due to them never being updated in realtime so there doesn't seem much point mounting things to them. PhysicsShape is updated in realtime.

#### Re: A little question about mountObject

Atomic Walrus
Posts: 6
Joined: Mon Feb 23, 2015 10:41 pm
Steve_Yorkshire wrote:FYI:
Mounted objects without a mountPoint will mount at origin of the model.

If you stick to mount0/1/2/etc you can't go wrong - but I do remember a "mount any node resource" but don't remember if it got added to the stock code.

A mountable object needs to be a StaticShape (which I've always found a confusing name cos it's actually a dynamic object which can be updated in realtime).

I wasn't aware TsStatic's were mountable due to them never being updated in realtime so there doesn't seem much point mounting things to them. PhysicsShape is updated in realtime.

I can't remember which version added TSStatics working as mountable props, but it definitely functions in stock 3.10. Since they don't have any game functionality they're a good low-overhead choice for mounting a visual prop to a vehicle or whatnot.

For most objects, the following code pasted into the end of processTick and advanceTime is sufficient to get them to behave correctly when mounted:

Code: Select all

if (isMounted()) {      MatrixF mat;      mMount.object->getMountTransform( mMount.node, mMount.xfm, &mat );      Parent::setTransform(mat);   }

#### Re: A little question about mountObject

Steve_Yorkshire
Posts: 239
Joined: Tue Feb 03, 2015 10:30 pm

try mounting a Cheetah to another Cheetah in stock 3.10!

#### Who is online

Users browsing this forum: No registered users and 1 guest