I have a Ogre::ManualObject *obj and want to create a quad using obj->begin(material->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST).
Now creating this quad and rotating it around the y axis at a paritcular position works fine. However I do not only want to be able to turn this quat around the y axis but give it any orientation using an input quaternion (w,x,y, z).
Does anyone know how I have to modify my current code to do that?:
Code: Select all
Ogre::ManualObject *obj = scene_manager_->createManualObject(obj_name);
scene_node_->attachObject(obj);
obj->begin(material->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST);
const float width = 20;
const float height = 20;
// position:
int offsetx = 0; // wenn null dann auf halber width
int offsety = -height/2; // wenn null dann am linken rand!
int offsetz = 5; // höhe in m
Ogre::Vector3 vec(width/2, 0, 0); // width/2 so lassen! verzerrung etc. einstellen.
Ogre::Quaternion quat;
//quat.FromAngleAxis(Ogre::Degree(90), Ogre::Vector3::UNIT_Y); // drehen um Y klappt, um X passeiert nix um Z klappt auch nicht!
quat.w = 0.707107;
quat.y = 0.707107;
vec = quat * vec;
std::cout<<quat<<std::endl;
obj->position(-vec.x+offsetx, height+offsety, -vec.z+offsetz);
obj->textureCoord(0, 0);
obj->position(vec.x+offsetx, height+offsety, vec.z+offsetz);
obj->textureCoord(1, 0);
obj->position(-vec.x+offsetx, offsety, -vec.z+offsetz);
obj->textureCoord(0, 1);
obj->position(vec.x+offsetx, offsety, vec.z+offsetz);
obj->textureCoord(1, 1);
int offset =0;
obj->triangle(0, 3, 1); // dreiecke in sich verdreht wenn ohne offset!
obj->triangle(0, 2, 3);
obj->end();