00001
00002
00003
00004
00005
00006
00007
00008 #include "Rect.h"
00009
00010 Rect::Rect(float length, float height, Ogre::ColourValue colour, Ogre::ManualObject* mObj) :
00011 length(length), height(height), colour(colour), mObj(mObj)
00012 {
00013 }
00014
00015 Rect::Rect(const Rect& orig)
00016 {
00017 }
00018
00019 Rect::~Rect()
00020 {
00021 }
00022
00023 void Rect::Draw(Ogre::Vector3 pos)
00024 {
00025 Ogre::Vector3 quad[4];
00026 quad[0] = Ogre::Vector3(pos.x - (length / 2.0), pos.y, pos.z - (height / 2.0));
00027 quad[1] = Ogre::Vector3(pos.x - (length / 2.0), pos.y, pos.z + (height / 2.0));
00028 quad[2] = Ogre::Vector3(pos.x + (length / 2.0), pos.y, pos.z + (height / 2.0));
00029 quad[3] = Ogre::Vector3(pos.x + (length / 2.0), pos.y, pos.z - (height / 2.0));
00030
00031 Ogre::MaterialPtr matptr = Ogre::MaterialManager::getSingleton().create("BaseColoured", "General");
00032 matptr->load();
00033 matptr->getBestTechnique()->getPass(0)->setVertexColourTracking(Ogre::TVC_DIFFUSE);
00034 matptr->getBestTechnique()->getPass(0)->setLightingEnabled(false);
00035
00036 mObj->begin("BaseColoured", Ogre::RenderOperation::OT_TRIANGLE_LIST);
00037 mObj->position(quad[0]);
00038 mObj->colour(colour);
00039
00040
00041 mObj->position(quad[1]);
00042 mObj->colour(colour);
00043
00044 mObj->position(quad[2]);
00045 mObj->colour(colour);
00046
00047 mObj->position(quad[3]);
00048 mObj->colour(colour);
00049
00050
00051 mObj->quad(0,1,2,3);
00052 mObj->end();
00053 }
00054
00055 void Rect::ClearVertices()
00056 {
00057 mObj->clear();
00058 }