void IResource.LoadFromXML(XmlNode node)
 {
     foreach (XmlAttribute attrib in node.Attributes)
     {
         switch (attrib.Name.ToLower())
         {
             case "name":
                 name = attrib.Value;
                 break;
             case "mesh":
                 mesh = ResourceManager.Inst.GetMesh(attrib.Value);
                 break;
             case "summary":
                 description = attrib.Value;
                 break;
             case "mass":
                 mass = float.Parse(attrib.Value);
                 break;
             case "candrop":
                 canDrop = bool.Parse(attrib.Value);
                 break;
             case "price":
                 price = int.Parse(attrib.Value);
                 break;
         }
     }
 }
Esempio n. 2
0
        protected void InitializeMesh(string name)
        {
            mesh = ResourceManager.Inst.GetMesh(name);
            rootNodes = mesh.GetRootNodes(out nodes);

            int vertexCount = 0;
            VertexBuffer origBuffer = mesh.GetVertexBuffer(out vertexCount);
            vertices = new VertexPNTTI[vertexCount];
            origBuffer.GetData<VertexPNTTI>(vertices);
            vertexBuffer = new VertexBuffer(GFX.Device, VertexPNTTI.SizeInBytes * vertexCount, BufferUsage.WriteOnly);
            vertexBuffer.SetData<VertexPNTTI>(vertices);

            List<AnimationNode> orderedNodes = new List<AnimationNode>();
            for (int i = 0; i < nodes.Count; i++)
            {
                string currKey = nodes.Keys[i];
                defaultTranslations.Add(currKey, nodes[currKey].Translation);
                defaultRotations.Add(currKey, nodes[currKey].Rotation);
            }

            AnimationNode[] tempNodes = mesh.GetNodes();
            for(int i = 0; i < tempNodes.Length; i++)
            {
                orderedNodes.Add(nodes[tempNodes[i].Name]);
            }
            this.orderedNodes = orderedNodes.ToArray();

            mainAnimationLayer = new AnimationLayer(this);
        }
 public override void OnAdd(Scene scene)
 {
     mesh = ResourceManager.Inst.GetMesh("Cecropia");
     base.OnAdd(scene);
     for(int i = 0; i < entityCount; i++)
     {
         Vector3 pos;
         Vector3 normal;
         scene.MainTerrain.GenerateRandomTransform(RandomHelper.RandomGen, out pos, out normal);
         ForestElement element = new ForestElement();
         element.Transform = new Transform();
         element.Transform.SetPosition(pos);
         element.Mesh = mesh;
         visibleMeshes.AddElement(element, false);
     }
     visibleMeshes.BuildTree();
     RecursivelyBuildBounds(visibleMeshes.GetRoot());
 }
 void IResource.LoadFromXML(XmlNode node)
 {
     string filename = string.Empty;
     foreach (XmlAttribute attrib in node.Attributes)
     {
         switch (attrib.Name.ToLower())
         {
             case "timestart":
                 timeStart = float.Parse(attrib.Value);
                 break;
             case "timeend":
                 timeEnd = float.Parse(attrib.Value);
                 break;
             case "fps":
                 fps = float.Parse(attrib.Value);
                 break;
             case "mesh":
                 mesh = ResourceManager.Inst.GetMesh(attrib.Value);
                 break;
             case "filename":
                 filename = attrib.Value;
                 break;
             case "name":
                 name = attrib.Value;
                 break;
             case "iscyclic":
                 IsCyclic = bool.Parse(attrib.Value);
                 break;
             case "recenter":
                 recenterRoots = bool.Parse(attrib.Value);
                 break;
         }
     }
     if (filename != string.Empty)
     {
         timeStart = 0;
         ReadSMD(filename);
         RescaleAnimation(animationFrames, timeStart, fps);
     }
     endTime = (timeEnd - timeStart) / fps;
     if (!IsCyclic)
         endTime += blendOutTime;
 }
Esempio n. 5
0
 public void AddMeshToRender(Mesh mesh)
 {
     meshesToRender.Enqueue(mesh);
     mesh.Rendered = false;
 }
Esempio n. 6
0
 protected void InitializeMesh(string name)
 {
     mesh = ResourceManager.Inst.GetMesh(name);
     rootNodes = mesh.GetRootNodes(out nodes);
 }
Esempio n. 7
0
 public Imposter(Mesh mesh)
 {
     Element = new RenderElement();
     Element.IndexBuffer = GFXPrimitives.ImposterGeometry.GetInstanceIndexBuffer();
     Element.IsAnimated = false;
     Element.PrimitiveCount = 8;
     Element.StartVertex = 0;
     Element.VertexBuffer = GFXPrimitives.ImposterGeometry.GetInstanceVertexBuffer();
     Element.VertexCount = 16;
     Element.VertexDec = GFXVertexDeclarations.PTIDec;
     Element.VertexStride = VertexPTI.SizeInBytes;
     //GFXPrimitives.CreateBillboardElement();
     ImposterMaterial = new Material();
     Vector3 scale = (mesh.GetBounds().Max - mesh.GetBounds().Min);
     Scale = Matrix.CreateScale(scale);
 }
Esempio n. 8
0
 public void AddMeshToRender(Mesh mesh)
 {
     meshesToRender.Add(mesh);
 }