511 lines
15 KiB
C
511 lines
15 KiB
C
|
/****************************************************************************
|
|||
|
Copyright (c) 2011-2013,WebJet Business Division,CYOU
|
|||
|
|
|||
|
http://www.genesis-3d.com.cn
|
|||
|
|
|||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
of this software and associated documentation files (the "Software"), to deal
|
|||
|
in the Software without restriction, including without limitation the rights
|
|||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
copies of the Software, and to permit persons to whom the Software is
|
|||
|
furnished to do so, subject to the following conditions:
|
|||
|
|
|||
|
The above copyright notice and this permission notice shall be included in
|
|||
|
all copies or substantial portions of the Software.
|
|||
|
|
|||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
|
THE SOFTWARE.
|
|||
|
****************************************************************************/
|
|||
|
#ifndef __meshres_H__
|
|||
|
#define __meshres_H__
|
|||
|
#include "resource/resource.h"
|
|||
|
#include "rendersystem/base/RenderDeviceTypes.h"
|
|||
|
#include "util/array.h"
|
|||
|
#include "math/float2.h"
|
|||
|
#include "math/float3.h"
|
|||
|
#include "math/float4.h"
|
|||
|
#include "math/color.h"
|
|||
|
#include "math/bbox.h"
|
|||
|
|
|||
|
#include <deque>
|
|||
|
|
|||
|
namespace Resources
|
|||
|
{
|
|||
|
|
|||
|
struct SubMesh
|
|||
|
{
|
|||
|
SubMesh()
|
|||
|
: firstVertex(0) , numVertex(0), FirstIndex(0), numIndex(0)
|
|||
|
{
|
|||
|
}
|
|||
|
IndexT firstVertex;
|
|||
|
SizeT numVertex;
|
|||
|
IndexT FirstIndex;
|
|||
|
SizeT numIndex;
|
|||
|
Math::bbox box;
|
|||
|
};
|
|||
|
|
|||
|
struct BoneInfo
|
|||
|
{
|
|||
|
BoneInfo()
|
|||
|
{
|
|||
|
boneIndex[0] = 0; boneIndex[1] = 0; boneIndex[2] = 0; boneIndex[3] = 0;
|
|||
|
boneWeight[0] = 0.0; boneWeight[1] = 0.0; boneWeight[2] = 0.0; boneWeight[3] = 0.0;
|
|||
|
}
|
|||
|
ushort boneIndex[4];
|
|||
|
float boneWeight[4];
|
|||
|
};
|
|||
|
typedef Util::Array<float> FloatArray;
|
|||
|
typedef Util::Array<Math::float2> Vec2fArray;
|
|||
|
typedef Util::Array<Math::float3> Vec3fArray;
|
|||
|
typedef Util::Array<Math::float4> Vec4fArray;
|
|||
|
typedef Util::Array<ushort> UShortArray;
|
|||
|
typedef Util::Array<uint> UIntArray;
|
|||
|
typedef Util::Array<Math::Color32> ColorArray;
|
|||
|
typedef Util::Array<BoneInfo> BoneInfoArray;
|
|||
|
typedef Util::Array<SubMesh> SubMeshArray;
|
|||
|
typedef Util::Array< Util::Array<uchar> > AffectedBonesIndex;
|
|||
|
|
|||
|
// <20><><EFBFBD>嶥<EFBFBD><E5B6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߺ<EFBFBD>Positon<6F><6E>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>
|
|||
|
class VertexIndex
|
|||
|
{
|
|||
|
public:
|
|||
|
enum code
|
|||
|
{
|
|||
|
egPosition = 0,
|
|||
|
egColor,
|
|||
|
egTexCoord,
|
|||
|
egNormal,
|
|||
|
egTangent,
|
|||
|
egBiNormal,
|
|||
|
egBoneInfo,
|
|||
|
egSize,
|
|||
|
};
|
|||
|
};
|
|||
|
|
|||
|
template<class _TContainer, int _TIndex>
|
|||
|
class VertexData: public _TContainer
|
|||
|
{
|
|||
|
public:
|
|||
|
enum
|
|||
|
{
|
|||
|
_index = _TIndex,
|
|||
|
};
|
|||
|
typedef _TContainer Container;
|
|||
|
typedef typename Container::value_type Elem;
|
|||
|
};
|
|||
|
|
|||
|
typedef VertexData<Vec3fArray, VertexIndex::egPosition> PositionData;
|
|||
|
typedef VertexData<ColorArray, VertexIndex::egColor> ColorData;
|
|||
|
typedef VertexData<Vec2fArray, VertexIndex::egTexCoord> TexCoordData;
|
|||
|
typedef VertexData<Vec3fArray, VertexIndex::egNormal> NormalData;
|
|||
|
typedef VertexData<Vec4fArray, VertexIndex::egTangent> TangentData;
|
|||
|
typedef VertexData<Vec4fArray, VertexIndex::egBiNormal> BiNormalData;
|
|||
|
typedef VertexData<BoneInfoArray, VertexIndex::egBoneInfo> BoneInfoData;
|
|||
|
typedef VertexData<FloatArray, VertexIndex::egSize> SizeData;
|
|||
|
|
|||
|
typedef UShortArray Index16Container;
|
|||
|
typedef UIntArray Index32Container;
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>16<31><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>굥Ԫ [0,15]
|
|||
|
const SizeT MaxTexcoordUnitLimit = 15;
|
|||
|
|
|||
|
class MeshRes: public Resource
|
|||
|
{
|
|||
|
__DeclareSubClass(MeshRes,Resource);
|
|||
|
friend class MeshSpliter;
|
|||
|
friend class MeshReviseWorkspace;
|
|||
|
public:
|
|||
|
MeshRes();
|
|||
|
virtual ~MeshRes();
|
|||
|
|
|||
|
/// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>״̬
|
|||
|
RenderBase::PrimitiveTopology::Code GetTopologyType() const;
|
|||
|
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|||
|
void SetTopologyType( RenderBase::PrimitiveTopology::Code t );
|
|||
|
|
|||
|
/// <20>õ<EFBFBD><C3B5><EFBFBD>Χ<EFBFBD>д<EFBFBD>С
|
|||
|
const Math::bbox& GetBoundingBox() const;
|
|||
|
|
|||
|
/// <20><><EFBFBD>ð<EFBFBD>Χ<EFBFBD>д<EFBFBD>С
|
|||
|
void SetBoundingBox( const Math::bbox& b );
|
|||
|
|
|||
|
/// slow<6F><77> <20><>Ҫ<EFBFBD>ڸ<EFBFBD><DAB8>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>á<EFBFBD> includeSubMeshΪtrueʱ<65><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>submesh<73>İ<EFBFBD>Χ<EFBFBD>д<EFBFBD>С
|
|||
|
void RecalculateBounds( bool includeSubMesh = true );
|
|||
|
|
|||
|
/// <20><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>indexָ<78><D6B8><EFBFBD><EFBFBD>submesh<73><68>Χ<EFBFBD>еĴ<D0B5>С<EFBFBD><D0A1> slow<6F><77> <20><>Ҫ<EFBFBD>ڸ<EFBFBD><DAB8>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>submesh<73><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD><DDBA><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
void RecalculateSubMeshBounds( IndexT index );
|
|||
|
|
|||
|
//// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>á<EFBFBD><C3A1><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD>ߵȣ<DFB5><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ
|
|||
|
SizeT GetVertexCount(void) const;
|
|||
|
|
|||
|
/**
|
|||
|
* GetMaxTexUnitIndex <EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param: void
|
|||
|
* @return: IndexT -1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>Ԫ
|
|||
|
* @see:
|
|||
|
* @remark: <EFBFBD><EFBFBD>0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
IndexT GetMaxTexUnitIndex(void) const;
|
|||
|
|
|||
|
/**
|
|||
|
* GetVertexData <EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|||
|
* @param: IndexT unit <EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>꣩<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @return: const typename T::Elem* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>Ԫ<EFBFBD>ص<EFBFBD>ָ<EFBFBD>빩ֱ<EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>ָ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NULL
|
|||
|
* @see:
|
|||
|
* @remark: use like: const PositionData::Elem* elem = pMesh->GetVertexData<PositionData>(); // PositionData::Elem* is Math::float3*
|
|||
|
|
|||
|
*/
|
|||
|
template< typename T>
|
|||
|
const typename T::Elem* GetVertexData(IndexT unit = 0 ) const;
|
|||
|
|
|||
|
/**
|
|||
|
* GetVertexData <EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param: IndexT unit <EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>꣩<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFB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!!!!!!
|
|||
|
use like: PositionData::Elem* elem = pMesh->GetVertexData<PositionData>(); // PositionData::Elem* is Math::float3*
|
|||
|
*/
|
|||
|
template< typename T>
|
|||
|
typename T::Elem* GetVertexData(IndexT unit = 0 );
|
|||
|
|
|||
|
/**
|
|||
|
* SetVertexData <EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param: const typename T::Elem * v ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><EFBFBD>NULL<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param: SizeT elemCount <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>С<EFBFBD><EFBFBD>0<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param: IndexT unit <EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>꣩<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>Ҫ<E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><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Position<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>submeshȫ<EFBFBD><EFBFBD>ʧЧ<EFBFBD><EFBFBD>
|
|||
|
use like: pMesh->SetVertexData<PositionData>(PositionData::Elem* elem , count ); // PositionData::Elem* is Math::float3*
|
|||
|
|
|||
|
*/
|
|||
|
template< typename T>
|
|||
|
bool SetVertexData( const typename T::Elem* v ,SizeT elemCount, IndexT unit = 0 );
|
|||
|
|
|||
|
/// <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>16λ<36><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>16λ<36><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чʱ<D0A7><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>16λ<36><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>32λ<32><CEBB><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ч
|
|||
|
bool IsUseIndex16(void) const;
|
|||
|
|
|||
|
/// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
SizeT GetIndexCount(void) const;
|
|||
|
|
|||
|
/// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>NULL
|
|||
|
const Index16Container::value_type* GetIndex16(void) const;
|
|||
|
const Index32Container::value_type* GetIndex32(void) const;
|
|||
|
|
|||
|
/// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>NULL<4C><4C>!!!!!!!!!!!!<21><><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3>ⲿӦ<E2B2BF>ñ<EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD>Ч<EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD>Crash!!!!!!!!!!!!!!!!!
|
|||
|
Index16Container::value_type* GetIndex16(void);
|
|||
|
Index32Container::value_type* GetIndex32(void);
|
|||
|
|
|||
|
/**
|
|||
|
* SetIndex16 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>16λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param: const Index16Container::value_type * v ΪNULL<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>16λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param: SizeT elemCount
|
|||
|
* @return: bool
|
|||
|
* @see:
|
|||
|
* @remark:
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>16λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>32λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ԭ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᱻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>submesh<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧЧ
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>submesh<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧЧ
|
|||
|
*/
|
|||
|
bool SetIndex16(const Index16Container::value_type* v, SizeT elemCount);
|
|||
|
|
|||
|
/// see SetIndex16
|
|||
|
bool SetIndex32(const Index32Container::value_type* v, SizeT elemCount);
|
|||
|
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>submesh<73><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
SizeT GetSubMeshCount(void) const;
|
|||
|
|
|||
|
//// <20>õ<EFBFBD>submesh
|
|||
|
const SubMesh* GetSubMesh(IndexT index ) const;
|
|||
|
|
|||
|
/// <20>õ<EFBFBD>submesh<73><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ<DEB8>!!!!!!!!!!!!<21><><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3>ⲿӦ<E2B2BF>ñ<EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD>Ч<EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD>Crash!!!!!!!!!!!!!!!!!
|
|||
|
SubMesh* GetSubMesh(IndexT index);
|
|||
|
|
|||
|
/// <20>õ<EFBFBD>ÿ<EFBFBD><C3BF>submesh<73>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
const Util::Array<uchar>& GetAffectedBonesIndex(IndexT index) const;
|
|||
|
Util::Array<uchar>& GetAffectedBonesIndex(IndexT index);
|
|||
|
|
|||
|
/**
|
|||
|
* SetSubMesh <EFBFBD><EFBFBD><EFBFBD><EFBFBD>submesh
|
|||
|
* @param: const SubMesh * submesh Ϊ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SubMesh
|
|||
|
* @param: IndexT index <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ǰSubMesh<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>submesh<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᴴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>ﵽindexָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @return: bool <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>óɹ<EFBFBD>
|
|||
|
* @see:
|
|||
|
* @remark: <EFBFBD><EFBFBD>submeshָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ͵<EFBFBD>ǰ<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Index<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SubMesh<EFBFBD>İ<EFBFBD>Χ<EFBFBD>У<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>SubMeshʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧЧ<EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱע<EFBFBD><EFBFBD>!!!!!
|
|||
|
*/
|
|||
|
bool SetSubMesh(const SubMesh* submesh, IndexT index);
|
|||
|
|
|||
|
void SetMeshID(const Util::String meshId);
|
|||
|
|
|||
|
const Util::String GetMeshID();
|
|||
|
|
|||
|
Util::Array<uint>& GetSubmeshUsedMaterial();
|
|||
|
|
|||
|
/// <20><><EFBFBD>鵱ǰmesh<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ч<EFBFBD><D0A7> slow
|
|||
|
bool Validate(void) const;
|
|||
|
|
|||
|
// @Resource::CalculateRuntimeSize
|
|||
|
virtual SizeT CalculateRuntimeSize(void) const;
|
|||
|
|
|||
|
static GPtr<MeshRes> EmptyMeshRes;
|
|||
|
static Util::Array<uchar> EmptyBonesIndex;
|
|||
|
protected:
|
|||
|
// @Resource::SwapLoadImpl
|
|||
|
virtual bool SwapLoadImpl( const GPtr<Resource>& tempRes);
|
|||
|
// @Resource::UnLoadImpl
|
|||
|
virtual void UnLoadImpl(void);
|
|||
|
|
|||
|
const void* GetDataImpl( VertexIndex::code t, IndexT unit ) const;
|
|||
|
bool SetDataImpl( VertexIndex::code t, const void* v, SizeT elemCount, IndexT unit );
|
|||
|
|
|||
|
bool ValidateSubMesh(const SubMesh* submesh ) const;
|
|||
|
protected:
|
|||
|
|
|||
|
RenderBase::PrimitiveTopology::Code mTopologyType;
|
|||
|
Math::bbox mBox;
|
|||
|
|
|||
|
Util::String meshId;
|
|||
|
|
|||
|
PositionData mPosition;
|
|||
|
ColorData mColor;
|
|||
|
Util::Array<TexCoordData> mTexCoords;
|
|||
|
NormalData mNormal;
|
|||
|
TangentData mTangent;
|
|||
|
BiNormalData mBiNormal;
|
|||
|
BoneInfoData mBoneInfo;
|
|||
|
|
|||
|
Index16Container mIndex16;
|
|||
|
Index32Container mIndex32;
|
|||
|
|
|||
|
SubMeshArray mSubMeshs;
|
|||
|
|
|||
|
AffectedBonesIndex mAffectedBonesIndex;
|
|||
|
Util::Array<uint> mSummeshUsedMaterial;
|
|||
|
|
|||
|
friend class MeshResLoader;
|
|||
|
friend class MeshResSaver;
|
|||
|
};
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
RenderBase::PrimitiveTopology::Code
|
|||
|
MeshRes::GetTopologyType() const
|
|||
|
{
|
|||
|
return mTopologyType;
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
void
|
|||
|
MeshRes::SetTopologyType( RenderBase::PrimitiveTopology::Code t )
|
|||
|
{
|
|||
|
mTopologyType = t;
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
const Math::bbox&
|
|||
|
MeshRes::GetBoundingBox() const
|
|||
|
{
|
|||
|
return mBox;
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
void
|
|||
|
MeshRes::SetBoundingBox( const Math::bbox& b )
|
|||
|
{
|
|||
|
mBox = b;
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
void
|
|||
|
MeshRes::SetMeshID(const Util::String id)
|
|||
|
{
|
|||
|
meshId = id;
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
SizeT
|
|||
|
MeshRes::GetVertexCount(void) const
|
|||
|
{
|
|||
|
return mPosition.Size();
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
IndexT
|
|||
|
MeshRes::GetMaxTexUnitIndex(void) const
|
|||
|
{
|
|||
|
return mTexCoords.IsEmpty() ? InvalidIndex: ( mTexCoords.Size()-1 );
|
|||
|
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
template< typename T>
|
|||
|
inline
|
|||
|
const typename T::Elem*
|
|||
|
MeshRes::GetVertexData(IndexT unit ) const
|
|||
|
{
|
|||
|
return (const typename T::Elem* )( GetDataImpl( (VertexIndex::code)(T::_index), unit ) );
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
template< typename T>
|
|||
|
inline
|
|||
|
typename T::Elem*
|
|||
|
MeshRes::GetVertexData(IndexT unit )
|
|||
|
{
|
|||
|
return (typename T::Elem* )( GetDataImpl( (VertexIndex::code)(T::_index), unit ) );
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
template< typename T>
|
|||
|
inline
|
|||
|
bool
|
|||
|
MeshRes::SetVertexData( const typename T::Elem* v ,SizeT elemCount, IndexT unit )
|
|||
|
{
|
|||
|
return SetDataImpl( (VertexIndex::code)(T::_index), v, elemCount, unit );
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
/* <20>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD>postion<6F><6E>ʵ<EFBFBD><CAB5>
|
|||
|
*/
|
|||
|
template<>
|
|||
|
bool
|
|||
|
MeshRes::SetVertexData<PositionData>( const PositionData::Elem* v ,SizeT elemCount, IndexT unit );
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
bool
|
|||
|
MeshRes::IsUseIndex16(void) const
|
|||
|
{
|
|||
|
return ( !mIndex16.IsEmpty() ) ? true: ( mIndex32.IsEmpty() );
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
SizeT
|
|||
|
MeshRes::GetIndexCount(void) const
|
|||
|
{
|
|||
|
if ( !mIndex16.IsEmpty() )
|
|||
|
{
|
|||
|
return mIndex16.Size();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return mIndex32.Size();
|
|||
|
}
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
const Index16Container::value_type*
|
|||
|
MeshRes::GetIndex16(void) const
|
|||
|
{
|
|||
|
return ( mIndex16.IsEmpty() ) ? NULL: ( &mIndex16[0] );
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
const Index32Container::value_type*
|
|||
|
MeshRes::GetIndex32(void) const
|
|||
|
{
|
|||
|
return ( mIndex32.IsEmpty() ) ? NULL: ( &mIndex32[0] );
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
Index16Container::value_type*
|
|||
|
MeshRes::GetIndex16(void)
|
|||
|
{
|
|||
|
return ( mIndex16.IsEmpty() ) ? NULL: ( &mIndex16[0] );
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
Index32Container::value_type*
|
|||
|
MeshRes::GetIndex32(void)
|
|||
|
{
|
|||
|
return ( mIndex32.IsEmpty() ) ? NULL: ( &mIndex32[0] );
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
SizeT
|
|||
|
MeshRes::GetSubMeshCount(void) const
|
|||
|
{
|
|||
|
return mSubMeshs.Size();
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
const SubMesh*
|
|||
|
MeshRes::GetSubMesh(IndexT index ) const
|
|||
|
{
|
|||
|
if ( index >= 0 && index < mSubMeshs.Size() )
|
|||
|
{
|
|||
|
return &(mSubMeshs[index]);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return NULL;
|
|||
|
}
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
SubMesh*
|
|||
|
MeshRes::GetSubMesh(IndexT index)
|
|||
|
{
|
|||
|
if ( index >= 0 && index < mSubMeshs.Size() )
|
|||
|
{
|
|||
|
return &(mSubMeshs[index]);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return NULL;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
inline
|
|||
|
Util::Array<uchar>&
|
|||
|
MeshRes::GetAffectedBonesIndex(IndexT index)
|
|||
|
{
|
|||
|
if (index >=0 && index < mAffectedBonesIndex.Size())
|
|||
|
{
|
|||
|
return mAffectedBonesIndex[index];
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
n_assert("AffectedBonesIndex: Out of bound");
|
|||
|
return EmptyBonesIndex;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
const Util::Array<uchar>&
|
|||
|
MeshRes::GetAffectedBonesIndex(IndexT index) const
|
|||
|
{
|
|||
|
const Util::Array<uchar>& tmp = GetAffectedBonesIndex(index);
|
|||
|
return tmp;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//--------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
const Util::String
|
|||
|
MeshRes::GetMeshID()
|
|||
|
{
|
|||
|
return meshId;
|
|||
|
}
|
|||
|
//-------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
Util::Array<uint>& MeshRes::GetSubmeshUsedMaterial()
|
|||
|
{
|
|||
|
return mSummeshUsedMaterial;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#endif // __meshres_H__
|