Changeset 5378 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Oct 14, 2005, 6:54:55 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/environment.cc
r5361 r5378 38 38 this->loadModel("models/ships/bolido.obj"); 39 39 40 /*if(this->obbTree == NULL)41 this->obbTree = new OBBTree(4, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount()); */40 if(this->obbTree == NULL) 41 this->obbTree = new OBBTree(4, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount()); 42 42 } 43 43 -
trunk/src/world_entities/test_entity.cc
r5357 r5378 37 37 // this->md2Model = new MD2Model("models/tris.md2", "models/tris.pcx"); 38 38 // this->md2Model = new MD2Model("models/goblin.md2", "maps/goblin.bmp"); 39 //this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices);39 this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices); 40 40 41 41 this->md2Model->setAnim(RUN); -
trunk/src/world_entities/weapons/crosshair.cc
r5357 r5378 64 64 65 65 this->setLayer(E2D_TOP); 66 this->rotation = 0;67 66 this->setRotationSpeed(5); 68 67 this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0); 69 68 70 this->position2D[0] = 0; 71 this->position2D[1] = 0; 72 69 this->setBindNode(this); 73 70 this->material = new Material; 74 71 … … 104 101 void Crosshair::setSize(float size) 105 102 { 106 this->s ize = size*.5;107 } ;103 this->setSize2D(size/2, size/2); 104 } 108 105 109 106 /** … … 124 121 if (event.type == EV_MOUSE_MOTION) 125 122 { 126 this->position2D[0] = event.x; 127 this->position2D[1] = event.y; 123 this->setAbsCoor2D(event.x, event.y); 128 124 } 129 130 /*131 GLdouble z;132 GLdouble objX, objY, objZ;133 glReadPixels (event.x, event.y, 1, 1, GL_DEPTH_COMPONENT, GL_DOUBLE, &z);134 135 136 if (gluUnProject(event.x,137 event.y,138 10,139 GraphicsEngine::modMat,140 GraphicsEngine::projMat,141 GraphicsEngine::viewPort,142 &objX,143 &objY,144 &objZ ))145 PRINT(0)("screen %d %d -> obj(%f/%f/%f)\n", event.x, event.y, objX, objY, objZ);146 else147 PRINT(0)("shit\n");148 */149 125 } 150 126 … … 156 132 { 157 133 // let the crosshair rotate 158 this-> rotation += dt * rotationSpeed;134 this->shiftDir2D(dt * rotationSpeed); 159 135 160 136 161 137 float z = 0.0f; 162 glReadPixels ((int)position2D[0], GraphicsEngine::getInstance()->getResolutionY()-(int)position2D[1]-1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z); 163 //cout << z << endl; 138 glReadPixels ((int)this->getAbsCoor2D().x, 139 GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1, 140 1, 141 1, 142 GL_DEPTH_COMPONENT, 143 GL_FLOAT, 144 &z); 145 164 146 165 147 GLdouble objX=.0, objY=.0, objZ=.0; 166 gluUnProject( position2D[0],167 GraphicsEngine::getInstance()->getResolutionY()- position2D[1]-1,148 gluUnProject(this->getAbsCoor2D().x, 149 GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1, 168 150 .99, // z 169 151 GraphicsEngine::modMat, … … 175 157 176 158 this->setAbsCoor(objX, objY, objZ); 177 178 //this->positioning();179 159 } 180 160 … … 184 164 void Crosshair::draw() const 185 165 { 186 // glBegin(GL_TRIANGLES);187 // glColor3f(1,0,0);188 // glVertex3f(objX, objY, objZ);189 // glVertex3f(objX, objY+1, objZ);190 // glVertex3f(objX, objY, objZ+1);191 // glEnd();192 166 glPushMatrix(); 193 GLdouble pos[3] = { 0.0, 0.0, 0.0}; 194 gluProject(this->getAbsCoor().x, 195 this->getAbsCoor().y, 196 this->getAbsCoor().z, 197 GraphicsEngine::modMat, 198 GraphicsEngine::projMat, 199 GraphicsEngine::viewPort, 200 pos, pos+1, pos+2 ); 167 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); 201 168 202 203 glTranslatef(position2D[0], position2D[1], 0); 204 glRotatef(this->rotation, 0,0,1); 169 glRotatef(this->getAbsDir2D(), 0,0,1); 205 170 this->material->select(); 206 171 glBegin(GL_TRIANGLE_STRIP); 207 172 glTexCoord2f(0, 0); 208 glVertex2f(- size, -size);173 glVertex2f(-this->getSizeX2D(), -this->getSizeY2D()); 209 174 glTexCoord2f(1, 0); 210 glVertex2f( size, -size);175 glVertex2f(this->getSizeX2D(), -this->getSizeY2D()); 211 176 glTexCoord2f(0, 1); 212 glVertex2f(- size, size);177 glVertex2f(-this->getSizeX2D(), this->getSizeY2D()); 213 178 glTexCoord2f(1, 1); 214 glVertex2f( size, size);179 glVertex2f(this->getSizeX2D(), this->getSizeY2D()); 215 180 glEnd(); 216 181 glPopMatrix(); -
trunk/src/world_entities/weapons/crosshair.h
r5039 r5378 40 40 41 41 private: 42 float position2D[2]; //!< The 2D-position on the screen43 44 42 Material* material; //!< a material for the Aim. 45 float rotation; //!< a rotation of the aim.46 43 float rotationSpeed; //!< Speed of the Rotation. 47 float size; //!< The Size of the Crosshair (in % of screen resolution 1 is fullscreen)48 44 }; 49 45 -
trunk/src/world_entities/world_entity.cc
r5302 r5378 98 98 bool WorldEntity::buildObbTree(unsigned int depth) 99 99 { 100 //if (this->obbTree)101 //delete this->obbTree;102 // 103 //if (this->model)104 //{105 //PRINTF(4)("creating obb tree\n");106 //this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());107 //return true;108 //}109 //else110 //{111 //PRINTF(2)("could not create obb-tree, because no model was loaded yet\n");112 //this->obbTree = NULL;113 //return false;114 //}100 if (this->obbTree) 101 delete this->obbTree; 102 103 if (this->model) 104 { 105 PRINTF(4)("creating obb tree\n"); 106 this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount()); 107 return true; 108 } 109 else 110 { 111 PRINTF(2)("could not create obb-tree, because no model was loaded yet\n"); 112 this->obbTree = NULL; 113 return false; 114 } 115 115 } 116 116
Note: See TracChangeset
for help on using the changeset viewer.