glOOP.h
上传用户:shxiangxiu
上传日期:2007-01-03
资源大小:1101k
文件大小:61k
源码类别:

OpenGL

开发平台:

Visual C++

  1. /////////////////////////////////////////////////////////////////////////////
  2. // glOOP.h : Header file; Defines the class definitions
  3. //
  4. // glOOP (OpenGL Object Oriented Programming library)
  5. // Copyright (c) Craig Fahrnbach, ImageWare Development, 1997-1999
  6. // All rights reserved.
  7. //
  8. // OpenGL is a registered trademark of Silicon Graphics
  9. //
  10. //
  11. // This program is provided for educational and personal use only and
  12. // is provided without guarantee or warrantee expressed or implied.
  13. //
  14. // Commercial use is strickly prohibited without written permission
  15. // from ImageWare Development.
  16. //
  17. // This program is -not- in the public domain.
  18. //
  19. //
  20. // This file should be included in your application's main
  21. // include file so that it is available to all modules that
  22. // need access the the OpenGL 3D classes
  23. //
  24. /////////////////////////////////////////////////////////////////////////////
  25. #include <glgl.h> // OpenGL extensions
  26. #include <glglu.h>
  27. #include <glglaux.h>
  28. #include <vfw.h>
  29. #include <math.h>
  30. #include "resource.h"
  31. #include "glMath.h"
  32. #include "MyFileIO.h"
  33. #ifndef _glOOP_H_
  34. #define _glOOP_H_
  35. /////////////////////////////////////////////////////////////////////////////
  36. // Define DLL import/export
  37. //
  38. #if !defined (_WIN32)
  39. #   define EXPORT __export
  40. #   define EXPORT32
  41. #else
  42. #   define EXPORT
  43. #   if defined DLL
  44. #      define EXPORT32 __declspec(dllexport)
  45. #   else
  46. #      define EXPORT32 __declspec(dllimport)
  47. #   endif
  48. #endif
  49. /////////////////////////////////////////////////////////////////////////////
  50. // Macros to display/remove hourglass cursor for lengthy operations
  51. //
  52. #define StartWait() m_hcurSave = SetCursor(LoadCursor(NULL, IDC_WAIT))
  53. #define EndWait()   SetCursor(m_hcurSave)
  54. #define WRITE_BUFFERS 2
  55. /////////////////////////////////////////////////////////////////////////////
  56. // Definitions
  57. //
  58. #define SHAPE_OBJECT 0
  59. #define LIGHT_OBJECT 1
  60. #define LIGHT_AMBIENT 0
  61. #define LIGHT_POINT 1
  62. #define LIGHT_SPOT 2
  63. #define DISPLAY_NONE 0
  64. #define DISPLAY_SPHERE 1
  65. #define DISPLAY_CYLINDER 2
  66. #define DISPLAY_RECTANGLE 3
  67. #define VIEW_ISO 0
  68. #define VIEW_FRONT 1
  69. #define VIEW_SIDE 2
  70. #define VIEW_TOP 3
  71. #define RENDER_WIREFRAME 0
  72. #define RENDER_FLAT 1
  73. #define RENDER_SMOOTH 2
  74. #define RENDER_RAYTRACE 3
  75. #define RENDER_OUTLINE 4
  76. #define CSG_TYPE_OR 0
  77. #define CSG_TYPE_SUB_AB 1
  78. #define CSG_TYPE_SUB_BA 2
  79. #define CSG_TYPE_AND 3
  80. #define MAX_FACES_PER_SEGMENT 100
  81. #define MAX_SEGMENTS 100
  82. #define NORMALS_PER_FACE 4
  83. /////////////////////////////////////////////////////////////////////////////
  84. // Type Definitions
  85. //
  86. typedef GLfloat LatheFace[4][4];
  87. /////////////////////////////////////////////////////////////////////////////
  88. // Global variables:
  89. //
  90. extern CString szIndent; // Object indent used for serialization
  91. static int iFileVersion = 140; // file Write version request (future use)
  92. static CString szFileVersion = _T("// Version: 1.40n");
  93. static CString szWorldFileHeader = _T("// ModelMagic3D World Definition Filen");
  94. static CString szObjectFileHeader = _T("// ModelMagic3D Object Definition Filen");
  95. static CString szMatlFileHeader = _T("// ModelMagic3D Material Defintion Filen");
  96. static CString szColorFileHeader = _T("// ModelMagic3D Color Definition Filen");
  97. static CString szIWDFileHeader = _T("// 'glOOP' and ModelMagic3D version 1.40, Copyright (c) 1997, 1998 ImageWare Developmentn// All rights reservedn// OpenGL is a registered trademark of Silicon Graphicsnn");
  98. // We track the number of lights so that we can append the 
  99. // light 'number' to the end of the default name..
  100. static unsigned int nLights = 0;
  101. // We track the number of shape types so that we can
  102. // append a number to the end of the default
  103. // name..
  104. static unsigned int nCloudObjects  = 0;
  105. static unsigned int nConeObjects  = 0;
  106. static unsigned int nCSGObjects  = 0;
  107. static unsigned int nCubeObjects  = 0;
  108. static unsigned int nCylinderObjects = 0;
  109. static unsigned int nDiskObjects  = 0;
  110. static unsigned int nGridObjects  = 0;
  111. static unsigned int nLatheObjects  = 0;
  112. static unsigned int nMeshObjects  = 0;
  113. static unsigned int nPlaneObjects  = 0;
  114. static unsigned int nSphereObjects  = 0;
  115. static unsigned int nTerrainObjects  = 0;
  116. static unsigned int nTorusObjects  = 0;
  117. static unsigned int nTriangleObjects = 0;
  118. static unsigned int nTTFObjects  = 0;
  119. static unsigned int nHSplineObjects  = 0;
  120. static unsigned int nNURBObjects  = 0;
  121. // When the user creates a new shape or light, we assign a unique 'name'
  122. // to the object for identification during the select process.
  123. static GLuint iGlobalNamesList = 1; // Counter for our list of names
  124. // Record the BitMap Image zero based index into the 
  125. // CImageList used for display in a CTreeCtrl
  126. static int iWorldBMImage = -1;
  127. static int iCameraBMImage = -1;
  128. static int iObjectCloudBMImage = -1;
  129. static int iObjectConeBMImage = -1;
  130. static int iObjectCSGBMImage = -1;
  131. static int iObjectCubeBMImage = -1;
  132. static int iObjectCylinderBMImage = -1;
  133. static int iObjectDiskBMImage = -1;
  134. static int iObjectGridBMImage = -1;
  135. static int iObjectLatheBMImage = -1;
  136. static int iObjectLightBMImage = -1;
  137. static int iObjectMeshBMImage = -1;
  138. static int iObjectPlaneBMImage = -1;
  139. static int iObjectSphereBMImage = -1;
  140. static int iObjectTerrainBMImage = -1;
  141. static int iObjectTorusBMImage = -1;
  142. static int iObjectTriangleBMImage = -1;
  143. static int iObjectTTFBMImage = -1;
  144. static int iObjectHSplineBMImage = -1;
  145. static int iObjectNURBBMImage = -1;
  146. // global names used to identify Animation procedures
  147. #define SZ_ANIMATE_SPIN _T("Spin")
  148. #define SZ_ANIMATE_WOBBLE _T("Wobble")
  149. #define SZ_ANIMATE_SEESAW _T("SeeSaw")
  150. #define SZ_ANIMATE_KEYFRAME _T("KeyFrame")
  151. #define SZ_ANIMATE_AVI _T("AVI Movie Animation")
  152. /////////////////////////////////////////////////////////////////////////////
  153. // Predefined classes:
  154. //
  155. class C3dWorld;
  156. class C3dObject;
  157. /////////////////////////////////////////////////////////////////////////////
  158. // C3dEngine
  159. class AFX_EXT_CLASS C3dEngine : public CObject
  160. {
  161. DECLARE_DYNAMIC(C3dEngine);
  162. //Construction
  163. public:
  164. C3dEngine();
  165. virtual ~C3dEngine();
  166. BOOL SetWindowPixelFormat(HDC hDC, DWORD dwFlags);
  167. BOOL EnableRC(HDC hDC, HGLRC hRC, BOOL bEnable);
  168. void DisplayError(LPSTR);
  169. inline HPALETTE C3dEngine::GetPalette()
  170.    { return (HPALETTE)m_hPalette; }
  171. //Implimentation
  172. protected:
  173. HPALETTE CreateNewPalette(HDC hDC);
  174. public:
  175. //Attributes
  176. protected:
  177. public:
  178. HPALETTE m_hPalette; // Handle to rendering context palette
  179. BOOL m_bDisplayErrorMessages;
  180. };
  181. // the one and only 3dEngine object
  182. extern EXPORT32 C3dEngine EXPORT the3dEngine;   
  183. /////////////////////////////////////////////////////////////////////////////
  184. class C3dColorList;
  185. ////////////////////////////////////////////////////////////////////
  186. // C3dColor
  187. class AFX_EXT_CLASS C3dColor : public CObject
  188. {
  189. DECLARE_DYNAMIC(C3dColor);
  190. // Construction
  191. public:
  192. C3dColor();
  193. virtual ~C3dColor();
  194. //Implimentation
  195. public:
  196. BOOL Compare(C3dColor* pColor);
  197. void Serialize(CArchive& ar, int iVersion);
  198. void GetColor4f(GLfloat *r, GLfloat *g, GLfloat *b, GLfloat *a);
  199. void SetColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
  200. void SetColor3fv(C3dColor* pColor);
  201. void SetColor4fv(C3dColor* pColor);
  202. static C3dColor* Create();
  203. static C3dColor* Create(CString szName,
  204. GLfloat r,
  205. GLfloat g,
  206. GLfloat b,
  207. GLfloat a);
  208. static void Delete(C3dColor* pColor);
  209. //Attributes
  210. protected:
  211. public:
  212. CString m_szName; // Name of this Color
  213. GLfloat m_fColor[4]; // RGBA color component
  214. };
  215. /////////////////////////////////////////////////////////////////////////////
  216. ///////////////////////////////////////////////////////////////////
  217. // C3dColorList
  218. class AFX_EXT_CLASS C3dColorList : protected CObList
  219. {
  220. DECLARE_DYNAMIC(C3dColorList);
  221. //Construction
  222. public:
  223. C3dColorList();
  224. virtual ~C3dColorList();
  225. //Implimentation
  226. public:
  227. C3dColor* LoadComboBox(CComboBox* pCombo, C3dColor* pColorSel);
  228. C3dColor* LoadListBox(CListBox* pList);
  229. void LoadColors(CString szFileName);
  230. void SaveColors(CString szFileName);
  231. void Serialize(CArchive& ar, int iVersion);
  232. void Append(C3dColor* pColor) {CObList::AddTail(pColor);}
  233. void Remove(C3dColor* pColor);
  234. void Delete(C3dColor* pColor);
  235. void DeleteAll();
  236. C3dColor* GetNext(POSITION& rPosition)
  237. {return (C3dColor*) CObList::GetNext(rPosition);}
  238. C3dColor* GetAt(POSITION& rPosition)
  239. {return (C3dColor*) CObList::GetAt(rPosition);}
  240. POSITION GetHeadPosition()
  241. {return (POSITION) CObList::GetHeadPosition();}
  242. C3dColor* Find(C3dColor* pColor);
  243. C3dColor* Find(CString szName);
  244. //Attributes
  245. protected:
  246. public:
  247. };
  248. /////////////////////////////////////////////////////////////////////////////
  249. // Declare a Color list pointer to use during file load
  250. extern C3dColorList* pColorList;
  251. class C3dMaterialList;
  252. ////////////////////////////////////////////////////////////////////
  253. // C3dMaterial
  254. class AFX_EXT_CLASS C3dMaterial : public CObject
  255. {
  256. DECLARE_DYNAMIC(C3dMaterial);
  257. // DECLARE_SERIAL(C3dMaterial);
  258. // Construction
  259. public:
  260. C3dMaterial();
  261. virtual ~C3dMaterial();
  262. //Implimentation
  263. public:
  264. void Serialize(CArchive& ar, int iVersion);
  265. void SetMaterialAttrib();
  266. static void ResetMaterialAttrib();
  267. static C3dMaterial* Create();
  268. static C3dMaterial* Create(CString szName,
  269. GLfloat ar, GLfloat ag, GLfloat ab, GLfloat aa,
  270. GLfloat dr, GLfloat dg, GLfloat db, GLfloat da,
  271. GLfloat sr, GLfloat sg, GLfloat sb, GLfloat sa,
  272. GLfloat er, GLfloat eg, GLfloat eb, GLfloat ea,
  273. GLfloat power,
  274. GLfloat IOR,
  275. GLfloat reflection,
  276. GLfloat translucency);
  277. static void Delete(C3dMaterial* pMaterial);
  278. //Attributes
  279. protected:
  280. public:
  281. CString m_szName; // Name of this Material
  282. C3dColor m_ColorAmbient; // Ambient color component
  283. C3dColor m_ColorDiffuse; // Diffuse color component
  284. C3dColor m_ColorSpecular; // Specular color component
  285. C3dColor m_ColorEmmissive; // Emmissive color component
  286. GLfloat m_fSpecularPower; // Gloss or Specular power 0-128
  287. GLfloat m_fReflection; // Reflection Coefficient (0.0 to 1.0)
  288. GLfloat m_fTranslucency; // Refraction Coefficient (0.0 to 1.0)
  289. GLfloat m_fIOR; // Materials Index Of Refraction, or IOR;
  290. };
  291. /////////////////////////////////////////////////////////////////////////////
  292. ///////////////////////////////////////////////////////////////////
  293. // C3dMaterialList
  294. class AFX_EXT_CLASS C3dMaterialList : protected CObList
  295. {
  296. DECLARE_DYNAMIC(C3dMaterialList);
  297. //Construction
  298. public:
  299. C3dMaterialList();
  300. virtual ~C3dMaterialList();
  301. //Implimentation
  302. public:
  303. void LoadMaterials(CString szFileName);
  304. void SaveMaterials(CString szFileName);
  305. C3dMaterial* LoadComboBox(CComboBox* pCombo);
  306. C3dMaterial* LoadListBox(CListBox* pList);
  307. void Serialize(CArchive& ar, int iVersion);
  308. void Append(C3dMaterial* pMaterial) {CObList::AddTail(pMaterial);}
  309. void Remove(C3dMaterial* pMaterial);
  310. void Delete(C3dMaterial* pMaterial);
  311. void DeleteAll();
  312. C3dMaterial* GetNext(POSITION& rPosition)
  313. {return (C3dMaterial*) CObList::GetNext(rPosition);}
  314. C3dMaterial* GetAt(POSITION& rPosition)
  315. {return (C3dMaterial*) CObList::GetAt(rPosition);}
  316. POSITION GetHeadPosition()
  317. {return (POSITION) CObList::GetHeadPosition();}
  318. C3dMaterial* Find(C3dMaterial* pMatl);
  319. C3dMaterial* Find(CString szName);
  320. //Attributes
  321. protected:
  322. public:
  323. };
  324. /////////////////////////////////////////////////////////////////////////////
  325. // Declare a material list pointer to use during file load
  326. extern C3dMaterialList* pMatlList;
  327. /////////////////////////////////////////////////////////////////////////////
  328. // CAudioPlayer
  329. class AFX_EXT_CLASS CAudioPlayer : public CObject
  330. {
  331. DECLARE_DYNAMIC(CAudioPlayer);
  332. //Construction
  333. public:
  334. CAudioPlayer();
  335. virtual ~CAudioPlayer();
  336. static CAudioPlayer* Create(LPSTR);
  337. //Implementation
  338. public:
  339. DWORD Play(double);
  340. DWORD Stop();
  341. DWORD Open(LPSTR);
  342. DWORD Close();
  343. DWORD GetVolumn(LPDWORD);
  344. DWORD GetPitch(LPDWORD);
  345. DWORD SetVolumn(DWORD);
  346. DWORD SetPitch(DWORD);
  347. void  SynchAudio(double);
  348. static void GetAviWaveformData(LPVOID, LPWAVEHDR);
  349. protected:
  350. DWORD InitAVI(LPSTR);
  351. DWORD Initialize();
  352. void  DisplayError(UINT);
  353. //Attributes
  354. public:
  355. // Function Prototypes
  356. void (*GetWaveformData)(LPVOID, LPWAVEHDR);
  357. BOOL m_bPlayAudioClip; // Flag for this Audio clip
  358. int m_iWBufferScale; // Audio write buffer scale size
  359. long m_lAudioLength; // Length of the audio clip (in milliseconds)
  360. DWORD m_dwDataSize; // Size of the audio data chunck
  361. PAVISTREAM m_pAudioStream; // Pointer to the AVI Audio stream interface.
  362. HANDLE m_hAudioData[WRITE_BUFFERS]; // Handle of waveform data memory 
  363. HPSTR m_lpAudioData[WRITE_BUFFERS]; // Pointer to waveform data memory 
  364. HGLOBAL m_hWaveHdr[WRITE_BUFFERS]; // Handle to waveform data block header 
  365. LPWAVEHDR m_lpWaveHdr[WRITE_BUFFERS]; // Pointer to waveform data block header
  366. protected:
  367. BOOL m_bDeviceOpen; // Audio Device Open?
  368. BOOL m_bSynchAudio; // Resynchronize audio stream
  369. clock_t m_SynchTime; // Time resynch was requested
  370. WAVEFORMATEX m_WFX; // Waveform-audio data structure
  371. };
  372. /////////////////////////////////////////////////////////////////////////////
  373. /////////////////////////////////////////////////////////////////////////////
  374. // CTexture
  375. class AFX_EXT_CLASS CTexture : public CObject
  376. {
  377. DECLARE_DYNAMIC(CTexture);
  378. //Construction
  379. public:
  380. CTexture();
  381. virtual ~CTexture();
  382. static BOOL CreateTexture(char* pFileName,  HPALETTE hPalette, CTexture **pTexture);
  383. //Implementation
  384. public:
  385. // Virtual overridable functions
  386. virtual BOOL OpenTexture(char* pFileName, HPALETTE hPalette);
  387. virtual void Serialize(CArchive& ar, int iVersion);
  388. void  SetTexture();
  389. void* ScaleDIB(HPALETTE hPalette, HANDLE hDibOriginal);
  390. GLint Scale_down_to_power_of_2(long x);
  391. void  GetTextureOrigin3f(GLfloat* x, GLfloat* y, GLfloat* z);
  392. void  SetTextureOrigin3f(GLfloat x, GLfloat y, GLfloat z);
  393. void  SetTextureCoord3f(GLfloat s, GLfloat t, GLfloat r);
  394. protected:
  395. BOOL  ApplyTexture();
  396. //Attributes
  397. public:
  398. GLubyte *m_pBits; // Pointer to scaled 32bpp Texture DIB bits
  399. HBITMAP m_hDibScaled; // Handle to scaled 32bpp Texture DIB
  400. CString m_szFileName; // File name of this DIB
  401. BOOL m_bCreateList; // Flag for identifying
  402. GLuint m_iDisplayList; // Display list name
  403. BOOL m_bApplyImage; // Flag for initializing our display list
  404. GLint m_iEnvmode;
  405. GLenum m_enumHint;
  406. GLint m_iMinfilter;
  407. GLint m_iMagfilter;
  408. GLint m_iWrap_S;
  409. GLint m_iWrap_T;
  410. BOOL m_bS_Gen;
  411. GLint m_iS_Mode;
  412. GLdouble m_dS_Coeffs[4];
  413. BOOL m_bT_Gen;
  414. GLint m_iT_Mode;
  415. GLdouble m_dT_Coeffs[4];
  416. BOOL m_bTransparent;
  417. BYTE m_bytTransparent_r;
  418. BYTE m_bytTransparent_g;
  419. BYTE m_bytTransparent_b;
  420. float m_fTransparentVariance;
  421. protected:
  422. LONG m_lScaledSizeX; // Size of our scaled image X dimension
  423. LONG m_lScaledSizeY; // Size of our scaled image Y dimension
  424. GLfloat m_fOrigin[3]; // Our texture origin
  425. };
  426. /////////////////////////////////////////////////////////////////////////////
  427. /////////////////////////////////////////////////////////////////////////////
  428. // CTextureDibImage
  429. class AFX_EXT_CLASS CTextureDibImage : public CTexture
  430. {
  431. DECLARE_DYNAMIC(CTextureDibImage);
  432. //Construction
  433. public:
  434. CTextureDibImage();
  435. virtual ~CTextureDibImage();
  436. //Implimentation
  437. public:
  438. // Virtual overrides
  439. BOOL OpenTexture(char* pFileName, HPALETTE hPalette);
  440. void Serialize(CArchive& ar, int iVersion);
  441. void* OpenDIBFile(LPSTR pszFileName, HPALETTE hPalette);
  442. void* ReadDIBitmap(BITMAPINFO **info);
  443. int   SaveDIBFile(LPSTR pszFileName, BITMAPINFO *pInfo, void *pBits);
  444. protected:
  445. //Attributes
  446. public:
  447. protected:
  448. };
  449. /////////////////////////////////////////////////////////////////////////////
  450. class CAnimAVI;
  451. /////////////////////////////////////////////////////////////////////////////
  452. // CTextureAviMovie
  453. class AFX_EXT_CLASS CTextureAviMovie : public CTexture
  454. {
  455. DECLARE_DYNAMIC(CTextureAviMovie);
  456. //Construction
  457. public:
  458. CTextureAviMovie();
  459. virtual ~CTextureAviMovie();
  460. //Implimentation
  461. public:
  462. // Virtual overrides
  463. BOOL OpenTexture(char* pFileName, HPALETTE hPalette);
  464. void Serialize(CArchive& ar, int iVersion);
  465. // Function Prototypes:
  466. BOOL  GetFrameRGBA(long lTime, HPALETTE hPalette);
  467. void  Play(double dTime);
  468. void  Stop();
  469. DWORD PlayAudio(double dTime);
  470. void  StopAudio();
  471. protected:
  472. DWORD InitAVI(LPSTR szFile);
  473. //Attributes
  474. public:
  475. BOOL m_bEnableAudio; // Enable audio flag
  476. BOOL m_bPlayContinuous; // Play AVI file continuously?
  477. BOOL m_bStartAudio; // First Video frame flag
  478. long m_lVideoLength; // Length of the AVI video clip (in milliseconds)
  479. CAnimAVI* m_pAnimAVI; // Pointer to our animation object
  480. CAudioPlayer* m_pAudioPlayer; // Pointer to our audio player
  481. protected:
  482. long m_lLastTimeIndex; // Time index of the stream last played;
  483. PAVIFILE m_pFile; // File interface pointer
  484. BITMAPINFO* m_pBMI; // Pointer to our current AVI frame DIB
  485. PGETFRAME m_pGetFrame; // Pointer to an AVI GetFrame object
  486. PAVISTREAM m_pVideoStream; // Pointer to the AVI Video stream interface.
  487. HPALETTE m_hPalette; // Handle to applications palette
  488. };
  489. /////////////////////////////////////////////////////////////////////////////
  490. class C3dCamera;
  491. /////////////////////////////////////////////////////////////////////////////
  492. // C3dGrid
  493. class AFX_EXT_CLASS C3dGrid : public CObject
  494. {
  495. DECLARE_DYNAMIC(C3dGrid);
  496. //Construction
  497. public:
  498. C3dGrid();
  499. virtual ~C3dGrid();
  500. //Implimentation
  501. public:
  502. static C3dGrid* Create(float fSpacing);
  503. void SetSize(float fSpacing);
  504. void PointToGrid(float *x, float *y, float *z);
  505. void Display(C3dWorld* pWorld, C3dCamera* pCamera);
  506. void GridXY(C3dCamera* pCamera);
  507. void Grid3D(C3dCamera* pCamera);
  508. //Attributes
  509. protected:
  510. public:
  511. GLfloat m_fGridWidth;
  512. GLfloat m_fGridDepth;
  513. GLfloat m_fSpacing;
  514. GLfloat m_fLineWidth;
  515. GLfloat m_fGridColor[4];
  516. };
  517. /////////////////////////////////////////////////////////////////////////////
  518. ////////////////////////////////////////////////////////////////////
  519. // C3dAxis
  520. class C3dAxis : public CObject
  521. {
  522. DECLARE_DYNAMIC(C3dAxis);
  523. //Construction
  524. public:
  525. C3dAxis();
  526. virtual ~C3dAxis();
  527. //Implimentation
  528. public:
  529. // virtual function overrides
  530. virtual void Serialize(CArchive& ar);
  531. //Function Prototypes:
  532. static C3dAxis* Create();
  533. void Display(GLdouble dAxisLength,
  534.  GLdouble dAxisRadius,
  535.  GLdouble dArrowLength,
  536.  GLdouble dArrowRadius,
  537.  GLint iSlices,
  538.  GLint iStacks,
  539.  GLfloat fColorX[4],
  540.  GLfloat fColorY[4],
  541.  GLfloat fColorZ[4],
  542.  BOOL bSolid);
  543. //Attributes
  544. protected:
  545. public:
  546. GLfloat m_fXAxisColor[4];
  547. GLfloat m_fYAxisColor[4];
  548. GLfloat m_fZAxisColor[4];
  549. };
  550. /////////////////////////////////////////////////////////////////////////////
  551. class C3dRect;
  552. ////////////////////////////////////////////////////////////////////
  553. // C3dBoundingBox
  554. class C3dBoundingBox : public CObject
  555. {
  556. DECLARE_DYNAMIC(C3dBoundingBox);
  557. //Construction
  558. public:
  559. C3dBoundingBox();
  560. virtual ~C3dBoundingBox();
  561. //Implimentation
  562. public:
  563. void TransformBounds(Matx4x4 XformMatrix);
  564. void SetMinMax(VECTORF A);
  565. void SetMinMax(VECTORF A, VECTORF B);
  566. void SetMinMax(C3dBoundingBox* pBox);
  567. void Display(float fOffset,
  568.  float fLineSize,
  569.  int iSlices,
  570.  int iStacks,
  571.  float fColor[3],
  572.  BOOL bSolid);
  573. //Attributes
  574. protected:
  575. public:
  576. GLfloat m_fMax[3];
  577. GLfloat m_fMin[3];
  578. GLfloat m_fHighlightColor[4];
  579. GLfloat m_fHighlightOffset;
  580. GLfloat m_fHighlightLineWidth;
  581. };
  582. /////////////////////////////////////////////////////////////////////////////
  583. ////////////////////////////////////////////////////////////////////
  584. // C3dPoint
  585. class AFX_EXT_CLASS C3dPoint : public CObject
  586. {
  587. DECLARE_DYNAMIC(C3dPoint);
  588. //Construction
  589. public:
  590.     C3dPoint();
  591.     virtual ~C3dPoint();
  592. //Implimentation
  593. public:
  594. static void Display(float x,
  595. float y,
  596. float z,
  597. float fRadius,
  598. float fColor[4],
  599. BOOL  bSolid);
  600. virtual void Serialize(CArchive& ar);
  601. void Display(float fRadius, float fColor[4], BOOL bSolid);
  602. void GetOrigin(GLfloat *x, GLfloat *y, GLfloat *z);
  603. void SetOrigin(GLfloat x, GLfloat y, GLfloat z);
  604. BOOL HitTest(float x, float y, float z, float test);
  605. BOOL IsPoint(C3dCamera*, C3dObject*, float, float, float);
  606. BOOL IsPoint(C3dCamera*, Matx4x4, float, float, float);
  607. protected:
  608. //Attributes
  609. protected:
  610. public:
  611. GLfloat m_fOrigin[4]; // Points world origin
  612. C3dColor m_Color; // Points color
  613. };
  614. /////////////////////////////////////////////////////////////////////////////
  615. ///////////////////////////////////////////////////////////////////
  616. // C3dPointList
  617. class AFX_EXT_CLASS C3dPointList : public CObList
  618. {
  619. DECLARE_DYNAMIC(C3dPointList);
  620. //Construction
  621. public:
  622. C3dPointList();
  623. virtual ~C3dPointList();
  624. //Implimentation
  625. public:
  626. void Append(C3dPoint* pPoint) {CObList::AddTail(pPoint);}
  627. void Remove(C3dPoint* pPoint);
  628. void Delete(C3dPoint* pPoint);
  629. void DeleteAll();
  630. void Display(C3dWorld* pWorld, C3dCamera* pCamera, BOOL bConnectPoints);
  631. C3dPoint* GetNext(POSITION& rPosition)
  632. {return (C3dPoint*) CObList::GetNext(rPosition);}
  633. C3dPoint* GetAt(POSITION& rPosition)
  634. {return (C3dPoint*) CObList::GetAt(rPosition);}
  635. POSITION GetHeadPosition()
  636. {return (POSITION) CObList::GetHeadPosition();}
  637. C3dPoint* Find(float, float, float, float);
  638. //Attributes
  639. protected:
  640. public:
  641. };
  642. /////////////////////////////////////////////////////////////////////////////
  643. ///////////////////////////////////////////////////////////////////
  644. // C3dPointArray
  645. class AFX_EXT_CLASS C3dPointArray : public CObject
  646. {
  647. DECLARE_DYNAMIC(C3dPointArray);
  648. //Construction
  649. public:
  650. C3dPointArray();
  651. virtual ~C3dPointArray();
  652. //Implimentation
  653. public:
  654. BOOL Create(int iNumPoints);
  655. BOOL SetArraySize(int iNumPoints);
  656. BOOL Add(float, float, float);
  657. BOOL CopyFromList(C3dPointList* pPointList);
  658. void Serialize(CArchive& ar, int iVersion, BOOL bReadColorData);
  659. void Display(C3dWorld* pWorld, C3dCamera* pCamera, C3dObject* pObject, float fPointSize, BOOL bConnectPoints);
  660. C3dPoint* Find(C3dCamera*, C3dObject*,float, float, float);
  661. void GetMinMax(C3dBoundingBox* pBox);
  662. //Attributes
  663. protected:
  664. public:
  665. C3dPoint* m_pPoints; // Array pointer
  666. int m_iNumPoints; // Number of points in array
  667. HGLOBAL m_hPoints; // handle of the allocated memory object.
  668. };
  669. /////////////////////////////////////////////////////////////////////////////
  670. class C3dObject;
  671. ///////////////////////////////////////////////////////////////////
  672. // C3dObjectList
  673. class AFX_EXT_CLASS C3dObjectList : public CObList
  674. {
  675. //Construction
  676. public:
  677. C3dObjectList();
  678. virtual ~C3dObjectList();
  679. //Implimentation
  680. public:
  681. void Append(C3dObject* pObject);
  682. void Remove(C3dObject* pObject);
  683. void Delete(C3dObject* pObject);
  684. void DeleteAll();
  685. C3dObject* Find(C3dObject* pObject);
  686. C3dObject* GetNext(POSITION& rPosition)
  687. {return (C3dObject*) CObList::GetNext(rPosition);}
  688. C3dObject* GetAt(POSITION& rPosition)
  689. {return (C3dObject*) CObList::GetAt(rPosition);}
  690. POSITION GetHeadPosition()
  691. {return (POSITION) CObList::GetHeadPosition();}
  692. //Attributes
  693. protected:
  694. public:
  695. };
  696. /////////////////////////////////////////////////////////////////////////////
  697. /////////////////////////////////////////////////////////////////////////////
  698. // CAnimation
  699. class AFX_EXT_CLASS CAnimation : public CObject
  700. {
  701. DECLARE_DYNAMIC(CAnimation);
  702. //Construction
  703. public:
  704.     CAnimation();
  705.     virtual ~CAnimation();
  706. //Implimentation
  707. public:
  708. // Virtual overridable functions
  709. virtual void AddAnimationPage(LPVOID, C3dObject*, C3dCamera*, C3dWorld*);
  710. virtual void AnimateCamera(C3dCamera* pCamera, double dTime);
  711. virtual void AnimateObject(C3dObject* pObject, double dTime);
  712. virtual void AnimateWorld(C3dWorld* pWorld, double dTime);
  713. virtual void Serialize(CArchive& ar, int iVersion);
  714. virtual void Reset();
  715. // Static Prototypes:
  716. static CAnimation* IsAnimationClass(CString* szString);
  717. // Function Prototypes:
  718. void ResetCommon();
  719. void SaveCameraAttributes(C3dCamera* pCamera);
  720. void SaveObjectAttributes(C3dObject* pObject);
  721. void RestoreCameraAttributes(C3dCamera* pCamera);
  722. void RestoreObjectAttributes(C3dObject* pObject);
  723. //Attributes
  724. protected:
  725. public:
  726. CString m_szName; // Name of the Animation procedure
  727. double m_dTimePrevious; // Time base of the last iteration
  728. BOOL m_bFirst; // First iteration of animation flag
  729. GLfloat m_fOrigin[4]; // Objects world origin
  730. GLfloat m_fScale[3]; // Objects scale
  731. GLfloat m_fRotation[3]; // Objects rotation
  732. GLfloat m_fTranslate[3]; // Objects translation about origin
  733. C3dColor m_Color; // Color component
  734. // The following colors apply to light objects
  735. C3dColor m_ColorAmb; // Ambient Color component
  736. C3dColor m_ColorDif; // Diffuse Color component
  737. C3dColor m_ColorSpc; // Specular Color component
  738. GLfloat m_fSpotAngle; // Spotlights' spot angle
  739. protected:
  740. };
  741. /////////////////////////////////////////////////////////////////////////////
  742. /////////////////////////////////////////////////////////////////////////////
  743. // CAnimationList
  744. class AFX_EXT_CLASS CAnimationList : public CObList
  745. {
  746. //Construction
  747. public:
  748. CAnimationList();
  749. virtual ~CAnimationList();
  750. //Implimentation
  751. public:
  752. void Append(CAnimation* pAnimation);
  753. void Remove(CAnimation* pAnimation);
  754. void Delete(CAnimation* pAnimation);
  755. void DeleteAll();
  756. void Serialize(CArchive& ar, int iVersion);
  757. CAnimation* Find(CString szName);
  758. CAnimation* GetNext(POSITION& rPosition)
  759. {return (CAnimation*) CObList::GetNext(rPosition);}
  760. CAnimation* GetAt(POSITION& rPosition)
  761. {return (CAnimation*) CObList::GetAt(rPosition);}
  762. POSITION GetHeadPosition()
  763. {return (POSITION) CObList::GetHeadPosition();}
  764. //Attributes
  765. protected:
  766. public:
  767. };
  768. /////////////////////////////////////////////////////////////////////////////
  769. class CKeyFrameList;
  770. class CKeyFrame;
  771. /////////////////////////////////////////////////////////////////////////////
  772. // CAnimation
  773. class AFX_EXT_CLASS CAnimKeyFrame : public CAnimation
  774. {
  775. DECLARE_DYNAMIC(CAnimKeyFrame);
  776. //Construction
  777. public:
  778.     CAnimKeyFrame();
  779.     virtual ~CAnimKeyFrame();
  780. //Implimentation
  781. public:
  782. // Virtual function overrides
  783. virtual void AddAnimationPage(LPVOID, C3dObject*, C3dCamera*, C3dWorld*);
  784. virtual void AnimateCamera(C3dCamera* pCamera, double dTime);
  785. virtual void AnimateObject(C3dObject* pObject, double dTime);
  786. virtual void Serialize(CArchive& ar, int iVersion);
  787. virtual void Reset();
  788. // Function Prototypes:
  789. //Attributes
  790. protected:
  791. public:
  792. BOOL m_bCycleKeyFrames;
  793. CKeyFrameList* m_pKeyFrameList;
  794. protected:
  795. };
  796. /////////////////////////////////////////////////////////////////////////////
  797. /////////////////////////////////////////////////////////////////////////////
  798. // CKeyFrame
  799. class AFX_EXT_CLASS CKeyFrame : public CObject
  800. {
  801. DECLARE_DYNAMIC(CKeyFrame);
  802. //Construction
  803. public:
  804.     CKeyFrame(double dTime, C3dObject* pObject);
  805.     virtual ~CKeyFrame();
  806. //Implimentation
  807. public:
  808. virtual void AnimateCamera(C3dCamera* pCamera, double dTime);
  809. virtual void AnimateObject(C3dObject* pObject, double dTime);
  810. virtual void Serialize(CArchive& ar, int iVersion);
  811. void SetObjectAttributes(C3dObject* pObject);
  812. //Attributes
  813. protected:
  814. public:
  815. CKeyFrame* m_pKeyFramePrevious;
  816. double m_dTime; // Time reference for this keyframe
  817. GLfloat m_fOrigin[4]; // Objects world origin
  818. GLfloat m_fScale[3]; // Objects scale
  819. GLfloat m_fRotation[3]; // Objects rotation
  820. GLfloat m_fTranslate[3]; // Objects translation about origin
  821. C3dColor m_Color; // Color component
  822. // The following colors apply to light objects
  823. C3dColor m_ColorAmb; // Ambient Color component
  824. C3dColor m_ColorDif; // Diffuse Color component
  825. C3dColor m_ColorSpc; // Specular Color component
  826. GLfloat m_fSpotAngle; // Spotlights' spot angle
  827. protected:
  828. };
  829. /////////////////////////////////////////////////////////////////////////////
  830. /////////////////////////////////////////////////////////////////////////////
  831. // CKeyFrameList
  832. class AFX_EXT_CLASS CKeyFrameList : public CObList
  833. {
  834. //Construction
  835. public:
  836. CKeyFrameList();
  837. virtual ~CKeyFrameList();
  838. //Implimentation
  839. public:
  840. BOOL AddKeyFrame(CKeyFrame* pKeyFrame);
  841. BOOL AddKeyFrame(double time, C3dObject* pObject);
  842. void Append(CKeyFrame* pKeyFrame);
  843. void Remove(CKeyFrame* pKeyFrame);
  844. void Delete(CKeyFrame* pKeyFrame);
  845. void DeleteAll();
  846. double GetLength();
  847. void Serialize(CArchive& ar, int iVersion);
  848. int GetNumKeys() {return GetCount();}
  849. CKeyFrame* Find(double dTime);
  850. CKeyFrame* FindClosest(double dTime, int *iKeyFrameTime);
  851. CKeyFrame* FindSmaller(double dTime);
  852. CKeyFrame* FindLarger(double dTime);
  853. CKeyFrame* GetNext(POSITION& rPosition)
  854. {return (CKeyFrame*) CObList::GetNext(rPosition);}
  855. CKeyFrame* GetAt(POSITION& rPosition)
  856. {return (CKeyFrame*) CObList::GetAt(rPosition);}
  857. POSITION GetHeadPosition()
  858. {return (POSITION) CObList::GetHeadPosition();}
  859. //Attributes
  860. protected:
  861. public:
  862. };
  863. /////////////////////////////////////////////////////////////////////////////
  864. /////////////////////////////////////////////////////////////////////////////
  865. // CAnimSpin
  866. class AFX_EXT_CLASS CAnimSpin : public CAnimation
  867. {
  868. DECLARE_DYNAMIC(CAnimSpin);
  869. //Construction
  870. public:
  871.     CAnimSpin();
  872.     virtual ~CAnimSpin();
  873. //Implimentation
  874. public:
  875. // Virtual function overrides
  876. virtual void AddAnimationPage(LPVOID, C3dObject*, C3dCamera*, C3dWorld*);
  877. virtual void AnimateCamera(C3dCamera* pCamera, double dTime);
  878. virtual void AnimateObject(C3dObject* pObject, double dTime);
  879. virtual void Serialize(CArchive& ar, int iVersion);
  880. virtual void Reset();
  881. // Function Prototypes:
  882. //Attributes
  883. protected:
  884. public:
  885. GLfloat m_fSpinX;
  886. GLfloat m_fSpinY;
  887. GLfloat m_fSpinZ;
  888. double m_dSpeedX;
  889. double m_dSpeedY;
  890. double m_dSpeedZ;
  891. };
  892. /////////////////////////////////////////////////////////////////////////////
  893. /////////////////////////////////////////////////////////////////////////////
  894. // CAnimWobble
  895. class AFX_EXT_CLASS CAnimWobble : public CAnimation
  896. {
  897. DECLARE_DYNAMIC(CAnimWobble);
  898. //Construction
  899. public:
  900.     CAnimWobble();
  901.     virtual ~CAnimWobble();
  902. //Implimentation
  903. public:
  904. // Virtual function overrides
  905. virtual void AddAnimationPage(LPVOID, C3dObject*, C3dCamera*, C3dWorld*);
  906. virtual void AnimateCamera(C3dCamera* pCamera, double dTime);
  907. virtual void AnimateObject(C3dObject* pObject, double dTime);
  908. virtual void Serialize(CArchive& ar, int iVersion);
  909. virtual void Reset();
  910. // Function Prototypes:
  911. //Attributes
  912. protected:
  913. BOOL m_bIncX; // Increment or decrement flags
  914. BOOL m_bIncY;
  915. BOOL m_bIncZ;
  916. public:
  917. GLfloat m_fWobbleX;
  918. GLfloat m_fWobbleY;
  919. GLfloat m_fWobbleZ;
  920. GLfloat m_fLimitX;
  921. GLfloat m_fLimitY;
  922. GLfloat m_fLimitZ;
  923. double m_dSpeedX;
  924. double m_dSpeedY;
  925. double m_dSpeedZ;
  926. };
  927. /////////////////////////////////////////////////////////////////////////////
  928. /////////////////////////////////////////////////////////////////////////////
  929. // CAnimAVI
  930. class AFX_EXT_CLASS CAnimAVI : public CAnimation
  931. {
  932. DECLARE_DYNAMIC(CAnimAVI);
  933. //Construction
  934. public:
  935.     CAnimAVI();
  936.     virtual ~CAnimAVI();
  937. //Implimentation
  938. public:
  939. // Virtual function overrides
  940. virtual void AddAnimationPage(LPVOID, C3dObject*, C3dCamera*, C3dWorld*);
  941. virtual void AnimateObject(C3dObject* pObject, double dTime);
  942. virtual void AnimateWorld(C3dWorld* pWorld, double dTime);
  943. virtual void Serialize(CArchive& ar, int iVersion);
  944. virtual void Reset();
  945. // Function Prototypes:
  946. //Attributes
  947. protected:
  948. public:
  949. CTextureAviMovie* m_pAviMovie; // Pointer to our AVI Movie
  950. };
  951. /////////////////////////////////////////////////////////////////////////////
  952. class C3dObjectPropSheet;
  953. /////////////////////////////////////////////////////////////////////////////
  954. // C3dObject
  955. class AFX_EXT_CLASS C3dObject : public CObject
  956. {
  957. DECLARE_DYNAMIC(C3dObject);
  958. //Construction
  959. public:
  960.     C3dObject();
  961.     virtual ~C3dObject();
  962. //Implementation
  963. public:
  964. // Virtual overridable functions
  965. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  966. virtual void Animate(double time);
  967. virtual void GetShapeBounds(C3dBoundingBox* pBox);
  968. virtual void DisplayObject(C3dWorld*, C3dCamera*);
  969. virtual int  LoadBitMapImage(CImageList*);
  970. virtual C3dObject* IsName(GLuint i, BOOL bSelParent = TRUE);
  971. virtual void Serialize(CArchive& ar, int iVersion);
  972. virtual void Build(C3dWorld*, C3dCamera*);
  973. virtual void DisplayPoints(C3dWorld* pWorld, C3dCamera* pCamera);
  974. virtual C3dPoint* FindPoint(C3dCamera* pCamera, float, float, float);
  975. virtual void SetObjPointOrigin(C3dPoint*, float, float, float);
  976. virtual void GetObjPointOrigin(C3dPoint*, float*, float*, float*);
  977. // Function Prototypes:
  978. static C3dObject* IsLightClass(CString* szString);
  979. static C3dObject* IsShapeClass(CString* szString);
  980. static C3dObject* LoadObject(CString szFileName, int* iType);
  981. void SaveObject(CString szFileName);
  982. void LoadChildObjects(CArchive& ar, int iVersion);
  983. void SaveChildObjects(CArchive& ar, int iVersion);
  984. void Rebuild();
  985. void AddAnimationPages(C3dWorld* pWorld, LPVOID);
  986. BOOL AddTexture(LPSTR);
  987. void DeleteTexture();
  988. void ResetAnimation();
  989. void AddChildObject(C3dObject* pObject);
  990. void SetAttributes(C3dWorld* pWorld, void *pData);
  991. void TransformObject(C3dWorld* pWorld);
  992. int  EditAnimation(CWnd* pParentWnd, C3dWorld* pWorld);
  993. int  EditAttributes(CWnd* pParentWnd, C3dWorld* pWorld);
  994. void RemoveDibImage();
  995. void DisplayChildObjects(C3dWorld* pWorld, C3dCamera* pCamera);
  996. void DisplayAxis(C3dWorld* pWorld);
  997. void DisplaySelected(C3dWorld* pWorld, BOOL bWorldCoordinates);
  998. void GetTransformMatrix(Matx4x4 XformMatrix, BOOL bGetParent=TRUE);
  999. void GetInvTransformMatrix(Matx4x4 XformMatrix, BOOL bGetParent=TRUE);
  1000. void GetRotationMatrix(Matx4x4 XformMatrix, BOOL bGetParent=TRUE);
  1001. void GetInvRotationMatrix(Matx4x4 XformMatrix, BOOL bGetParent=TRUE);
  1002. void GetBounds(C3dBoundingBox* pBox, BOOL bWorldCoordinates);
  1003. void GetOrigin(GLfloat *x, GLfloat *y, GLfloat *z);
  1004. void GetOrigin(GLfloat *x, GLfloat *y, GLfloat *z, GLfloat *w);
  1005. void GetRotation(GLfloat *x, GLfloat *y, GLfloat *z);
  1006. void GetScale(GLfloat *x, GLfloat *y, GLfloat *z);
  1007. void GetTranslation(GLfloat *x, GLfloat *y, GLfloat *z);
  1008. void SetTexture(CTexture* pTexture);
  1009. void SetMaterial(C3dMaterial* pMaterial);
  1010. void SetOrigin(GLfloat x, GLfloat y, GLfloat z);
  1011. void SetOrigin(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
  1012. void SetRotation(GLfloat x, GLfloat y, GLfloat z);
  1013. void SetScale(GLfloat x, GLfloat y, GLfloat z);
  1014. void SetTranslation(GLfloat x, GLfloat y, GLfloat z);
  1015. void SetColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
  1016. void SetColor4fv(C3dColor* pColor);
  1017. CAnimKeyFrame* GetKeyFrameList(int *iNumKeys);
  1018. //Attributes
  1019. protected:
  1020. public:
  1021. int m_iType; // ID of object 0=Shape, 1=Light, 2=??, etc
  1022. C3dObject* m_pParent; // pointer to parent object
  1023. GLfloat m_fOrigin[4]; // Objects world origin
  1024. GLfloat m_fScale[3]; // Objects scale
  1025. GLfloat m_fRotation[3]; // Objects rotation
  1026. GLfloat m_fTranslate[3]; // Objects translation about origin
  1027. CString m_szName; // Name of this Object
  1028. GLuint m_iName; // Unsigned integer name of this object
  1029. C3dColor m_Color; // Color component
  1030. C3dMaterial* m_pMaterial; // Our objects' material
  1031. CTexture* m_pTexture; // Our objects' texture
  1032. GLUquadricObj* m_pQuad; // Pointer to a quadric object
  1033. CAnimationList m_AnimList; // List of this objects' animation procedures
  1034. C3dPointArray* m_pPointArray; // Pointer to an array of points
  1035. C3dObjectList m_ObjectList; // List of Child Objects which
  1036. // make up this object..
  1037. BOOL m_bInside;
  1038. BOOL m_bSolidColor;
  1039. int m_iBMImage;
  1040. BOOL m_bBuildLists;
  1041. unsigned int m_iDisplayLists;
  1042. };
  1043. /////////////////////////////////////////////////////////////////////////////
  1044. class C3dPageCone;
  1045. /////////////////////////////////////////////////////////////////////////////
  1046. // C3dObjectCone
  1047. class AFX_EXT_CLASS C3dObjectCone : public C3dObject
  1048. {
  1049. DECLARE_DYNAMIC(C3dObjectCone);
  1050. //Construction
  1051. public:
  1052.     C3dObjectCone();
  1053.     virtual ~C3dObjectCone();
  1054. //Implimentation
  1055. public:
  1056. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1057. virtual int  LoadBitMapImage(CImageList*);
  1058. virtual void Serialize(CArchive& ar, int iVersion);
  1059. virtual void Build(C3dWorld*, C3dCamera*);
  1060. void InitVertices();
  1061. void CalNormals(C3dPoint* pNormals, BOOL bSmooth=TRUE);
  1062. //Implimentation
  1063. protected:
  1064. //Attributes
  1065. protected:
  1066. public:
  1067. BOOL m_bSolid;
  1068. BOOL m_bSmooth;
  1069. float m_fHeight;
  1070. float m_fBaseRadius;
  1071. int m_iSegments;
  1072. C3dPageCone* m_pAttribPage;
  1073. };
  1074. /////////////////////////////////////////////////////////////////////////////
  1075. class C3dPageCSG;
  1076. ////////////////////////////////////////////////////////////////////
  1077. // C3dObjectCSG
  1078. class AFX_EXT_CLASS C3dObjectCSG : public C3dObject
  1079. {
  1080. DECLARE_DYNAMIC(C3dObjectCSG);
  1081. //Construction
  1082. public:
  1083.     C3dObjectCSG();
  1084.     virtual ~C3dObjectCSG();
  1085. //Implimentation
  1086. public:
  1087. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1088. virtual void GetShapeBounds(C3dBoundingBox* pBox);
  1089. virtual int  LoadBitMapImage(CImageList*);
  1090. virtual void Serialize(CArchive& ar, int iVersion);
  1091. virtual void DisplayObject(C3dWorld* pWorld, C3dCamera* pCamera);
  1092. virtual void Build(C3dWorld*, C3dCamera*);
  1093. //Attributes
  1094. protected:
  1095. void Object_OR(C3dWorld*, C3dCamera*);
  1096. void Object_SUB(C3dWorld*, C3dCamera*, C3dObject*, C3dObject*);
  1097. void Object_AND(C3dWorld*, C3dCamera*, C3dObject*, C3dObject*);
  1098. void Inside(C3dWorld*, C3dCamera*, C3dObject* a, C3dObject* b, GLenum face, GLenum test);
  1099. void Fixup(C3dWorld*, C3dCamera*, C3dObject*);
  1100. public:
  1101. int m_iCSGType;
  1102. C3dPageCSG* m_pAttribPage;
  1103. };
  1104. /////////////////////////////////////////////////////////////////////////////
  1105. class C3dPageCube;
  1106. ////////////////////////////////////////////////////////////////////
  1107. // C3dObjectCube
  1108. class AFX_EXT_CLASS C3dObjectCube : public C3dObject
  1109. {
  1110. DECLARE_DYNAMIC(C3dObjectCube);
  1111. //Construction
  1112. public:
  1113.     C3dObjectCube();
  1114.     virtual ~C3dObjectCube();
  1115. //Implementation
  1116. public:
  1117. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1118. virtual int  LoadBitMapImage(CImageList*);
  1119. virtual void Serialize(CArchive& ar, int iVersion);
  1120. virtual void Build(C3dWorld*, C3dCamera*);
  1121. void InitVertices();
  1122. //Attributes
  1123. protected:
  1124. public:
  1125. float m_fHeight;
  1126. float m_fWidth;
  1127. float m_fDepth;
  1128. C3dPageCube* m_pAttribPage;
  1129. };
  1130. /////////////////////////////////////////////////////////////////////////////
  1131. class C3dPageCylinder;
  1132. ////////////////////////////////////////////////////////////////////
  1133. // C3dObjectCylinder
  1134. class AFX_EXT_CLASS C3dObjectCylinder : public C3dObject
  1135. {
  1136. DECLARE_DYNAMIC(C3dObjectCylinder);
  1137. //Construction
  1138. public:
  1139.     C3dObjectCylinder();
  1140.     virtual ~C3dObjectCylinder();
  1141. //Implimentation
  1142. public:
  1143. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1144. virtual int  LoadBitMapImage(CImageList*);
  1145. virtual void Serialize(CArchive& ar, int iVersion);
  1146. virtual void Build(C3dWorld*, C3dCamera*);
  1147. void InitVertices();
  1148. void CalNormals(C3dPoint* pNormals, BOOL bSmooth=TRUE);
  1149. //Implimentation
  1150. protected:
  1151. //Attributes
  1152. protected:
  1153. public:
  1154. BOOL m_bSolid;
  1155. BOOL m_bSmooth;
  1156. float m_fHeight;
  1157. float m_fTopRadius;
  1158. float m_fBaseRadius;
  1159. int m_iSegments;
  1160. C3dPageCylinder* m_pAttribPage;
  1161. };
  1162. /////////////////////////////////////////////////////////////////////////////
  1163. class C3dPageDisk;
  1164. ////////////////////////////////////////////////////////////////////
  1165. // C3dObjectDisk
  1166. class AFX_EXT_CLASS C3dObjectDisk : public C3dObject
  1167. {
  1168. DECLARE_DYNAMIC(C3dObjectDisk);
  1169. //Construction
  1170. public:
  1171.     C3dObjectDisk();
  1172.     virtual ~C3dObjectDisk();
  1173. //Implimentation
  1174. public:
  1175. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1176. virtual int  LoadBitMapImage(CImageList*);
  1177. virtual void Serialize(CArchive& ar, int iVersion);
  1178. virtual void Build(C3dWorld*, C3dCamera*);
  1179. void InitVertices();
  1180. //Implimentation
  1181. protected:
  1182. //Attributes
  1183. protected:
  1184. public:
  1185. GLfloat m_fInnerRadius;
  1186. GLfloat m_fOuterRadius;
  1187. GLfloat m_fSweepAngle;
  1188. int m_iSegments;
  1189. int m_iRings;
  1190. C3dPageDisk* m_pAttribPage;
  1191. };
  1192. /////////////////////////////////////////////////////////////////////////////
  1193. class C3dPageGrid;
  1194. ////////////////////////////////////////////////////////////////////
  1195. // C3dObjectGrid
  1196. class AFX_EXT_CLASS C3dObjectGrid : public C3dObject
  1197. {
  1198. DECLARE_DYNAMIC(C3dObjectGrid);
  1199. //Construction
  1200. public:
  1201.     C3dObjectGrid();
  1202.     virtual ~C3dObjectGrid();
  1203. //Implimentation
  1204. public:
  1205. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1206. virtual void GetShapeBounds(C3dBoundingBox* pBox);
  1207. virtual int  LoadBitMapImage(CImageList*);
  1208. virtual void Serialize(CArchive& ar, int iVersion);
  1209. virtual void Build(C3dWorld*, C3dCamera*);
  1210. //Implimentation
  1211. protected:
  1212. //Attributes
  1213. protected:
  1214. public:
  1215. C3dColor m_AltColor; // Color component
  1216. GLfloat m_fWidth;
  1217. GLfloat m_fDepth;
  1218. int m_iDivisionsX;
  1219. int m_iDivisionsY;
  1220. C3dPageGrid* m_pAttribPage;
  1221. };
  1222. /////////////////////////////////////////////////////////////////////////////
  1223. class C3dPageLathe;
  1224. ////////////////////////////////////////////////////////////////////
  1225. // C3dObjectLathe
  1226. class AFX_EXT_CLASS C3dObjectLathe : public C3dObject
  1227. {
  1228. DECLARE_DYNAMIC(C3dObjectLathe);
  1229. //Construction
  1230. public:
  1231.     C3dObjectLathe();
  1232.     virtual ~C3dObjectLathe();
  1233. //Implimentation
  1234. public:
  1235. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1236. virtual void GetShapeBounds(C3dBoundingBox* pBox);
  1237. virtual int  LoadBitMapImage(CImageList*);
  1238. virtual void Serialize(CArchive& ar, int iVersion);
  1239. virtual void Build(C3dWorld*, C3dCamera*);
  1240. protected:
  1241. void CalNormals(LatheFace Vertice, LatheFace Normal);
  1242. void CalSmoothNormals(LatheFace Vertice,  int iFace, float fTheta, LatheFace Normal);
  1243. //Attributes
  1244. protected:
  1245. public:
  1246. int m_iSegments; // Number of segments in our lathe object
  1247. float m_fSweepAngle; // Sweep Angle 
  1248. BOOL m_bSmooth; // Smooth Faces
  1249. float m_fMaxAngle; // Max angle between faces to smooth
  1250. C3dPageLathe* m_pAttribPage;
  1251. };
  1252. /////////////////////////////////////////////////////////////////////////////
  1253. class C3dPageNURB;
  1254. ////////////////////////////////////////////////////////////////////
  1255. // C3dObjectNURB
  1256. class AFX_EXT_CLASS C3dObjectNURB : public C3dObject
  1257. {
  1258. DECLARE_DYNAMIC(C3dObjectNURB);
  1259. //Construction
  1260. public:
  1261.     C3dObjectNURB();
  1262.     virtual ~C3dObjectNURB();
  1263. //Implimentation
  1264. public:
  1265. virtual void AddAttributePage(C3dWorld*, LPVOID);
  1266. virtual int  LoadBitMapImage(CImageList*);
  1267. virtual void Serialize(CArchive& ar, int iVersion);
  1268. virtual void DisplayObject(C3dWorld*, C3dCamera*);
  1269. virtual void Build(C3dWorld*, C3dCamera*);
  1270. void InitVertices();
  1271. int  InitKnots();
  1272. //Implimentation
  1273. protected:
  1274. //Attributes
  1275. protected:
  1276. public:
  1277. float m_fWidth;
  1278. float m_fDepth;
  1279. int m_iUSegments;
  1280. int m_iVSegments;
  1281. int m_iNumUCtrlPoints;
  1282. int m_iNumVCtrlPoints;
  1283. GLfloat* m_pUKnots; // Pointer to our parametric u knot values
  1284. HGLOBAL m_hUKnots; // handle of the allocated memory object.
  1285. GLfloat* m_pVKnots; // Pointer to our parametric V knot values
  1286. HGLOBAL m_hVKnots; // handle of the allocated memory object.
  1287. GLUnurbsObj* m_pNURBObj;
  1288. C3dPageNURB* m_pAttribPage;
  1289. };
  1290. /////////////////////////////////////////////////////////////////////////////
  1291. class C3dPagePlane;
  1292. ////////////////////////////////////////////////////////////////////
  1293. // C3dObjectPlane
  1294. class AFX_EXT_CLASS C3dObjectPlane : public C3dObject
  1295. {
  1296. DECLARE_DYNAMIC(C3dObjectPlane);
  1297. //Construction
  1298. public:
  1299.     C3dObjectPlane();
  1300.     virtual ~C3dObjectPlane();
  1301. //Implimentation
  1302. public:
  1303. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1304. virtual int  LoadBitMapImage(CImageList*);
  1305. virtual void Serialize(CArchive& ar, int iVersion);
  1306. virtual void Build(C3dWorld*, C3dCamera*);
  1307. void InitVertices();
  1308. //Implimentation
  1309. protected:
  1310. //Attributes
  1311. protected:
  1312. public:
  1313. float m_fWidth;
  1314. float m_fDepth;
  1315. C3dPagePlane* m_pAttribPage;
  1316. };
  1317. /////////////////////////////////////////////////////////////////////////////
  1318. class C3dPageCloud;
  1319. ////////////////////////////////////////////////////////////////////
  1320. // C3dObjectCloud
  1321. class AFX_EXT_CLASS C3dObjectCloud : public C3dObject
  1322. {
  1323. DECLARE_DYNAMIC(C3dObjectCloud);
  1324. //Construction
  1325. public:
  1326.     C3dObjectCloud();
  1327.     virtual ~C3dObjectCloud();
  1328. static void CopyParameters(C3dObjectCloud* pSrc, C3dObjectCloud* pDest);
  1329. //Implimentation
  1330. public:
  1331. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1332. virtual int  LoadBitMapImage(CImageList*);
  1333. virtual void GetShapeBounds(C3dBoundingBox* pBox);
  1334. virtual void Serialize(CArchive& ar, int iVersion);
  1335. virtual void DisplayPoints(C3dWorld* pWorld, C3dCamera* pCamera);
  1336. virtual void Build(C3dWorld*, C3dCamera*);
  1337. void InitVertices();
  1338. void RenderCloudImageMap(C3dWorld* pWorld, C3dCamera* pCamera);
  1339. BOOL RenderCloudTextureMap(C3dWorld* pWorld, C3dCamera* pCamera);
  1340. void SetSkyPixelColor(int size, GLubyte *skyTex);
  1341. float RandNum(float min, float max);
  1342. int   PowerOf2(int size);
  1343. float AvgDiamondVals(int i, int j, int stride, int size, int subSize);
  1344. float AvgSquareVals (int i, int j, int stride, int size);
  1345. void  FillFractualArray (int size, float heightScale);
  1346. float* Alloc2DFractArray(int size);
  1347. void FreeFractArray();
  1348. //Implimentation
  1349. protected:
  1350. //Attributes
  1351. protected:
  1352. unsigned int m_iCloudTextureMap;
  1353. unsigned int m_iCloudImageMap;
  1354. public:
  1355. int m_iSize;
  1356. int m_iTile;
  1357. int m_iTextureWrap;
  1358. int m_iHeightSeed;
  1359. float m_fWidth;
  1360. float m_fDepth;
  1361. float m_fBumpHeight;
  1362. float m_fOpacity;
  1363. float m_fDensity;
  1364. float* m_pFa;
  1365. C3dColor m_ColorHighlight;
  1366. C3dPageCloud* m_pAttribPage;
  1367. };
  1368. /////////////////////////////////////////////////////////////////////////////
  1369. class C3dPageSphere;
  1370. ////////////////////////////////////////////////////////////////////
  1371. // C3dObjectSphere
  1372. class AFX_EXT_CLASS C3dObjectSphere : public C3dObject
  1373. {
  1374. DECLARE_DYNAMIC(C3dObjectSphere);
  1375. //Construction
  1376. public:
  1377.     C3dObjectSphere();
  1378.     virtual ~C3dObjectSphere();
  1379. //Implimentation
  1380. public:
  1381. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1382. virtual void GetShapeBounds(C3dBoundingBox* pBox);
  1383. virtual int  LoadBitMapImage(CImageList*);
  1384. virtual void Serialize(CArchive& ar, int iVersion);
  1385. virtual void Build(C3dWorld*, C3dCamera*);
  1386. //Implimentation
  1387. protected:
  1388. //Attributes
  1389. protected:
  1390. public:
  1391. int m_iNumMajor;
  1392. int m_iNumMinor;
  1393. float m_fRadius;
  1394. C3dPageSphere* m_pAttribPage;
  1395. };
  1396. /////////////////////////////////////////////////////////////////////////////
  1397. class C3dPageTerrain;
  1398. ////////////////////////////////////////////////////////////////////
  1399. // C3dObjectTerrain
  1400. class AFX_EXT_CLASS C3dObjectTerrain : public C3dObject
  1401. {
  1402. DECLARE_DYNAMIC(C3dObjectTerrain);
  1403. //Construction
  1404. public:
  1405.     C3dObjectTerrain();
  1406.     virtual ~C3dObjectTerrain();
  1407. //Implimentation
  1408. public:
  1409. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1410. virtual int  LoadBitMapImage(CImageList*);
  1411. virtual void GetShapeBounds(C3dBoundingBox* pBox);
  1412. virtual void Serialize(CArchive& ar, int iVersion);
  1413. virtual void DisplayPoints(C3dWorld* pWorld, C3dCamera* pCamera);
  1414. virtual void Build(C3dWorld*, C3dCamera*);
  1415. void CopyParameters(C3dObjectTerrain* pObj);
  1416. void RenderTerrain(BOOL bCreateList, BOOL bReflect);
  1417. void RenderTextureMaps();
  1418. void DisplayAsTriangles(int i, int j, BOOL bReflect);
  1419. void DisplayAsTriangleStrip(int i, int j, BOOL bReflect);
  1420. void InitTerrainColor();
  1421. void SetTerrainColor(int i, int j, BOOL bReflect);
  1422. BOOL AddSubTexture(LPSTR szFileName, CTexture** pTexture);
  1423. void DeleteSubTexture(CTexture* pTexture);
  1424. void InitTerrain();
  1425. void AvgNormals(int i, int j, C3dPointArray *fa, VECTORF* pNormal, BOOL bDiagonal);
  1426. void FillFractualArray(C3dPoint *fa, int size, float heightScale, float h);
  1427. void InitColorHeightValues();
  1428. int  PowerOf2(int size);
  1429. float RandNum(float min, float max);
  1430. float AvgSquareVals(int i, int j, int stride, int size, C3dPoint *fa);
  1431. float AvgDiamondVals(int i, int j, int stride, int size, int subSize, C3dPoint *fa);
  1432. void SetTextureCoord(int i, int j);
  1433. void SetTextureList(VECTORF p1, VECTORF p2, VECTORF p3);
  1434. BOOL RenderTextureImageMap(C3dWorld* pWorld, C3dCamera* pCamera);
  1435. //Implimentation
  1436. protected:
  1437. //Attributes
  1438. protected:
  1439. float m_fSnowHeight;
  1440. float m_fRockHeight;
  1441. float m_fGrassHeight;
  1442. float m_fWaterHeight;
  1443. unsigned int m_iTerrainGridDisplayList;
  1444. unsigned int m_iTexImageMap;
  1445. public:
  1446. BOOL m_bMapTexturesToSubGrid;
  1447. BOOL m_bApplySubGridTextures;
  1448. BOOL m_bReflect;
  1449. BOOL m_bSmoothNormals;
  1450. int m_iSize;
  1451. int m_iTile;
  1452. float m_fWidth;
  1453. float m_fDepth;
  1454. float m_fHeight;
  1455. int m_iHeightSeed;
  1456. float m_fSeaLevel;
  1457. C3dColor m_ColorSnow;
  1458. C3dColor m_ColorRock;
  1459. C3dColor m_ColorGrass;
  1460. C3dColor m_ColorWater;
  1461. CTexture* m_pTextureSnow; // Our objects' texture
  1462. CTexture* m_pTextureRock; // Our objects' texture
  1463. CTexture* m_pTextureGrass; // Our objects' texture
  1464. CTexture* m_pTextureWater; // Our objects' texture
  1465. C3dPageTerrain* m_pAttribPage;
  1466. };
  1467. /////////////////////////////////////////////////////////////////////////////
  1468. class C3dPageTorus;
  1469. ////////////////////////////////////////////////////////////////////
  1470. // C3dObjectTorus
  1471. class AFX_EXT_CLASS C3dObjectTorus : public C3dObject
  1472. {
  1473. DECLARE_DYNAMIC(C3dObjectTorus);
  1474. //Construction
  1475. public:
  1476.     C3dObjectTorus();
  1477.     virtual ~C3dObjectTorus();
  1478. //Implimentation
  1479. public:
  1480. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1481. virtual void GetShapeBounds(C3dBoundingBox* pBox);
  1482. virtual int  LoadBitMapImage(CImageList*);
  1483. virtual void Serialize(CArchive& ar, int iVersion);
  1484. virtual void Build(C3dWorld*, C3dCamera*);
  1485. //Implimentation
  1486. protected:
  1487. //Attributes
  1488. protected:
  1489. public:
  1490. int m_iNumMajor;
  1491. int m_iNumMinor;
  1492. float m_fMajorRadius;
  1493. float m_fMinorRadius;
  1494. C3dPageTorus* m_pAttribPage;
  1495. };
  1496. /////////////////////////////////////////////////////////////////////////////
  1497. class C3dPageTriangle;
  1498. ////////////////////////////////////////////////////////////////////
  1499. // C3dObjectTriangle
  1500. class AFX_EXT_CLASS C3dObjectTriangle : public C3dObject
  1501. {
  1502. DECLARE_DYNAMIC(C3dObjectTriangle);
  1503. //Construction
  1504. public:
  1505.     C3dObjectTriangle();
  1506.     virtual ~C3dObjectTriangle();
  1507. //Implimentation
  1508. public:
  1509. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1510. virtual int  LoadBitMapImage(CImageList*);
  1511. virtual void Serialize(CArchive& ar, int iVersion);
  1512. virtual void Build(C3dWorld*, C3dCamera*);
  1513. void InitVertices();
  1514. //Implimentation
  1515. protected:
  1516. //Attributes
  1517. protected:
  1518. public:
  1519. float m_fWidth;
  1520. float m_fDepth;
  1521. C3dPageTriangle* m_pAttribPage;
  1522. };
  1523. /////////////////////////////////////////////////////////////////////////////
  1524. class C3dPageTTF;
  1525. ////////////////////////////////////////////////////////////////////
  1526. // C3dObjectTTF  (True Type Font)
  1527. class AFX_EXT_CLASS C3dObjectTTF : public C3dObject
  1528. {
  1529. DECLARE_DYNAMIC(C3dObjectTTF);
  1530. //Construction
  1531. public:
  1532.     C3dObjectTTF();
  1533.     virtual ~C3dObjectTTF();
  1534. //Implimentation
  1535. public:
  1536. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1537. virtual void GetShapeBounds(C3dBoundingBox* pBox);
  1538. virtual void DisplayObject(C3dWorld*, C3dCamera*);
  1539. virtual int  LoadBitMapImage(CImageList*);
  1540. virtual void Serialize(CArchive& ar, int iVersion);
  1541. virtual void Build(C3dWorld*, C3dCamera*);
  1542. protected:
  1543. //Attributes
  1544. protected:
  1545. public:
  1546. LOGFONT m_LogFont;
  1547. GLfloat m_fStringLength;
  1548. GLfloat m_fCharHeight;
  1549. GLfloat m_fCharDepth;
  1550. };
  1551. /////////////////////////////////////////////////////////////////////////////
  1552. class C3dPageLight;
  1553. ///////////////////////////////////////////////////////////////////
  1554. // C3dObjectLight
  1555. class AFX_EXT_CLASS C3dObjectLight : public C3dObject
  1556. {
  1557. DECLARE_SERIAL(C3dObjectLight);
  1558. //Construction
  1559. public:
  1560.     C3dObjectLight();
  1561.     virtual ~C3dObjectLight();
  1562. //Implimentation
  1563. public:
  1564. virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
  1565. virtual void GetShapeBounds(C3dBoundingBox* pBox);
  1566. virtual int  LoadBitMapImage(CImageList*);
  1567. virtual void Serialize(CArchive& ar, int iVersion);
  1568. virtual void Build(C3dWorld*, C3dCamera*);
  1569. virtual void DisplayPoints(C3dWorld* pWorld, C3dCamera* pCamera);
  1570. virtual C3dPoint* FindPoint(C3dCamera* pCamera, float, float, float);
  1571. virtual void SetObjPointOrigin(C3dPoint*, float, float, float);
  1572. virtual void GetObjPointOrigin(C3dPoint*, float*, float*, float*);
  1573. void EnableLight(GLenum, C3dWorld*, C3dCamera*);
  1574. void GetDirection(GLfloat *x, GLfloat *y, GLfloat *z);
  1575. void GetAttenuation(GLfloat *k, GLfloat *l, GLfloat *q);
  1576. void GetSpecularPwr(GLfloat *pwr);
  1577. void GetSpotAngle(GLfloat *angle);
  1578. void GetRadius(GLfloat *radius);
  1579. void SetDirection(GLfloat x, GLfloat y, GLfloat z);
  1580. void SetAttenuation(GLfloat k, GLfloat l, GLfloat q);
  1581. void SetSpecularPwr(GLfloat pwr);
  1582. void SetSpotAngle(GLfloat angle);
  1583. void SetRadius(GLfloat radius);
  1584. //Attributes
  1585. protected:
  1586. GLfloat m_fDirection[3]; // Direction of Light
  1587. GLfloat m_fSpecHighlight; // Specular highlight exponent
  1588. GLfloat m_fRadius; // Lights size or radius
  1589. GLfloat m_fLength; // Lights length
  1590. GLfloat m_fConstantAttenuation;
  1591. GLfloat m_fLinearAttenuation;
  1592. GLfloat m_fQuadraticAttenuation;
  1593. C3dPageLight* m_pLightPage;
  1594. public:
  1595. int m_iLightType; // Light Type:  0=Ambient, 1=Point, 2=Spot
  1596. int m_iDisplayAs; // Display As:  0=Sphere, 1=Cylinder, 2=Rect
  1597. C3dColor m_ColorAmbient; // Ambient color component
  1598. C3dColor m_ColorDiffuse; // Diffuse color component
  1599. C3dColor m_ColorSpecular; // Specular color component
  1600. GLfloat m_fSpotAngle; // Spot Angle (degrees)
  1601. };
  1602. /////////////////////////////////////////////////////////////////////////////
  1603. ///////////////////////////////////////////////////////////////////
  1604. // C3dLightList
  1605. class AFX_EXT_CLASS C3dLightList : protected CObList
  1606. {
  1607. //Construction
  1608. public:
  1609. C3dLightList();
  1610. virtual ~C3dLightList();
  1611. //Implimentation
  1612. public:
  1613. void Append(C3dObject* pLight) {CObList::AddTail(pLight);}
  1614. void Remove(C3dObject* pLight);
  1615. void Delete(C3dObject* pLight);
  1616. void DeleteAll();
  1617. C3dObject* GetNext(POSITION& rPosition)
  1618. {return (C3dObject*) CObList::GetNext(rPosition);}
  1619. C3dObject* GetAt(POSITION& rPosition)
  1620. {return (C3dObject*) CObList::GetAt(rPosition);}
  1621. POSITION GetHeadPosition()
  1622. {return (POSITION) CObList::GetHeadPosition();}
  1623. //Attributes
  1624. protected:
  1625. public:
  1626. };
  1627. /////////////////////////////////////////////////////////////////////////////
  1628. /////////////////////////////////////////////////////////////////////////////
  1629. // C3dCamera
  1630. class AFX_EXT_CLASS C3dCamera : public CObject
  1631. {
  1632. DECLARE_DYNAMIC(C3dCamera);
  1633. //Construction
  1634. public:
  1635.     C3dCamera();
  1636.     virtual ~C3dCamera();
  1637. //Implimentation
  1638. public:
  1639. virtual void Serialize(CArchive& ar, int iVersion);
  1640. int  EditAttributes(CWnd* pParentWnd, C3dWorld* pWorld);
  1641. int  EditAnimation(CWnd* pParentWnd, C3dWorld* pWorld);
  1642. void AddAnimationPages(C3dWorld* pWorld, LPVOID pSht);
  1643. void Animate(double time);
  1644. void ResetAnimation();
  1645. int  LoadBitMapImage(CImageList* pList);
  1646. void GetTransformMatrix(Matx4x4 XformMatrix);
  1647. void GetInvTransformMatrix(Matx4x4 XformMatrix);
  1648. void GetRotationMatrix(Matx4x4 XformMatrix);
  1649. void GetInvRotationMatrix(Matx4x4 XformMatrix);
  1650. void GetOrigin(GLfloat *x, GLfloat *y, GLfloat *z);
  1651. void GetRotation(GLfloat *x, GLfloat *y, GLfloat *z);
  1652. void SetOrigin(GLfloat x, GLfloat y, GLfloat z);
  1653. void SetRotation(GLfloat x, GLfloat y, GLfloat z);
  1654. void ResetView(int w, int h);
  1655. void PositionCamera();
  1656. void GetWorldCoord(int ix, int iy, GLfloat fz, VECTORF coord);
  1657. //Attributes
  1658. protected:
  1659. public:
  1660. CString m_szName; // Name of this camera
  1661. CAnimationList m_AnimList; // List of this cameras' animation procedures
  1662. int m_iBMImage; // Cameras' bitmap image index
  1663. BOOL m_bBuildLists;
  1664. unsigned int m_iDisplayLists;
  1665. int m_bPerspective;
  1666. int m_iViewType;
  1667. GLsizei m_iScreenWidth;
  1668. GLsizei m_iScreenHeight;
  1669. GLfloat m_fFovY; // Y-Axis field of view
  1670. GLfloat m_fAspect; // width(x) to height(y) aspect
  1671. GLfloat m_fLeft;
  1672. GLfloat m_fRight;
  1673. GLfloat m_fBottom;
  1674. GLfloat m_fTop;
  1675. GLfloat m_fNear;
  1676. GLfloat m_fFar;
  1677. GLfloat m_fOrigin[3];
  1678. GLfloat m_fRotation[3];
  1679. GLdouble m_dModelViewMatrix[16];
  1680. protected:
  1681. };
  1682. /////////////////////////////////////////////////////////////////////////////
  1683. /////////////////////////////////////////////////////////////////////////////
  1684. // C3dFog
  1685. class C3dFog : public CObject
  1686. {
  1687. DECLARE_DYNAMIC(C3dFog);
  1688. //Construction
  1689. public:
  1690.     C3dFog();
  1691.     virtual ~C3dFog();
  1692. //Implimentation
  1693. public:
  1694. void SetAttributes();
  1695. virtual void Serialize(CArchive& ar, int iVersion);
  1696. //Attributes
  1697. protected:
  1698. public:
  1699. GLenum m_enumMode;
  1700. GLenum m_enumHint;
  1701. GLfloat m_fDensity;
  1702. GLfloat m_fStart;
  1703. GLfloat m_fEnd;
  1704. C3dColor m_Color;
  1705. protected:
  1706. };
  1707. /////////////////////////////////////////////////////////////////////////////
  1708. class C3dBackgroundPropSheet;
  1709. /////////////////////////////////////////////////////////////////////////////
  1710. // C3dWorld
  1711. class AFX_EXT_CLASS C3dWorld : public CObject
  1712. {
  1713. // DECLARE_DYNAMIC(C3dWorld);
  1714. DECLARE_SERIAL(C3dWorld);
  1715. //Construction
  1716. public:
  1717.     C3dWorld();
  1718.     virtual ~C3dWorld();
  1719. static C3dWorld* CreateWorld();
  1720. void DeleteWorld();
  1721. //Implimentation
  1722. public:
  1723. virtual void Serialize(CArchive& ar, C3dCamera* pCamera);
  1724. BOOL AddTexture(LPSTR);
  1725. void DeleteTexture();
  1726. void AddAnimationPages(C3dWorld* pWorld, LPVOID pSht);
  1727. int  EditAnimation(CWnd* pParentWnd, C3dWorld* pWorld);
  1728. void AddObject(C3dObject* pObject, C3dObject* pParent);
  1729. BOOL CreateDefMaterials(C3dMaterialList* pMatlList);
  1730. BOOL CreateDefColors(C3dColorList* pColorList);
  1731. void AddMaterial(C3dMaterial* pMaterial);
  1732. void DeleteObject(C3dObject* pObject);
  1733. void DisplayWorld(HDC hDC, C3dCamera* pCamera, double dTime);
  1734. void DisplayBackgroundImage(C3dCamera* pCamera);
  1735. C3dObject* ProcessSelection(C3dCamera* pCamera, int xPos, int yPos, BOOL bSelParent);
  1736. int  LoadBitMapImage(CImageList*);
  1737. void Animate(C3dCamera* pCamera, double time);
  1738. void ResetAnimation(C3dCamera* pCamera);
  1739. void RenderScene(C3dCamera* pCamera);
  1740. void SetupRC();
  1741. void RebuildAllObjects();
  1742. BOOL EditAttributes();
  1743. void InitializeLights(C3dCamera* pCamera);
  1744. protected:
  1745. //Attributes
  1746. protected:
  1747. public:
  1748. CString m_szName; // Name of this world
  1749. GLenum m_NumLights; // Number of lights
  1750. C3dLightList m_LightList; // List of Lights
  1751. C3dObjectList m_ObjectList; // List of Objects
  1752. C3dObject* m_pSelectedObj; // Currently selected object
  1753. C3dColorList m_ColorList; // List of Colors
  1754. CString m_szColorFile; // Color list file name
  1755. C3dMaterialList m_MaterialList; // List of Materials
  1756. CString m_szMatlFile; // Matl list file name
  1757. C3dPointList m_PointList; // List of Points used for creation of objects
  1758. C3dPoint* m_pSelectedPnt; // Currently selected object
  1759. C3dGrid* m_pGrid; // Grid pointer
  1760. C3dColor m_BackgroundColor;
  1761. CTexture* m_pBkgndTexture;
  1762. CAnimationList m_AnimList; // List of world animation procedures
  1763. int m_iBMImage; // Zero based index to a CImageList
  1764. BOOL m_bAnimate;
  1765. BOOL m_bFly;
  1766. BOOL m_bDisplayAxis;
  1767. BOOL m_bDisplayGrid;
  1768. BOOL m_bDisplayPoints;
  1769. int m_iRenderMode;
  1770. BOOL m_bCullFaces;
  1771. C3dBackgroundPropSheet* m_pBackgroundPropSheet;
  1772. // World attribute flags
  1773. BOOL m_bFogEnable;
  1774. C3dFog m_Fog;
  1775. // GLdouble m_dCameraMatrix[16];
  1776. //  TO DO:  REMOVE THESE CLASSES AND REPLACE WITH
  1777. // STATIC FUNCTION CALLS...
  1778. // (DON'T NEED TO BE MEMBERS OF C3DWORLD..)
  1779. C3dAxis* m_pAxis; // Axis pointer
  1780. C3dBoundingBox* m_pBoundingBox; // Bounding Box pointer
  1781. };
  1782. /////////////////////////////////////////////////////////////////////////////
  1783. /////////////////////////////////////////////////////////////////////////////
  1784. // Include all external extensions
  1785. #include "3dObjectHSpline.h"
  1786. #endif // _glOOP_H_