Jump to content

[SOLVED] World direction problem


photo

Recommended Posts

Hello.

I face a problem concerning the world direction of an object.
I create a box using the create_box function in primiives.h

I set the world direction to 0,0,-1.
After 1-2 updates, the world direction becomes 0,0,-1 even though i dsont change it.

Here is the code of the object.

class DummyObject {

Object object;

DummyObject(Vec3 position) {
object = create_box(vec3(1.0f),0,translate(position));
object.setWorldDirection(vec3_zero);
log.message("initial direction: " + object.getWorldDirection() + "\n");
}

~DummyObject() {}

void update() {
vec3 position = object.getWorldPosition();
log.message("World direction: " + object.getWorldDirection() + "\n");
position += object.getWorldDirection();
object.setWorldTransform(translate(position));
}
};

and here is the output:
post-624-0-61858400-1337205671_thumb.png

Why does the direction change without calling any setWorldDirection to the specific object?

Thank you.
Link to comment

Direction vector can't be a vec3_zero. It is always a vector with unit length.

 

Thus, when you try to set vec3_zero as an object direction, engine calculates new transformation for it. And apparently it becomes default direction vector: (0,0,-1)

Link to comment
×
×
  • Create New...