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

📄 mgcgprenderermesh.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
//
// RESTRICTED USE SOURCE CODE
// http://www.magic-software.com/License/restricted.pdf

#ifndef MGCGPRENDERERMESH_H
#define MGCGPRENDERERMESH_H

#include "MgcGPTriMesh.h"
#include "MgcVertexColorState.h"
class MgcLightState;
class MgcMaterialState;


class MgcGPRendererMesh : public MgcGPTriMesh
{
    MgcDeclareRTTI;
    MgcDeclareStream;

public:
    // construction and destruction
    MgcGPRendererMesh ();
    virtual ~MgcGPRendererMesh ();

    // model vertices and lighting
    MgcVector3& ModelVertex (unsigned int uiV) const;
    MgcVector3* GetModelVertices () const;
    bool HasModelVertices () const;
    bool HasLights () const;
    void GetLightingStatus (MgcLightState* pkLState,
        MgcMaterialState* pkMState, MgcVertexColorState* pkVState,
        MgcColor* akVertexColors);

    // visibility
    bool GetVertexVisible (unsigned int uiV) const;
    bool GetEdgeVisible (unsigned int uiE) const;
    bool GetTriangleVisible (unsigned int uiT) const;
    MgcReal& Depth (unsigned int uiV);

protected:
    friend class MgcGPRenderer;

    // renderer utilities
    void Copy (const MgcGPTriMesh& rkMesh);

    // extension of mesh from clipped data
    unsigned int AddVertex ();
    unsigned int AddEdge ();
    unsigned int AddTriangle ();

    // mesh growth
    virtual void GrowVertices (unsigned int uiNewQuantity, bool bCopy);
    virtual void GrowEdges (unsigned int uiNewQuantity, bool bCopy);
    virtual void GrowTriangles (unsigned int uiNewQuantity, bool bCopy);

    // vertices
    MgcTStorage<bool> m_abVertexVisible;
    MgcTStorage<bool> m_abVertexNeedsLighting;
    MgcTStorage<MgcReal> m_afDistance;
    MgcTStorage<unsigned int> m_auiOldEdge;
    MgcTStorage<unsigned int> m_auiNewEdge;
    MgcTStorage<MgcReal> m_afDepth;

    // edges
    MgcTStorage<bool> m_abEdgeVisible;
    MgcTStorage<unsigned int> m_auiClipVertex;
    MgcTStorage<MgcReal> m_afClipParam;

    // triangles
    MgcTStorage<bool> m_abTriangleVisible;

    // interpolation and lighting of attributes
    void Interpolate (unsigned int uiV0, unsigned int uiV1, MgcReal fParam,
        unsigned int uiClipV);
    void InterpolateVertexAttributes (unsigned int uiV);
    void MarkVertexForLighting (unsigned int uiOldVerticesUsed,
        unsigned int uiV);
    void LightVertices (unsigned int uiOldVerticesUsed);
    void ComputeVertexAttributes (unsigned int uiOldVerticesUsed);

    // lighters
    typedef void (MgcGPRendererMesh::*LightFunction)(unsigned int);
    static LightFunction ms_aaoLighter
        [MgcVertexColorState::SM_QUANTITY]
        [MgcVertexColorState::LM_QUANTITY];

    void SourceIgnoreLightingEmissive (unsigned int uiQuantity);
    void SourceIgnoreLightingDiffuse (unsigned int uiQuantity);
    void SourceEmissiveLightingEmissive (unsigned int uiQuantity);
    void SourceEmissiveLightingDiffuse (unsigned int uiQuantity);
    void SourceDiffuseLightingEmissive (unsigned int uiQuantity);
    void SourceDiffuseLightingDiffuse (unsigned int uiQuantity);

    void ComputeDiffuseSpecular (unsigned int uiQuantity, MgcColor& rkAmbient,
        bool& rbHasSpecular);

    // current lighting state and members for lighting calculations
    MgcLightState* m_pkLState;
    MgcMaterialState* m_pkMState;
    MgcVertexColorState* m_pkVState;
    MgcTClassStorage<MgcVector3> m_akModelVertex;
    MgcTClassStorage<MgcColor> m_akDiffuse;
    MgcTClassStorage<MgcColor> m_akSpecular;
    MgcVector3 m_kCameraModelLocation;
    bool m_bHasModelVertices;
    bool m_bHasLights;
};

MgcSmartPointer(MgcGPRendererMesh);
MgcRegisterStream(MgcGPRendererMesh);
#include "MgcGPRendererMesh.inl"

#endif

⌨️ 快捷键说明

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