Jump to content

A little question about mountObject


alierainy123

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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:

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...