/****************************************************************************** libx42.net - skinned vertex animation library (.NET API) Copyright (C) 2007 HermitWorks Entertainment Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA. ******************************************************************************/ #pragma once #include "Vector.h" #include "Enums.h" #include "StreamAdapter.h" namespace Libx42 { ref class TempMem; ref class OptimizationContext; ref class StreamAdapter; ref class Bone; ref class BoneCollection; ref class AnimationGroup; ref class AnimationGroupCollection; ref class Influence; ref class InfluenceCollection; ref class Tag; ref class TagCollection; ref class Group; ref class GroupCollection; ref class Lod; ref class LodCollection; ref class IndexCollection; ref class Pose; ref class VertexData; ref class AnimationBuffer; ref class AnimationData; public value struct Sphere { public: Sphere( Math::Vector3 center, float radius ) { Center = center; Radius = radius; } property Math::Vector3 Center; property float Radius; }; public value struct AxisAlignedBoundingBox { public: AxisAlignedBoundingBox( Math::Vector3 minCorner, Math::Vector3 maxCorner ) { MinCorner = minCorner; MaxCorner = maxCorner; } property Math::Vector3 MinCorner; property Math::Vector3 MaxCorner; }; [Serializable] public ref class Model : public Runtime::Serialization::ISerializable, public ICloneable { public: Model( System::String ^path ); Model( System::IO::Stream ^stream ); [ComponentModel::EditorBrowsable( ComponentModel::EditorBrowsableState::Advanced )] property const x42data_t& RawModelData { const x42data_t& get( void ) { return *m; } } property int RuntimeDataSize { int get( void ) { return mBuf_size; } } property FileVersion DataVersion { FileVersion get( void ) { return (FileVersion)RawModelData.header.ident.version; } } property bool HasNormalData { bool get( void ) { return m->vertNorm != 0; } } property bool HasTangentBasisData { bool get( void ) { return m->vertTan != 0; } } property bool HasTextureCoordinateData { bool get( void ) { return m->vertTc != 0; } } property bool HasColorData { bool get( void ) { return m->vertCl != 0; } } property int BaseFrame { int get( void ) { return (int)m->header.baseFrame; } } property int FrameCount { int get( void ) { return (int)m->header.numFrames; } } property BoneCollection^ Bones { BoneCollection^ get( void ) { return bones; } } property AnimationGroupCollection^ AnimationGroups { AnimationGroupCollection^ get( void ) { return animGroups; } } property Libx42::AnimationData^ AnimationData { Libx42::AnimationData^ get( void ) { return animData; } } property InfluenceCollection^ Influences { InfluenceCollection^ get( void ) { return infs; } } property TagCollection ^Tags { TagCollection^ get( void ) { return tags; } } property GroupCollection^ Groups { GroupCollection^ get( void ) { return groups; } } property LodCollection^ Lods { LodCollection^ get( void ) { return lods; } } property VertexData^ Vertices { VertexData^ get( void ) { return verts; } } property IndexCollection^ Indices { IndexCollection^ get( void ) { return indices; } } property Sphere BoundingSphere { Sphere get( void ) { return Sphere( Math::Vector3( m->header.boundingSphere.center[0], m->header.boundingSphere.center[1], m->header.boundingSphere.center[2] ), m->header.boundingSphere.radius ); } } property AxisAlignedBoundingBox BoundingBox { AxisAlignedBoundingBox get( void ) { return AxisAlignedBoundingBox( Math::Vector3( m->header.boundingBox.mins[0], m->header.boundingBox.mins[1], m->header.boundingBox.mins[2] ), Math::Vector3( m->header.boundingBox.maxs[0], m->header.boundingBox.maxs[1], m->header.boundingBox.maxs[2] ) ); } } Pose^ CreatePose( void ); AnimationBuffer ^CreateAnimationBuffer( AnimationFlags flags ); virtual Model^ Clone( void ) { return gcnew Model( this ); } void Save( IO::Stream ^stream ); void Save( String ^filename ); protected: Model( Runtime::Serialization::SerializationInfo^ info, Runtime::Serialization::StreamingContext context ); virtual void GetObjectData( Runtime::Serialization::SerializationInfo^ info, Runtime::Serialization::StreamingContext context ) = Runtime::Serialization::ISerializable::GetObjectData; Model( Model ^src ); internal: x42data_t *m; property TempMem^ TmpMem { TempMem^ get( void ); } property OptimizationContext^ Opts { OptimizationContext^ get( void ); } String^ GetModelString( x42NameIndex_t string ); private: int mBuf_size; BoneCollection ^bones; AnimationGroupCollection ^animGroups; Libx42::AnimationData ^animData; InfluenceCollection ^infs; TagCollection ^tags; GroupCollection ^groups; LodCollection ^lods; IndexCollection ^indices; VertexData ^verts; TempMem ^tmp; OptimizationContext ^opts; ~Model( void ); !Model( void ); void CheckDisposed( void ); Model( const x42data_t *src, size_t cb ); void InitFromStream( StreamAdapter ^adapter ); void InitFromBuffer( const x42data_t *src, size_t cb ); void FinishInit( void ); void Save( StreamAdapter ^adapter ); virtual Object^ Clone2( void ) sealed = ICloneable::Clone { return Clone(); } }; };