Rotate quad that was added as triangle list

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
mlacht
Gnoblar
Posts: 8
Joined: Wed Mar 13, 2019 10:59 am
x 1

Rotate quad that was added as triangle list

Post by mlacht » 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?
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 872
Joined: Sun Mar 30, 2014 2:51 pm
x 176
Contact:

Re: Rotate quad that was added as triangle list

Post by paroj » Wed Mar 13, 2019 2:58 pm

attach obj to a scene node and then use setOrientation
0 x

mlacht
Gnoblar
Posts: 8
Joined: Wed Mar 13, 2019 10:59 am
x 1

Re: Rotate quad that was added as triangle list

Post by mlacht » 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.
0 x

mlacht
Gnoblar
Posts: 8
Joined: Wed Mar 13, 2019 10:59 am
x 1

Re: Rotate quad that was added as triangle list

Post by mlacht » 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....
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 872
Joined: Sun Mar 30, 2014 2:51 pm
x 176
Contact:

Re: Rotate quad that was added as triangle list

Post by paroj » 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
0 x

mlacht
Gnoblar
Posts: 8
Joined: Wed Mar 13, 2019 10:59 am
x 1

Re: Rotate quad that was added as triangle list

Post by mlacht » 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....
0 x

Post Reply