📄 chmaze.h
字号:
void EndFrameTime();
void StartFrameTime();
protected:
bool NewBackground( ChDib* pDIB );
void ClearAnchors();
bool IsAnchor( int iX, int iY ) { ChQvAnchorSensor *pAnchor; return IsAnchor( iX, iY, pAnchor );};
bool IsAnchor( int iX, int iY, pChQvAnchorSensor &pAnchor );
void StartAnchor( int iX, int iY );
void UpdateAnchor( int iX, int iY );
void EndAnchor( int iX, int iY );
void StartMouseMove( int iX, int iY );
void UpdateMouseMove( int iX, int iY );
void EndMouseMove( int iX, int iY );
void DrawMouseMoveCrosshair( CDC* pDC );
void DrawMouseMoveVector( CDC* pDC );
float CalcMouseHorzMove();
float CalcMouseVertMove();
// Parser related methods
bool AddParseInfo( ChParseInfo* pParseInfo );
bool RemoveParseInfo( ChParseInfo* pParseInfo );
bool AbortParsing();
virtual void OnSettingsChanged();
HMENU m_hCameraMenu;
void FindCameraMenu();
static HMENU FindMenu(CMenu * pMenu, string &strName);
static HMENU FindParentMenu(CMenu * pTopMenu, const HMENU hChildMenu, int &index);
bool SetupCameraMenu();
protected:
// Generated message map functions
//{{AFX_MSG(ChMazeWnd)
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnDestroy();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnPaint();
afx_msg void OnCameraNext();
afx_msg void OnCameraPrev();
afx_msg void OnOptResetSpeed();
afx_msg void OnOptimizeBetter();
afx_msg void OnOptimizeFaster();
afx_msg void OnCollisionChecking();
//}}AFX_MSG
public:
afx_msg void OnHeadlightSwitch();
afx_msg void OnResetCamera();
afx_msg void OnBrighten();
afx_msg void OnDimmer();
afx_msg void OnExamine();
afx_msg void OnFly();
afx_msg void OnWalk();
protected:
afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
afx_msg BOOL OnQueryNewPalette();
afx_msg void OnSysKeyDown( UINT, UINT, UINT );
afx_msg void OnSysKeyUp( UINT, UINT, UINT );
afx_msg LONG OnPrefChange( UINT wParam, LONG lParam );
afx_msg LONG OnProgressMsg( UINT wParam, LONG lParam );
afx_msg LONG OnMazeError( UINT wParam, LONG lParam );
afx_msg LONG OnParseError( UINT wParam, LONG lParam );
afx_msg LONG OnParseComplete( UINT wParam, LONG lParam );
afx_msg LONG OnLoadTexture( UINT wParam, LONG lParam );
afx_msg LONG OnVrmlEvent( UINT wParam, LONG lParam );
afx_msg LONG OnActivateWnd( UINT wParam, LONG lParam );
afx_msg void OnCameraMenuCommand(UINT uID);
afx_msg void OnCameraMenuUpdateCommand(CCmdUI* pCmdUI);
DECLARE_MESSAGE_MAP()
protected:
QvNode* m_pRoot;
#if defined( CH_USE_OPENGL )
CDC* m_pDC; // DC for OSB dib; OGL will draw here
HGLRC m_hRC; // OGL rendering context
#elif defined( CH_USE_3DR )
ChRenderContext m_RC;
#elif defined( CH_USE_RLAB ) || defined(CH_USE_D3D)
ChRenderContext m_RC;
#endif
float m_fAspect;
ChColor m_backGroundColor;
DWORD m_luTime;
#if defined(CH_VRML_VIEWER) || defined(CH_VRML_PLUGIN )
ChHTTPConn *m_pHttpConn;
ChGraphicStreamManager *m_pGraphicStream;
#endif
ChGraphicPageID m_currentPage;
bool m_boolLightOn;
protected:
#if !defined(CH_VRML_PLUGIN ) && !defined(CH_VRML_VIEWER)
ChHookManager* m_pHookMgr;
#endif
ChQvBounds *m_pBounds;
ChDib m_dibBkgnd;
ChMazeCameraControl* m_pCameraControl;
float m_fUserSpeedFactor;
ChKeyMap m_keyMap;
ChPtrList<ChQvAnchorSensor> m_anchors;
ChQvAnchorSensor *m_pAnchor;
bool m_boolIsHintDisplayed;
HCURSOR m_hAnchorCursor;
HCURSOR m_hCursor; // current cursor
ChGraphicPageID m_pageCount; // page id factory for this viewer; each view object has their current one
bool m_boolInMouseAnchor;
bool m_boolInMouseMove;
chint16 m_sCrosshairHalfWidth;
chint16 m_sCrosshairHalfHeight;
ChPoint m_ptMouseStart;
ChPoint m_ptMouse;
ChPoint m_ptLastMouse;
UINT m_uiMoveTimer;
UINT m_uiTickTimer;
// Dirty flag after motion for hittesting later
bool m_boolMouseMove;
//Ch3DViewerMode m_sceneViewerMode;
bool m_boolMoving;
ChVrmlSettings *m_pSettings;
//Ch3DCollisionMode m_sceneCollisionMode;
string m_strURL;
ChPtrList<ChParseInfo> m_parseThreadList;
CRITICAL_SECTION m_syncParser;
HANDLE m_hParseThreadEvent;
#if defined(CH_VRML_EVENTS) && !defined( CH_VRML_PLUGIN )
ChVrmlBrowser *m_pVrmlBrowser;
#endif
ChVrmlStateTransition *m_pNavigators[viewerModeCount];
CMenu* m_pScoutMenu;
static int m_iObjectCount;
};
class ChQvState:public QvState
{
public:
// Traversal types
enum type
{
draw,
command,
editNode,
findGlobals,
spawnRequests,
purgeTree,
getBounds,
queryNode,
buildInstance,
hitTest
};
protected:
ChMazeWnd* m_pView;
int m_numLights;
type m_type;
string m_strCmd;
string m_strSubCmd;
string m_strKey;
string m_strVRML;
int m_iData;
float m_fData;
// Default proerties
QvShapeHints * m_pHint;
QvMaterialBinding * m_pMaterialBinding;
QvMaterial * m_pMaterial;
QvPerspectiveCamera * m_pCamera;
bool m_boolKeyFound; // key is in scope
bool m_boolCmdDone; // for one shot cmds
QvNode *m_pNode; // node from vrml to use in cmd
public:
ChQvState(ChMazeWnd* pView);
// command
ChQvState(ChMazeWnd* pView, string strCmd, int iData, float fData) :
QvState(), m_pView(pView), m_numLights(0), m_type(command),
m_strCmd(strCmd), m_iData(iData), m_fData(fData), m_boolKeyFound(0), m_boolCmdDone(0),
m_pHint(0), m_pMaterialBinding(0), m_pMaterial(0), m_pCamera(0)
{};
// edit node
ChQvState(ChMazeWnd* pView, string& strCmd, string& strSubCmd,
string& strKey, string& strVRML, QvNode *pNode) :
QvState(), m_pView(pView), m_numLights(0), m_type(editNode),
m_strCmd(strCmd), m_iData(0), m_fData(0), m_boolKeyFound(0), m_boolCmdDone(0),
m_strSubCmd(strSubCmd), m_strKey(strKey), m_strVRML(strVRML), m_pNode(pNode),
m_pHint(0), m_pMaterialBinding(0), m_pMaterial(0), m_pCamera(0)
{};
// generic to derive
ChQvState(ChMazeWnd* pView, type aType) :
QvState(), m_pView(pView), m_numLights(0), m_type(aType),
m_iData(0), m_fData(0), m_boolKeyFound(0), m_boolCmdDone(0), m_pNode(0),
m_pHint(0), m_pMaterialBinding(0), m_pMaterial(0), m_pCamera(0)
{};
virtual ~ChQvState()
{
pop();
delete m_pHint;
delete m_pMaterialBinding;
delete m_pMaterial;
delete m_pCamera;
}
ChQvState& operator=( const ChQvState& v );
inline ChMazeWnd* GetView() {return m_pView;};
inline type GetType() {return m_type;};
inline string& GetCmd() {return m_strCmd;};
inline string& GetSubCmd() {return m_strSubCmd;};
inline int GetIData() {return m_iData;};
inline float GetFData() {return m_fData;};
inline QvNode *GetNode() {return m_pNode;};
inline bool IsKeyFound() {return m_boolKeyFound;};
inline bool IsCmdDone() {return m_boolCmdDone;};
inline ChQvState* SetKeyFound(bool val) {m_boolKeyFound = val;return this;};
inline ChQvState* SetCmdDone(bool val) {m_boolCmdDone = val;return this;};
inline int NextLight() { return ++m_numLights; };
virtual void popElement(StackIndex stackIndex); // jwd: needs to be virtual for derivation
int PopLight() { return m_numLights--; };
inline QvNode * GetTopNode(StackIndex index)
{
QvNode * pNode = 0;
QvElement *pElt = getTopElement(index);
if(pElt)
{
pNode = (QvNode *)(pElt->data);
}
return pNode;
};
protected:
void Kill();
void Copy(const ChQvState& state);
};
class ChQvGlobalSearchState : public ChQvState
{
protected:
float m_fAspect;
ChColor m_backGround;
ChShadingLevel m_shading;
QvNode* m_pCamera;
QvElement::NodeType m_cameraType; // perspective or ortho
bool m_boolLightOn;
Ch3DViewerMode m_viewerMode;
Ch3DCollisionMode m_collisionMode;
public:
ChQvGlobalSearchState( ChMazeWnd* pView ) :
ChQvState( pView, findGlobals ),
m_shading( defaultShading ),
m_boolLightOn(false),
m_viewerMode(none),
m_fAspect(0.),
m_collisionMode(invalidCollisionMode)
// former bg was .85 gray
{
// The default is now black // changed for 1.1
m_backGround.set( 0, 0, 0);
}
inline ChQvGlobalSearchState* SetShading( ChShadingLevel shading )
{ m_shading = shading; return this; }
inline ChQvGlobalSearchState* SetBackground( ChColor backGround )
{ m_backGround = backGround; return this; }
inline ChQvGlobalSearchState* SetAspect( float fAspect )
{ m_fAspect = fAspect; return this; }
inline ChQvGlobalSearchState* SetCamera( QvNode * pNode, QvElement::NodeType cameraType )
{ m_pCamera = pNode; m_cameraType = cameraType; return this; }
inline ChQvGlobalSearchState* SetLightOn()
{ m_boolLightOn = true; return this; }
inline ChQvGlobalSearchState* SetViewerMode(Ch3DViewerMode viewerMode)
{ m_viewerMode = viewerMode; return this; };
inline ChQvGlobalSearchState* SetCollisionMode(Ch3DCollisionMode mode)
{ m_collisionMode = mode; return this; };
inline float GetAspect() { return m_fAspect;}
inline ChColor GetBackground() { return m_backGround; }
inline ChShadingLevel GetShading() { return m_shading; }
inline bool GetLightOn() { return m_boolLightOn; }
inline Ch3DViewerMode GetViewerMode() { return m_viewerMode; };
inline Ch3DCollisionMode GetCollisionMode() { return m_collisionMode; };
};
class ChQvBounds;
class ChQvBoundsState : public ChQvState
{
protected:
//ChQvBounds *m_pBounds;
public:
ChQvBoundsState(ChMazeWnd* pView) : ChQvState(pView, getBounds)
{
};
ChQvBoundsState& operator=( const ChQvState& v );
};
class ChMazeSceneHTTPReq;
class ChQvSpawnState : public ChQvState
{
public:
protected:
bool m_boolSpawned;
string m_strDefaultURL;
public:
ChQvSpawnState(ChMazeWnd* pView, const string &strDefaultURL) :
ChQvState(pView, spawnRequests), m_boolSpawned(false), m_strDefaultURL(strDefaultURL)
{
};
inline string &GetDefaultURL() { return m_strDefaultURL; };
};
// traverse this to purge unused inlines from all child nodes
#if 1
class ChQvPurgeState : public ChQvState
{
public:
protected:
public:
ChQvPurgeState(ChMazeWnd* pView) :
ChQvState(pView, purgeTree)
{
};
};
#endif
// Instance tree builder
class ChQvInstance;
class ChQvGroupInstance;
class ChQvBuildState : public ChQvState
{
public:
protected:
ChQvGroupInstance *m_pParent;
int iShapeCount;
public:
ChQvBuildState(ChMazeWnd* pView) :
ChQvState(pView, buildInstance), m_pParent(0), iShapeCount(0)
{
};
ChQvGroupInstance *GetCurrentParent() {return m_pParent;};
ChQvBuildState *SetCurrentParent(ChQvGroupInstance *pParent) {m_pParent = pParent; return this;};
int AddShape() {iShapeCount++; return iShapeCount;};
int GetShapeCount() {return iShapeCount;};
int SetShapeCount(int count) {iShapeCount = count; return iShapeCount;};
};
// Class to read VRML from iostreams; this lets us use strings!
class istream;
class istrstream;
class ChQvInput:public QvInput
{
public:
protected:
istrstream *m_is;
public:
ChQvInput() : QvInput() {};
virtual QvBool get(char &c);
virtual QvBool eof() const;
virtual void putBack(char c);
void setFilePointer(istrstream *newSP) {m_is = newSP;};
};
// Class to read VRML from Memory mapped files;
class ChQvFileMapInput : public QvInput
{
public:
ChQvFileMapInput();
~ChQvFileMapInput();
void setFilePointer(HANDLE hFile );
virtual QvBool get(char &c);
virtual QvBool eof() const;
virtual void putBack(char c);
void Abort( )
{
m_boolCancel = true;
}
protected:
HANDLE m_hFile; // File handle to map
HANDLE m_hFileMap; // File mapping object
char* m_pMappedView; // Pointer to the mapped file
long m_lFileSize; // Size of the file
long m_lCurrIndex; // current index
bool m_boolCancel;
};
#endif // !defined( _CHMAZE_H )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -