Jump to content

[1.7.10] Rendering, SetRotationAngles and accessing the Entity class


Recommended Posts

Hi guys,


I am hunting a bug that makes my animation skipping few frames from time to time ... and I am able to fix it. But I do not understand why. Maybe you can help me out.


Look at the following short method code sections ... option A and option B. This code is in the SetRotationAngles method of my model class.


Option A


this.bodysegment1.rotateAngleY = 0.15F *(MathHelper.cos(f2 * _shark.GetTailFlapSpeed()  * 0.327F) );
    this.bodysegment2.rotateAngleY = 0.15F *(MathHelper.cos(f2 * _shark.GetTailFlapSpeed()  * 0.327F - (float)(Math.PI/6)) );
    this.bodysegment3.rotateAngleY = 0.15F *(MathHelper.cos(f2 * _shark.GetTailFlapSpeed()  * 0.327F - (float)(Math.PI/3)) );
    this.bodysegment4.rotateAngleY = 0.15F *(MathHelper.cos(f2 * _shark.GetTailFlapSpeed() * 0.327F - (float)(Math.PI/2)) );
    this.bodysegment5.rotateAngleY = 0.15F *(MathHelper.cos(f2 * _shark.GetTailFlapSpeed() * 0.327F - (float)(2*Math.PI/3)) );
    this.bodysegment6.rotateAngleY = 0.15F *(MathHelper.cos(f2 * _shark.GetTailFlapSpeed()  * 0.327F - (float)(5*Math.PI/6)) );


Option B


	    this.bodysegment1.rotateAngleY = 0.15F *(MathHelper.cos(f2 * 0.7F  * 0.327F) );
    this.bodysegment2.rotateAngleY = 0.15F *(MathHelper.cos(f2 * 0.7F * 0.327F - (float)(Math.PI/6)) );
    this.bodysegment3.rotateAngleY = 0.15F *(MathHelper.cos(f2 * 0.7F  * 0.327F - (float)(Math.PI/3)) );
    this.bodysegment4.rotateAngleY = 0.15F *(MathHelper.cos(f2 * 0.7F * 0.327F - (float)(Math.PI/2)) );
    this.bodysegment5.rotateAngleY = 0.15F *(MathHelper.cos(f2 * 0.7F* 0.327F - (float)(2*Math.PI/3)) );
    this.bodysegment6.rotateAngleY = 0.15F *(MathHelper.cos(f2 * 0.7F  * 0.327F - (float)(5*Math.PI/6)) );



The Option A and the Option B section are in fact the same code, as the exception of _shark.GetTailFlapSpeed in Option A and 0.7F and Option B.


If I execute the code Option A, it access the entity object passed in parameters (named _shark), which will return a simple 0.7F value.


If I execute the code Option B, I simply hardcode the 0.7F value.


That is really weird, if I execute the Option A code, that access a simple property ... the animation jump some frame commonly. If I execute the Option B code, then the animation is perfect.


I even tried putting the value of _shark.GetTailFlapSpeed() in a variable ...therefore calling it only once ... which has the same effect. I am confused. Why accesing a simple method in the entity class makes the animation run not smoothly. Is it a client/server class synchro thing?


Here is the content of that little method.


public float GetTailFlapSpeed()
	return GetBaseTailFlapSpeed() + (currentSpeed*0.2F);



currentSpeed is a simple protected float value in a parent class.


And here is the GetBaseTailFlapSpeed method ... both are from a parent class. As you will see, the access is purely direct ... how come it creates a glitch?


protected final float GetBaseTailFlapSpeed()
return pBaseTailFlapSpeed;



Link to comment
Share on other sites

I know its a tough one ...so maybe I can try something else.


Is it possible to link the Model class to the Entity class. So when the entity class is modified server side, I would send a Message that update the model class client side?


I know that the entity is available from the model class methods ...but since accessing it causes glitches in the animation, I could try to always keep my Model class updated with IMessage...


Any hints?

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.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

By using this site, you agree to our Terms of Use.