Changeset 10065 in orxonox.OLD for branches/camera/src/world_entities
- Timestamp:
- Dec 13, 2006, 3:23:05 PM (18 years ago)
- Location:
- branches/camera/src/world_entities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/camera/src/world_entities/camera.cc
r9869 r10065 18 18 #include "key_mapper.h" 19 19 #include "glincl.h" 20 #include "vector.h" 21 #include <iostream.h> 22 20 23 21 24 ObjectListDefinition(Camera); … … 138 141 this->viewVector = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized(); 139 142 this->frustumPlane = Plane(this->viewVector, this->getAbsCoor() + this->viewVector * 0.1); 140 141 143 this->upVector = this->getAbsDirV(); 144 145 146 142 147 143 148 … … 179 184 Vector targetPosition = this->target->getAbsCoor(); 180 185 181 //Setting the Camera Eye, lookAt and up Vectors182 gl uLookAt(cameraPosition.x, cameraPosition.y, cameraPosition.z,186 //Setting the Camera Eye, lookAt and up Vectors 187 glLookAt(cameraPosition.x, cameraPosition.y, cameraPosition.z, 183 188 targetPosition.x, targetPosition.y, targetPosition.z, 184 189 this->upVector.x, this->upVector.y, this->upVector.z); … … 217 222 } 218 223 } 224 225 /* 226 Vector* Camera::translate(Vector* newPos, float speed) 227 { 228 glTranslatef(Vector); 229 230 } 231 232 233 float Camera::iterate(float dt, Vector target) 234 { 235 Vector tmpVec = (this->getAbsCorr() - target); 236 if (tmpVec > 0.01) 237 Vector ret = this->getAbsCorr; 238 ret += tmpVec * fabsf(dt); 239 return ret; 240 } 241 */ 242 void Camera::Rotate() 243 { 244 this->fovy=this->fovy+1; 245 } 246 247 248 void Camera::glLookAt(float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz) 249 { 250 //Vector* eye=new Vector(eyex, eyey, eyez); 251 Vector* center=new Vector (centerx, centery, centerz); 252 Vector* up=new Vector(upx, upy, upz); 253 254 center->x-=eyex; 255 center->y-=eyey; 256 center->z-=eyez; 257 258 center->normalize(); 259 up->normalize(); 260 Vector* s = VectorProd(center, up); 261 Vector* u = VectorProd(s, center); 262 GLfloat Matrix[]={s->x, s->y, s->z, 0, u->x, u->y, u->z, 0, -center->x, -center->y, -center->z, 0, 0, 0, 0, 1}; 263 264 glMultMatrixf(Matrix); 265 glTranslated(-eyex, -eyey, -eyez); 266 delete center; 267 delete up; 268 delete s; 269 delete u; 270 271 } 272 273 274 275 276 Vector* Camera::VectorProd(Vector* v1, Vector* v2) 277 { 278 Vector* temp= new Vector(); 279 temp->x=v1->y * v2->z - v1->z * v2->y; 280 temp->y=v1->z * v2->x - v1->x * v2->z; 281 temp->z=v1->x * v2->y - v1->y * v2->x; 282 return temp; 283 } 284 285 286 287 288 289 290 291 292 293 294 295 219 296 220 297 … … 228 305 this->registerObject(this, CameraTarget::_objectList); 229 306 // this->setParentMode(PNODE_MOVEMENT); 230 } 231 307 308 309 } 310 311 312 CameraTarget::detach() 313 { 314 State::getCameraTargetNode()->setParentSoft(NULL); 315 } 316 317 318 319 320 -
branches/camera/src/world_entities/camera.h
r9869 r10065 58 58 inline float distance(const PNode* node) const { return distance(node->getAbsCoor()); } 59 59 60 void glLookAt(float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz); 61 Vector* VectorProd(Vector* v1, Vector* v2); 62 void Rotate(); 60 63 void tick(float dt); 61 64 void apply (); -
branches/camera/src/world_entities/test_entity.cc
r10018 r10065 25 25 26 26 27 27 #include "material.h" 28 28 29 29 #include "state.h" … … 73 73 this->registerObject(this, TestEntity::_objectList); 74 74 this->toList(OM_GROUP_00); 75 76 this->material = new Material(); 77 this->material->setIllum(3); 78 this->material->setDiffuse(1.0,1.0,1.0); 79 this->material->setSpecular(0.0,0.0,0.0); 80 this->material->setAmbient(1.0, 1.0, 1.0); 81 this->material->setDiffuseMap("maps/TE2.tga"); 75 82 } 76 83 … … 93 100 glDisable(GL_LIGHTING); 94 101 // glDisable(GL_BLEND); 95 // 102 // 96 103 // glEnable(GL_TEXTURE_2D); 97 104 // glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter)); … … 104 111 //PRINTF(0)("axis: %f\n", axis); 105 112 glEnable(GL_BLEND); // Turn Blending On 106 113 107 114 108 115 … … 121 128 glEnd(); 122 129 123 //glPopMatrix();124 //glPopAttrib();130 glPopMatrix(); 131 glPopAttrib(); 125 132 } 126 133 … … 130 137 void TestEntity::tick (float time) 131 138 { 132 if (state==0) 133 i=0; 134 else 135 i=i+0.005; 136 137 138 139 139 if (state==0 && i==1) 140 i=0; 141 if (state==1 && i<=1) 142 i=i+0.005; 140 143 } 141 144 142 145 143 //voidTestEntity::changeState (bool sta)144 //{145 //state=sta;146 //}146 void TestEntity::changeState (bool sta) 147 { 148 state=sta; 149 } -
branches/camera/src/world_entities/test_entity.h
r10018 r10065 5 5 6 6 class TiXmlElement; 7 7 class Material; 8 8 9 9 class TestEntity : public WorldEntity 10 10 { 11 11 ObjectListDeclaration(TestEntity); 12 13 private: 14 15 Material* material; 12 16 13 17 public: … … 19 23 virtual void loadParams(const TiXmlElement* root); 20 24 21 25 void changeState (bool); 22 26 virtual void tick (float time); 23 27 virtual void draw() const;
Note: See TracChangeset
for help on using the changeset viewer.