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

📄 mgcmorphcontroller.h

📁 3D Game Engine Design Source Code非常棒
💻 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 MGCMORPHCONTROLLER_H
#define MGCMORPHCONTROLLER_H

#include "MgcController.h"
class MgcGeometry;
class MgcVector3;


class MgcMorphController : public MgcController
{
    MgcDeclareRTTI;
    MgcDeclareStream;

public:
    // Construction and destruction.  Any data that remains in the vertex
    // arrays or weight arrays will be deleted by MgcMorphController.  If
    // that data is to be retrieved by the application so that is is not
    // deleted by the destructor, call SetVertices and SetWeights with null
    // pointers.
    MgcMorphController (MgcGeometry* pkObject = 0);
    virtual ~MgcMorphController ();

    // Target access.  A call to SetTargetQuantity will reallocate the
    // array of vertex pointers.  The application should provide the actual
    // arrays of vertices by calls to SetVertices.  It is possible to set
    // the vertices without changing the target quantity.  In this case the
    // SetVertices call returns the pointer to the old data and the
    // application is responsible for deleting the old data.
    void SetTargetQuantity (unsigned int uiTargetQuantity);
    unsigned int GetTargetQuantity () const;
    MgcVector3* SetVertices (unsigned int uiTarget, MgcVector3* akVertex);
    MgcVector3* GetVertices (unsigned int uiTarget);

    // Key access.  A call to SetKeyQuantity will reallocate the array of
    // weight pointers.  The application should provide the actual arrays of
    // weights by calls to SetWeights.
    void SetKeyQuantity (unsigned int uiKeyQuantity);
    unsigned int GetKeyQuantity () const;
    MgcReal* SetTimes (MgcReal* afTime);
    MgcReal* GetTimes ();
    MgcReal* SetWeights (unsigned int uiKey, MgcReal* afWeight);
    MgcReal* GetWeights (unsigned int uiKey);

    // updates
    virtual bool Update (MgcReal fAppTime);
    bool& UpdateNormals ();

protected:
    void DeleteTargets ();
    void DeleteTimes ();
    void DeleteWeights ();

    // lookup on bounding keys
    void GetKeyInfo (MgcReal fCtrlTime, MgcReal& rfTime, MgcReal& rfOmTime,
        unsigned int& ruiI0, unsigned int& ruiI1);

    // Target geometry.  The number of vertices per target must match the
    // number of vertices in the managed geometry object.  The array of
    // vertices at location 0 are those of one of the targets.  Based on the
    // comments about morph keys, the array at location i >= 1 is computed
    // as the difference between the i-th target and the 0-th target.
    unsigned int m_uiTargetQuantity;
    MgcVector3** m_aakVertex;  // [target_quantity][geometry_quantity]
    bool m_bUpdateNormals;

    // Morph keys.  The morphed object is a combination of N targets by
    // weights w[0] through w[N-1] with w[i] in [0,1] and sum_i w[i] = 1.
    // Each combination is sum_{i=0}^{N-1} w[i]*X[i] where X[i] is a vertex
    // of the i-th target.  This can be rewritten as a combination
    // X[0] + sum_{i=0}^{N-2} w[i] Y[i] where w'[i] = w[i+1] and
    // Y[i] = X[i+1] - X[0].  The weights stored in this class are the
    // w'[i] (to reduce storage).  This also reduces computation time by a
    // small amount (coefficient of X[0] is 1, so no multiplication must
    // occur).
    unsigned int m_uiKeyQuantity;
    MgcReal* m_afTime;  // [key_quantity]
    MgcReal** m_aafWeight;  // [key_quantity][target_quantity-1]

    // for O(1) lookup on bounding keys
    unsigned int m_uiLastIndex;
};

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

#endif

⌨️ 快捷键说明

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