ogl3d.cpp
上传用户:lbr_007
上传日期:2019-05-31
资源大小:282k
文件大小:19k
- // ogl3d.cpp
- //
- #include "stdafx.h"
- #include "ogl3d.h"
- #include "dibbmp.h"
- #include <math.h>
- #include <vector>
- #include <arraycontainer.h>
- const int OGL3D_EARTH_LIST = 111;
- const int OGL3D_EARTH_LINES = 222;
- const int SOLAR_SYSTEM_LIST = 333;
- OGL3D::OGL3D(void)
- {
- InitOGL3D();
- }
- OGL3D::~OGL3D(void)
- {
- }
- void OGL3D::SetTexture(DIBSection& dib)
- {
- if (dib.IsCreated())
- {
- GenTexture(dib);
- }
- }
- void OGL3D::GenTexture(DIBSection& dib)
- {
- UINT32 width = dib.Width();
- UINT32 height = dib.Height();
- int w, h;
- UINT32 max_dimension = width > height ? width : height;
- if (width >= 512) w = 512;
- else if (width >= 256) w = 256;
- else if (width >= 128) w = 128;
- else if (width >= 64) w = 64;
- else if (width >= 32) w = 32;
- else w = 16;
- if (height >= 512) h = 512;
- else if (height >= 256) h = 256;
- else if (height >= 128) h = 128;
- else if (height >= 64) h = 64;
- else if (height >= 32) h = 32;
- else h = 16;
- dib.ResizeImage(m_texture_dib,w,h);
- if (m_texture_dib.IsCreated())
- {
- m_have_texture = 1;
- }
- }
- void OGL3D::RenderSpecialEffects(void)
- {
- double origin[] = { 0.0, 0.0, 0.0};
- double v1[] = { -0.25, 0.65, -0.95 };
- double v2[] = { 0.70, -0.60, 0.80 };
- double v3[3];
- v3[0] = (v1[1]*v2[2] - v1[2]*v2[1]);
- v3[1] = (v1[2]*v2[0] - v1[0]*v2[1]);
- v3[2] = (v1[0]*v2[1] - v1[1]*v2[0]);
- glBegin( GL_LINES );
- glColor3ub(64,64,64);
- glVertex3dv((GLdouble *)origin);
- glVertex3dv((GLdouble *)v1);
- glVertex3dv((GLdouble *)origin);
- glVertex3dv((GLdouble *)v2);
- glVertex3dv((GLdouble *)origin);
- glVertex3dv((GLdouble *)v3);
- glEnd();
- DrawCone(v1);
- DrawCone(v2);
- glColor3ub(192,192,192);
- DrawCone(v3);
- }
- void OGL3D::RenderPath(void)
- {
- GLdouble u[3], v[3], w[3];
- GLdouble R = 1.005;
- double lat1 = 39.0;
- double lon1 = 77.0;
- double lat2 = 0.0;
- double lon2 = 110.0;
- const double delta = 500.0;
- double lat, lon, phi1, phi2, theta1, theta2, lon_incr, lat_incr, d;
- glColor3ub(128,128,128);
- u[0] = 0.0; u[1] = 1.25; u[2] = 0.0;
- v[0] = 0.0; v[1] = -1.25; v[2] = 0.0;
- DrawCone(u);
- DrawCone(v);
-
- glBegin( GL_LINES );
- {
-
- phi1 = phi2 = lon1 * GEO::DE2RA;
- glVertex3dv(u);
- glVertex3dv(v);
- glColor3ub(32,32,32);
- lat_incr = (90.0 - lat1) / delta;
- for (lat = 90.0; lat >= (lat1+lat_incr); lat -= lat_incr){
- theta1 = lat * GEO::DE2RA;
- theta2 = (lat - lat_incr) * GEO::DE2RA;
- u[0] = R * cos(phi1) * cos(theta1);//x
- u[1] = R * sin(theta1);//y
- u[2] = R * sin(phi1) * cos(theta1);//z
-
- v[0] = R * cos(phi2) * cos(theta2);//x
- v[1] = R * sin(theta2);//y
- v[2] = R * sin(phi2) * cos(theta2);//z
- glVertex3dv(u);
- glVertex3dv(v);
- }
- v[0] = v[1] = v[2] = 0.0;
- glVertex3dv(u);
- glVertex3dv(v);
- phi1 = phi2 = lon2 * GEO::DE2RA;
- lat_incr = (90.0 - lat2) / delta;
- for (lat = 90.0; lat >= (lat2+lat_incr); lat -= lat_incr){
- theta1 = lat * GEO::DE2RA;
- theta2 = (lat - lat_incr) * GEO::DE2RA;
- u[0] = R * cos(phi1) * cos(theta1);//x
- u[1] = R * sin(theta1);//y
- u[2] = R * sin(phi1) * cos(theta1);//z
-
- v[0] = R * cos(phi2) * cos(theta2);//x
- v[1] = R * sin(theta2);//y
- v[2] = R * sin(phi2) * cos(theta2);//z
- glVertex3dv(u);
- glVertex3dv(v);
- }
- lat_incr = (lat2 - lat1) / delta;
- lon_incr = (lon2 - lon1) / delta;
- for (d = 0.0; d < (delta-1.0); d += 1.0000){
- theta1 = (lat1 + d * lat_incr) * GEO::DE2RA;
- theta2 = (lat1 + (d+1.00) * lat_incr) * GEO::DE2RA;
- phi1 = (lon1 + d * lon_incr) * GEO::DE2RA;
- phi2 = (lon1 + (d+1.00) * lon_incr) * GEO::DE2RA;
- u[0] = R * cos(phi1) * cos(theta1);//x
- u[1] = R * sin(theta1);//y
- u[2] = R * sin(phi1) * cos(theta1);//z
-
- v[0] = R * cos(phi2) * cos(theta2);//x
- v[1] = R * sin(theta2);//y
- v[2] = R * sin(phi2) * cos(theta2);//z
- glVertex3dv(u);
- glVertex3dv(v);
- }
- R = 2.0;
- u[0] = R * cos(phi2) * cos(theta2);//x
- u[1] = R * sin(theta2);//y
- u[2] = R * sin(phi2) * cos(theta2);//z
- glVertex3dv(u);
- glVertex3dv(v);
- R = 1.005;
- theta1 = lat1 * GEO::DE2RA;
- phi1 = lon1 * GEO::DE2RA;
- v[0] = 0.0;//R * cos(phi1) * cos(theta1);//x
- v[1] = 0.0;//R * sin(theta1);//y
- v[2] = 0.0;//R * sin(phi1) * cos(theta1);//z
- glVertex3dv(u);
- glVertex3dv(v);
- }
- glEnd();
- glColor3ub(200,200,255);
- glBegin( GL_TRIANGLES );
- {
- R = 1.005;
- phi1 = lon1 * GEO::DE2RA;
- theta1 = lat1 * GEO::DE2RA;
- phi2 = lon2 * GEO::DE2RA;
- theta2 = lat2 * GEO::DE2RA;
- u[0] = R * cos(phi1) * cos(theta1);//x
- u[1] = R * sin(theta1);//y
- u[2] = R * sin(phi1) * cos(theta1);//z
-
- R = 2.0;
- v[0] = R * cos(phi2) * cos(theta2);//x
- v[1] = R * sin(theta2);//y
- v[2] = R * sin(phi2) * cos(theta2);//z
- w[0] = w[1] = w[2] = 0.0;
- glVertex3dv(u);
- glVertex3dv(v);
- glVertex3dv(w);
- }
- glEnd();
- }
- void OGL3D::RenderPlane(void)
- {
- GLdouble u[3], v[3], w[3], n[3], uu[3], vv[3];
- double delta = 1.0;
- double theta;
- double R = 1.010;
- UINT32 count;
- w[0] = w[1] = w[2] = 0.0;
- glColor3ub(200,200,255);
- /*
- glPushMatrix();
- {
- glRotated(20.0, 0.0, 0.0, 1.0);
- glBegin( GL_TRIANGLES );
- {
- count = 0;
- for (theta=0.0;theta < 360.0; theta += delta){
- u[0] = R * cos(theta*GEO::DE2RA);
- u[1] = 0.0;
- u[2] = R * sin(theta*GEO::DE2RA);
- v[0] = R * cos((theta+delta)*GEO::DE2RA);
- v[1] = 0.0;
- v[2] = R * sin((theta+delta)*GEO::DE2RA);
- glVertex3dv(w);
- glVertex3dv(v);
- glVertex3dv(u);
- if (count == 0)
- {
- memcpy(uu,u,(size_t)(sizeof(double)*3));
- }
- if (count == 35)
- {
- memcpy(vv,u,(size_t)(sizeof(double)*3));
- }
- if (count == 12)
- {
- n[0] = 1.2 * cos(theta*GEO::DE2RA);
- n[1] = 0.0;
- n[2] = 1.2 * sin(theta*GEO::DE2RA);
- }
- count++;
- }
- }
- glEnd();
- glColor3ub(32,32,32);
- DrawCone(uu,false);
- DrawCone(vv,false);
- glBegin( GL_LINES );
- {
- u[0] = 0.0; u[1] = 0.75; u[2] = 0.0;
- glVertex3dv(w);
- glVertex3dv(u);
- //glVertex3dv(w);
- //glVertex3dv(n);
- }
- glEnd();
- DrawCone(u);
- //DrawCone(n);
- }
- glPopMatrix();
- */
- glColor3ub(200,200,255);
- glPushMatrix();
- {
- glRotated(60.0, 0.0, 1.0, 0.0);
- glRotated(50.0, 0.0, 0.0, 1.0);
- glBegin( GL_TRIANGLES );
- {
- count = 0;
- for (theta=0.0;theta < 360.0; theta += delta){
- u[0] = R * cos(theta*GEO::DE2RA);
- u[1] = 0.0;
- u[2] = R * sin(theta*GEO::DE2RA);
- v[0] = R * cos((theta+delta)*GEO::DE2RA);
- v[1] = 0.0;
- v[2] = R * sin((theta+delta)*GEO::DE2RA);
- glVertex3dv(w);
- glVertex3dv(v);
- glVertex3dv(u);
- if (count == 25)
- {
- memcpy(uu,u,(size_t)(sizeof(double)*3));
- }
- if (count == 75)
- {
- memcpy(vv,u,(size_t)(sizeof(double)*3));
- }
- count++;
- }
- }
- glEnd();
- glColor3ub(32,32,32);
- DrawCone(uu,false);
- DrawCone(vv,false);
- glBegin( GL_LINES );
- {
- u[0] = 0.0; u[1] = 0.75; u[2] = 0.0;
- glVertex3dv(w);
- glVertex3dv(u);
- }
- glEnd();
- DrawCone(u);
- }
- glPopMatrix();
- }
- void OGL3D::RenderPrimaryImage(void)
- {
- if ( m_draw_mode == DrawLines )
- {
- glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
- }
- else
- {
- glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
- }
- #ifndef RENDER_FUNCTION
- glColor3ub(96,96,96);
- RenderGlobe();
- //RenderCylinder();
- RenderRectangle();
- //RenderCone();
- //GLView3D::RenderPrimaryImage();
- //RenderSpecialEffects();
- //RenderEarthImage();
- //RenderPath();
- //RenderPlane();
- #else
- //RenderFunction();
- #endif
- }
- namespace FXYDomain {
- const double xmin = 0.0;
- const double xmax = 8.0;
- const double ymin = 0.0;
- const double ymax = 8.0;
- const double xincr = 0.50;
- const double yincr = 0.50;
- };
- #define FXY(x,y) (2.0 * exp(-x) * exp(-2.0 * y))
- void OGL3D::RenderFunction(void)
- {
- //GLView3D::RenderPrimaryImage();
- UINT32 ndx1, ndx2;
- double x, y, z, zmin, zmax;
- double scale;
- GLdouble u[3], v[3], w[3], n[3];
- UINT32 nrows = (UINT32)(0.50 + (FXYDomain::ymax - FXYDomain::ymin)/FXYDomain::yincr);
- UINT32 ncols = (UINT32)(0.50 + (FXYDomain::xmax - FXYDomain::xmin)/FXYDomain::xincr);
- zmin = 1e10;
- zmax = -1e10;
- ArrayContainer<double> grid;
- grid.SetBufferSize(nrows*ncols);
- for (UINT32 row = 0; row < nrows; row++){
- y = FXYDomain::ymin + row * FXYDomain::yincr;
- for (UINT32 col = 0; col < ncols; col++){
- x = FXYDomain::xmin + col * FXYDomain::xincr;
- z = FXY(x,y);
- if (z < zmin) zmin = z;
- if (z > zmax) zmax = z;
- grid.AddElement(z);
- }
- }
- double xscale = 1.0 / (FXYDomain::xmax - FXYDomain::xmin);
- double yscale = 1.0 / (FXYDomain::ymax - FXYDomain::ymin);
- double zscale = 1.0 / (zmax - zmin);
- scale = (xscale < yscale) ? xscale : yscale;
- scale = (scale < zscale) ? scale : zscale;
- double * ptr = grid.GetData();
- glColor3ub(0,0,224);
- if ( m_draw_mode == DrawLines )
- {
- glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
- }
- else
- {
- glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
- }
- /*
- glBegin( GL_TRIANGLES );
- {
- for (UINT32 row = 0; row < (nrows-1); row++){
- y = FXYDomain::ymin + row * FXYDomain::yincr;
- for (UINT32 col = 0; col < (ncols-1); col++){
- x = FXYDomain::xmin + col * FXYDomain::xincr;
- ndx1 = row * ncols + col;
- ndx2 = (row + 1) * ncols + col;
- u[0] = x*scale; u[1] = ptr[ndx1]*scale; u[2] = y*scale;
- v[0] = (x + FXYDomain::xincr)*scale; v[1] = ptr[ndx2+1]*scale; v[2] = (y + FXYDomain::yincr)*scale;
- w[0] = x*scale; w[1] = ptr[ndx2]*scale; w[2] = (y + FXYDomain::yincr)*scale;
- NormalVector(u,v,w,n);
- glNormal3dv(n);
- glVertex3dv(u);
- glVertex3dv(v);
- glVertex3dv(w);
- u[0] = x*scale; u[1] = ptr[ndx1]*scale; u[2] = y*scale;
- v[0] = (x + FXYDomain::xincr)*scale; v[1] = ptr[ndx1+1]*scale; v[2] = y*scale;
- w[0] = (x + FXYDomain::xincr)*scale; w[1] = ptr[ndx2+1]*scale; w[2] = (y + FXYDomain::yincr)*scale;
- NormalVector(u,w,v,n);
- glNormal3dv(n);
- glVertex3dv(u);
- glVertex3dv(w);
- glVertex3dv(v);
- }
- }
- }
- glEnd();
- */
- glColor3ub(224,0,0);
- glBegin(GL_LINES);
- {
- for (int i=1;i<19;i++){
- y = (double)i/2.0;
- u[0] = sqrt(y)*scale; u[1] = 0.0; u[2] = y*scale;
- v[0] = 8.0*scale;; v[1] = 0.0; v[2] = y*scale;
- glVertex3dv(u);
- glVertex3dv(v);
- }
- }
- glEnd();
- }
- void OGL3D::RenderRectangle()
- {
- glColor3ub(224,0,0);
- glPushMatrix();
- {
- GLdouble D = 0.50;
- glRotated(-45.0, 0.0, 1.0, 0.0);
- glRotated(-60.0, 1.0, 0.0, 0.0);
- glTranslated(0.0, 0.0, 1.0);
- glBegin(GL_LINES);
- {
- GLdouble u[3], v[3], w[3];
- u[0] = -D; u[1] = -D; u[2] = 0.0;
- v[0] = D; v[1] = -D; v[2] = 0.0;
- glVertex3dv(u);
- glVertex3dv(v);
- u[0] = D; u[1] = D; u[2] = 0.0;
- glVertex3dv(v);
- glVertex3dv(u);
- v[0] = -D; v[1] = D; v[2] = 0.0;
- glVertex3dv(u);
- glVertex3dv(v);
- u[0] = -D; u[1] = -D; u[2] = 0.0;
- glVertex3dv(v);
- glVertex3dv(u);
- }
- glEnd();
- }
- glPopMatrix();
- }
- void OGL3D::RenderCylinder()
- {
- glPushMatrix();
- {
-
- glRotated(90.0, 0.0, 1.0, 0.0);
- glTranslated(0.0, 0.0, -1.0);
- GLUquadricObj * q = gluNewQuadric();
- gluQuadricDrawStyle(q, GLU_LINE);
- gluQuadricNormals(q, GLU_SMOOTH);
- gluCylinder(q, 1.0, 1.0, 2.0, 36, 36);
- gluDeleteQuadric(q);
- }
- glPopMatrix();
- }
- void OGL3D::RenderCone()
- {
- glPushMatrix();
- {
- glTranslated(0.0, 1.414, 0.0);
- glRotated(90.0, 1.0, 0.0, 0.0);
- GLUquadricObj * q = gluNewQuadric();
- //gluQuadricDrawStyle(q, m_draw_mode==DrawLines ? GLU_LINE : GLU_FILL );
- gluQuadricDrawStyle(q, GLU_LINE);
- gluQuadricNormals(q, GLU_SMOOTH);
- gluCylinder(q, 0.00, 1.414, 1.414, 36, 36);
- gluDeleteQuadric(q);
- }
- glPopMatrix();
- }
- void OGL3D::RenderGlobe()
- {
- /*
- glPushMatrix();
- {
- glRotated(-90.0, 1.0, 0.0, 0.0);
- GLUquadricObj * q = gluNewQuadric();
- //gluQuadricDrawStyle(q, m_draw_mode==DrawLines ? GLU_LINE : GLU_FILL);
- gluQuadricDrawStyle(q, GLU_FILL);
- gluQuadricNormals(q, GLU_SMOOTH);
- gluSphere(q,1.0,16,16);
- gluDeleteQuadric(q);
- }
- glPopMatrix();
- */
- const int NumLatitudes = 18;
- const int NumLongitudes = 36;
- double start_lat, start_lon;
- double theta1, phi1, theta2, phi2, lat_incr, lon_incr;
- GLdouble u[3], v[3], w[3], n[3];
- GLdouble R;
- if (!m_model_built)
- {
- glNewList( OGL3D_EARTH_LIST, GL_COMPILE);
- glColor3ub(192,192,192);
- if (m_have_texture)
- {
- glTexImage2D(GL_TEXTURE_2D,0,3,m_texture_dib.Width(),m_texture_dib.Height(),
- 0,GL_BGR_EXT,GL_UNSIGNED_BYTE,(GLvoid *)m_texture_dib.GetBits());
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
- //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glEnable( GL_TEXTURE_2D );
- }
- else
- {
- glDisable( GL_TEXTURE_2D );
- }
- m_model_built = 1;
- glBegin( GL_TRIANGLES );
- start_lat = -90;
- start_lon = 0.0;
- R = 1.0;
- lat_incr = 180.0 / NumLatitudes;
- lon_incr = 360.0 / NumLongitudes;
- int row, col;
- for (col = 0; col < NumLongitudes; col++){
- phi1 = (start_lon + col * lon_incr) * GEO::DE2RA;
- phi2 = (start_lon + (col + 1) * lon_incr) * GEO::DE2RA;
- for (row = 0; row < NumLatitudes; row++){
- theta1 = (start_lat + row * lat_incr) * GEO::DE2RA;
- theta2 = (start_lat + (row + 1) * lat_incr) * GEO::DE2RA;
- u[0] = R * cos(phi1) * cos(theta1);//x
- u[1] = R * sin(theta1);//y
- u[2] = R * sin(phi1) * cos(theta1);//z
-
- v[0] = R * cos(phi1) * cos(theta2);//x
- v[1] = R * sin(theta2);//y
- v[2] = R * sin(phi1) * cos(theta2);//z
- w[0] = R * cos(phi2) * cos(theta2);//x
- w[1] = R * sin(theta2);//y
- w[2] = R * sin(phi2) * cos(theta2);//z
- NormalVector(u,v,w,n);
- glNormal3dv(n);
- glTexCoord2d((180.0 - phi1*GEO::RA2DE)/360.0,(theta1 + GEO::PIOVER2)*GEO::RA2DE/180.0);
- glVertex3dv(u);
- glTexCoord2d((180.0 - phi1*GEO::RA2DE)/360.0,(theta2 + GEO::PIOVER2)*GEO::RA2DE/180.0);
- glVertex3dv(v);
- glTexCoord2d((180.0 - phi2*GEO::RA2DE)/360.0,(theta2 + GEO::PIOVER2)*GEO::RA2DE/180.0);
- glVertex3dv(w);
- v[0] = R * cos(phi2) * cos(theta1);//x
- v[1] = R * sin(theta1);//y
- v[2] = R * sin(phi2) * cos(theta1);//z
- NormalVector(u,w,v,n);
- glNormal3dv(n);
- glTexCoord2d((180.0 - phi1*GEO::RA2DE)/360.0,(theta1 + GEO::PIOVER2)*GEO::RA2DE/180.0);
- glVertex3dv(u);
- glTexCoord2d((180.0 - phi2*GEO::RA2DE)/360.0,(theta2 + GEO::PIOVER2)*GEO::RA2DE/180.0);
- glVertex3dv(w);
- glTexCoord2d((180.0 - phi2*GEO::RA2DE)/360.0,(theta1 + GEO::PIOVER2)*GEO::RA2DE/180.0);
- glVertex3dv(v);
- }
- }
- glEnd();
- if (m_have_texture)
- {
- glDisable( GL_TEXTURE_2D );
- }
- glEndList();
- }
- glCallList( OGL3D_EARTH_LIST );
- }
- void OGL3D::RenderEarthImage(void)
- {
- const int NumLatitudes = 36;
- const int NumLongitudes = 72;
- double start_lat, start_lon;
- double theta1, phi1, theta2, phi2, lat_incr, lon_incr;
- GLdouble u[3], v[3], w[3], n[3];
- GLdouble R;
- if (!m_model_built)
- {
- glNewList( OGL3D_EARTH_LIST, GL_COMPILE);
- glColor3ub(192,192,192);
- if (m_have_texture)
- {
- glTexImage2D(GL_TEXTURE_2D,0,3,m_texture_dib.Width(),m_texture_dib.Height(),
- 0,GL_BGR_EXT,GL_UNSIGNED_BYTE,(GLvoid *)m_texture_dib.GetBits());
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
- //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glEnable( GL_TEXTURE_2D );
- }
- else
- {
- glDisable( GL_TEXTURE_2D );
- }
- m_model_built = 1;
- glBegin( GL_TRIANGLES );
- start_lat = -90;
- start_lon = 0.0;
- R = 1.0;
- lat_incr = 180.0 / NumLatitudes;
- lon_incr = 360.0 / NumLongitudes;
- int row, col;
- for (col = 0; col < NumLongitudes; col++){
- phi1 = (start_lon + col * lon_incr) * GEO::DE2RA;
- phi2 = (start_lon + (col + 1) * lon_incr) * GEO::DE2RA;
- for (row = 0; row < NumLatitudes; row++){
- theta1 = (start_lat + row * lat_incr) * GEO::DE2RA;
- theta2 = (start_lat + (row + 1) * lat_incr) * GEO::DE2RA;
- u[0] = R * cos(phi1) * cos(theta1);//x
- u[1] = R * sin(theta1);//y
- u[2] = R * sin(phi1) * cos(theta1);//z
-
- v[0] = R * cos(phi1) * cos(theta2);//x
- v[1] = R * sin(theta2);//y
- v[2] = R * sin(phi1) * cos(theta2);//z
- w[0] = R * cos(phi2) * cos(theta2);//x
- w[1] = R * sin(theta2);//y
- w[2] = R * sin(phi2) * cos(theta2);//z
- NormalVector(u,v,w,n);
- glNormal3dv(n);
- glTexCoord2d((180.0 - phi1*GEO::RA2DE)/360.0,(theta1 + GEO::PIOVER2)*GEO::RA2DE/180.0);
- glVertex3dv(u);
- glTexCoord2d((180.0 - phi1*GEO::RA2DE)/360.0,(theta2 + GEO::PIOVER2)*GEO::RA2DE/180.0);
- glVertex3dv(v);
- glTexCoord2d((180.0 - phi2*GEO::RA2DE)/360.0,(theta2 + GEO::PIOVER2)*GEO::RA2DE/180.0);
- glVertex3dv(w);
- v[0] = R * cos(phi2) * cos(theta1);//x
- v[1] = R * sin(theta1);//y
- v[2] = R * sin(phi2) * cos(theta1);//z
- NormalVector(u,w,v,n);
- glNormal3dv(n);
- glTexCoord2d((180.0 - phi1*GEO::RA2DE)/360.0,(theta1 + GEO::PIOVER2)*GEO::RA2DE/180.0);
- glVertex3dv(u);
- glTexCoord2d((180.0 - phi2*GEO::RA2DE)/360.0,(theta2 + GEO::PIOVER2)*GEO::RA2DE/180.0);
- glVertex3dv(w);
- glTexCoord2d((180.0 - phi2*GEO::RA2DE)/360.0,(theta1 + GEO::PIOVER2)*GEO::RA2DE/180.0);
- glVertex3dv(v);
- }
- }
- glEnd();
- if (m_have_texture)
- {
- glDisable( GL_TEXTURE_2D );
- }
- //GLView3D::RenderPrimaryImage();
- glEndList();
- /*
- glNewList( OGL3D_EARTH_LINES, GL_COMPILE );
- start_lat = -85.0;
- lat_incr = 5.0000;
- lon_incr = 5.0 / 60.0; // 5 minutes of arc
- R = 1.00100;
- glBegin( GL_LINES );
- for (col = 0; col < NumLongitudes; col++){
- phi1 = (start_lon + col * lon_incr) * GEO::DE2RA;
- phi2 = (start_lon + (col + 1) * lon_incr) * GEO::DE2RA;
- for (row = 0; row < NumLatitudes; row++){
- theta1 = (start_lat + row * lat_incr) * GEO::DE2RA;
- theta2 = (start_lat + (row + 1) * lat_incr) * GEO::DE2RA;
- u[0] = R * cos(phi1) * cos(theta1);//x
- u[1] = R * sin(theta1);//y
- u[2] = R * sin(phi1) * cos(theta1);//z
-
- v[0] = R * cos(phi1) * cos(theta2);//x
- v[1] = R * sin(theta2);//y
- v[2] = R * sin(phi1) * cos(theta2);//z
- w[0] = R * cos(phi2) * cos(theta2);//x
- w[1] = R * sin(theta2);//y
- w[2] = R * sin(phi2) * cos(theta2);//z
- glVertex3dv(u);
- glVertex3dv(v);
- glVertex3dv(v);
- glVertex3dv(w);
- v[0] = R * cos(phi2) * cos(theta1);//x
- v[1] = R * sin(theta1);//y
- v[2] = R * sin(phi2) * cos(theta1);//z
- glVertex3dv(u);
- glVertex3dv(v);
- glVertex3dv(v);
- glVertex3dv(w);
- }
- }
- glEnd();
- glEndList();
- */
- }
- glCallList( OGL3D_EARTH_LIST );
- //glCallList( OGL3D_EARTH_LINES );
- }