Page 1 of 1

### Rotate quad that was added as triangle list

Posted: Wed Mar 13, 2019 11:05 am
Hey I am new to ORGE and I have a simple question,

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();
``````
Or is it possible to rotate the whole object in the end?

### Re: Rotate quad that was added as triangle list

Posted: Wed Mar 13, 2019 2:58 pm
attach obj to a scene node and then use setOrientation

### Re: Rotate quad that was added as triangle list

Posted: Wed Mar 13, 2019 5:43 pm
I have multiple quads and all should have differnt orientation.
all are attached to the same scene node for this reasons rotating the scene node would rotate all quads...... which I do not want.

### Re: Rotate quad that was added as triangle list

Posted: Wed Mar 13, 2019 6:53 pm
I want to have multiple quads added as objects to scene_node and all should have different orientation.

If I now use scene_node_->setOrientation(quad) I will rotate all quads...

How can I solve that?

Should I use e.g. different scene_nodes and add them all to my scene manager? How to add those? I did not find a function therefore....

Basically I want to have multiple quads in rviz at a certain orientation and position....

### Re: Rotate quad that was added as triangle list

Posted: Thu Mar 14, 2019 2:09 am
mlacht wrote:
Wed Mar 13, 2019 6:53 pm
Should I use e.g. different scene_nodes and add them all to my scene manager? How to add those? I did not find a function therefore....
yes. see https://ogrecave.github.io/ogre/api/lat ... scene.html

### Re: Rotate quad that was added as triangle list

Posted: Thu Mar 14, 2019 9:04 am
Thanks! That worked for me.

My problem just was that i always had quat.w = 0 for this reason I did not saw that the rotating works....