The next code rotates my modelinstance about its centerpoint y-axis. HOWEVER, once I transfer the modelinstance foward the rotation will get all flawed! I’m not certain what is occurring. I want for the rotation to work the identical all the time NOT simply earlier than I begin shifting the modelinstance foward!
Right here how I apply my rotation after urgent the D key:
BoundingBox bbox = new BoundingBox();
ThreeDWithMultipleScreensGame.gameMainPlayerReference.calculateBoundingBox(bbox);
bbox.mul(/*node_.globalTransform*/ThreeDWithMultipleScreensGame.gameMainPlayerReference.remodel);
Vector3 centerVector_ = new Vector3();
bbox.getCenter(centerVector_);
Gdx.app.log("okcenter","right here: " + centerVector_.toString());
if(true){
Matrix4 m4 = new Matrix4();
m4.set(ThreeDWithMultipleScreensGame.gameMainPlayerReference.remodel);
//m4.translate(10,0,10).rotate(0,1,0,-20f*LevelOneScreen.playerRotationSpeed*deltatime).translate(-10,0,-10);
m4.translate(centerVector_).rotate(0,1,0,-20f*LevelOneScreen.playerRotationSpeed*deltatime).translate(-1f*centerVector_.x,-1f*centerVector_.y,-1f*centerVector_.z);
Gdx.app.log("multiply","we've: " + centerVector_.cpy().scl(-1f).toString());
ThreeDWithMultipleScreensGame.gameMainPlayerReference.remodel.set(m4);
ThreeDWithMultipleScreensGame.gameMainPlayerReference.calculateTransforms();
}
And, right here is how I translate my modelinstance foward:
vecyr.set(0,0,0); //clearing vecyr... necessary
mat4_.set(ThreeDWithMultipleScreensGame.gameMainPlayerReference.remodel);
vecyr.z-=deltatime*LevelOneScreen.playerSpeed;
mat4_.translate(vecyr);
ThreeDWithMultipleScreensGame.gameMainPlayerReference.remodel.set(mat4_);
ThreeDWithMultipleScreensGame.gameMainPlayerReference.calculateTransforms();
ThreeDWithMultipleScreensGame.gameMainPlayerReference.remodel.getTranslation(ThreeDWithMultipleScreensGame.playerCurrentPosition);
digital camera.place.add(vecyr);
digital camera.lookAt(10f,0,ThreeDWithMultipleScreensGame.playerCurrentPosition.z-7.5f);
digital camera.replace();
Why does the rotation solely work earlier than I begin shifting my modelinstance foward?