Rotating player in simpleUpdate dosen’t loop?

I want my player(in this case a box) to constantly rotate for purly learning purposes of the way a 3d world interacts with java coding, so I’m wondering why the following code will rotate the player once very quickly then stop…(Look in simpleUpdate)





public class Main extends SimpleApplication {

private Spatial player_placeholder;

public static void main(String[] args) {

Main app = new Main();

app.start();

}



public void simpleInitApp() {

//Load Players’ place holder

//Load Player model

player_placeholder = assetManager.loadModel(“Models/player_piece.j3o”);



//Load Players Materials

Material player_placeholder_mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);



//Attach materials to the player

player_placeholder_mat.setTexture(“ColorMap”,assetManager.loadTexture(“Materials/Bricks.jpg”));

player_placeholder.setMaterial(player_placeholder_mat);



//Attach player to the stage/world

rootNode.attachChild(player_placeholder);

//Move to a start location

player_placeholder.move(0, 1, 0);



//Load skyBox and Floor/ground

Spatial skyBox = assetManager.loadModel(“Scenes/mainSkyBox.j3o”);

rootNode.attachChild(skyBox);



Spatial ground = assetManager.loadModel(“Scenes/mainTerrain.j3o”);

rootNode.attachChild(ground);

//Move gound a bit lower so camera can see by default

ground.move(0,-1,0);



// You must add a directional light to make the model visible!

DirectionalLight sun = new DirectionalLight();

sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal());

rootNode.addLight(sun);



//Disable default flyCam

flyCam.setEnabled(false);



}



public void simpleUpdate(float tpf) {

Quaternion player_rotation = player_placeholder.getWorldRotation();

float player_rotation_y = player_rotation.getY();

player_rotation_y += 1;

player_placeholder.rotate(player_rotation.getX(), player_rotation_y, player_rotation.getZ());

}



public void simpleRender(RenderManager rm) {

//TODO: add render code

}

}

Is it becuase simpleUpdate dosen’t loop like i thought it did?

If I recall correctly, to rotate, you must use the following:



player_placeholder.rotate(value_x, value_y, value_z);



Where values are in Radians. To convert use: value*FastMath.DEG_TO_RAD.



Rotation doesn’t work like moving - you don’t tell the object what rotation it must go to, but what rotation it needs to do.

  1. Please for the love of all that is good, learn to use code blocks. Though it does nicely clue the rest of us immediately into your skill level… which is probably not 100% bad in this case.


  2. Do the JME tutorials. And go through these docs (not necessarily in that order):

    https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies

    https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies



    You should probably start with the last one. Your understanding of how a Quaternion works would be greatly improved.



    All of those things will give you answers to the first 100 questions you will ask otherwise.



    Edit: only just realized I’d already given you one of those links. Seriously, though, you are clearly just starting out and it pays to do the foundational stuff.
@pspeed said:
1) Please for the love of all that is good, learn to use code blocks. Though it does nicely clue the rest of us immediately into your skill level... which is probably not 100% bad in this case.

2) Do the JME tutorials. And go through these docs (not necessarily in that order):
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies

You should probably start with the last one. Your understanding of how a Quaternion works would be greatly improved.

All of those things will give you answers to the first 100 questions you will ask otherwise.

Edit: only just realized I'd already given you one of those links. Seriously, though, you are clearly just starting out and it pays to do the foundational stuff.

lol to #1 I use code blocks it just pastes all aligned up like how it is....






to #2 I've been through all the tutorials multiple times.
I'm at the point where i need to learn and experience jMonkey so I guess I probubly will be asking questions that are found in the tutorials how ever the tutorials can't tell me exactly how to incorporate my new knowledge with out a little bit of trial and error at first ;)


@memonick said:
If I recall correctly, to rotate, you must use the following:

player_placeholder.rotate(value_x, value_y, value_z);

Where values are in Radians. To convert use: value*FastMath.DEG_TO_RAD.

Rotation doesn't work like moving - you don't tell the object what rotation it must go to, but what rotation it needs to do.


That cleared up my confusion, thanks mate!
@shanebeastlyb said:
lol to #1 I use code blocks it just pastes all aligned up like how it is....


No, I mean the forum code blocks. The little Java button up there above the post box.

It's the difference between:
System.out.println( "Hello, World." );
...and...
[java]
System.out.println( "I'm too 133t for this sheet." );
[/java]

I’m sure I remember one of the very first tutorials doing exactly this - it spins a box.



Make sure you look at how it uses tpf as well. It’s very important :slight_smile:

@pspeed said:
No, I mean the forum code blocks. The little Java button up there above the post box.

It's the difference between:
System.out.println( "Hello, World." );
...and...
[java]
System.out.println( "I'm too 133t for this sheet." );
[/java]

oh, thanks I was looking for the code
@zarch said:
I'm sure I remember one of the very first tutorials doing exactly this - it spins a box.

Make sure you look at how it uses tpf as well. It's very important :)

I don't intend to waste peoples time, I've been over the tutoirals alot, Its just alot of information at once, Although I'm not new to programming, Java is a language I just picked up two months ago and learning to incorporate that with 3d is just alot of info to take in, I appreciate everyones patience on this forum so Thanks again everyone! :D

Best of luck :slight_smile: It was (and still is :smiley: ) hard for me even though I knew Java, so I know how it feels!

It’s a lot of info to take in at once, even for people like me who’ve been programming java for years and already know the basic 3d principles/etc :slight_smile:



All I can suggest is not trying to do to much at once - and to actually work through the tutorials writing each one yourself and making it work as you go. That will be a useful exercise in both Java and JME3.