Changeset 402 for cafu/trunk
- Timestamp:
- 10/09/11 12:17:14 (8 months ago)
- Location:
- cafu/trunk
- Files:
-
- 5 modified
-
CaWE/ModelEditor/ScenePropGrid.cpp (modified) (3 diffs)
-
CaWE/ModelEditor/ScenePropGrid.hpp (modified) (1 diff)
-
CaWE/ModelEditor/SceneView3D.cpp (modified) (2 diffs)
-
Libs/Models/AnimPose.cpp (modified) (6 diffs)
-
Libs/Models/AnimPose.hpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/CaWE/ModelEditor/ScenePropGrid.cpp
r400 r402 51 51 m_Model_ShowMesh(wxConfigBase::Get()->Read("ModelEditor/SceneSetup/Model_ShowMesh", 1l)!=0), 52 52 m_Model_ShowSkeleton(wxConfigBase::Get()->Read("ModelEditor/SceneSetup/Model_ShowSkeleton", 0l)!=0), 53 m_Model_ShowTriangleNormals(wxConfigBase::Get()->Read("ModelEditor/SceneSetup/Model_ShowTriangleNormals", 0l)!=0), 54 m_Model_ShowTangentSpace(wxConfigBase::Get()->Read("ModelEditor/SceneSetup/Model_ShowTangentSpace", 0l)!=0), 53 55 m_AmbientLightColor(wxColour(wxConfigBase::Get()->Read("ModelEditor/SceneSetup/AmbientLightColor", "rgb(96, 96, 96)"))), 54 56 m_AmbientTexture(NULL), … … 129 131 AppendIn(ModelProps, new wxBoolProperty("Show Mesh", wxPG_LABEL, m_Model_ShowMesh)); 130 132 AppendIn(ModelProps, new wxBoolProperty("Show Skeleton", wxPG_LABEL, m_Model_ShowSkeleton)); 133 AppendIn(ModelProps, new wxBoolProperty("Show triangle normals", wxPG_LABEL, m_Model_ShowTriangleNormals)); 134 AppendIn(ModelProps, new wxBoolProperty("Show tangent-space", wxPG_LABEL, m_Model_ShowTangentSpace)); 131 135 132 136 … … 216 220 } 217 221 } 218 else if (PropName=="Model.Show Mesh") m_Model_ShowMesh =Prop->GetValue().GetBool(); 219 else if (PropName=="Model.Show Skeleton") m_Model_ShowSkeleton=Prop->GetValue().GetBool(); 222 else if (PropName=="Model.Show Mesh") m_Model_ShowMesh =Prop->GetValue().GetBool(); 223 else if (PropName=="Model.Show Skeleton") m_Model_ShowSkeleton =Prop->GetValue().GetBool(); 224 else if (PropName=="Model.Show triangle normals") m_Model_ShowTriangleNormals=Prop->GetValue().GetBool(); 225 else if (PropName=="Model.Show tangent-space") m_Model_ShowTangentSpace =Prop->GetValue().GetBool(); 220 226 else if (PropName=="Frame No.") { AnimState.Pose.SetFrameNr(PropValueF); m_IsRecursiveSelfNotify=true; m_Parent->GetModelDoc()->UpdateAllObservers_AnimStateChanged(); m_IsRecursiveSelfNotify=false; } 221 227 else if (PropName=="Speed") { AnimState.Speed=PropValueF; m_IsRecursiveSelfNotify=true; m_Parent->GetModelDoc()->UpdateAllObservers_AnimStateChanged(); m_IsRecursiveSelfNotify=false; } -
cafu/trunk/CaWE/ModelEditor/ScenePropGrid.hpp
r381 r402 58 58 bool m_Model_ShowMesh; 59 59 bool m_Model_ShowSkeleton; 60 bool m_Model_ShowTriangleNormals; 61 bool m_Model_ShowTangentSpace; 60 62 wxColour m_AmbientLightColor; 61 63 MatSys::TextureMapI* m_AmbientTexture; ///< A uniform 2x2 texture colored in the ambient light color, used as lightmap for the ground plane. -
cafu/trunk/CaWE/ModelEditor/SceneView3D.cpp
r400 r402 411 411 412 412 413 // Render the triangle normals and/or the tangent-space axes of the model in this pose. 414 if ((ScenePropGrid->m_Model_ShowTriangleNormals || ScenePropGrid->m_Model_ShowTangentSpace) && MatSys::Renderer->GetCurrentRenderAction()==MatSys::RendererI::AMBIENT) 415 { 416 static MatSys::MeshT TangentSpace(MatSys::MeshT::Lines); 417 418 TangentSpace.Vertices.Overwrite(); 419 420 for (unsigned long MeshNr=0; MeshNr<Model->GetMeshes().Size(); MeshNr++) 421 { 422 const CafuModelT::MeshT& Mesh =Model->GetMeshes()[MeshNr]; 423 const AnimPoseT::MeshInfoT& MeshInfo=Anim.Pose.GetMeshInfos()[MeshNr]; 424 425 for (unsigned long TriNr=0; TriNr<Mesh.Triangles.Size(); TriNr++) 426 { 427 const CafuModelT::MeshT::TriangleT& Tri=Mesh.Triangles[TriNr]; 428 Vector3fT Center; 429 430 for (unsigned int i=0; i<3; i++) 431 { 432 const AnimPoseT::MeshInfoT::VertexT& VertexInfo=MeshInfo.Vertices[Tri.VertexIdx[i]]; 433 434 Center+=VertexInfo.Pos; 435 436 if (ScenePropGrid->m_Model_ShowTangentSpace) 437 { 438 // Render the tangent-space axes at each vertex. 439 for (unsigned int AxisNr=0; AxisNr<3; AxisNr++) 440 { 441 Vector3fT Axis; Axis[AxisNr]=1.0f; 442 443 TangentSpace.Vertices.PushBackEmpty(2); 444 MatSys::MeshT::VertexT& V1=TangentSpace.Vertices[TangentSpace.Vertices.Size()-2]; 445 MatSys::MeshT::VertexT& V2=TangentSpace.Vertices[TangentSpace.Vertices.Size()-1]; 446 447 V1.SetOrigin(VertexInfo.Pos); 448 V1.SetColor(Axis.x, Axis.y, Axis.z); 449 450 const Vector3fT Vec=(AxisNr==0) ? VertexInfo.Normal : 451 (AxisNr==1) ? VertexInfo.Tangent : 452 VertexInfo.BiNormal; 453 454 V2.SetOrigin(VertexInfo.Pos + Vec); 455 V2.SetColor(Axis.x, Axis.y, Axis.z); 456 } 457 } 458 } 459 460 // Render the triangle's normal vector. 461 if (ScenePropGrid->m_Model_ShowTriangleNormals) 462 { 463 Center/=3.0f; 464 465 TangentSpace.Vertices.PushBackEmpty(2); 466 MatSys::MeshT::VertexT& V1=TangentSpace.Vertices[TangentSpace.Vertices.Size()-2]; 467 MatSys::MeshT::VertexT& V2=TangentSpace.Vertices[TangentSpace.Vertices.Size()-1]; 468 469 V1.SetOrigin(Center); 470 V1.SetColor(0.5f, Tri.Polarity ? 0 : 0.5f, 0); 471 472 V2.SetOrigin(Center + MeshInfo.Triangles[TriNr].Normal); 473 V2.SetColor(0.5f, Tri.Polarity ? 0 : 0.5f, 0); 474 } 475 } 476 } 477 478 MatSys::Renderer->SetCurrentMaterial(m_Renderer.GetRMatWireframe()); 479 MatSys::Renderer->RenderMesh(TangentSpace); 480 } 481 482 413 483 // Render the GUI fixtures. 414 484 if (MatSys::Renderer->GetCurrentRenderAction()==MatSys::RendererI::AMBIENT) … … 425 495 if (!Model->IsVertexNrOK(GF, PointNr)) continue; 426 496 427 Points[PointNr]=Anim.Pose.Get VertexPos(GF.Points[PointNr].MeshNr, GF.Points[PointNr].VertexNr);497 Points[PointNr]=Anim.Pose.GetMeshInfos()[GF.Points[PointNr].MeshNr].Vertices[GF.Points[PointNr].VertexNr].Pos; 428 498 PointsOK|=(1 << PointNr); 429 499 } -
cafu/trunk/Libs/Models/AnimPose.cpp
r401 r402 37 37 m_BoundingBox() 38 38 { 39 NormalizeInput(); 39 40 } 40 41 … … 135 136 MatSys::Renderer->SetCurrentMaterial(m_Model.GetRenderMaterial(MeshNr, SkinNr)); 136 137 MatSys::Renderer->RenderMesh(m_Draw_Meshes[MeshNr]); 137 138 #if 0139 // Render the tangent space axes for each vertex.140 static MaterialT SolidColorMaterial;141 SolidColorMaterial.UseMeshColors=true;142 143 static MatSys::MeshT TangentSpaceAxes(MatSys::MeshT::Lines);144 TangentSpaceAxes.Vertices.Overwrite();145 146 for (unsigned long VertexNr=0; VertexNr<m_Draw_Meshes[MeshNr].Vertices.Size(); VertexNr++)147 {148 const float scale=1.0f;149 const Vector3fT Orig =Vector3fT(m_Draw_Meshes[MeshNr].Vertices[VertexNr].Origin);150 const Vector3fT S_ =Vector3fT(m_Draw_Meshes[MeshNr].Vertices[VertexNr].Tangent);151 const Vector3fT T_ =Vector3fT(m_Draw_Meshes[MeshNr].Vertices[VertexNr].BiNormal);152 const Vector3fT N_ =Vector3fT(m_Draw_Meshes[MeshNr].Vertices[VertexNr].Normal);153 const float col_ =m_Meshes[MeshNr].Triangles[VertexNr / 3].Polarity ? 0.5f : 0.0f;154 const unsigned long Ofs =TangentSpaceAxes.Vertices.Size();155 156 TangentSpaceAxes.Vertices.PushBackEmpty(6);157 158 TangentSpaceAxes.Vertices[Ofs+0].SetOrigin(Orig);159 TangentSpaceAxes.Vertices[Ofs+0].SetColor(1, col_, col_);160 TangentSpaceAxes.Vertices[Ofs+1].SetOrigin(Orig+S_*scale);161 TangentSpaceAxes.Vertices[Ofs+1].SetColor(1, col_, col_);162 163 TangentSpaceAxes.Vertices[Ofs+2].SetOrigin(Orig);164 TangentSpaceAxes.Vertices[Ofs+2].SetColor(col_, 1, col_);165 TangentSpaceAxes.Vertices[Ofs+3].SetOrigin(Orig+T_*scale);166 TangentSpaceAxes.Vertices[Ofs+3].SetColor(col_, 1, col_);167 168 TangentSpaceAxes.Vertices[Ofs+4].SetOrigin(Orig);169 TangentSpaceAxes.Vertices[Ofs+4].SetColor(col_, col_, 1);170 TangentSpaceAxes.Vertices[Ofs+5].SetOrigin(Orig+N_*scale);171 TangentSpaceAxes.Vertices[Ofs+5].SetColor(col_, col_, 1);172 }173 174 MatSys::RenderMaterialT* SolidColorRenderMat=MatSys::Renderer->RegisterMaterial(&SolidColorMaterial);175 176 MatSys::Renderer->SetCurrentMaterial(SolidColorRenderMat);177 MatSys::Renderer->RenderMesh(TangentSpaceAxes);178 179 MatSys::Renderer->FreeMaterial(SolidColorRenderMat);180 181 // FIXME! Rendering the stencil shadows uses the same material as the ambient pass does!182 // (The call to FreeMaterial() above implies that no material is being set, and thus without this line,183 // no stencil shadows get rendered!)184 MatSys::Renderer->SetCurrentMaterial(m_Meshes[MeshNr].RenderMaterial);185 #endif186 138 } 187 139 break; … … 416 368 417 369 418 const Vector3fT& AnimPoseT::GetVertexPos(unsigned int MeshNr, unsigned int VertexNr) const370 const ArrayT<MatrixT>& AnimPoseT::GetJointMatrices() const 419 371 { 420 372 Recache(); 421 373 422 return m_ MeshInfos[MeshNr].Vertices[VertexNr].Pos;423 } 424 425 426 const ArrayT< MatrixT>& AnimPoseT::GetJointMatrices() const374 return m_JointMatrices; 375 } 376 377 378 const ArrayT<AnimPoseT::MeshInfoT>& AnimPoseT::GetMeshInfos() const 427 379 { 428 380 Recache(); 429 381 430 return m_ JointMatrices;382 return m_MeshInfos; 431 383 } 432 384 … … 710 662 const float f =uv01.x*uv02.y-uv01.y*uv02.x>0.0 ? 1.0f : -1.0f; 711 663 712 const Vector3fT TriInfo_ Draw_Tangent =myNormalize(Edge02.GetScaled(-uv01.y*f) + Edge01.GetScaled(uv02.y*f));713 const Vector3fT TriInfo_ Draw_BiNormal=myNormalize(Edge02.GetScaled( uv01.x*f) - Edge01.GetScaled(uv02.x*f));664 const Vector3fT TriInfo_Tangent =myNormalize(Edge02.GetScaled(-uv01.y*f) + Edge01.GetScaled(uv02.y*f)); 665 const Vector3fT TriInfo_BiNormal=myNormalize(Edge02.GetScaled( uv01.x*f) - Edge01.GetScaled(uv02.x*f)); 714 666 715 667 … … 737 689 738 690 VertexInfo.Normal +=TriInfo.Normal*TriWeight[i]; 739 VertexInfo.Tangent +=TriInfo_ Draw_Tangent*TriWeight[i];740 VertexInfo.BiNormal+=TriInfo_ Draw_BiNormal*TriWeight[i];691 VertexInfo.Tangent +=TriInfo_Tangent*TriWeight[i]; 692 VertexInfo.BiNormal+=TriInfo_BiNormal*TriWeight[i]; 741 693 742 694 for (unsigned long DupNr=0; DupNr<Vertex.GeoDups.Size(); DupNr++) … … 746 698 747 699 DupVertexInfo.Normal +=TriInfo.Normal*TriWeight[i]; 748 DupVertexInfo.Tangent +=TriInfo_ Draw_Tangent*(Tri.Polarity==DupVertex.Polarity ? TriWeight[i] : -TriWeight[i]);749 DupVertexInfo.BiNormal+=TriInfo_ Draw_BiNormal*TriWeight[i];700 DupVertexInfo.Tangent +=TriInfo_Tangent*(Tri.Polarity==DupVertex.Polarity ? TriWeight[i] : -TriWeight[i]); 701 DupVertexInfo.BiNormal+=TriInfo_BiNormal*TriWeight[i]; 750 702 } 751 703 } -
cafu/trunk/Libs/Models/AnimPose.hpp
r401 r402 53 53 { 54 54 public: 55 56 /// The instances of this struct parallel and augment the \c CafuModelT::MeshT instances in the related \c CafuModelT. 57 struct MeshInfoT 58 { 59 struct TriangleT 60 { 61 Vector3fT Normal; ///< The normal vector of this triangle, required for the shadow-silhouette determination. 62 }; 63 64 struct VertexT 65 { 66 Vector3fT Pos; ///< The spatial position of this vertex. 67 Vector3fT Normal; ///< The tangent-space normal vector of this vertex. 68 Vector3fT Tangent; ///< The tangent-space tangent vector of this vertex. 69 Vector3fT BiNormal; ///< The tangent-space binormal vector of this vertex. 70 }; 71 72 ArrayT<TriangleT> Triangles; 73 ArrayT<VertexT> Vertices; 74 }; 75 55 76 56 77 /// This struct describes information about a parent or "super" model whose skeleton pose … … 117 138 unsigned int FindClosestVertex(unsigned int MeshNr, unsigned int TriNr, const Vector3fT& P) const; 118 139 119 /// Returns the spatial position of the given vertex in the specified mesh. 120 const Vector3fT& GetVertexPos(unsigned int MeshNr, unsigned int VertexNr) const; 121 122 /// This method returns the set of transformation matrices (one per joint) at the given sequence and frame number. 140 /// Returns the set of transformation matrices (one per joint) at the given sequence and frame number. 123 141 const ArrayT<MatrixT>& GetJointMatrices() const; 124 142 125 /// This method returns the MatSys meshes for this pose. 143 /// Returns the mesh infos with additional data for each mesh in this pose. 144 const ArrayT<MeshInfoT>& GetMeshInfos() const; 145 146 /// Returns the MatSys meshes for this pose. 126 147 const ArrayT<MatSys::MeshT>& GetDrawMeshes() const; 127 148 128 /// This method returns the bounding-box for this pose.149 /// Returns the bounding-box for this pose. 129 150 const BoundingBox3fT& GetBB() const; 130 151 131 152 132 153 private: 133 134 /// The instances of this struct parallel and augment the \c CafuModelT::MeshT instances in the related \c CafuModelT.135 struct MeshInfoT136 {137 struct TriangleT138 {139 Vector3fT Normal; ///< The normal vector of this triangle, required for the shadow-silhouette determination.140 };141 142 struct VertexT143 {144 Vector3fT Pos; ///< The spatial position of this vertex.145 Vector3fT Normal; ///< The tangent-space normal vector of this vertex.146 Vector3fT Tangent; ///< The tangent-space tangent vector of this vertex.147 Vector3fT BiNormal; ///< The tangent-space binormal vector of this vertex.148 };149 150 ArrayT<TriangleT> Triangles;151 ArrayT<VertexT> Vertices;152 };153 154 154 155 155 void NormalizeInput(); … … 158 158 void Recache() const; 159 159 160 const CafuModelT& m_Model; ///< The related model that this is a pose for.161 int m_SequNr; ///< The animation sequence number at which we have computed the cache data.162 float m_FrameNr; ///< The animation frame number at which we have computed the cache data.160 const CafuModelT& m_Model; ///< The related model that this is a pose for. 161 int m_SequNr; ///< The animation sequence number at which we have computed the cache data. 162 float m_FrameNr; ///< The animation frame number at which we have computed the cache data. 163 163 const SuperT* m_Super; 164 // ArrayT<...> m_Def; ///< Array of { channel, sequence, framenr, (forceloop), blendweight } tuples.165 // bool m_DoCache; ///< Cache the computed data? (Set to true by the user if he want to re-use this instance.)164 // ArrayT<...> m_Def; ///< Array of { channel, sequence, framenr, (forceloop), blendweight } tuples. 165 // bool m_DoCache; ///< Cache the computed data? (Set to true by the user if he want to re-use this instance.) 166 166 167 mutable bool m_NeedsRecache; ///< wird auf 'true' gesetzt wann immer SetSequ(), SetFrameNr() oder AdvanceAll() o.ä. aufgerufen wird, übernimmt m_Draw_CachedDataAt*Nr Funktionalität.168 mutable ArrayT<MatrixT> m_JointMatrices; ///< The transformation matrices that represent the pose of the skeleton at the given animation sequence and frame number.169 mutable ArrayT<MeshInfoT> m_MeshInfos; ///< Additional data for each mesh in m_Model.170 mutable ArrayT<MatSys::MeshT> m_Draw_Meshes; ///< The draw meshes resulting from the m_JointMatrices.171 mutable BoundingBox3fT m_BoundingBox; ///< The bounding-box for the model in this pose.167 mutable bool m_NeedsRecache; ///< wird auf 'true' gesetzt wann immer SetSequ(), SetFrameNr() oder AdvanceAll() o.ä. aufgerufen wird, übernimmt m_Draw_CachedDataAt*Nr Funktionalität. 168 mutable ArrayT<MatrixT> m_JointMatrices; ///< The transformation matrices that represent the pose of the skeleton at the given animation sequence and frame number. 169 mutable ArrayT<MeshInfoT> m_MeshInfos; ///< Additional data for each mesh in m_Model. 170 mutable ArrayT<MatSys::MeshT> m_Draw_Meshes; ///< The draw meshes resulting from the m_JointMatrices. 171 mutable BoundingBox3fT m_BoundingBox; ///< The bounding-box for the model in this pose. 172 172 }; 173 173
