/// <summary> /// Copies only the geometry (Mesh, /// MinimumBoundingBox, MinimumBoundingSphere, TriangleCount and Transforms) /// </summary> /// <param name="model">A source model from which to copy</param> public override void CopyGeometry(IModel model) { if (!(model is AnimatedModel)) { return; } AnimatedModel srcModel = (AnimatedModel)model; skinnedModel = srcModel.SkinnedModel; vertices.AddRange(((IPhysicsMeshProvider)model).Vertices); indices.AddRange(((IPhysicsMeshProvider)model).Indices); // Look up our custom skinning information. skinningData = srcModel.skinnedModel.Tag as SkinningData; if (skinningData == null) { throw new GoblinException("This model does not contain a SkinningData tag."); } // Create an animation player, and start decoding an animation clip. animationPlayer = new AnimationPlayer(skinningData); triangleCount = srcModel.TriangleCount; boundingBox = srcModel.MinimumBoundingBox; boundingSphere = srcModel.MinimumBoundingSphere; UseInternalMaterials = srcModel.UseInternalMaterials; }
public IModel Load(String path, String modelAssetName) { path = (path.Equals("")) ? State.GetSettingVariable("ModelDirectory") : path; String filePath = Path.Combine(path, modelAssetName); XNAModel xnaModel = State.Content.Load <XNAModel>(@"" + filePath); // Get matrix transformations of the model if (xnaModel != null) { IModel model = new AnimatedModel(xnaModel); return(model); } else { Log.Write("SkinnedModel " + filePath + " does not exist "); return(null); } }
public IModel Load(String path, String modelAssetName) { path = (path.Equals("")) ? State.GetSettingVariable("ModelDirectory") : path; String filePath = Path.Combine(path, modelAssetName); XNAModel xnaModel = State.Content.Load<XNAModel>(@"" + filePath); // Get matrix transformations of the model if (xnaModel != null) { IModel model = new AnimatedModel(xnaModel); return model; } else { Log.Write("SkinnedModel " + filePath + " does not exist "); return null; } }
private void LoadModel() { AnimatedModelLoader loader = new AnimatedModelLoader(); animatedModel = (AnimatedModel)loader.Load("", "dude"); animatedModel.UseInternalMaterials = true; GeometryNode modelNode = new GeometryNode("Dude"); modelNode.Model = animatedModel; animatedModel.LoadAnimationClip("Take 001"); modelTransNode = new TransformNode(); modelTransNode.Translation = new Vector3(20, 0, 0); scene.RootNode.AddChild(modelTransNode); modelTransNode.AddChild(modelNode); }