Turret moving

Hi! I’ve got little problem. I’m working on Tank game, where we steering tank in similar way like in Battlefield game series, simple rotating turret in X axis, changing gun elevation in Y axis, and hull rotating in Z axis.

I figured out 2 ideas:

  1. Single model, separated into 3 objects, (hull, turret, gun), but when i load obj file, jme3 render only hull. I don’t k’now how to manage rotatation and animation of those 3 parts (should I use bones?)

  2. 3 separated models of hull, turret, gun, but i’ve got no idea how to “combine” them in the code…

    I prefer 2nd way, because I feel more comfortable with programming than 3d artist…

    Could you post me some code, functions or tutorial? Becaouse i didn’t found answer in Basic Tutorials and forum posts.

i’m sory i made a mistake

in 2nd case i thought of 3 separated FILES

  1. There isn’t really any reason to use .obj i would just go directly from a .blend to a j3o you can right click .blend files in the SDK assests folder and convert them to .j3o (you will have to do this every time you update the file…)

    i would do 3 objects, and use .rotate() on the geometries… just because if there isn’t any mesh deformation, there’s no reason to complicate things with using bones and animations

    This one might help you…


    But really i think you should go through all the basic tutorials (scene graph for dummies as well) and this problem won’t seem that difficult to you

    EDIT… additionally there isn’t any reason to do seperate files… if you lode multiple objects in one file, you should be able to get at them inidividually by doing a ParentNode.getChild(“ObjectName”) where the object name is the name you can give it in Blender… or something very similar to this… basically you can treat them individually even if they are from the same file
1 Like

Create a node, add the geometries for the components of the tank to it. Then to move the whole tank move the node, to rotate the turret just modify the local rotation of the turret spatial.

1 Like