Changeset 391 for cafu/trunk
- Timestamp:
- 09/22/11 14:13:56 (8 months ago)
- Location:
- cafu/trunk/Libs/Models
- Files:
-
- 11 modified
-
Loader.hpp (modified) (1 diff)
-
Loader_ase.hpp (modified) (1 diff)
-
Loader_assimp.hpp (modified) (1 diff)
-
Loader_cmdl.cpp (modified) (1 diff)
-
Loader_cmdl.hpp (modified) (1 diff)
-
Loader_fbx.hpp (modified) (1 diff)
-
Loader_lwo.hpp (modified) (1 diff)
-
Loader_md5.hpp (modified) (1 diff)
-
Loader_mdl.hpp (modified) (1 diff)
-
Model_cmdl.cpp (modified) (3 diffs)
-
Model_cmdl.hpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/Libs/Models/Loader.hpp
r382 r391 65 65 virtual void Load(ArrayT<CafuModelT::GuiFixtureT>& GuiFixtures, ArrayT<CafuModelT::GuiLocT>& GuiLocs)=0; 66 66 67 /// Loads the animation channels (groups of joints) of the Cafu model. 68 virtual void Load(ArrayT<CafuModelT::ChannelT>& Channels)=0; 69 67 70 /// Postprocesses the file data according to flags given to the constructor. 68 71 virtual void Postprocess(ArrayT<CafuModelT::MeshT>& Meshes); -
cafu/trunk/Libs/Models/Loader_ase.hpp
r382 r391 43 43 void Load(ArrayT<CafuModelT::SkinT>& Skins, const MaterialManagerImplT& MaterialMan) { } 44 44 void Load(ArrayT<CafuModelT::GuiFixtureT>& GuiFixtures, ArrayT<CafuModelT::GuiLocT>& GuiLocs); 45 void Load(ArrayT<CafuModelT::ChannelT>& Channels) { } 45 46 46 47 -
cafu/trunk/Libs/Models/Loader_assimp.hpp
r382 r391 47 47 void Load(ArrayT<CafuModelT::SkinT>& Skins, const MaterialManagerImplT& MaterialMan) { } 48 48 void Load(ArrayT<CafuModelT::GuiFixtureT>& GuiFixtures, ArrayT<CafuModelT::GuiLocT>& GuiLocs) { } 49 void Load(ArrayT<CafuModelT::ChannelT>& Channels) { } 49 50 50 51 -
cafu/trunk/Libs/Models/Loader_cmdl.cpp
r384 r391 528 528 529 529 530 void LoaderCafuT::Load(ArrayT<CafuModelT::ChannelT>& Channels) 531 { 532 // Read the channels. 533 lua_getglobal(m_LuaState, "Channels"); 534 { 535 Channels.Overwrite(); 536 Channels.PushBackEmptyExact(lua_objlen_ul(m_LuaState, -1)); 537 538 for (unsigned long ChannelNr=0; ChannelNr<Channels.Size(); ChannelNr++) 539 { 540 CafuModelT::ChannelT& Channel=Channels[ChannelNr]; 541 542 lua_rawgeti(m_LuaState, -1, ChannelNr+1); 543 { 544 lua_getfield(m_LuaState, -1, "name"); 545 { 546 const char* Name=lua_tostring(m_LuaState, -1); 547 Channel.Name=Name ? Name : "Channel"; 548 } 549 lua_pop(m_LuaState, 1); 550 551 lua_getfield(m_LuaState, -1, "joints"); 552 { 553 const unsigned long NumJoints=lua_objlen_ul(m_LuaState, -1); 554 555 for (unsigned int c=0; c<NumJoints; c++) 556 { 557 lua_rawgeti(m_LuaState, -1, c+1); 558 Channel.SetMember(lua_tointeger(m_LuaState, -1)); 559 lua_pop(m_LuaState, 1); 560 } 561 } 562 lua_pop(m_LuaState, 1); 563 } 564 lua_pop(m_LuaState, 1); 565 } 566 } 567 lua_pop(m_LuaState, 1); 568 } 569 570 530 571 /*static*/ int LoaderCafuT::SetVersion(lua_State* LuaState) 531 572 { -
cafu/trunk/Libs/Models/Loader_cmdl.hpp
r382 r391 46 46 void Load(ArrayT<CafuModelT::SkinT>& Skins, const MaterialManagerImplT& MaterialMan); 47 47 void Load(ArrayT<CafuModelT::GuiFixtureT>& GuiFixtures, ArrayT<CafuModelT::GuiLocT>& GuiLocs); 48 void Load(ArrayT<CafuModelT::ChannelT>& Channels); 48 49 49 50 -
cafu/trunk/Libs/Models/Loader_fbx.hpp
r382 r391 44 44 void Load(ArrayT<CafuModelT::SkinT>& Skins, const MaterialManagerImplT& MaterialMan); 45 45 void Load(ArrayT<CafuModelT::GuiFixtureT>& GuiFixtures, ArrayT<CafuModelT::GuiLocT>& GuiLocs); 46 void Load(ArrayT<CafuModelT::ChannelT>& Channels) { } 46 47 47 48 -
cafu/trunk/Libs/Models/Loader_lwo.hpp
r382 r391 40 40 void Load(ArrayT<CafuModelT::SkinT>& Skins, const MaterialManagerImplT& MaterialMan) { } 41 41 void Load(ArrayT<CafuModelT::GuiFixtureT>& GuiFixtures, ArrayT<CafuModelT::GuiLocT>& GuiLocs) { } 42 void Load(ArrayT<CafuModelT::ChannelT>& Channels) { } 42 43 43 44 -
cafu/trunk/Libs/Models/Loader_md5.hpp
r382 r391 42 42 void Load(ArrayT<CafuModelT::SkinT>& Skins, const MaterialManagerImplT& MaterialMan) { } 43 43 void Load(ArrayT<CafuModelT::GuiFixtureT>& GuiFixtures, ArrayT<CafuModelT::GuiLocT>& GuiLocs) { } 44 void Load(ArrayT<CafuModelT::ChannelT>& Channels) { } 44 45 }; 45 46 -
cafu/trunk/Libs/Models/Loader_mdl.hpp
r382 r391 48 48 void Load(ArrayT<CafuModelT::SkinT>& Skins, const MaterialManagerImplT& MaterialMan); 49 49 void Load(ArrayT<CafuModelT::GuiFixtureT>& GuiFixtures, ArrayT<CafuModelT::GuiLocT>& GuiLocs) { } 50 void Load(ArrayT<CafuModelT::ChannelT>& Channels) { } 50 51 51 52 -
cafu/trunk/Libs/Models/Model_cmdl.cpp
r390 r391 209 209 210 210 211 bool CafuModelT::ChannelT::IsMember(unsigned int JointNr) const 212 { 213 const unsigned int BlockNr=JointNr >> 5; 214 const unsigned int BitNr =JointNr & 31; 215 const unsigned int BitMask=1 << BitNr; 216 217 if (BlockNr >= m_BitBlocks.Size()) return false; 218 219 return (m_BitBlocks[BlockNr] & BitMask) != 0; 220 } 221 222 223 void CafuModelT::ChannelT::SetMember(unsigned int JointNr, bool Member) 224 { 225 const unsigned int BlockNr=JointNr >> 5; 226 const unsigned int BitNr =JointNr & 31; 227 const unsigned int BitMask=1 << BitNr; 228 229 // Grow as needed. 230 while (BlockNr >= m_BitBlocks.Size()) 231 m_BitBlocks.PushBack(0); 232 233 if (Member) m_BitBlocks[BlockNr] |= BitMask; 234 else m_BitBlocks[BlockNr] &= ~BitMask; 235 } 236 237 211 238 CafuModelT::CafuModelT(ModelLoaderT& Loader) 212 239 : m_FileName(Loader.GetFileName()), … … 234 261 Loader.Load(m_Skins, m_MaterialMan); 235 262 Loader.Load(m_GuiFixtures, m_GuiLocs); 263 Loader.Load(m_Channels); 236 264 Loader.Postprocess(m_Meshes); 237 265 … … 851 879 << "AxisY={ " << serialize(GuiLoc.AxisY) << " }; " 852 880 << "},\n"; 881 } 882 883 OutStream << "}\n"; 884 885 886 // *** Write the channels. *** 887 OutStream << "\nChannels=\n{\n"; 888 889 for (unsigned long ChanNr=0; ChanNr<m_Channels.Size(); ChanNr++) 890 { 891 const ChannelT& Channel=m_Channels[ChanNr]; 892 bool IsFirst=true; 893 894 OutStream << "\t{\n" 895 << "\t\tname=\"" << Channel.Name << "\";\n" 896 << "\t\tjoints={ "; 897 898 for (unsigned long JointNr=0; JointNr<m_Joints.Size(); JointNr++) 899 { 900 if (Channel.IsMember(JointNr)) 901 { 902 if (!IsFirst) OutStream << ", "; 903 OutStream << JointNr; 904 IsFirst=false; 905 } 906 } 907 908 OutStream << " };\n" 909 << "\t},\n"; 853 910 } 854 911 -
cafu/trunk/Libs/Models/Model_cmdl.hpp
r390 r391 29 29 #include "Math3D/Matrix.hpp" 30 30 #include "Model.hpp" 31 32 #if defined(_WIN32) && _MSC_VER<1600 33 #include "pstdint.h" // Paul Hsieh's portable implementation of the stdint.h header. 34 #else 35 #include <stdint.h> 36 #endif 31 37 32 38 … … 166 172 167 173 168 /// This struct describes additional/alternative skins for th is model.174 /// This struct describes additional/alternative skins for the meshes of this model. 169 175 struct SkinT 170 176 { … … 206 212 Vector3fT AxisX; 207 213 Vector3fT AxisY; 214 }; 215 216 217 /// Channels allow animations to play only on a subset of the joints, 218 /// so that multiple animations can play on different parts of the model at the same time. 219 /// For example, you can play a walking animation on the legs, an animation for swinging 220 /// the arms on the upper body, and an animation for moving the eyes on the head. 221 /// 222 /// Technically, a channel defines a group of joints. It is used to limit or "filter" 223 /// animations such that they affect only the joints that are members of the channel. 224 struct ChannelT 225 { 226 std::string Name; ///< The name of this channel. 227 228 bool IsMember(unsigned int JointNr) const; 229 void SetMember(unsigned int JointNr, bool Member=true); 230 231 232 private: 233 234 ArrayT<uint32_t> m_BitBlocks; 208 235 }; 209 236 … … 250 277 const ArrayT<SkinT>& GetSkins() const { return m_Skins; } 251 278 const ArrayT<GuiFixtureT>& GetGuiFixtures() const { return m_GuiFixtures; } 279 const ArrayT<ChannelT>& GetChannels() const { return m_Channels; } 252 280 253 281 /// This method returns the set of drawing matrices (one per joint) at the given sequence and frame number. … … 315 343 ArrayT<GuiFixtureT> m_GuiFixtures; ///< Array of GUI fixtures in the model. 316 344 ArrayT<GuiLocT> m_GuiLocs; ///< Array of locations where GUIs can be attached to this model. 345 ArrayT<ChannelT> m_Channels; ///< Array of channels in this model. 317 346 318 347
