⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mgcturret.h

📁 《3D游戏引擎设计》的源码
💻 H
字号:
// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement.  The various license agreements may be found at
// the Magic Software web site.  This file is subject to the license
//
// FREE SOURCE CODE
// http://www.magic-software.com/License/free.pdf

#ifndef MGCTURRET_H
#define MGCTURRET_H

#include "MgcMatrix3.h"

class MgcTurret
{
public:
    MgcTurret ();

    MgcReal& TranslateSpeed (int i);
    MgcReal& RotateSpeed (int i);

    void BindKeysToTranslateRight (int iKeyM, int iKeyP, MgcReal fSpeed);
    void BindKeysToTranslateUp (int iKeyM, int iKeyP, MgcReal fSpeed);
    void BindKeysToTranslateDirection (int iKeyM, int iKeyP, MgcReal fSpeed);

    void BindKeysToRotateRight (int iKeyM, int iKeyP, MgcReal fSpeed);
    void BindKeysToRotateUp (int iKeyM, int iKeyP, MgcReal fSpeed);
    void BindKeysToRotateDirection (int iKeyM, int iKeyP, MgcReal fSpeed);

    bool ReadKeyboard ();

    const MgcMatrix3& GetRotate () const;
    const MgcVector3& GetTranslate () const;

protected:
    bool ReadTrn (int i);
    bool ReadRot (int i);
    void BindTrnKeys (int i, int iKeyM, int iKeyP, MgcReal fSpeed);
    void BindRotKeys (int i, int iKeyM, int iKeyP, MgcReal fSpeed);

    int m_iTrnKeyM[3];
    int m_iTrnKeyP[3];
    MgcReal m_fTrnSpeed[3];
    int m_iRotKeyM[3];
    int m_iRotKeyP[3];
    MgcReal m_fRotSpeed[3];
    bool m_bUseAxis[3];
    bool m_bUpdateAxis[3];
    MgcVector3 m_kAxis[3];

    // local transforms for turret
    MgcMatrix3 m_kRotate[3];
    MgcVector3 m_kTranslate[3];

    // composite transforms for global motion
    MgcMatrix3 m_kRotateComp;
    MgcVector3 m_kTranslateComp;
};

//---------------------------------------------------------------------------
inline MgcReal& MgcTurret::TranslateSpeed (int i)
{
    return m_fTrnSpeed[i];
}
//---------------------------------------------------------------------------
inline MgcReal& MgcTurret::RotateSpeed (int i)
{
    return m_fRotSpeed[i];
}
//---------------------------------------------------------------------------
inline const MgcMatrix3& MgcTurret::GetRotate () const
{
    return m_kRotateComp;
}
//---------------------------------------------------------------------------
inline const MgcVector3& MgcTurret::GetTranslate () const
{
    return m_kTranslateComp;
}
//---------------------------------------------------------------------------

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -