Hi guys,
I finally got my ship with the right texture. Now i want to fake the movement of going up and down with the waves in the simpleUpdate.
int max = -300;
if (start){
for( i = 0 ; i > max ; i--){
r.setLocalTranslation(new Vector3f(-1300, i, -500));
}
}
And do something to get it down again.
Is this a nice way to simulate the ship going up and down with the waves?
Has anyone got suggestions?
Thanks in advance.
R
Hi,
also I created my own HeightGenerator(), so I can get the actual height of the wave.
projectedGrid = new ProjectedGrid( "ProjectedGrid", cam, 50, 50, 0.01f, new HeightGenerator() {
public float getHeight( float x, float z, float time ) {
hoehe=FastMath.sin(x*0.05f+time*2.0f)+FastMath.cos(z*0.1f+time*1.0f)*4;
return hoehe;
}
} );
and then rotate the shipmodel with the height value in the update method:
modelship.getLocalRotation().fromAngles(-1.55f, 1.6f, hoehe/20f);
//or
modelship.getLocalRotation().fromAngles(-1.55f+(hoehe/16), 0.0f, 0.0f);
hope this will help.
but my ship model is a spatial…
Is that a problem?
I did it your way.
But now i can't see my ship model any more when i do this.
r1.getLocalRotation().fromAngles(-1.55f, 1.6f, hoehe/20f);
How come?
i got my ship to float!! Awesome!
Can I aswel let the camera rotate with the waves as if i was on that ship?
bosun
6
You don't need to roll your own HeightGenerator to get at the height value. You could do it like this:
heightGen= new WaterHeightGenerator();
projectedGrid = new ProjectedGrid( "ProjectedGrid", cam, 50, 50, 0.01f, heightGen);
You can then get the height value with
float height = heightGen.getHeight(
ship.getWorldTranslation().x,
ship.getWorldTranslation().z,
Timer.getTimer().getTimeInSeconds() );
a more universal wave which you could use would be the sine wave. just a thought