A little question about mountObject

Expanding and utilizing the engine via C++.
6 posts Page 1 of 1
alierainy123
Posts: 2
Joined: Tue Mar 20, 2018 2:53 am
by alierainy123 » Tue Mar 20, 2018 3: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?
alierainy123
Posts: 2
Joined: Tue Mar 20, 2018 2:53 am
by alierainy123 » Tue Mar 20, 2018 3:53 am
please help me
Atomic Walrus
Posts: 6
Joined: Mon Feb 23, 2015 10:41 pm
by Atomic Walrus » Tue Mar 20, 2018 6:42 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.
Steve_Yorkshire
Posts: 248
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Tue Mar 20, 2018 9:01 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.
Atomic Walrus
Posts: 6
Joined: Mon Feb 23, 2015 10:41 pm
by Atomic Walrus » Wed Mar 21, 2018 2:54 am
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); }
ShapeBase also had this functionality added in a recent version -- try mounting a Cheetah to another Cheetah in stock 3.10!
Steve_Yorkshire
Posts: 248
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Wed Mar 28, 2018 5:46 pm
try mounting a Cheetah to another Cheetah in stock 3.10!
Image

:mrgreen:
6 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest