thirdpillow icon indicating copy to clipboard operation
thirdpillow copied to clipboard

How to rotate the object?

Open PolGraphic opened this issue 9 years ago • 1 comments

Hi. Thank you for the great and simple render engine!

I know I can rotate the camera with e.g. rotate_y(-.1f);.

The problem is, how to rotate the object itself (single object)?

I was trying with engine::render() changes:

 for (int i = 0; i < scene.things.size(); i++) {
    thing* t = scene.things[i];
    mesh m = t->get_mesh();
    t_transform * tt = m.get_t_transform(); //get transformation?
    tt->set_rotation(new vector3(0, rotationValue, 0)); //set rotation?
    image texture = t->get_texture();
    matrix4 mt = t->t.get_projected_t_transformation();
    rast->draw_mesh_textured(*frame, m, texture, mt);
}

But it had no impact on model rotation.

PolGraphic avatar Jan 21 '16 19:01 PolGraphic

you have to think of the rotation as a vector pointing in a direction. you might want to try tt->set_rotation(tt->get_rotation()->rotate(radians, axisOfRotation));

https://github.com/ArkaneCow/thirdpillow/blob/master/thirdpillow/src/vector3.cpp#L14

Sorry, this is very verbose and I admit I would like to rework the code so that rotation is more intuitive. Please let me know if this worked for you.

js0nwu avatar Jan 22 '16 03:01 js0nwu