Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/graphics/importer/model.cc @ 6303

Last change on this file since 6303 was 6073, checked in by bensch, 19 years ago

trunk: sync

File size: 2.2 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Patrick Boenzli
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_MODEL
17
18#include "model.h"
19
20#include "glincl.h"
21
22using namespace std;
23
24/**
25 * standard constructor
26 * @todo this constructor is not jet implemented - do it
27*/
28Model::Model()
29{
30//   this->setClassID(CL_PROTO_ID, "ProtoClass");
31  this->pModelInfo.numVertices = 0;
32  this->pModelInfo.numTriangles = 0;
33  this->pModelInfo.numNormals = 0;
34  this->pModelInfo.numTexCoor = 0;
35
36  this->pModelInfo.pVertices = NULL;
37  this->pModelInfo.pTriangles = NULL;
38  this->pModelInfo.pNormals = NULL;
39  this->pModelInfo.pTexCoor = NULL;
40}
41
42
43/**
44 * standard deconstructor
45*/
46Model::~Model()
47{
48  // delete what has to be deleted here
49}
50
51
52
53void Model::draw() const
54{
55  const GLfloat* pVertices = NULL;
56  const GLfloat* pNorm = NULL;
57 
58  glBegin(GL_TRIANGLES);
59  for( int i = 0; i < this->pModelInfo.numTriangles; ++i)
60    {
61      //printf("int i = %i\n", i);
62      pNorm = &this->pModelInfo.pNormals[this->pModelInfo.pTriangles[i].indexToNormals[0]];
63      pVertices = &this->pModelInfo.pVertices[this->pModelInfo.pTriangles[i].indexToVertices[0]];
64      glNormal3f(pNorm[0], pNorm[1], pNorm[2]);
65      glVertex3f(pVertices[0], pVertices[1], pVertices[2]);
66     
67      pNorm = &this->pModelInfo.pNormals[this->pModelInfo.pTriangles[i].indexToNormals[1]];
68      pVertices = &this->pModelInfo.pVertices[this->pModelInfo.pTriangles[i].indexToVertices[1]];
69      glNormal3f(pNorm[0], pNorm[1], pNorm[2]);
70      glVertex3f(pVertices[0], pVertices[1], pVertices[2]);
71     
72      pNorm = &this->pModelInfo.pNormals[this->pModelInfo.pTriangles[i].indexToNormals[2]];
73      pVertices = &this->pModelInfo.pVertices[this->pModelInfo.pTriangles[i].indexToVertices[2]];
74      glNormal3f(pNorm[0], pNorm[1], pNorm[2]);
75      glVertex3f(pVertices[0], pVertices[1], pVertices[2]);
76     
77    }
78  glEnd();
79}
Note: See TracBrowser for help on using the repository browser.