Example #1
0
        public AnimationData(SimPe.Plugin.Anim.AnimationFrameBlock afb, Ambertation.Graphics.MeshBox mb, int framecount)
        {
            //Console.WriteLine(mb.ToString());
            this.afb = afb;
            this.mb  = mb;
            this.fct = framecount;
            frames   = new SimPe.Geometry.Vectors3f();

            SimPe.Plugin.Anim.AnimationFrame[] iframes = afb.Frames;

            /*scale = new SimPe.Geometry.Vector3f();
             * scale.X = nb.Transform.TranslationVector.X / (float)iframes[0].X;
             * scale.Y = nb.Transform.TranslationVector.Y / (float)iframes[0].Y;
             * scale.Z = nb.Transform.TranslationVector.Z / (float)iframes[0].Z;*/

            SimPe.Plugin.Anim.AnimationFrameBlock afb2 = new AnimationFrameBlock(afb.Parent);
            for (int i = 0; i <= framecount; i++)
            {
                frames.Add(new SimPe.Geometry.Vector3f());
            }

            InterpolateFrames(iframes, 0);             //X-Axis
            InterpolateFrames(iframes, 1);             //Y-Axis
            InterpolateFrames(iframes, 2);             //Z-Axis
        }
Example #2
0
        private void lb_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (lb.SelectedItem == null)
            {
                return;
            }
            jointmap.Clear();

            ListedMeshBlocks lmb = (ListedMeshBlocks)lb.SelectedItem;

            if (lmb.CRES == null || lmb.GMDC == null)
            {
                return;
            }

            SimPe.Plugin.ResourceNode rn = (SimPe.Plugin.ResourceNode)lmb.CRES.Blocks[0];

            if (root != null)
            {
                root.Dispose();
            }
            root = new Ambertation.Graphics.MeshList();


            AddJoint(lmb, rn, root, tv.Nodes);

            animdata.Clear();
            foreach (SimPe.Plugin.Anim.AnimationFrameBlock afb in lmb.ANIMBlock.Part2)
            {
                SimPe.Plugin.Anim.AnimationFrameBlock afb2 = afb.CloneBase(true);
                object o = jointmap[afb.Name];
                if (o == null)
                {
                    continue;
                }
                Ambertation.Graphics.MeshBox mb = (Ambertation.Graphics.MeshBox)o;

                animdata.Add(new AnimationData(afb2, mb, lmb.ANIMBlock.Animation.TotalTime));
            }

            if (inter)
            {
                return;
            }
            inter = true;
            //dx.Reset();
            dx.ResetViewport(new Microsoft.DirectX.Vector3(-2, -2, -2), new Microsoft.DirectX.Vector3(2, 2, 2));
            dx.Render();
            inter = false;
        }
Example #3
0
        void AddJoint(ListedMeshBlocks lmb, SimPe.Interfaces.Scenegraph.ICresChildren bl, Ambertation.Graphics.MeshList parent, System.Windows.Forms.TreeNodeCollection nodes)
        {
            SimPe.Plugin.TransformNode tn = bl.StoredTransformNode;


            if (tn != null)
            {
                Ambertation.Graphics.MeshBox mb = new Ambertation.Graphics.MeshBox(
                    Microsoft.DirectX.Direct3D.Mesh.Sphere(dx.Device, 0.02f, 12, 24),
                    1,
                    Ambertation.Graphics.DirectXPanel.GetMaterial(Color.Wheat)
                    );
                mb.Wire = false;

                Ambertation.Scenes.Transformation trans = new Ambertation.Scenes.Transformation();
                trans.Rotation.X = tn.Rotation.GetEulerAngles().X;
                trans.Rotation.Y = tn.Rotation.GetEulerAngles().Y;
                trans.Rotation.Z = tn.Rotation.GetEulerAngles().Z;

                trans.Translation.X = tn.TransformX;
                trans.Translation.Y = tn.TransformY;
                trans.Translation.Z = tn.TransformZ;

                mb.Transform = Ambertation.Scenes.Converter.ToDx(trans);

                TreeNode tnode = new TreeNode(tn.ToString());
                tnode.Tag = mb;
                nodes.Add(tnode);
                jointmap[bl.GetName()] = mb;

                parent.Add(mb);

                foreach (SimPe.Interfaces.Scenegraph.ICresChildren cld in bl)
                {
                    AddJoint(lmb, cld, mb, tnode.Nodes);
                }
            }
            else
            {
                foreach (SimPe.Interfaces.Scenegraph.ICresChildren cld in bl)
                {
                    AddJoint(lmb, cld, parent, nodes);
                }
            }
        }