private void LoadFromColladaSceneNode(ColladaSceneNodeBase node) { if (node.Type != ColladaSceneNodeBase.NodeType.Node && node.Type != ColladaSceneNodeBase.NodeType.Scene) { return; } // This is not correct. When using a skin there is an 'instance_controller' if (node.Instance_Geometry != null) { ColladaMesh mesh = node.Instance_Geometry; for (int iPart = 0; iPart < mesh.Parts.Count; iPart++) { ColladaMesh.PrimitiveList meshPart = mesh.Parts[iPart]; SkinnedMesh skinnedMesh = new SkinnedMesh(skinnedModel); Matrix objectMatrix = node.GetFullMatrix() * Matrix.CreateRotationX(-MathHelper.PiOver2); LoadMesh(skinnedMesh, mesh, meshPart, objectMatrix); skinnedModel.Meshes.Add(skinnedMesh); //model.FullData.ObjectMatrix = node.GetFullMatrix(); // TODO: this only counts when model is from max! //model.FullData.ObjectMatrix = model.FullData.ObjectMatrix * Matrix.CreateRotationX( -MathHelper.PiOver2 ); } } for (int iNode = 0; iNode < node.Nodes.Count; iNode++) { LoadFromColladaSceneNode(node.Nodes[iNode]); } }
/// <summary> /// Returns the total matrix built from this nodes parents. /// </summary> /// <returns></returns> public Matrix GetFullMatrix() { if (parent == null) { return(Matrix); } return(Matrix * parent.GetFullMatrix()); }