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

📄 mgcbeziercylinder.cpp

📁 《3D游戏引擎设计》的源码
💻 CPP
字号:
// 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

#include "MgcBezierCylinder.h"
#include "MgcTriMesh.h"

MgcImplementRTTI(MgcBezierCylinder,MgcBezierPatch);
MgcImplementStream(MgcBezierCylinder);

//----------------------------------------------------------------------------
MgcBezierCylinder::MgcBezierCylinder (unsigned int uiDegree,
    unsigned int uiIndexQuantity, unsigned int* auiIndex)
    :
    MgcBezierPatch(uiDegree,uiIndexQuantity,auiIndex)
{
    m_uiCylinderLevel = 0;
}
//----------------------------------------------------------------------------
MgcBezierCylinder::MgcBezierCylinder ()
{
}
//----------------------------------------------------------------------------
void MgcBezierCylinder::GenerateConnectivity (unsigned int uiLevel,
    MgcTriMesh* pkMesh, unsigned int& ruiTriangleStart)
{
    // generate connectivity array and put in proper location in trimesh

    unsigned int uiTwoPowL = (1 << uiLevel);
    unsigned int uiTwoPowLPlusOne = uiTwoPowL + 1;
    unsigned int uiTwoPowC = (1 << m_uiCylinderLevel);
    unsigned int uiTwoPowCPlusOne = uiTwoPowC + 1;
    unsigned int* puiConnect = pkMesh->Connectivity() + 3*ruiTriangleStart;
    for (unsigned int uiY = 0, uiYStart = 0; uiY < uiTwoPowC; uiY++)
    {
        unsigned int uiI0 = uiYStart;
        uiYStart += uiTwoPowLPlusOne;
        unsigned int uiI1 = uiI0 + 1;
        unsigned int uiI2 = uiYStart;
        unsigned int uiI3 = uiI2 + 1;
        for (unsigned int uiX = 0; uiX < uiTwoPowL; uiX++)
        {
            *puiConnect++ = uiI0;
            *puiConnect++ = uiI1;
            *puiConnect++ = uiI2;
            *puiConnect++ = uiI1;
            *puiConnect++ = uiI3;
            *puiConnect++ = uiI2;
            uiI0++;
            uiI1++;
            uiI2++;
            uiI3++;
        }
    }
}
//----------------------------------------------------------------------------

//---------------------------------------------------------------------------
// streaming
//---------------------------------------------------------------------------
MgcObject* MgcBezierCylinder::Factory (MgcStream& rkStream)
{
    // MgcBezierCylinder is abstract, Factory never called
    return 0;
}
//---------------------------------------------------------------------------
void MgcBezierCylinder::Load (MgcStream& rkStream, MgcStream::Link* pkLink)
{
    MgcBezierPatch::Load(rkStream,pkLink);
}
//---------------------------------------------------------------------------
void MgcBezierCylinder::Link (MgcStream& rkStream, MgcStream::Link* pkLink)
{
    MgcBezierPatch::Link(rkStream,pkLink);
}
//---------------------------------------------------------------------------
bool MgcBezierCylinder::Register (MgcStream& rkStream)
{
    return MgcBezierPatch::Register(rkStream);
}
//---------------------------------------------------------------------------
void MgcBezierCylinder::Save (MgcStream& rkStream)
{
    MgcBezierPatch::Save(rkStream);
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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