/// <summary> /// Creates all the child MeshNodes of a certain node. /// </summary> /// <param name="model">Model from which the nodes are to be created.</param> /// <param name="bone">Bone being checked.</param> /// <param name="node">Node to which child nodes are to be added.</param> private void CreateNodes(Model model, ModelBone bone, SceneNode node) { bool childFound = false; //Go through the meshes in the model and try to find one whose parent bone is the //one for which nodes are being created. foreach (ModelMesh mesh in model.Meshes) { //If we found the mesh we were looking for... if (mesh.ParentBone == bone) { childFound = true; //Create the MeshPart objects from the XNA ModelMeshPart objects. List <MeshPart> parts = new List <MeshPart>(); foreach (ModelMeshPart part in mesh.MeshParts) { MeshPart newPart = new MeshPart(Root, part.IndexBuffer, part.NumVertices, part.PrimitiveCount, part.StartIndex, part.VertexBuffer, part.VertexOffset, null); parts.Add(newPart); } //Create the new mesh node and attach it to the node to which we are //currently adding children. MeshNode newMesh = new MeshNode(Root, parts); node.AttachChild(newMesh); //Set the mesh transform matrix in the mesh node. newMesh.MeshTransformMatrix = bone.Transform; //Go through each child bone of the bone passed in the argument. foreach (ModelBone b in bone.Children) { //Repeat the process but now check the children of the current bone and add //the nodes to the new mesh node. CreateNodes(model, b, newMesh); } //We already found a mesh whose parent bone matched the current bone so //we can break and test another child bone or return. break; } } if (!childFound) { foreach (ModelBone b in bone.Children) { CreateNodes(model, b, node); } } }
/// <summary> /// Attaches the node of the component to the node passed in the parameter. /// </summary> /// <param name="node">Node to which the node of the component is to be attached.</param> protected override void Attach(SceneNode node) { node.AttachChild(mTextModel); }
/// <summary> /// Attaches the node of the component to the node passed in the parameter. /// </summary> /// <param name="node">Node to which the node of the component is to be attached.</param> protected override void Attach(SceneNode node) { node.AttachChild(mQuad); }