public Plane(AnimatTools.Framework.DataObject doParent)
     : base(doParent)
 {
     m_vMapLocation = new AnimatTools.Framework.Vec3d(this, 0, 0, 0);
     m_vMapSize = new AnimatTools.Framework.Vec3d(this, 100, 100, 0);
 }
        public override void LoadData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml)
        {
            base.LoadData (ref dsSim, ref doStructure, ref oXml);

            oXml.IntoElem();
            m_fltHeight = oXml.GetChildFloat("Height", m_fltHeight);
            m_strHeightFieldImage = oXml.GetChildString("HeightFieldImage", m_strHeightFieldImage);

            if(oXml.FindChildElement("MapLocation", false))
                m_vMapLocation = Util.LoadVec3d(ref oXml, "MapLocation", this);

            if(oXml.FindChildElement("MapSize", false))
                m_vMapSize = Util.LoadVec3d(ref oXml, "MapSize", this);

            m_fltMapScale = oXml.GetChildFloat("MapScale", m_fltMapScale);
            oXml.OutOfElem(); //out of body
        }
        protected override void CloneInternal(AnimatTools.Framework.DataObject doOriginal, bool bCutData, AnimatTools.Framework.DataObject doRoot)
        {
            base.CloneInternal (doOriginal, bCutData, doRoot);

            Plane doOrigBody = (Plane) doOriginal;
            m_fltHeight = doOrigBody.m_fltHeight;
            m_strHeightFieldImage = doOrigBody.m_strHeightFieldImage;
            m_vMapLocation = (AnimatTools.Framework.Vec3d) doOrigBody.m_vMapLocation.Clone(this, bCutData, doRoot);
            m_vMapSize  = (AnimatTools.Framework.Vec3d) doOrigBody.m_vMapSize.Clone(this, bCutData, doRoot);
            m_fltMapScale = doOrigBody.m_fltMapScale;
        }
        public static void SaveMeshVertices(ref AnimatTools.Interfaces.StdXml oXml, string strName, Mesh myMesh, bool bSaveIndices)
        {
            CustomVertex.PositionNormalTextured[] cvVerts = new CustomVertex.PositionNormalTextured[myMesh.NumberVertices];

            oXml.AddChildElement(strName);
            oXml.IntoElem();  //Into the mesh

            GraphicsStream buffer = myMesh.LockVertexBuffer(LockFlags.ReadOnly);
            AnimatTools.Framework.Vec3d vVertex = new AnimatTools.Framework.Vec3d(null);

            for(int i=0; i<myMesh.NumberVertices; i++)
            {
                buffer.Position = i * myMesh.NumberBytesPerVertex;
                cvVerts[i] = (CustomVertex.PositionNormalTextured)buffer.Read(typeof(CustomVertex.PositionNormalTextured));
                //System.Diagnostics.Debug.WriteLine("v " + cvVerts[i].X + " " + cvVerts[i].Y + " " + cvVerts[i].Z);

                vVertex.X = cvVerts[i].X;// - this.AbsoluteLocation.X;
                vVertex.Y = cvVerts[i].Y;// - this.AbsoluteLocation.Y;
                vVertex.Z = cvVerts[i].Z;// - this.AbsoluteLocation.Z;

                Util.SaveVector(ref oXml, "Vector", vVertex);

                //Debug.WriteLine("data.Write(new CustomVertex.PositionTextured(" + vVertex.X + "f, " + vVertex.Y + "f, " + vVertex.Z + "f, 0f, 0f));");
                //if(i%3 == 0) Debug.WriteLine("");
                //Debug.WriteLine("V: " + i + "  (" + cvVerts[i].X + ", " + cvVerts[i].Y + ", " + cvVerts[i].Z + ", " + cvVerts[i].Nx + ", " + cvVerts[i].Ny + ", " + cvVerts[i].Nz + ")");
            }
            myMesh.UnlockVertexBuffer();

            if(bSaveIndices)
            {
                using (IndexBuffer ib = myMesh.IndexBuffer)
                {
                    GraphicsStream gs = ib.Lock(0, myMesh.NumberFaces*3*2, LockFlags.ReadOnly);

                    string strIndex = "";
                    short iIndex;
                    for(int i=0; i<myMesh.NumberFaces*3; i++)
                    {
                        gs.Position = i * 2;
                        iIndex = (short) gs.Read(typeof(short));

                        strIndex += iIndex.ToString();
                        if(i<gs.Length-1) strIndex += ",";
                    }

                    oXml.AddChildElement("IndexBuffer", strIndex);

                    ib.Unlock();
                }
            }

            oXml.OutOfElem();  //Out of the mesh
        }