6e8fbca745
match the genesis editor version 1.3.0.653.
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 <20>õ<EFBFBD><C3B5><EFBFBD>ǰ<EFBFBD><C7B0>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>
|
||
* @param: void
|
||
* @return: IndexT -1<><31>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>Ԫ
|
||
* @see:
|
||
* @remark: <20><>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>Ԫ<EFBFBD><D4AA>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>
|
||
*/
|
||
IndexT GetMaxTexUnitIndex(void) const;
|
||
|
||
/**
|
||
* GetVertexData <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||
* @param: IndexT unit <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>꣩<EFBFBD><EAA3A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
* @return: const typename T::Elem* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD>ص<EFBFBD>ָ<EFBFBD>빩ֱ<EBB9A9><D6B1><EFBFBD>ģ<DEB8>ָ<EFBFBD><D6B8>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2A3ACB7><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 <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
* @param: IndexT unit <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>꣩<EFBFBD><EAA3A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
* @return: typename T::Elem* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD>ص<EFBFBD>ָ<EFBFBD>룬ָ<EBA3AC><D6B8>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2A3ACB7><EFBFBD>NULL
|
||
* @see:
|
||
* @remark: !!!!!!!!!!!!<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>ָ<EFBFBD><D6B8><EFBFBD>Ķ<EFBFBD><C4B6>㲻<EFBFBD><E3B2BB>Խ<EFBFBD><D4BD>!!!!!!!!!!!!!!!!!
|
||
use like: PositionData::Elem* elem = pMesh->GetVertexData<PositionData>(); // PositionData::Elem* is Math::float3*
|
||
*/
|
||
template< typename T>
|
||
typename T::Elem* GetVertexData(IndexT unit = 0 );
|
||
|
||
/**
|
||
* SetVertexData <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
* @param: const typename T::Elem * v ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><D6B7>NULL<4C><4C><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
* @param: SizeT elemCount <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>С<EFBFBD><D0A1>0<EFBFBD><30><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
* @param: IndexT unit <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>꣩<EFBFBD><EAA3A9>ָ<EFBFBD><D6B8>Ҫ<EFBFBD>ĵĵ<C4B5>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
||
* @return: bool <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>óɹ<C3B3>
|
||
* @see:
|
||
* @remark: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ǿ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>positionΪ<6E><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>С<EFBFBD>͵<EFBFBD>ǰ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
|
||
<09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>positionʱ<6E><CAB1><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>Position<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сʱ<D0A1><CAB1><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>submeshȫ<68><C8AB>ʧЧ<CAA7><D0A7>
|
||
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 <20><><EFBFBD><EFBFBD>16λ<36><CEBB><EFBFBD><EFBFBD>
|
||
* @param: const Index16Container::value_type * v ΪNULL<4C><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>16λ<36><CEBB><EFBFBD><EFBFBD>
|
||
* @param: SizeT elemCount
|
||
* @return: bool
|
||
* @see:
|
||
* @remark:
|
||
<09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
|
||
<09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>16λ<36><CEBB><EFBFBD><EFBFBD>32λ<32><CEBB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ԭ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᱻ<EFBFBD><E1B1BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>submesh<73><68><EFBFBD><EFBFBD>ʧЧ
|
||
<09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>submesh<73><68><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 <20><><EFBFBD><EFBFBD>submesh
|
||
* @param: const SubMesh * submesh Ϊ<><CEAA>ʱ<EFBFBD><CAB1>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SubMesh
|
||
* @param: IndexT index <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ǰSubMesh<73><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>submesh<73><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чʱ<D0A7><CAB1><EFBFBD><EFBFBD><EFBFBD>ᴴ<EFBFBD><E1B4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>ﵽindexָ<78><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
* @return: bool <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>óɹ<C3B3>
|
||
* @see:
|
||
* @remark: <20><>submeshָ<68><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ͵<DDBA>ǰ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Index<65><78><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
||
<09><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>SubMesh<73>İ<EFBFBD>Χ<EFBFBD>У<EFBFBD><D0A3><EFBFBD>Ҫ<EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><D8BA><EFBFBD><EFBFBD><EFBFBD>
|
||
<09><>ɾ<EFBFBD><C9BE>SubMeshʱ<68><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>ʧЧ<CAA7><D0A7>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱע<CAB1><D7A2>!!!!!
|
||
*/
|
||
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__
|