Changeset 505

Show
Ignore:
Timestamp:
02/13/08 12:41:20 (11 months ago)
Author:
phill
Message:

o Exposed morph data to .NET.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/morph-targets/libx42.net/Group.cpp

    r462 r505  
    2929#include "VertexData.h" 
    3030#include "UtilTypes.h" 
     31#include "MorphTarget.h" 
    3132 
    3233using namespace System; 
     
    4344        indices = gcnew IndexCollection( owner, this ); 
    4445        verts = gcnew VertexData( this ); 
     46        morphs = gcnew MorphData( this ); 
    4547} 
    4648 
  • branches/morph-targets/libx42.net/Group.h

    r462 r505  
    3535ref class IndexCollection; 
    3636ref class VertexData; 
     37ref class MorphData; 
    3738 
    3839public ref class Group 
     
    8586        } 
    8687 
     88        property MorphData^ Morphs 
     89        { 
     90                MorphData^ get( void ) { return morphs; } 
     91        } 
     92 
    8793internal: 
    8894        Group( Model ^owner, int index ); 
     
    95101        IndexCollection^ indices; 
    96102        VertexData^ verts; 
     103        MorphData ^morphs; 
    97104}; 
    98105 
  • branches/morph-targets/libx42.net/Model.cpp

    r504 r505  
    3939#include "VertexData.h" 
    4040#include "MorphTarget.h" 
     41#include "MorphDeltaData.h" 
    4142 
    4243using namespace System; 
     
    141142        infs = gcnew InfluenceCollection( this ); 
    142143        tags = gcnew TagCollection( this ); 
    143         morphDeltas = gcnew MorphDeltaCollection( this ); 
     144        morphs = gcnew Libx42::MorphData( this ); 
     145        morphData = gcnew MorphDeltaData( this ); 
    144146        groups = gcnew GroupCollection( this, 0, m->header.numGroups ); 
    145147        lods = gcnew LodCollection( this ); 
  • branches/morph-targets/libx42.net/Model.h

    r504 r505  
    5151ref class AnimationBuffer; 
    5252ref class AnimationData; 
    53 ref class MorphDeltaCollection; 
     53ref class MorphData; 
     54ref class MorphDeltaData; 
    5455 
    5556public value struct Sphere 
     
    178179        } 
    179180 
    180         property MorphDeltaCollection^ MorphDeltas 
    181         { 
    182                 MorphDeltaCollection^ get( void ) { return morphDeltas; } 
     181        property MorphData^ Morphs 
     182        { 
     183                MorphData^ get( void ) { return morphs; } 
     184        } 
     185 
     186        property MorphDeltaData^ MorphData 
     187        { 
     188                MorphDeltaData^ get( void ) { return morphData; } 
    183189        } 
    184190 
     
    253259        LodCollection ^lods; 
    254260        IndexCollection ^indices; 
    255         MorphDeltaCollection ^morphDeltas; 
     261        Libx42::MorphData ^morphs; 
     262        MorphDeltaData ^morphData; 
    256263 
    257264        VertexData ^verts; 
  • branches/morph-targets/libx42.net/MorphTarget.cpp

    r504 r505  
    2424#include "MorphTarget.h" 
    2525 
     26#include "MorphDeltaData.h" 
    2627#include "Model.h" 
    2728#include "Group.h" 
     
    3738        : owner( owner ), index( index ) 
    3839{ 
    39  
     40        deltaData = gcnew MorphDeltaData( this ); 
    4041} 
    4142 
     
    6465        List< MorphDelta^ > ^lst = gcnew List< MorphDelta^ >; 
    6566 
    66         for( int i = 0; i < group->Owner->MorphDeltas->Count; i++
     67        for each( MorphDelta ^delta in group->Owner->Morphs->Deltas
    6768        { 
    68                 if( group->Owner->MorphDeltas[i]->TargetGroup == group ) 
    69                         lst->Add( group->Owner->MorphDeltas[i] ); 
     69                if( delta->TargetGroup == group ) 
     70                        lst->Add( delta ); 
    7071        } 
    7172 
     
    7374} 
    7475 
    75 MorphDeltaCollection::MorphDeltaCollection( MorphTarget ^target
    76         : ModelItemCollection( target->Owner ) 
     76MorphDeltaCollection::MorphDeltaCollection( Model ^owner, IEnumerable< MorphDelta^ > ^deltas
     77        : ModelItemCollection( owner ) 
    7778{ 
     79        items = (gcnew List< MorphDelta^ >( deltas ))->ToArray(); 
     80} 
     81 
     82MorphTarget::MorphTarget( Model ^owner, IEnumerable< MorphDelta^ > ^deltas ) 
     83        : owner( owner ) 
     84{ 
     85        morphDeltas = gcnew MorphDeltaCollection( owner, deltas ); 
     86        for each( MorphDelta ^delta in morphDeltas ) 
     87                delta->target = this; 
     88} 
     89 
     90String^ MorphTarget::Name::get( void ) 
     91{ 
     92        return owner->GetModelString( morphDeltas[0]->RawTarget.targetName ); 
     93} 
     94 
     95MorphTargetCollection::MorphTargetCollection( Model ^owner, IEnumerable< MorphTarget^ > ^targets ) 
     96        : ModelItemCollection( owner ) 
     97{ 
     98        items = (gcnew List< MorphTarget^ >( targets ))->ToArray(); 
     99} 
     100 
     101MorphData::MorphData( Model ^owner ) 
     102        : owner( owner ) 
     103{ 
     104        deltas = gcnew MorphDeltaCollection( owner ); 
     105 
     106        List< List< MorphDelta^ >^ > ^targLists = gcnew List< List< MorphDelta^ >^ >; 
     107        for each( MorphDelta ^delta in deltas ) 
     108        { 
     109                List< MorphDelta^ > ^target = nullptr; 
     110 
     111                for each( List< MorphDelta^ > ^targ in targLists ) 
     112                { 
     113                        if( targ[0]->RawTarget.targetName == delta->RawTarget.targetName ) 
     114                        { 
     115                                target = targ; 
     116                                break; 
     117                        } 
     118                } 
     119 
     120                if( !target ) 
     121                { 
     122                        target = gcnew List< MorphDelta^ >; 
     123                        targLists->Add( target ); 
     124                } 
     125 
     126                target->Add( delta ); 
     127        } 
     128 
     129        List< MorphTarget^ > ^targets = gcnew List< MorphTarget^ >; 
     130        for each( List< MorphDelta^ > ^targ in targLists ) 
     131                targets->Add( gcnew MorphTarget( owner, targ ) ); 
     132 
     133        MorphData::targets = gcnew MorphTargetCollection( owner, targets ); 
     134} 
     135 
     136MorphData::MorphData( Group ^group ) 
     137        : owner( group->Owner ) 
     138{ 
     139        deltas = gcnew MorphDeltaCollection( group ); 
     140 
     141        List< MorphTarget^ > ^targets = gcnew List< MorphTarget^ >; 
     142        for each( MorphDelta ^delta  in deltas ) 
     143        { 
     144                if( !targets->Contains( delta->MorphTarget ) ) 
     145                        targets->Add( delta->MorphTarget ); 
     146        } 
     147 
     148        MorphData::targets = gcnew MorphTargetCollection( owner, targets ); 
    78149} 
    79150 
  • branches/morph-targets/libx42.net/MorphTarget.h

    r504 r505  
    3131ref class Model; 
    3232ref class Group; 
     33ref class MorphDeltaData; 
    3334 
    3435ref class MorphTarget; 
     36ref class MorphData; 
    3537 
    3638public ref class MorphDelta 
     
    4749        property Libx42::MorphTarget^ MorphTarget { Libx42::MorphTarget^ get( void ) { return target; } } 
    4850 
     51        property MorphDeltaData^ DeltaData { MorphDeltaData^ get( void ) { return deltaData; } } 
     52 
    4953internal: 
    5054        Libx42::MorphTarget ^target; 
     
    5458        Model ^owner; 
    5559        int index; 
     60 
     61        MorphDeltaData ^deltaData; 
    5662}; 
    5763 
     
    6268        MorphDeltaCollection( Model ^owner ); 
    6369        MorphDeltaCollection( Group ^group ); 
    64         MorphDeltaCollection( MorphTarget ^target ); 
     70        MorphDeltaCollection( Model ^owner, Collections::Generic::IEnumerable< MorphDelta^ > ^deltas ); 
    6571}; 
    6672 
     
    7177 
    7278        property MorphDeltaCollection^ MorphDeltas { MorphDeltaCollection^ get( void ) { return morphDeltas; } } 
     79        property String^ Name { String^ get( void ); } 
     80 
    7381internal: 
    74          
     82        MorphTarget( Model ^owner, Collections::Generic::IEnumerable< MorphDelta^ > ^deltas );   
     83 
    7584private: 
    7685        Model ^owner; 
     
    7988}; 
    8089 
     90public ref class MorphTargetCollection 
     91        : public ModelItemCollection< MorphTarget^ > 
     92{ 
     93public: 
     94 
     95internal: 
     96        MorphTargetCollection( Model ^owner, Collections::Generic::IEnumerable< MorphTarget^ > ^targets ); 
    8197 
    8298}; 
     99 
     100public ref class MorphData 
     101{ 
     102public: 
     103        property Model^ Owner { Model^ get( void ) { return owner; } } 
     104 
     105        property MorphTargetCollection^ Targets { MorphTargetCollection^ get( void ) { return targets; } } 
     106        property MorphDeltaCollection^ Deltas { MorphDeltaCollection^ get( void ) { return deltas; } } 
     107 
     108internal: 
     109        MorphData( Model ^owner ); 
     110        MorphData( Group ^group ); 
     111 
     112private: 
     113        Model ^owner; 
     114        MorphTargetCollection ^targets; 
     115        MorphDeltaCollection ^deltas; 
     116}; 
     117 
     118}; 
  • branches/morph-targets/libx42.net/VertexData.cpp

    r462 r505  
    129129        : owner( model ) 
    130130{ 
    131         offset = 0; 
    132         count = model->m->header.numVerts; 
    133          
    134         InitStreams( offset, count ); 
     131        InitStreams( 0, model->m->header.numVerts ); 
    135132} 
    136133 
     
    138135        : owner( group->Owner ) 
    139136{ 
    140         offset = group->RawGroup.firstVert; 
    141         count = group->RawGroup.numVerts; 
    142  
    143         InitStreams( offset, count ); 
     137        InitStreams( group->RawGroup.firstVert, group->RawGroup.numVerts ); 
    144138} 
    145139 
    146140void VertexData::InitStreams( int startIdx, int count ) 
    147141{ 
     142        VertexData::offset = startIdx; 
     143        VertexData::count = count; 
     144 
    148145        vp = gcnew DataStream< VertexPosition >( owner, owner->m->vertPos + startIdx, sizeof( x42vertAnim_t ), 0, count ); 
    149146 
  • branches/morph-targets/libx42.net/libx42.net.vcproj

    r504 r505  
    289289                        </File> 
    290290                        <File 
     291                                RelativePath=".\MorphDeltaData.cpp" 
     292                                > 
     293                        </File> 
     294                        <File 
     295                                RelativePath=".\MorphDeltaData.h" 
     296                                > 
     297                        </File> 
     298                        <File 
    291299                                RelativePath=".\MorphTarget.cpp" 
    292300                                >