glOOP.h
资源名称:gloop.zip [点击查看]
上传用户:shxiangxiu
上传日期:2007-01-03
资源大小:1101k
文件大小:61k
源码类别:
OpenGL
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // glOOP.h : Header file; Defines the class definitions
- //
- // glOOP (OpenGL Object Oriented Programming library)
- // Copyright (c) Craig Fahrnbach, ImageWare Development, 1997-1999
- // All rights reserved.
- //
- // OpenGL is a registered trademark of Silicon Graphics
- //
- //
- // This program is provided for educational and personal use only and
- // is provided without guarantee or warrantee expressed or implied.
- //
- // Commercial use is strickly prohibited without written permission
- // from ImageWare Development.
- //
- // This program is -not- in the public domain.
- //
- //
- // This file should be included in your application's main
- // include file so that it is available to all modules that
- // need access the the OpenGL 3D classes
- //
- /////////////////////////////////////////////////////////////////////////////
- #include <glgl.h> // OpenGL extensions
- #include <glglu.h>
- #include <glglaux.h>
- #include <vfw.h>
- #include <math.h>
- #include "resource.h"
- #include "glMath.h"
- #include "MyFileIO.h"
- #ifndef _glOOP_H_
- #define _glOOP_H_
- /////////////////////////////////////////////////////////////////////////////
- // Define DLL import/export
- //
- #if !defined (_WIN32)
- # define EXPORT __export
- # define EXPORT32
- #else
- # define EXPORT
- # if defined DLL
- # define EXPORT32 __declspec(dllexport)
- # else
- # define EXPORT32 __declspec(dllimport)
- # endif
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Macros to display/remove hourglass cursor for lengthy operations
- //
- #define StartWait() m_hcurSave = SetCursor(LoadCursor(NULL, IDC_WAIT))
- #define EndWait() SetCursor(m_hcurSave)
- #define WRITE_BUFFERS 2
- /////////////////////////////////////////////////////////////////////////////
- // Definitions
- //
- #define SHAPE_OBJECT 0
- #define LIGHT_OBJECT 1
- #define LIGHT_AMBIENT 0
- #define LIGHT_POINT 1
- #define LIGHT_SPOT 2
- #define DISPLAY_NONE 0
- #define DISPLAY_SPHERE 1
- #define DISPLAY_CYLINDER 2
- #define DISPLAY_RECTANGLE 3
- #define VIEW_ISO 0
- #define VIEW_FRONT 1
- #define VIEW_SIDE 2
- #define VIEW_TOP 3
- #define RENDER_WIREFRAME 0
- #define RENDER_FLAT 1
- #define RENDER_SMOOTH 2
- #define RENDER_RAYTRACE 3
- #define RENDER_OUTLINE 4
- #define CSG_TYPE_OR 0
- #define CSG_TYPE_SUB_AB 1
- #define CSG_TYPE_SUB_BA 2
- #define CSG_TYPE_AND 3
- #define MAX_FACES_PER_SEGMENT 100
- #define MAX_SEGMENTS 100
- #define NORMALS_PER_FACE 4
- /////////////////////////////////////////////////////////////////////////////
- // Type Definitions
- //
- typedef GLfloat LatheFace[4][4];
- /////////////////////////////////////////////////////////////////////////////
- // Global variables:
- //
- extern CString szIndent; // Object indent used for serialization
- static int iFileVersion = 140; // file Write version request (future use)
- static CString szFileVersion = _T("// Version: 1.40n");
- static CString szWorldFileHeader = _T("// ModelMagic3D World Definition Filen");
- static CString szObjectFileHeader = _T("// ModelMagic3D Object Definition Filen");
- static CString szMatlFileHeader = _T("// ModelMagic3D Material Defintion Filen");
- static CString szColorFileHeader = _T("// ModelMagic3D Color Definition Filen");
- 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");
- // We track the number of lights so that we can append the
- // light 'number' to the end of the default name..
- static unsigned int nLights = 0;
- // We track the number of shape types so that we can
- // append a number to the end of the default
- // name..
- static unsigned int nCloudObjects = 0;
- static unsigned int nConeObjects = 0;
- static unsigned int nCSGObjects = 0;
- static unsigned int nCubeObjects = 0;
- static unsigned int nCylinderObjects = 0;
- static unsigned int nDiskObjects = 0;
- static unsigned int nGridObjects = 0;
- static unsigned int nLatheObjects = 0;
- static unsigned int nMeshObjects = 0;
- static unsigned int nPlaneObjects = 0;
- static unsigned int nSphereObjects = 0;
- static unsigned int nTerrainObjects = 0;
- static unsigned int nTorusObjects = 0;
- static unsigned int nTriangleObjects = 0;
- static unsigned int nTTFObjects = 0;
- static unsigned int nHSplineObjects = 0;
- static unsigned int nNURBObjects = 0;
- // When the user creates a new shape or light, we assign a unique 'name'
- // to the object for identification during the select process.
- static GLuint iGlobalNamesList = 1; // Counter for our list of names
- // Record the BitMap Image zero based index into the
- // CImageList used for display in a CTreeCtrl
- static int iWorldBMImage = -1;
- static int iCameraBMImage = -1;
- static int iObjectCloudBMImage = -1;
- static int iObjectConeBMImage = -1;
- static int iObjectCSGBMImage = -1;
- static int iObjectCubeBMImage = -1;
- static int iObjectCylinderBMImage = -1;
- static int iObjectDiskBMImage = -1;
- static int iObjectGridBMImage = -1;
- static int iObjectLatheBMImage = -1;
- static int iObjectLightBMImage = -1;
- static int iObjectMeshBMImage = -1;
- static int iObjectPlaneBMImage = -1;
- static int iObjectSphereBMImage = -1;
- static int iObjectTerrainBMImage = -1;
- static int iObjectTorusBMImage = -1;
- static int iObjectTriangleBMImage = -1;
- static int iObjectTTFBMImage = -1;
- static int iObjectHSplineBMImage = -1;
- static int iObjectNURBBMImage = -1;
- // global names used to identify Animation procedures
- #define SZ_ANIMATE_SPIN _T("Spin")
- #define SZ_ANIMATE_WOBBLE _T("Wobble")
- #define SZ_ANIMATE_SEESAW _T("SeeSaw")
- #define SZ_ANIMATE_KEYFRAME _T("KeyFrame")
- #define SZ_ANIMATE_AVI _T("AVI Movie Animation")
- /////////////////////////////////////////////////////////////////////////////
- // Predefined classes:
- //
- class C3dWorld;
- class C3dObject;
- /////////////////////////////////////////////////////////////////////////////
- // C3dEngine
- class AFX_EXT_CLASS C3dEngine : public CObject
- {
- DECLARE_DYNAMIC(C3dEngine);
- //Construction
- public:
- C3dEngine();
- virtual ~C3dEngine();
- BOOL SetWindowPixelFormat(HDC hDC, DWORD dwFlags);
- BOOL EnableRC(HDC hDC, HGLRC hRC, BOOL bEnable);
- void DisplayError(LPSTR);
- inline HPALETTE C3dEngine::GetPalette()
- { return (HPALETTE)m_hPalette; }
- //Implimentation
- protected:
- HPALETTE CreateNewPalette(HDC hDC);
- public:
- //Attributes
- protected:
- public:
- HPALETTE m_hPalette; // Handle to rendering context palette
- BOOL m_bDisplayErrorMessages;
- };
- // the one and only 3dEngine object
- extern EXPORT32 C3dEngine EXPORT the3dEngine;
- /////////////////////////////////////////////////////////////////////////////
- class C3dColorList;
- ////////////////////////////////////////////////////////////////////
- // C3dColor
- class AFX_EXT_CLASS C3dColor : public CObject
- {
- DECLARE_DYNAMIC(C3dColor);
- // Construction
- public:
- C3dColor();
- virtual ~C3dColor();
- //Implimentation
- public:
- BOOL Compare(C3dColor* pColor);
- void Serialize(CArchive& ar, int iVersion);
- void GetColor4f(GLfloat *r, GLfloat *g, GLfloat *b, GLfloat *a);
- void SetColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
- void SetColor3fv(C3dColor* pColor);
- void SetColor4fv(C3dColor* pColor);
- static C3dColor* Create();
- static C3dColor* Create(CString szName,
- GLfloat r,
- GLfloat g,
- GLfloat b,
- GLfloat a);
- static void Delete(C3dColor* pColor);
- //Attributes
- protected:
- public:
- CString m_szName; // Name of this Color
- GLfloat m_fColor[4]; // RGBA color component
- };
- /////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- // C3dColorList
- class AFX_EXT_CLASS C3dColorList : protected CObList
- {
- DECLARE_DYNAMIC(C3dColorList);
- //Construction
- public:
- C3dColorList();
- virtual ~C3dColorList();
- //Implimentation
- public:
- C3dColor* LoadComboBox(CComboBox* pCombo, C3dColor* pColorSel);
- C3dColor* LoadListBox(CListBox* pList);
- void LoadColors(CString szFileName);
- void SaveColors(CString szFileName);
- void Serialize(CArchive& ar, int iVersion);
- void Append(C3dColor* pColor) {CObList::AddTail(pColor);}
- void Remove(C3dColor* pColor);
- void Delete(C3dColor* pColor);
- void DeleteAll();
- C3dColor* GetNext(POSITION& rPosition)
- {return (C3dColor*) CObList::GetNext(rPosition);}
- C3dColor* GetAt(POSITION& rPosition)
- {return (C3dColor*) CObList::GetAt(rPosition);}
- POSITION GetHeadPosition()
- {return (POSITION) CObList::GetHeadPosition();}
- C3dColor* Find(C3dColor* pColor);
- C3dColor* Find(CString szName);
- //Attributes
- protected:
- public:
- };
- /////////////////////////////////////////////////////////////////////////////
- // Declare a Color list pointer to use during file load
- extern C3dColorList* pColorList;
- class C3dMaterialList;
- ////////////////////////////////////////////////////////////////////
- // C3dMaterial
- class AFX_EXT_CLASS C3dMaterial : public CObject
- {
- DECLARE_DYNAMIC(C3dMaterial);
- // DECLARE_SERIAL(C3dMaterial);
- // Construction
- public:
- C3dMaterial();
- virtual ~C3dMaterial();
- //Implimentation
- public:
- void Serialize(CArchive& ar, int iVersion);
- void SetMaterialAttrib();
- static void ResetMaterialAttrib();
- static C3dMaterial* Create();
- static C3dMaterial* Create(CString szName,
- GLfloat ar, GLfloat ag, GLfloat ab, GLfloat aa,
- GLfloat dr, GLfloat dg, GLfloat db, GLfloat da,
- GLfloat sr, GLfloat sg, GLfloat sb, GLfloat sa,
- GLfloat er, GLfloat eg, GLfloat eb, GLfloat ea,
- GLfloat power,
- GLfloat IOR,
- GLfloat reflection,
- GLfloat translucency);
- static void Delete(C3dMaterial* pMaterial);
- //Attributes
- protected:
- public:
- CString m_szName; // Name of this Material
- C3dColor m_ColorAmbient; // Ambient color component
- C3dColor m_ColorDiffuse; // Diffuse color component
- C3dColor m_ColorSpecular; // Specular color component
- C3dColor m_ColorEmmissive; // Emmissive color component
- GLfloat m_fSpecularPower; // Gloss or Specular power 0-128
- GLfloat m_fReflection; // Reflection Coefficient (0.0 to 1.0)
- GLfloat m_fTranslucency; // Refraction Coefficient (0.0 to 1.0)
- GLfloat m_fIOR; // Materials Index Of Refraction, or IOR;
- };
- /////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- // C3dMaterialList
- class AFX_EXT_CLASS C3dMaterialList : protected CObList
- {
- DECLARE_DYNAMIC(C3dMaterialList);
- //Construction
- public:
- C3dMaterialList();
- virtual ~C3dMaterialList();
- //Implimentation
- public:
- void LoadMaterials(CString szFileName);
- void SaveMaterials(CString szFileName);
- C3dMaterial* LoadComboBox(CComboBox* pCombo);
- C3dMaterial* LoadListBox(CListBox* pList);
- void Serialize(CArchive& ar, int iVersion);
- void Append(C3dMaterial* pMaterial) {CObList::AddTail(pMaterial);}
- void Remove(C3dMaterial* pMaterial);
- void Delete(C3dMaterial* pMaterial);
- void DeleteAll();
- C3dMaterial* GetNext(POSITION& rPosition)
- {return (C3dMaterial*) CObList::GetNext(rPosition);}
- C3dMaterial* GetAt(POSITION& rPosition)
- {return (C3dMaterial*) CObList::GetAt(rPosition);}
- POSITION GetHeadPosition()
- {return (POSITION) CObList::GetHeadPosition();}
- C3dMaterial* Find(C3dMaterial* pMatl);
- C3dMaterial* Find(CString szName);
- //Attributes
- protected:
- public:
- };
- /////////////////////////////////////////////////////////////////////////////
- // Declare a material list pointer to use during file load
- extern C3dMaterialList* pMatlList;
- /////////////////////////////////////////////////////////////////////////////
- // CAudioPlayer
- class AFX_EXT_CLASS CAudioPlayer : public CObject
- {
- DECLARE_DYNAMIC(CAudioPlayer);
- //Construction
- public:
- CAudioPlayer();
- virtual ~CAudioPlayer();
- static CAudioPlayer* Create(LPSTR);
- //Implementation
- public:
- DWORD Play(double);
- DWORD Stop();
- DWORD Open(LPSTR);
- DWORD Close();
- DWORD GetVolumn(LPDWORD);
- DWORD GetPitch(LPDWORD);
- DWORD SetVolumn(DWORD);
- DWORD SetPitch(DWORD);
- void SynchAudio(double);
- static void GetAviWaveformData(LPVOID, LPWAVEHDR);
- protected:
- DWORD InitAVI(LPSTR);
- DWORD Initialize();
- void DisplayError(UINT);
- //Attributes
- public:
- // Function Prototypes
- void (*GetWaveformData)(LPVOID, LPWAVEHDR);
- BOOL m_bPlayAudioClip; // Flag for this Audio clip
- int m_iWBufferScale; // Audio write buffer scale size
- long m_lAudioLength; // Length of the audio clip (in milliseconds)
- DWORD m_dwDataSize; // Size of the audio data chunck
- PAVISTREAM m_pAudioStream; // Pointer to the AVI Audio stream interface.
- HANDLE m_hAudioData[WRITE_BUFFERS]; // Handle of waveform data memory
- HPSTR m_lpAudioData[WRITE_BUFFERS]; // Pointer to waveform data memory
- HGLOBAL m_hWaveHdr[WRITE_BUFFERS]; // Handle to waveform data block header
- LPWAVEHDR m_lpWaveHdr[WRITE_BUFFERS]; // Pointer to waveform data block header
- protected:
- BOOL m_bDeviceOpen; // Audio Device Open?
- BOOL m_bSynchAudio; // Resynchronize audio stream
- clock_t m_SynchTime; // Time resynch was requested
- WAVEFORMATEX m_WFX; // Waveform-audio data structure
- };
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // CTexture
- class AFX_EXT_CLASS CTexture : public CObject
- {
- DECLARE_DYNAMIC(CTexture);
- //Construction
- public:
- CTexture();
- virtual ~CTexture();
- static BOOL CreateTexture(char* pFileName, HPALETTE hPalette, CTexture **pTexture);
- //Implementation
- public:
- // Virtual overridable functions
- virtual BOOL OpenTexture(char* pFileName, HPALETTE hPalette);
- virtual void Serialize(CArchive& ar, int iVersion);
- void SetTexture();
- void* ScaleDIB(HPALETTE hPalette, HANDLE hDibOriginal);
- GLint Scale_down_to_power_of_2(long x);
- void GetTextureOrigin3f(GLfloat* x, GLfloat* y, GLfloat* z);
- void SetTextureOrigin3f(GLfloat x, GLfloat y, GLfloat z);
- void SetTextureCoord3f(GLfloat s, GLfloat t, GLfloat r);
- protected:
- BOOL ApplyTexture();
- //Attributes
- public:
- GLubyte *m_pBits; // Pointer to scaled 32bpp Texture DIB bits
- HBITMAP m_hDibScaled; // Handle to scaled 32bpp Texture DIB
- CString m_szFileName; // File name of this DIB
- BOOL m_bCreateList; // Flag for identifying
- GLuint m_iDisplayList; // Display list name
- BOOL m_bApplyImage; // Flag for initializing our display list
- GLint m_iEnvmode;
- GLenum m_enumHint;
- GLint m_iMinfilter;
- GLint m_iMagfilter;
- GLint m_iWrap_S;
- GLint m_iWrap_T;
- BOOL m_bS_Gen;
- GLint m_iS_Mode;
- GLdouble m_dS_Coeffs[4];
- BOOL m_bT_Gen;
- GLint m_iT_Mode;
- GLdouble m_dT_Coeffs[4];
- BOOL m_bTransparent;
- BYTE m_bytTransparent_r;
- BYTE m_bytTransparent_g;
- BYTE m_bytTransparent_b;
- float m_fTransparentVariance;
- protected:
- LONG m_lScaledSizeX; // Size of our scaled image X dimension
- LONG m_lScaledSizeY; // Size of our scaled image Y dimension
- GLfloat m_fOrigin[3]; // Our texture origin
- };
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // CTextureDibImage
- class AFX_EXT_CLASS CTextureDibImage : public CTexture
- {
- DECLARE_DYNAMIC(CTextureDibImage);
- //Construction
- public:
- CTextureDibImage();
- virtual ~CTextureDibImage();
- //Implimentation
- public:
- // Virtual overrides
- BOOL OpenTexture(char* pFileName, HPALETTE hPalette);
- void Serialize(CArchive& ar, int iVersion);
- void* OpenDIBFile(LPSTR pszFileName, HPALETTE hPalette);
- void* ReadDIBitmap(BITMAPINFO **info);
- int SaveDIBFile(LPSTR pszFileName, BITMAPINFO *pInfo, void *pBits);
- protected:
- //Attributes
- public:
- protected:
- };
- /////////////////////////////////////////////////////////////////////////////
- class CAnimAVI;
- /////////////////////////////////////////////////////////////////////////////
- // CTextureAviMovie
- class AFX_EXT_CLASS CTextureAviMovie : public CTexture
- {
- DECLARE_DYNAMIC(CTextureAviMovie);
- //Construction
- public:
- CTextureAviMovie();
- virtual ~CTextureAviMovie();
- //Implimentation
- public:
- // Virtual overrides
- BOOL OpenTexture(char* pFileName, HPALETTE hPalette);
- void Serialize(CArchive& ar, int iVersion);
- // Function Prototypes:
- BOOL GetFrameRGBA(long lTime, HPALETTE hPalette);
- void Play(double dTime);
- void Stop();
- DWORD PlayAudio(double dTime);
- void StopAudio();
- protected:
- DWORD InitAVI(LPSTR szFile);
- //Attributes
- public:
- BOOL m_bEnableAudio; // Enable audio flag
- BOOL m_bPlayContinuous; // Play AVI file continuously?
- BOOL m_bStartAudio; // First Video frame flag
- long m_lVideoLength; // Length of the AVI video clip (in milliseconds)
- CAnimAVI* m_pAnimAVI; // Pointer to our animation object
- CAudioPlayer* m_pAudioPlayer; // Pointer to our audio player
- protected:
- long m_lLastTimeIndex; // Time index of the stream last played;
- PAVIFILE m_pFile; // File interface pointer
- BITMAPINFO* m_pBMI; // Pointer to our current AVI frame DIB
- PGETFRAME m_pGetFrame; // Pointer to an AVI GetFrame object
- PAVISTREAM m_pVideoStream; // Pointer to the AVI Video stream interface.
- HPALETTE m_hPalette; // Handle to applications palette
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dCamera;
- /////////////////////////////////////////////////////////////////////////////
- // C3dGrid
- class AFX_EXT_CLASS C3dGrid : public CObject
- {
- DECLARE_DYNAMIC(C3dGrid);
- //Construction
- public:
- C3dGrid();
- virtual ~C3dGrid();
- //Implimentation
- public:
- static C3dGrid* Create(float fSpacing);
- void SetSize(float fSpacing);
- void PointToGrid(float *x, float *y, float *z);
- void Display(C3dWorld* pWorld, C3dCamera* pCamera);
- void GridXY(C3dCamera* pCamera);
- void Grid3D(C3dCamera* pCamera);
- //Attributes
- protected:
- public:
- GLfloat m_fGridWidth;
- GLfloat m_fGridDepth;
- GLfloat m_fSpacing;
- GLfloat m_fLineWidth;
- GLfloat m_fGridColor[4];
- };
- /////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
- // C3dAxis
- class C3dAxis : public CObject
- {
- DECLARE_DYNAMIC(C3dAxis);
- //Construction
- public:
- C3dAxis();
- virtual ~C3dAxis();
- //Implimentation
- public:
- // virtual function overrides
- virtual void Serialize(CArchive& ar);
- //Function Prototypes:
- static C3dAxis* Create();
- void Display(GLdouble dAxisLength,
- GLdouble dAxisRadius,
- GLdouble dArrowLength,
- GLdouble dArrowRadius,
- GLint iSlices,
- GLint iStacks,
- GLfloat fColorX[4],
- GLfloat fColorY[4],
- GLfloat fColorZ[4],
- BOOL bSolid);
- //Attributes
- protected:
- public:
- GLfloat m_fXAxisColor[4];
- GLfloat m_fYAxisColor[4];
- GLfloat m_fZAxisColor[4];
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dRect;
- ////////////////////////////////////////////////////////////////////
- // C3dBoundingBox
- class C3dBoundingBox : public CObject
- {
- DECLARE_DYNAMIC(C3dBoundingBox);
- //Construction
- public:
- C3dBoundingBox();
- virtual ~C3dBoundingBox();
- //Implimentation
- public:
- void TransformBounds(Matx4x4 XformMatrix);
- void SetMinMax(VECTORF A);
- void SetMinMax(VECTORF A, VECTORF B);
- void SetMinMax(C3dBoundingBox* pBox);
- void Display(float fOffset,
- float fLineSize,
- int iSlices,
- int iStacks,
- float fColor[3],
- BOOL bSolid);
- //Attributes
- protected:
- public:
- GLfloat m_fMax[3];
- GLfloat m_fMin[3];
- GLfloat m_fHighlightColor[4];
- GLfloat m_fHighlightOffset;
- GLfloat m_fHighlightLineWidth;
- };
- /////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
- // C3dPoint
- class AFX_EXT_CLASS C3dPoint : public CObject
- {
- DECLARE_DYNAMIC(C3dPoint);
- //Construction
- public:
- C3dPoint();
- virtual ~C3dPoint();
- //Implimentation
- public:
- static void Display(float x,
- float y,
- float z,
- float fRadius,
- float fColor[4],
- BOOL bSolid);
- virtual void Serialize(CArchive& ar);
- void Display(float fRadius, float fColor[4], BOOL bSolid);
- void GetOrigin(GLfloat *x, GLfloat *y, GLfloat *z);
- void SetOrigin(GLfloat x, GLfloat y, GLfloat z);
- BOOL HitTest(float x, float y, float z, float test);
- BOOL IsPoint(C3dCamera*, C3dObject*, float, float, float);
- BOOL IsPoint(C3dCamera*, Matx4x4, float, float, float);
- protected:
- //Attributes
- protected:
- public:
- GLfloat m_fOrigin[4]; // Points world origin
- C3dColor m_Color; // Points color
- };
- /////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- // C3dPointList
- class AFX_EXT_CLASS C3dPointList : public CObList
- {
- DECLARE_DYNAMIC(C3dPointList);
- //Construction
- public:
- C3dPointList();
- virtual ~C3dPointList();
- //Implimentation
- public:
- void Append(C3dPoint* pPoint) {CObList::AddTail(pPoint);}
- void Remove(C3dPoint* pPoint);
- void Delete(C3dPoint* pPoint);
- void DeleteAll();
- void Display(C3dWorld* pWorld, C3dCamera* pCamera, BOOL bConnectPoints);
- C3dPoint* GetNext(POSITION& rPosition)
- {return (C3dPoint*) CObList::GetNext(rPosition);}
- C3dPoint* GetAt(POSITION& rPosition)
- {return (C3dPoint*) CObList::GetAt(rPosition);}
- POSITION GetHeadPosition()
- {return (POSITION) CObList::GetHeadPosition();}
- C3dPoint* Find(float, float, float, float);
- //Attributes
- protected:
- public:
- };
- /////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- // C3dPointArray
- class AFX_EXT_CLASS C3dPointArray : public CObject
- {
- DECLARE_DYNAMIC(C3dPointArray);
- //Construction
- public:
- C3dPointArray();
- virtual ~C3dPointArray();
- //Implimentation
- public:
- BOOL Create(int iNumPoints);
- BOOL SetArraySize(int iNumPoints);
- BOOL Add(float, float, float);
- BOOL CopyFromList(C3dPointList* pPointList);
- void Serialize(CArchive& ar, int iVersion, BOOL bReadColorData);
- void Display(C3dWorld* pWorld, C3dCamera* pCamera, C3dObject* pObject, float fPointSize, BOOL bConnectPoints);
- C3dPoint* Find(C3dCamera*, C3dObject*,float, float, float);
- void GetMinMax(C3dBoundingBox* pBox);
- //Attributes
- protected:
- public:
- C3dPoint* m_pPoints; // Array pointer
- int m_iNumPoints; // Number of points in array
- HGLOBAL m_hPoints; // handle of the allocated memory object.
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dObject;
- ///////////////////////////////////////////////////////////////////
- // C3dObjectList
- class AFX_EXT_CLASS C3dObjectList : public CObList
- {
- //Construction
- public:
- C3dObjectList();
- virtual ~C3dObjectList();
- //Implimentation
- public:
- void Append(C3dObject* pObject);
- void Remove(C3dObject* pObject);
- void Delete(C3dObject* pObject);
- void DeleteAll();
- C3dObject* Find(C3dObject* pObject);
- C3dObject* GetNext(POSITION& rPosition)
- {return (C3dObject*) CObList::GetNext(rPosition);}
- C3dObject* GetAt(POSITION& rPosition)
- {return (C3dObject*) CObList::GetAt(rPosition);}
- POSITION GetHeadPosition()
- {return (POSITION) CObList::GetHeadPosition();}
- //Attributes
- protected:
- public:
- };
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // CAnimation
- class AFX_EXT_CLASS CAnimation : public CObject
- {
- DECLARE_DYNAMIC(CAnimation);
- //Construction
- public:
- CAnimation();
- virtual ~CAnimation();
- //Implimentation
- public:
- // Virtual overridable functions
- virtual void AddAnimationPage(LPVOID, C3dObject*, C3dCamera*, C3dWorld*);
- virtual void AnimateCamera(C3dCamera* pCamera, double dTime);
- virtual void AnimateObject(C3dObject* pObject, double dTime);
- virtual void AnimateWorld(C3dWorld* pWorld, double dTime);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Reset();
- // Static Prototypes:
- static CAnimation* IsAnimationClass(CString* szString);
- // Function Prototypes:
- void ResetCommon();
- void SaveCameraAttributes(C3dCamera* pCamera);
- void SaveObjectAttributes(C3dObject* pObject);
- void RestoreCameraAttributes(C3dCamera* pCamera);
- void RestoreObjectAttributes(C3dObject* pObject);
- //Attributes
- protected:
- public:
- CString m_szName; // Name of the Animation procedure
- double m_dTimePrevious; // Time base of the last iteration
- BOOL m_bFirst; // First iteration of animation flag
- GLfloat m_fOrigin[4]; // Objects world origin
- GLfloat m_fScale[3]; // Objects scale
- GLfloat m_fRotation[3]; // Objects rotation
- GLfloat m_fTranslate[3]; // Objects translation about origin
- C3dColor m_Color; // Color component
- // The following colors apply to light objects
- C3dColor m_ColorAmb; // Ambient Color component
- C3dColor m_ColorDif; // Diffuse Color component
- C3dColor m_ColorSpc; // Specular Color component
- GLfloat m_fSpotAngle; // Spotlights' spot angle
- protected:
- };
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // CAnimationList
- class AFX_EXT_CLASS CAnimationList : public CObList
- {
- //Construction
- public:
- CAnimationList();
- virtual ~CAnimationList();
- //Implimentation
- public:
- void Append(CAnimation* pAnimation);
- void Remove(CAnimation* pAnimation);
- void Delete(CAnimation* pAnimation);
- void DeleteAll();
- void Serialize(CArchive& ar, int iVersion);
- CAnimation* Find(CString szName);
- CAnimation* GetNext(POSITION& rPosition)
- {return (CAnimation*) CObList::GetNext(rPosition);}
- CAnimation* GetAt(POSITION& rPosition)
- {return (CAnimation*) CObList::GetAt(rPosition);}
- POSITION GetHeadPosition()
- {return (POSITION) CObList::GetHeadPosition();}
- //Attributes
- protected:
- public:
- };
- /////////////////////////////////////////////////////////////////////////////
- class CKeyFrameList;
- class CKeyFrame;
- /////////////////////////////////////////////////////////////////////////////
- // CAnimation
- class AFX_EXT_CLASS CAnimKeyFrame : public CAnimation
- {
- DECLARE_DYNAMIC(CAnimKeyFrame);
- //Construction
- public:
- CAnimKeyFrame();
- virtual ~CAnimKeyFrame();
- //Implimentation
- public:
- // Virtual function overrides
- virtual void AddAnimationPage(LPVOID, C3dObject*, C3dCamera*, C3dWorld*);
- virtual void AnimateCamera(C3dCamera* pCamera, double dTime);
- virtual void AnimateObject(C3dObject* pObject, double dTime);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Reset();
- // Function Prototypes:
- //Attributes
- protected:
- public:
- BOOL m_bCycleKeyFrames;
- CKeyFrameList* m_pKeyFrameList;
- protected:
- };
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // CKeyFrame
- class AFX_EXT_CLASS CKeyFrame : public CObject
- {
- DECLARE_DYNAMIC(CKeyFrame);
- //Construction
- public:
- CKeyFrame(double dTime, C3dObject* pObject);
- virtual ~CKeyFrame();
- //Implimentation
- public:
- virtual void AnimateCamera(C3dCamera* pCamera, double dTime);
- virtual void AnimateObject(C3dObject* pObject, double dTime);
- virtual void Serialize(CArchive& ar, int iVersion);
- void SetObjectAttributes(C3dObject* pObject);
- //Attributes
- protected:
- public:
- CKeyFrame* m_pKeyFramePrevious;
- double m_dTime; // Time reference for this keyframe
- GLfloat m_fOrigin[4]; // Objects world origin
- GLfloat m_fScale[3]; // Objects scale
- GLfloat m_fRotation[3]; // Objects rotation
- GLfloat m_fTranslate[3]; // Objects translation about origin
- C3dColor m_Color; // Color component
- // The following colors apply to light objects
- C3dColor m_ColorAmb; // Ambient Color component
- C3dColor m_ColorDif; // Diffuse Color component
- C3dColor m_ColorSpc; // Specular Color component
- GLfloat m_fSpotAngle; // Spotlights' spot angle
- protected:
- };
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // CKeyFrameList
- class AFX_EXT_CLASS CKeyFrameList : public CObList
- {
- //Construction
- public:
- CKeyFrameList();
- virtual ~CKeyFrameList();
- //Implimentation
- public:
- BOOL AddKeyFrame(CKeyFrame* pKeyFrame);
- BOOL AddKeyFrame(double time, C3dObject* pObject);
- void Append(CKeyFrame* pKeyFrame);
- void Remove(CKeyFrame* pKeyFrame);
- void Delete(CKeyFrame* pKeyFrame);
- void DeleteAll();
- double GetLength();
- void Serialize(CArchive& ar, int iVersion);
- int GetNumKeys() {return GetCount();}
- CKeyFrame* Find(double dTime);
- CKeyFrame* FindClosest(double dTime, int *iKeyFrameTime);
- CKeyFrame* FindSmaller(double dTime);
- CKeyFrame* FindLarger(double dTime);
- CKeyFrame* GetNext(POSITION& rPosition)
- {return (CKeyFrame*) CObList::GetNext(rPosition);}
- CKeyFrame* GetAt(POSITION& rPosition)
- {return (CKeyFrame*) CObList::GetAt(rPosition);}
- POSITION GetHeadPosition()
- {return (POSITION) CObList::GetHeadPosition();}
- //Attributes
- protected:
- public:
- };
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // CAnimSpin
- class AFX_EXT_CLASS CAnimSpin : public CAnimation
- {
- DECLARE_DYNAMIC(CAnimSpin);
- //Construction
- public:
- CAnimSpin();
- virtual ~CAnimSpin();
- //Implimentation
- public:
- // Virtual function overrides
- virtual void AddAnimationPage(LPVOID, C3dObject*, C3dCamera*, C3dWorld*);
- virtual void AnimateCamera(C3dCamera* pCamera, double dTime);
- virtual void AnimateObject(C3dObject* pObject, double dTime);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Reset();
- // Function Prototypes:
- //Attributes
- protected:
- public:
- GLfloat m_fSpinX;
- GLfloat m_fSpinY;
- GLfloat m_fSpinZ;
- double m_dSpeedX;
- double m_dSpeedY;
- double m_dSpeedZ;
- };
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // CAnimWobble
- class AFX_EXT_CLASS CAnimWobble : public CAnimation
- {
- DECLARE_DYNAMIC(CAnimWobble);
- //Construction
- public:
- CAnimWobble();
- virtual ~CAnimWobble();
- //Implimentation
- public:
- // Virtual function overrides
- virtual void AddAnimationPage(LPVOID, C3dObject*, C3dCamera*, C3dWorld*);
- virtual void AnimateCamera(C3dCamera* pCamera, double dTime);
- virtual void AnimateObject(C3dObject* pObject, double dTime);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Reset();
- // Function Prototypes:
- //Attributes
- protected:
- BOOL m_bIncX; // Increment or decrement flags
- BOOL m_bIncY;
- BOOL m_bIncZ;
- public:
- GLfloat m_fWobbleX;
- GLfloat m_fWobbleY;
- GLfloat m_fWobbleZ;
- GLfloat m_fLimitX;
- GLfloat m_fLimitY;
- GLfloat m_fLimitZ;
- double m_dSpeedX;
- double m_dSpeedY;
- double m_dSpeedZ;
- };
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // CAnimAVI
- class AFX_EXT_CLASS CAnimAVI : public CAnimation
- {
- DECLARE_DYNAMIC(CAnimAVI);
- //Construction
- public:
- CAnimAVI();
- virtual ~CAnimAVI();
- //Implimentation
- public:
- // Virtual function overrides
- virtual void AddAnimationPage(LPVOID, C3dObject*, C3dCamera*, C3dWorld*);
- virtual void AnimateObject(C3dObject* pObject, double dTime);
- virtual void AnimateWorld(C3dWorld* pWorld, double dTime);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Reset();
- // Function Prototypes:
- //Attributes
- protected:
- public:
- CTextureAviMovie* m_pAviMovie; // Pointer to our AVI Movie
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dObjectPropSheet;
- /////////////////////////////////////////////////////////////////////////////
- // C3dObject
- class AFX_EXT_CLASS C3dObject : public CObject
- {
- DECLARE_DYNAMIC(C3dObject);
- //Construction
- public:
- C3dObject();
- virtual ~C3dObject();
- //Implementation
- public:
- // Virtual overridable functions
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual void Animate(double time);
- virtual void GetShapeBounds(C3dBoundingBox* pBox);
- virtual void DisplayObject(C3dWorld*, C3dCamera*);
- virtual int LoadBitMapImage(CImageList*);
- virtual C3dObject* IsName(GLuint i, BOOL bSelParent = TRUE);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Build(C3dWorld*, C3dCamera*);
- virtual void DisplayPoints(C3dWorld* pWorld, C3dCamera* pCamera);
- virtual C3dPoint* FindPoint(C3dCamera* pCamera, float, float, float);
- virtual void SetObjPointOrigin(C3dPoint*, float, float, float);
- virtual void GetObjPointOrigin(C3dPoint*, float*, float*, float*);
- // Function Prototypes:
- static C3dObject* IsLightClass(CString* szString);
- static C3dObject* IsShapeClass(CString* szString);
- static C3dObject* LoadObject(CString szFileName, int* iType);
- void SaveObject(CString szFileName);
- void LoadChildObjects(CArchive& ar, int iVersion);
- void SaveChildObjects(CArchive& ar, int iVersion);
- void Rebuild();
- void AddAnimationPages(C3dWorld* pWorld, LPVOID);
- BOOL AddTexture(LPSTR);
- void DeleteTexture();
- void ResetAnimation();
- void AddChildObject(C3dObject* pObject);
- void SetAttributes(C3dWorld* pWorld, void *pData);
- void TransformObject(C3dWorld* pWorld);
- int EditAnimation(CWnd* pParentWnd, C3dWorld* pWorld);
- int EditAttributes(CWnd* pParentWnd, C3dWorld* pWorld);
- void RemoveDibImage();
- void DisplayChildObjects(C3dWorld* pWorld, C3dCamera* pCamera);
- void DisplayAxis(C3dWorld* pWorld);
- void DisplaySelected(C3dWorld* pWorld, BOOL bWorldCoordinates);
- void GetTransformMatrix(Matx4x4 XformMatrix, BOOL bGetParent=TRUE);
- void GetInvTransformMatrix(Matx4x4 XformMatrix, BOOL bGetParent=TRUE);
- void GetRotationMatrix(Matx4x4 XformMatrix, BOOL bGetParent=TRUE);
- void GetInvRotationMatrix(Matx4x4 XformMatrix, BOOL bGetParent=TRUE);
- void GetBounds(C3dBoundingBox* pBox, BOOL bWorldCoordinates);
- void GetOrigin(GLfloat *x, GLfloat *y, GLfloat *z);
- void GetOrigin(GLfloat *x, GLfloat *y, GLfloat *z, GLfloat *w);
- void GetRotation(GLfloat *x, GLfloat *y, GLfloat *z);
- void GetScale(GLfloat *x, GLfloat *y, GLfloat *z);
- void GetTranslation(GLfloat *x, GLfloat *y, GLfloat *z);
- void SetTexture(CTexture* pTexture);
- void SetMaterial(C3dMaterial* pMaterial);
- void SetOrigin(GLfloat x, GLfloat y, GLfloat z);
- void SetOrigin(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
- void SetRotation(GLfloat x, GLfloat y, GLfloat z);
- void SetScale(GLfloat x, GLfloat y, GLfloat z);
- void SetTranslation(GLfloat x, GLfloat y, GLfloat z);
- void SetColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
- void SetColor4fv(C3dColor* pColor);
- CAnimKeyFrame* GetKeyFrameList(int *iNumKeys);
- //Attributes
- protected:
- public:
- int m_iType; // ID of object 0=Shape, 1=Light, 2=??, etc
- C3dObject* m_pParent; // pointer to parent object
- GLfloat m_fOrigin[4]; // Objects world origin
- GLfloat m_fScale[3]; // Objects scale
- GLfloat m_fRotation[3]; // Objects rotation
- GLfloat m_fTranslate[3]; // Objects translation about origin
- CString m_szName; // Name of this Object
- GLuint m_iName; // Unsigned integer name of this object
- C3dColor m_Color; // Color component
- C3dMaterial* m_pMaterial; // Our objects' material
- CTexture* m_pTexture; // Our objects' texture
- GLUquadricObj* m_pQuad; // Pointer to a quadric object
- CAnimationList m_AnimList; // List of this objects' animation procedures
- C3dPointArray* m_pPointArray; // Pointer to an array of points
- C3dObjectList m_ObjectList; // List of Child Objects which
- // make up this object..
- BOOL m_bInside;
- BOOL m_bSolidColor;
- int m_iBMImage;
- BOOL m_bBuildLists;
- unsigned int m_iDisplayLists;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageCone;
- /////////////////////////////////////////////////////////////////////////////
- // C3dObjectCone
- class AFX_EXT_CLASS C3dObjectCone : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectCone);
- //Construction
- public:
- C3dObjectCone();
- virtual ~C3dObjectCone();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Build(C3dWorld*, C3dCamera*);
- void InitVertices();
- void CalNormals(C3dPoint* pNormals, BOOL bSmooth=TRUE);
- //Implimentation
- protected:
- //Attributes
- protected:
- public:
- BOOL m_bSolid;
- BOOL m_bSmooth;
- float m_fHeight;
- float m_fBaseRadius;
- int m_iSegments;
- C3dPageCone* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageCSG;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectCSG
- class AFX_EXT_CLASS C3dObjectCSG : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectCSG);
- //Construction
- public:
- C3dObjectCSG();
- virtual ~C3dObjectCSG();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual void GetShapeBounds(C3dBoundingBox* pBox);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void DisplayObject(C3dWorld* pWorld, C3dCamera* pCamera);
- virtual void Build(C3dWorld*, C3dCamera*);
- //Attributes
- protected:
- void Object_OR(C3dWorld*, C3dCamera*);
- void Object_SUB(C3dWorld*, C3dCamera*, C3dObject*, C3dObject*);
- void Object_AND(C3dWorld*, C3dCamera*, C3dObject*, C3dObject*);
- void Inside(C3dWorld*, C3dCamera*, C3dObject* a, C3dObject* b, GLenum face, GLenum test);
- void Fixup(C3dWorld*, C3dCamera*, C3dObject*);
- public:
- int m_iCSGType;
- C3dPageCSG* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageCube;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectCube
- class AFX_EXT_CLASS C3dObjectCube : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectCube);
- //Construction
- public:
- C3dObjectCube();
- virtual ~C3dObjectCube();
- //Implementation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Build(C3dWorld*, C3dCamera*);
- void InitVertices();
- //Attributes
- protected:
- public:
- float m_fHeight;
- float m_fWidth;
- float m_fDepth;
- C3dPageCube* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageCylinder;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectCylinder
- class AFX_EXT_CLASS C3dObjectCylinder : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectCylinder);
- //Construction
- public:
- C3dObjectCylinder();
- virtual ~C3dObjectCylinder();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Build(C3dWorld*, C3dCamera*);
- void InitVertices();
- void CalNormals(C3dPoint* pNormals, BOOL bSmooth=TRUE);
- //Implimentation
- protected:
- //Attributes
- protected:
- public:
- BOOL m_bSolid;
- BOOL m_bSmooth;
- float m_fHeight;
- float m_fTopRadius;
- float m_fBaseRadius;
- int m_iSegments;
- C3dPageCylinder* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageDisk;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectDisk
- class AFX_EXT_CLASS C3dObjectDisk : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectDisk);
- //Construction
- public:
- C3dObjectDisk();
- virtual ~C3dObjectDisk();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Build(C3dWorld*, C3dCamera*);
- void InitVertices();
- //Implimentation
- protected:
- //Attributes
- protected:
- public:
- GLfloat m_fInnerRadius;
- GLfloat m_fOuterRadius;
- GLfloat m_fSweepAngle;
- int m_iSegments;
- int m_iRings;
- C3dPageDisk* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageGrid;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectGrid
- class AFX_EXT_CLASS C3dObjectGrid : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectGrid);
- //Construction
- public:
- C3dObjectGrid();
- virtual ~C3dObjectGrid();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual void GetShapeBounds(C3dBoundingBox* pBox);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Build(C3dWorld*, C3dCamera*);
- //Implimentation
- protected:
- //Attributes
- protected:
- public:
- C3dColor m_AltColor; // Color component
- GLfloat m_fWidth;
- GLfloat m_fDepth;
- int m_iDivisionsX;
- int m_iDivisionsY;
- C3dPageGrid* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageLathe;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectLathe
- class AFX_EXT_CLASS C3dObjectLathe : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectLathe);
- //Construction
- public:
- C3dObjectLathe();
- virtual ~C3dObjectLathe();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual void GetShapeBounds(C3dBoundingBox* pBox);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Build(C3dWorld*, C3dCamera*);
- protected:
- void CalNormals(LatheFace Vertice, LatheFace Normal);
- void CalSmoothNormals(LatheFace Vertice, int iFace, float fTheta, LatheFace Normal);
- //Attributes
- protected:
- public:
- int m_iSegments; // Number of segments in our lathe object
- float m_fSweepAngle; // Sweep Angle
- BOOL m_bSmooth; // Smooth Faces
- float m_fMaxAngle; // Max angle between faces to smooth
- C3dPageLathe* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageNURB;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectNURB
- class AFX_EXT_CLASS C3dObjectNURB : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectNURB);
- //Construction
- public:
- C3dObjectNURB();
- virtual ~C3dObjectNURB();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld*, LPVOID);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void DisplayObject(C3dWorld*, C3dCamera*);
- virtual void Build(C3dWorld*, C3dCamera*);
- void InitVertices();
- int InitKnots();
- //Implimentation
- protected:
- //Attributes
- protected:
- public:
- float m_fWidth;
- float m_fDepth;
- int m_iUSegments;
- int m_iVSegments;
- int m_iNumUCtrlPoints;
- int m_iNumVCtrlPoints;
- GLfloat* m_pUKnots; // Pointer to our parametric u knot values
- HGLOBAL m_hUKnots; // handle of the allocated memory object.
- GLfloat* m_pVKnots; // Pointer to our parametric V knot values
- HGLOBAL m_hVKnots; // handle of the allocated memory object.
- GLUnurbsObj* m_pNURBObj;
- C3dPageNURB* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPagePlane;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectPlane
- class AFX_EXT_CLASS C3dObjectPlane : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectPlane);
- //Construction
- public:
- C3dObjectPlane();
- virtual ~C3dObjectPlane();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Build(C3dWorld*, C3dCamera*);
- void InitVertices();
- //Implimentation
- protected:
- //Attributes
- protected:
- public:
- float m_fWidth;
- float m_fDepth;
- C3dPagePlane* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageCloud;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectCloud
- class AFX_EXT_CLASS C3dObjectCloud : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectCloud);
- //Construction
- public:
- C3dObjectCloud();
- virtual ~C3dObjectCloud();
- static void CopyParameters(C3dObjectCloud* pSrc, C3dObjectCloud* pDest);
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual int LoadBitMapImage(CImageList*);
- virtual void GetShapeBounds(C3dBoundingBox* pBox);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void DisplayPoints(C3dWorld* pWorld, C3dCamera* pCamera);
- virtual void Build(C3dWorld*, C3dCamera*);
- void InitVertices();
- void RenderCloudImageMap(C3dWorld* pWorld, C3dCamera* pCamera);
- BOOL RenderCloudTextureMap(C3dWorld* pWorld, C3dCamera* pCamera);
- void SetSkyPixelColor(int size, GLubyte *skyTex);
- float RandNum(float min, float max);
- int PowerOf2(int size);
- float AvgDiamondVals(int i, int j, int stride, int size, int subSize);
- float AvgSquareVals (int i, int j, int stride, int size);
- void FillFractualArray (int size, float heightScale);
- float* Alloc2DFractArray(int size);
- void FreeFractArray();
- //Implimentation
- protected:
- //Attributes
- protected:
- unsigned int m_iCloudTextureMap;
- unsigned int m_iCloudImageMap;
- public:
- int m_iSize;
- int m_iTile;
- int m_iTextureWrap;
- int m_iHeightSeed;
- float m_fWidth;
- float m_fDepth;
- float m_fBumpHeight;
- float m_fOpacity;
- float m_fDensity;
- float* m_pFa;
- C3dColor m_ColorHighlight;
- C3dPageCloud* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageSphere;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectSphere
- class AFX_EXT_CLASS C3dObjectSphere : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectSphere);
- //Construction
- public:
- C3dObjectSphere();
- virtual ~C3dObjectSphere();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual void GetShapeBounds(C3dBoundingBox* pBox);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Build(C3dWorld*, C3dCamera*);
- //Implimentation
- protected:
- //Attributes
- protected:
- public:
- int m_iNumMajor;
- int m_iNumMinor;
- float m_fRadius;
- C3dPageSphere* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageTerrain;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectTerrain
- class AFX_EXT_CLASS C3dObjectTerrain : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectTerrain);
- //Construction
- public:
- C3dObjectTerrain();
- virtual ~C3dObjectTerrain();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual int LoadBitMapImage(CImageList*);
- virtual void GetShapeBounds(C3dBoundingBox* pBox);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void DisplayPoints(C3dWorld* pWorld, C3dCamera* pCamera);
- virtual void Build(C3dWorld*, C3dCamera*);
- void CopyParameters(C3dObjectTerrain* pObj);
- void RenderTerrain(BOOL bCreateList, BOOL bReflect);
- void RenderTextureMaps();
- void DisplayAsTriangles(int i, int j, BOOL bReflect);
- void DisplayAsTriangleStrip(int i, int j, BOOL bReflect);
- void InitTerrainColor();
- void SetTerrainColor(int i, int j, BOOL bReflect);
- BOOL AddSubTexture(LPSTR szFileName, CTexture** pTexture);
- void DeleteSubTexture(CTexture* pTexture);
- void InitTerrain();
- void AvgNormals(int i, int j, C3dPointArray *fa, VECTORF* pNormal, BOOL bDiagonal);
- void FillFractualArray(C3dPoint *fa, int size, float heightScale, float h);
- void InitColorHeightValues();
- int PowerOf2(int size);
- float RandNum(float min, float max);
- float AvgSquareVals(int i, int j, int stride, int size, C3dPoint *fa);
- float AvgDiamondVals(int i, int j, int stride, int size, int subSize, C3dPoint *fa);
- void SetTextureCoord(int i, int j);
- void SetTextureList(VECTORF p1, VECTORF p2, VECTORF p3);
- BOOL RenderTextureImageMap(C3dWorld* pWorld, C3dCamera* pCamera);
- //Implimentation
- protected:
- //Attributes
- protected:
- float m_fSnowHeight;
- float m_fRockHeight;
- float m_fGrassHeight;
- float m_fWaterHeight;
- unsigned int m_iTerrainGridDisplayList;
- unsigned int m_iTexImageMap;
- public:
- BOOL m_bMapTexturesToSubGrid;
- BOOL m_bApplySubGridTextures;
- BOOL m_bReflect;
- BOOL m_bSmoothNormals;
- int m_iSize;
- int m_iTile;
- float m_fWidth;
- float m_fDepth;
- float m_fHeight;
- int m_iHeightSeed;
- float m_fSeaLevel;
- C3dColor m_ColorSnow;
- C3dColor m_ColorRock;
- C3dColor m_ColorGrass;
- C3dColor m_ColorWater;
- CTexture* m_pTextureSnow; // Our objects' texture
- CTexture* m_pTextureRock; // Our objects' texture
- CTexture* m_pTextureGrass; // Our objects' texture
- CTexture* m_pTextureWater; // Our objects' texture
- C3dPageTerrain* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageTorus;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectTorus
- class AFX_EXT_CLASS C3dObjectTorus : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectTorus);
- //Construction
- public:
- C3dObjectTorus();
- virtual ~C3dObjectTorus();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual void GetShapeBounds(C3dBoundingBox* pBox);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Build(C3dWorld*, C3dCamera*);
- //Implimentation
- protected:
- //Attributes
- protected:
- public:
- int m_iNumMajor;
- int m_iNumMinor;
- float m_fMajorRadius;
- float m_fMinorRadius;
- C3dPageTorus* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageTriangle;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectTriangle
- class AFX_EXT_CLASS C3dObjectTriangle : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectTriangle);
- //Construction
- public:
- C3dObjectTriangle();
- virtual ~C3dObjectTriangle();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Build(C3dWorld*, C3dCamera*);
- void InitVertices();
- //Implimentation
- protected:
- //Attributes
- protected:
- public:
- float m_fWidth;
- float m_fDepth;
- C3dPageTriangle* m_pAttribPage;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageTTF;
- ////////////////////////////////////////////////////////////////////
- // C3dObjectTTF (True Type Font)
- class AFX_EXT_CLASS C3dObjectTTF : public C3dObject
- {
- DECLARE_DYNAMIC(C3dObjectTTF);
- //Construction
- public:
- C3dObjectTTF();
- virtual ~C3dObjectTTF();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual void GetShapeBounds(C3dBoundingBox* pBox);
- virtual void DisplayObject(C3dWorld*, C3dCamera*);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Build(C3dWorld*, C3dCamera*);
- protected:
- //Attributes
- protected:
- public:
- LOGFONT m_LogFont;
- GLfloat m_fStringLength;
- GLfloat m_fCharHeight;
- GLfloat m_fCharDepth;
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dPageLight;
- ///////////////////////////////////////////////////////////////////
- // C3dObjectLight
- class AFX_EXT_CLASS C3dObjectLight : public C3dObject
- {
- DECLARE_SERIAL(C3dObjectLight);
- //Construction
- public:
- C3dObjectLight();
- virtual ~C3dObjectLight();
- //Implimentation
- public:
- virtual void AddAttributePage(C3dWorld* pWorld, LPVOID);
- virtual void GetShapeBounds(C3dBoundingBox* pBox);
- virtual int LoadBitMapImage(CImageList*);
- virtual void Serialize(CArchive& ar, int iVersion);
- virtual void Build(C3dWorld*, C3dCamera*);
- virtual void DisplayPoints(C3dWorld* pWorld, C3dCamera* pCamera);
- virtual C3dPoint* FindPoint(C3dCamera* pCamera, float, float, float);
- virtual void SetObjPointOrigin(C3dPoint*, float, float, float);
- virtual void GetObjPointOrigin(C3dPoint*, float*, float*, float*);
- void EnableLight(GLenum, C3dWorld*, C3dCamera*);
- void GetDirection(GLfloat *x, GLfloat *y, GLfloat *z);
- void GetAttenuation(GLfloat *k, GLfloat *l, GLfloat *q);
- void GetSpecularPwr(GLfloat *pwr);
- void GetSpotAngle(GLfloat *angle);
- void GetRadius(GLfloat *radius);
- void SetDirection(GLfloat x, GLfloat y, GLfloat z);
- void SetAttenuation(GLfloat k, GLfloat l, GLfloat q);
- void SetSpecularPwr(GLfloat pwr);
- void SetSpotAngle(GLfloat angle);
- void SetRadius(GLfloat radius);
- //Attributes
- protected:
- GLfloat m_fDirection[3]; // Direction of Light
- GLfloat m_fSpecHighlight; // Specular highlight exponent
- GLfloat m_fRadius; // Lights size or radius
- GLfloat m_fLength; // Lights length
- GLfloat m_fConstantAttenuation;
- GLfloat m_fLinearAttenuation;
- GLfloat m_fQuadraticAttenuation;
- C3dPageLight* m_pLightPage;
- public:
- int m_iLightType; // Light Type: 0=Ambient, 1=Point, 2=Spot
- int m_iDisplayAs; // Display As: 0=Sphere, 1=Cylinder, 2=Rect
- C3dColor m_ColorAmbient; // Ambient color component
- C3dColor m_ColorDiffuse; // Diffuse color component
- C3dColor m_ColorSpecular; // Specular color component
- GLfloat m_fSpotAngle; // Spot Angle (degrees)
- };
- /////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- // C3dLightList
- class AFX_EXT_CLASS C3dLightList : protected CObList
- {
- //Construction
- public:
- C3dLightList();
- virtual ~C3dLightList();
- //Implimentation
- public:
- void Append(C3dObject* pLight) {CObList::AddTail(pLight);}
- void Remove(C3dObject* pLight);
- void Delete(C3dObject* pLight);
- void DeleteAll();
- C3dObject* GetNext(POSITION& rPosition)
- {return (C3dObject*) CObList::GetNext(rPosition);}
- C3dObject* GetAt(POSITION& rPosition)
- {return (C3dObject*) CObList::GetAt(rPosition);}
- POSITION GetHeadPosition()
- {return (POSITION) CObList::GetHeadPosition();}
- //Attributes
- protected:
- public:
- };
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // C3dCamera
- class AFX_EXT_CLASS C3dCamera : public CObject
- {
- DECLARE_DYNAMIC(C3dCamera);
- //Construction
- public:
- C3dCamera();
- virtual ~C3dCamera();
- //Implimentation
- public:
- virtual void Serialize(CArchive& ar, int iVersion);
- int EditAttributes(CWnd* pParentWnd, C3dWorld* pWorld);
- int EditAnimation(CWnd* pParentWnd, C3dWorld* pWorld);
- void AddAnimationPages(C3dWorld* pWorld, LPVOID pSht);
- void Animate(double time);
- void ResetAnimation();
- int LoadBitMapImage(CImageList* pList);
- void GetTransformMatrix(Matx4x4 XformMatrix);
- void GetInvTransformMatrix(Matx4x4 XformMatrix);
- void GetRotationMatrix(Matx4x4 XformMatrix);
- void GetInvRotationMatrix(Matx4x4 XformMatrix);
- void GetOrigin(GLfloat *x, GLfloat *y, GLfloat *z);
- void GetRotation(GLfloat *x, GLfloat *y, GLfloat *z);
- void SetOrigin(GLfloat x, GLfloat y, GLfloat z);
- void SetRotation(GLfloat x, GLfloat y, GLfloat z);
- void ResetView(int w, int h);
- void PositionCamera();
- void GetWorldCoord(int ix, int iy, GLfloat fz, VECTORF coord);
- //Attributes
- protected:
- public:
- CString m_szName; // Name of this camera
- CAnimationList m_AnimList; // List of this cameras' animation procedures
- int m_iBMImage; // Cameras' bitmap image index
- BOOL m_bBuildLists;
- unsigned int m_iDisplayLists;
- int m_bPerspective;
- int m_iViewType;
- GLsizei m_iScreenWidth;
- GLsizei m_iScreenHeight;
- GLfloat m_fFovY; // Y-Axis field of view
- GLfloat m_fAspect; // width(x) to height(y) aspect
- GLfloat m_fLeft;
- GLfloat m_fRight;
- GLfloat m_fBottom;
- GLfloat m_fTop;
- GLfloat m_fNear;
- GLfloat m_fFar;
- GLfloat m_fOrigin[3];
- GLfloat m_fRotation[3];
- GLdouble m_dModelViewMatrix[16];
- protected:
- };
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // C3dFog
- class C3dFog : public CObject
- {
- DECLARE_DYNAMIC(C3dFog);
- //Construction
- public:
- C3dFog();
- virtual ~C3dFog();
- //Implimentation
- public:
- void SetAttributes();
- virtual void Serialize(CArchive& ar, int iVersion);
- //Attributes
- protected:
- public:
- GLenum m_enumMode;
- GLenum m_enumHint;
- GLfloat m_fDensity;
- GLfloat m_fStart;
- GLfloat m_fEnd;
- C3dColor m_Color;
- protected:
- };
- /////////////////////////////////////////////////////////////////////////////
- class C3dBackgroundPropSheet;
- /////////////////////////////////////////////////////////////////////////////
- // C3dWorld
- class AFX_EXT_CLASS C3dWorld : public CObject
- {
- // DECLARE_DYNAMIC(C3dWorld);
- DECLARE_SERIAL(C3dWorld);
- //Construction
- public:
- C3dWorld();
- virtual ~C3dWorld();
- static C3dWorld* CreateWorld();
- void DeleteWorld();
- //Implimentation
- public:
- virtual void Serialize(CArchive& ar, C3dCamera* pCamera);
- BOOL AddTexture(LPSTR);
- void DeleteTexture();
- void AddAnimationPages(C3dWorld* pWorld, LPVOID pSht);
- int EditAnimation(CWnd* pParentWnd, C3dWorld* pWorld);
- void AddObject(C3dObject* pObject, C3dObject* pParent);
- BOOL CreateDefMaterials(C3dMaterialList* pMatlList);
- BOOL CreateDefColors(C3dColorList* pColorList);
- void AddMaterial(C3dMaterial* pMaterial);
- void DeleteObject(C3dObject* pObject);
- void DisplayWorld(HDC hDC, C3dCamera* pCamera, double dTime);
- void DisplayBackgroundImage(C3dCamera* pCamera);
- C3dObject* ProcessSelection(C3dCamera* pCamera, int xPos, int yPos, BOOL bSelParent);
- int LoadBitMapImage(CImageList*);
- void Animate(C3dCamera* pCamera, double time);
- void ResetAnimation(C3dCamera* pCamera);
- void RenderScene(C3dCamera* pCamera);
- void SetupRC();
- void RebuildAllObjects();
- BOOL EditAttributes();
- void InitializeLights(C3dCamera* pCamera);
- protected:
- //Attributes
- protected:
- public:
- CString m_szName; // Name of this world
- GLenum m_NumLights; // Number of lights
- C3dLightList m_LightList; // List of Lights
- C3dObjectList m_ObjectList; // List of Objects
- C3dObject* m_pSelectedObj; // Currently selected object
- C3dColorList m_ColorList; // List of Colors
- CString m_szColorFile; // Color list file name
- C3dMaterialList m_MaterialList; // List of Materials
- CString m_szMatlFile; // Matl list file name
- C3dPointList m_PointList; // List of Points used for creation of objects
- C3dPoint* m_pSelectedPnt; // Currently selected object
- C3dGrid* m_pGrid; // Grid pointer
- C3dColor m_BackgroundColor;
- CTexture* m_pBkgndTexture;
- CAnimationList m_AnimList; // List of world animation procedures
- int m_iBMImage; // Zero based index to a CImageList
- BOOL m_bAnimate;
- BOOL m_bFly;
- BOOL m_bDisplayAxis;
- BOOL m_bDisplayGrid;
- BOOL m_bDisplayPoints;
- int m_iRenderMode;
- BOOL m_bCullFaces;
- C3dBackgroundPropSheet* m_pBackgroundPropSheet;
- // World attribute flags
- BOOL m_bFogEnable;
- C3dFog m_Fog;
- // GLdouble m_dCameraMatrix[16];
- // TO DO: REMOVE THESE CLASSES AND REPLACE WITH
- // STATIC FUNCTION CALLS...
- // (DON'T NEED TO BE MEMBERS OF C3DWORLD..)
- C3dAxis* m_pAxis; // Axis pointer
- C3dBoundingBox* m_pBoundingBox; // Bounding Box pointer
- };
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // Include all external extensions
- #include "3dObjectHSpline.h"
- #endif // _glOOP_H_