Changeset 475
- Timestamp:
- 02/07/12 10:36:33 (4 months ago)
- Location:
- cafu/trunk
- Files:
-
- 4 added
- 6 modified
-
CaWE/ModelEditor/Commands/SetMeshShadows.cpp (added)
-
CaWE/ModelEditor/Commands/SetMeshShadows.hpp (added)
-
CaWE/ModelEditor/Commands/SetMeshTSMethod.cpp (added)
-
CaWE/ModelEditor/Commands/SetMeshTSMethod.hpp (added)
-
CaWE/ModelEditor/MeshInspector.cpp (modified) (3 diffs)
-
CaWE/ModelEditor/MeshInspector.hpp (modified) (1 diff)
-
Libs/Models/AnimPose.cpp (modified) (1 diff)
-
Libs/Models/Loader_cmdl.cpp (modified) (1 diff)
-
Libs/Models/Model_cmdl.cpp (modified) (2 diffs)
-
Libs/Models/Model_cmdl.hpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/CaWE/ModelEditor/MeshInspector.cpp
r455 r475 25 25 #include "Commands/Rename.hpp" 26 26 #include "Commands/SetMaterial.hpp" 27 #include "Commands/SetMeshShadows.hpp" 28 #include "Commands/SetMeshTSMethod.hpp" 27 29 28 30 #include "../EditorMaterial.hpp" … … 179 181 "Material", Mat ? Mat->Name : "<NULL>", m_ModelDoc)); 180 182 181 wxPGProperty* UseGivenTS=Append(new wxBoolProperty("Use given TS", wxPG_LABEL, false)); 182 DisableProperty(UseGivenTS); 183 184 wxPGProperty* CastShadows=Append(new wxBoolProperty("Cast Shadows", wxPG_LABEL, true)); 185 DisableProperty(CastShadows); 183 const wxChar* TSM_Strings[] = { wxT("HARD"), wxT("GLOBAL"), wxT("SG_LOCAL"), wxT("SG_GLOBAL"), NULL }; 184 const long TSM_Indices[] = { CafuModelT::MeshT::HARD, CafuModelT::MeshT::GLOBAL, CafuModelT::MeshT::SG_LOCAL, CafuModelT::MeshT::SG_GLOBAL }; 185 wxPGProperty* TSMethod=Append(new wxEnumProperty("Tangent-space method", wxPG_LABEL, TSM_Strings, TSM_Indices, Mesh.TSMethod)); 186 TSMethod->SetHelpString("The method that is used for generating the tangent-space axes at the vertices of this mesh. See the documentation for details."); 187 188 wxPGProperty* CastShadows=Append(new wxBoolProperty("Cast Shadows", wxPG_LABEL, Mesh.CastShadows)); 189 CastShadows->SetHelpString("If checked, this mesh casts shadows when lit by dynamic light sources."); 186 190 187 191 wxPGProperty* NumTriangles=Append(new wxIntProperty("Num Triangles", wxPG_LABEL, Mesh.Triangles.Size())); … … 227 231 bool ok=true; 228 232 229 if (PropName=="Name" ) ok=m_Parent->SubmitCommand(new CommandRenameT(m_ModelDoc, MESH, MeshNr, Event.GetValue().GetString())); 230 else if (PropName=="Material") ok=m_Parent->SubmitCommand(new CommandSetMaterialT(m_ModelDoc, MeshNr, m_ModelDoc->GetSelSkinNr(), Event.GetValue().GetString())); 233 if (PropName=="Name" ) ok=m_Parent->SubmitCommand(new CommandRenameT(m_ModelDoc, MESH, MeshNr, Event.GetValue().GetString())); 234 else if (PropName=="Material") ok=m_Parent->SubmitCommand(new CommandSetMaterialT(m_ModelDoc, MeshNr, m_ModelDoc->GetSelSkinNr(), Event.GetValue().GetString())); 235 else if (PropName=="Tangent-space method") ok=m_Parent->SubmitCommand(new CommandSetMeshTSMethodT(m_ModelDoc, MeshNr, CafuModelT::MeshT::TangentSpaceMethodT(Event.GetValue().GetInteger()))); 236 else if (PropName=="Cast Shadows") ok=m_Parent->SubmitCommand(new CommandSetMeshShadowsT(m_ModelDoc, MeshNr, Event.GetValue().GetBool())); 231 237 else 232 238 { -
cafu/trunk/CaWE/ModelEditor/MeshInspector.hpp
r457 r475 54 54 DECLARE_EVENT_TABLE() 55 55 56 ModelDocumentT* m_ModelDoc;57 ChildFrameT* m_Parent;58 bool m_IsRecursiveSelfNotify;56 ModelDocumentT* m_ModelDoc; 57 ChildFrameT* m_Parent; 58 bool m_IsRecursiveSelfNotify; 59 59 }; 60 60 } -
cafu/trunk/Libs/Models/AnimPose.cpp
r469 r475 514 514 const MaterialT* MeshMat =m_Model.GetMaterial(MeshNr, SkinNr); 515 515 516 if (!Mesh.CastShadows) continue; 516 517 if (MeshMat==NULL || MeshMat->NoShadows) continue; 517 518 -
cafu/trunk/Libs/Models/Loader_cmdl.cpp
r474 r475 197 197 Mesh.Material=MaterialMan.RegisterMaterial(CreateDefaultMaterial(MatName)); 198 198 } 199 } 200 lua_pop(m_LuaState, 1); 201 202 lua_getfield(m_LuaState, -1, "tsMethod"); 203 { 204 const char* Method=lua_tostring(m_LuaState, -1); 205 Mesh.SetTSMethod(Method ? Method : "default"); 206 } 207 lua_pop(m_LuaState, 1); 208 209 lua_getfield(m_LuaState, -1, "castShadows"); 210 { 211 Mesh.CastShadows=lua_isnumber(m_LuaState, -1) ? (lua_tonumber(m_LuaState, -1)!=0) : (lua_toboolean(m_LuaState, -1)!=0); 199 212 } 200 213 lua_pop(m_LuaState, 1); -
cafu/trunk/Libs/Models/Model_cmdl.cpp
r474 r475 125 125 // All weights were equal - the vertices are geodups of each other! 126 126 return true; 127 } 128 129 130 std::string CafuModelT::MeshT::GetTSMethod() const 131 { 132 switch (TSMethod) 133 { 134 case HARD: return "HARD"; 135 case GLOBAL: return "GLOBAL"; 136 case SG_LOCAL: return "SG_LOCAL"; 137 case SG_GLOBAL: return "SG_GLOBAL"; 138 } 139 140 return "?"; 141 } 142 143 144 void CafuModelT::MeshT::SetTSMethod(const std::string& m) 145 { 146 TSMethod=GLOBAL; 147 148 if (m=="HARD") TSMethod=HARD; 149 else if (m=="GLOBAL") TSMethod=GLOBAL; 150 else if (m=="SG_LOCAL") TSMethod=SG_LOCAL; 151 else if (m=="SG_GLOBAL") TSMethod=SG_GLOBAL; 127 152 } 128 153 … … 681 706 OutStream << "\t\t" << "name=\"" << Mesh.Name << "\";\n"; 682 707 OutStream << "\t\t" << "Material=\"" << (Mesh.Material ? Mesh.Material->Name : "") << "\";\n"; 708 OutStream << "\t\t" << "tsMethod=\"" << Mesh.GetTSMethod() << "\";\n"; 709 OutStream << "\t\t" << "castShadows=" << (Mesh.CastShadows ? "true" : "false") << ";\n"; // Don't rely on the proper locale being set... 683 710 684 711 // Write the mesh weights. -
cafu/trunk/Libs/Models/Model_cmdl.hpp
r474 r475 47 47 namespace ModelEditor { class CommandSetAnimNextT; } 48 48 namespace ModelEditor { class CommandSetMaterialT; } 49 namespace ModelEditor { class CommandSetMeshTSMethodT; } 50 namespace ModelEditor { class CommandSetMeshShadowsT; } 49 51 namespace ModelEditor { class CommandTransformJointT; } 50 52 namespace ModelEditor { class CommandUpdateAnimT; } … … 76 78 struct MeshT 77 79 { 80 /// The methods that can be used to generate the tangent-space axes at the vertices of a mesh. 81 /// 82 /// In this context, "global" smoothing means that when the side of a pyramid or cone is considered, 83 /// for computing the tangent-space of its tip vertex, all sides of the pyramid enter the average, 84 /// because they all share the common tip vertex. 85 /// As a result, the normal vector at the tip is straight (axial), the same for all sides, and the 86 /// interpolated "shape" in tangent-space is really a half-sphere rather than a cone. 87 /// 88 /// In contrast, "local" smoothing averages only the current side with its left and right neighbours. 89 /// The resulting tangent-space normal vectors at the tip vertices remain orthogonal to their triangle, 90 /// and the interpolated tangent-space shape is a cone rather than a half-sphere. 91 enum TangentSpaceMethodT 92 { 93 HARD, ///< Hard edges, no smoothing: The tangent-space of the triangle is used as the tangent-space of its vertices. (Any smoothing groups info, if available, is ignored.) 94 GLOBAL, ///< Considers all triangles in the mesh to be in the same common smoothing group, and smoothes them globally. (Any smoothing groups info, if available, is ignored.) This method is equivalent to SG_GLOBAL when all triangles are in the same smoothing group. It is also the default method, as it requires no smoothing groups info at all, provides better performance than SG_GLOBAL, and was implemented in earlier versions of Cafu. 95 SG_LOCAL, ///< Takes the given smoothing groups into account and provides "local" smoothing. 96 SG_GLOBAL ///< [NOT YET IMPLEMENTED! At this time, this is the same as GLOBAL.] Takes the given smoothing groups into account and provides "global" smoothing. 97 }; 98 78 99 /// A single triangle. 79 100 struct TriangleT … … 118 139 119 140 /// The default constructor. 120 MeshT() : Material(NULL), RenderMaterial(NULL) {}141 MeshT() : Material(NULL), RenderMaterial(NULL), TSMethod(GLOBAL), CastShadows(true) {} 121 142 122 143 /// Determines whether the two vertices with array indices Vertex1Nr and Vertex2Nr are geometrical duplicates of each other. … … 131 152 bool AreGeoDups(unsigned int Vertex1Nr, unsigned int Vertex2Nr) const; 132 153 154 /// Returns a string representation of the TSMethod enum member. 155 std::string GetTSMethod() const; 156 157 /// Sets the TSMethod enum member by string. 158 /// The given string should be one of the strings returned by GetTSMethod(). 159 /// If the string does not match a known method, TSMethod is set to GLOBAL. 160 /// @param m The method to set TSMethod to. 161 void SetTSMethod(const std::string& m); 162 133 163 std::string Name; ///< Name of this mesh. 134 164 MaterialT* Material; ///< The material of this mesh. 135 165 MatSys::RenderMaterialT* RenderMaterial; ///< The render material used to render this mesh. 136 // bool CastShadows; ///< Should this mesh cast shadows? 166 TangentSpaceMethodT TSMethod; ///< How to generate the tangent-space axes at the vertices of this mesh? For meshes with normal-maps, the method should match the one that was used in the program that created the normal-maps. 167 bool CastShadows; ///< Should this mesh cast shadows? 137 168 ArrayT<TriangleT> Triangles; ///< List of triangles this mesh consists of. 138 169 ArrayT<VertexT> Vertices; ///< List of vertices this mesh consists of. … … 312 343 friend class ModelEditor::CommandSetAnimNextT; 313 344 friend class ModelEditor::CommandSetMaterialT; 345 friend class ModelEditor::CommandSetMeshTSMethodT; 346 friend class ModelEditor::CommandSetMeshShadowsT; 314 347 friend class ModelEditor::CommandTransformJointT; 315 348 friend class ModelEditor::CommandUpdateAnimT;
