Jump to content

[SOLVED] transform and position bug.


photo

Recommended Posts

Posted

PlayerActor actor;

Player player;

ObjectMesh statue;

 

int init() {

 

actor = new PlayerActor();

actor.setPosition(vec3(0.0f,0.0f,10.0f));

 

statue = new ObjectMesh("data/samples/common/meshes/statue.mesh");

statue.setMaterial("mesh_base","*");

 

player = new PlayerSpectator();

player.setPosition(vec3(0.0f,15.0f,10.0f));

player.setDirection(vec3(0.755f,-4.0f,0.25f));

 

engine.game.setPlayer(player);

 

return 1;

}

int update() {

 

statue.setWorldTransform(actor.getWorldTransform());

actor.setPosition(actor.getPosition());

 

return 1;

}

 

 

 

Нужно еще землю добавить.

при выражение actor.setPosition(actor.getPosition()); происходит разворот объекта на 180 градусов.

Почему так происходит? о_О

 

 

 

 

We should also add the ground.

In marked actor.setPosition (actor.getPosition()); it reverses the object 180 degrees.

WTF????? о_О

  • 1 year later...
Posted

Hello necroposting! I missed you so much.

 

Just to be clear with that topic: any transform changes force Player node to recalculate its inner state (direction, angles and all that stuff). So, for example, direction will be 'negative forward' like in this code:

direction = normalize(vec3(-getWorldTransform().getColumn3(2)));

After that, in flush, transform will be recalculated from direction so here goes the flip. To solve that use both setPosition and setViewDirection functions.

vec3 old_viewdir = actor.getViewDirection();
actor.setPosition(actor.getPosition());
actor.setViewDirection(old_viewdir);
×
×
  • Create New...