Changeset 6654 in orxonox.OLD for branches/network/src/world_entities/planet.cc
- Timestamp:
- Jan 23, 2006, 12:08:34 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/world_entities/planet.cc
r6634 r6654 27 27 #include "network_game_manager.h" 28 28 #include "converter.h" 29 #include "vertex_array_model.h" 30 #include "primitive_model.h" 29 31 30 32 using namespace std; … … 44 46 45 47 this->material = new Material(); 46 this->material->setIllum(10); 48 //this->material->setIllum(20); 49 //this->material->setAmbient(0.1, 0.1, 0.1); 50 51 52 53 //st float radius, const unsigned int loops, const unsigned int segmentsPerLoop 47 54 48 55 this->loadParams(root); 56 57 // VertexArrayModel* model = new VertexArrayModel(); 58 // model->spiralSphere(this->size, 10, 10); 59 // this->setModel(model); 60 // model->debug(); 61 // 62 PrimitiveModel* model = new PrimitiveModel(PRIM_SPHERE, this->size, 50); 63 this->setModel(model); 49 64 } 50 65 … … 98 113 { 99 114 115 100 116 glMatrixMode(GL_MODELVIEW); 101 117 glPushMatrix(); 118 119 glShadeModel(GL_SMOOTH); 102 120 103 121 /* translate */ … … 109 127 this->material->select(); 110 128 111 112 Vector c; 113 double r = this->size; 114 int n = 200; 115 int method = 1; 116 double theta1 = 0; 117 double theta2 = 2 * M_PI; 118 double phi1 = -M_PI/2.0; 119 double phi2 = M_PI/2.0; 120 121 122 int i,j; 123 double jdivn,j1divn,idivn,dosdivn,unodivn=1/(double)n,ndiv2=(double)n/2,t1,t2,t3,cost1,cost2,cte1,cte3; 124 cte3 = (theta2-theta1)/n; 125 cte1 = (phi2-phi1)/ndiv2; 126 dosdivn = 2*unodivn; 127 Vector e,p,e2,p2; 128 129 130 t2=phi1; 131 cost2=cos(phi1); 132 j1divn=0; 133 for (j=0;j<ndiv2;j++) { 134 t1 = t2;//t1 = phi1 + j * cte1; 135 t2 += cte1;//t2 = phi1 + (j + 1) * cte1; 136 t3 = theta1 - cte3; 137 cost1 = cost2;//cost1=cos(t1); 138 cost2 = cos(t2); 139 e.y = sin(t1); 140 e2.y = sin(t2); 141 p.y = c.y + r * e.y; 142 p2.y = c.y + r * e2.y; 143 144 if (method == 0) 145 glBegin(GL_QUAD_STRIP); 146 else 147 glBegin(GL_TRIANGLE_STRIP); 148 149 idivn=0; 150 jdivn=j1divn; 151 j1divn+=dosdivn;//=2*(j+1)/(double)n; 152 for (i=0;i<=n;i++) { 153 //t3 = theta1 + i * (theta2 - theta1) / n; 154 t3 += cte3; 155 e.x = cost1 * cos(t3); 156 //e.y = sin(t1); 157 e.z = cost1 * sin(t3); 158 p.x = c.x + r * e.x; 159 //p.y = c.y + r * e.y; 160 p.z = c.z + r * e.z; 161 glNormal3f(e.x,e.y,e.z); 162 glTexCoord2f(idivn,jdivn); 163 glVertex3f(p.x,p.y,p.z); 164 165 166 e2.x = cost2 * cos(t3); 167 //e.y = sin(t2); 168 e2.z = cost2 * sin(t3); 169 p2.x = c.x + r * e2.x; 170 //p.y = c.y + r * e.y; 171 p2.z = c.z + r * e2.z; 172 glNormal3f(e2.x,e2.y,e2.z); 173 glTexCoord2f(idivn,j1divn); 174 glVertex3f(p2.x,p2.y,p2.z); 175 idivn += unodivn; 176 } 177 glEnd(); 178 } 129 // /WorldEntity::draw(); 130 this->getModel(0)->draw(); 131 // static_cast<VertexArrayModel*>(this->getModel(0))->debug(); 179 132 } 180 133
Note: See TracChangeset
for help on using the changeset viewer.