Creating rectangle manual objects

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

Creating rectangle manual objects

Post by mlacht » Fri Mar 15, 2019 8:46 am

Hey there,

I want to add a general rectangle image to a material btw. a Ogre::ManualObject *obj. My code already works for quads however it fails for rectnalges as you can see in this image:

Image

Here is my current code:

Code: Select all

Ogre::ManualObject *obj = scene_manager_->createManualObject(obj_name);
 //  create a quad for this tile
      obj->begin(material->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST);

      //  bottom left
      obj->position(0, 0, 0);
      obj->textureCoord(0.0f, 0.0f);
      obj->normal(0.0f, 0.0f, 1.0f);

      // top right
      obj->position(0 + tile_w, 0 + tile_h, 0);
      obj->textureCoord(1.0f, 1.0f);
      obj->normal(0.0f, 0.0f, 1.0f);

      // top left
      obj->position(0, 0 + tile_h, -0);
      obj->textureCoord(0.0f, 1.0f);
      obj->normal(0.0f, 0.0f, 1.0f);

      //  bottom left
      obj->position(0, 0, 0);
      obj->textureCoord(0.0f, 0.0f);
      obj->normal(0.0f, 0.0f, 1.0f);

      // bottom right
      obj->position(0+ tile_w, 0, 0);
      obj->textureCoord(1.0f, 0.0f);
      obj->normal(0.0f, 0.0f, 1.0f);

      // top right
      obj->position(0 + tile_w, 0 + tile_h, 0);
      obj->textureCoord(1.0f, 1.0f);
      obj->normal(0.0f, 0.0f, 1.0f);

   obj->end();
   

I also saw that there are other tutorials as http://wiki.ogre3d.org/Intermediate+Tutorial+5, but all are focusing on quads.

Any ideas how I have to modify my code?
0 x

Post Reply