Earth3D.h
上传用户:lbr_007
上传日期:2019-05-31
资源大小:282k
文件大小:4k
- // Earth3D.h
- //
- #ifndef EARTH3D_H_
- #define EARTH3D_H_
- #include <glview.h>
- #include <dibsect.h>
- #include <ArrayContainer.h>
- #include <utmproj.h>
- class GEOTex {
- void initTexture(void)
- {
- m_hScale = m_vScale = 1.0;
- m_pj = 0;
- }
- public:
- //
- // m_imgData holds the actual (r,g,b) pixels - one byte per component.
- // m_texWidth & m_texHeight store the dimensions of the texture data
- // m_imgWidth & m_imgHeight store the dimensions of the picture within
- // the texture data. so m_imgWidth & m_imgHeight may be smaller than
- // m_texWidth & m_texHeight...this is all on account of the OpenGL
- // requirement that each dimension of the texture be a power of 2 in
- // magnitude, at the same time we want to maintain the aspect ratio of
- // the original image.
- //
- ArrayContainer<unsigned char> m_imgData;
- double m_hScale;
- double m_vScale;
- UINT32 m_texWidth;
- UINT32 m_texHeight;
- UTMProjection * m_pj;
- GEORef m_gr;
- GEOTex(void){ initTexture();}
- GEOTex(const GEOTex& t)
- {
- initTexture();
- Copy(t);
- }
- ~GEOTex(void){}
- void Copy(const GEOTex& t)
- {
- m_imgData.Copy(t.m_imgData);
- m_hScale = t.m_hScale;
- m_vScale = t.m_vScale;
- m_texWidth = t.m_texWidth;
- m_texHeight = t.m_texHeight;
- m_gr = t.m_gr;
- }
- GEOTex& operator = (const GEOTex& t)
- {
- Copy(t);
- return *this;
- }
- void CreateTexture(DIBSection& dib, UTMProjection * pj);
- void DrawTexture(void);
- bool IsCreated(void)const{ return (m_imgData.GetSize() > 0) ? true : false;}
- };
- class Earth3D : public GLView3D {
- public:
- enum Earth3DDrawModes {
- DrawLines,
- DrawTriangles
- };
- private:
- void InitEarth3D(void)
- {
- m_model_built = 0;
- m_draw_mode = DrawTriangles;
- m_rebuildEarth = m_rebuildTexture = true;
- m_flyMode = false;
- m_drawFlyer = true;
- m_flyFirstPerson = false;
- m_buildAircraft = true;
- }
- protected:
- GEOTex m_gt;
- int m_model_built;
- Earth3DDrawModes m_draw_mode;
-
- DIBSection m_texture_dib;
- bool m_rebuildEarth;
- bool m_rebuildTexture;
- // lat & lon of the center of the image
- double m_centerLat;
- double m_centerLon;
- // bunch of vectors for figuring out the view direction
- double m_eyeDist;
- double m_centerPt[3];
- double m_eyePt[3];
- double m_unitSouthPt[3];
- double m_unitEastPt[3];
- double m_unitCenterPt[3];
- double m_upVec[3];
- DIBSection m_northHdr;
- // picking and flying variables
- double m_pickLat;
- double m_pickLon;
- bool m_pickPoint;
- bool m_flyMode;
- bool m_drawFlyer;
- bool m_flyFirstPerson;
- bool m_buildAircraft;
- GLdouble m_flyPt[3];
- GLdouble m_flyTo[3];
- public:
- Earth3D(void);
- ~Earth3D(void);
- virtual void RenderPrimaryImage(void);
- virtual void SetOrientation(void);
- void RenderEarthImage(void);
- void RenderPickImage(void);
- void RenderDirectionHeaders(DIBSection& dib, int direction);
- void RenderGEOImage(void);
- void RenderAircraftImage(void);
- void SetGeoImage(DIBSection * dib, UTMProjection * pj);
- void SetDrawingMode(Earth3DDrawModes mode){ m_draw_mode = mode;}
- Earth3DDrawModes GetDrawingMode(void)const{ return m_draw_mode;}
- void RebuildEarth(void){ m_rebuildEarth = true;}
- void RebuildTexture(void){ m_rebuildTexture = true;}
- void RebuildAircraft(void){ m_buildAircraft = true;}
- virtual void RebuildImage(void){ m_reRender = true; RebuildEarth(); RebuildTexture(); RebuildAircraft();}
- void GenTexture(DIBSection& dib);
- void SetTexture(DIBSection& dib);
- void GeoToXYZ(double lat, double lon, double& x, double& y, double& z, double R = 1.0);
- bool PickedPoint(void)const{ return m_pickPoint;}
- double GetPickedLat(void)const{ return m_pickLat;}
- double GetPickedLon(void)const{ return m_pickLon;}
- void SetFlyMode(bool tf){ m_flyMode = tf;}
- bool GetFlyMode(void)const{ return m_flyMode;}
- void SetFlyPosition(double u[3], double v[3], bool firstPerson);
- };
- #endif