Esempio n. 1
0
        private void timeLine1_KeyFrameRemoved(DPOW.Reader.Animation animation, int Time)
        {
            DPOW.Reader.Element elem = animation.getFrameOnTime(Time, false).Element;
            animation.RemoveKeyFrame((short)Time);
            if (!animation.HasElement(elem))
            {
                dpow.RemoveElement(elem);
            }

            trcFrameBar.Maximum = dpow.getAnimation(treObjects.SelectedNode.Text).MaxTime;
        }
Esempio n. 2
0
        private SceneNode buildElement(DPOW.Reader.Element elem, string name)
        {
            if (mgr.HasSceneNode(name + "_node"))
            {
                return(mgr.GetSceneNode(name + "_node"));
            }

            SceneNode node = mgr.CreateSceneNode(name + "_node");

            node.SetPosition(elem.Position.X * 200, -elem.Position.Y * 200, -elem.Position.Z * 10);

            for (int i = 0; i < elem.Images.Length; i++)
            {
                string imgname = name + "_text" + i.ToString();

                SceneNode    textnode = node.CreateChildSceneNode(name + "_text" + i.ToString() + "_node", new Vector3(elem.Images[i].Position.X * 200, -elem.Images[i].Position.Y * 200, -elem.Images[i].Position.Z * 10));
                ManualObject manual   = mgr.CreateManualObject(name + "_text" + i.ToString());
                string       matname;
                matname = dpow.Textures[elem.Images[i].TextureId];
                // Build new material, if it's selected
                if (imgname == SelectedItem)
                {
                    matname = "Selected";
                }

                /*else
                 * {
                 *  MaterialPtr newmat = ((MaterialPtr)MaterialManager.Singleton.GetByName(matname, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)).Clone(imgname + "_mat");
                 *  matname = imgname + "_mat";
                 * }*/
                manual.Begin(matname, RenderOperation.OperationTypes.OT_TRIANGLE_STRIP);

                for (int j = 0; j < elem.Images[i].Points.Length; j++)
                {
                    manual.Position(elem.Images[i].Points[j].X * 200, -elem.Images[i].Points[j].Y * 200, -elem.Images[i].Points[j].Z * 10);
                    manual.TextureCoord(elem.Images[i].Points[j].U, elem.Images[i].Points[j].V);
                    if (elem.Images[i].isGradient)
                    {
                        manual.Colour((float)elem.Images[i].Points[j].Color.R / 255, (float)elem.Images[i].Points[j].Color.G / 255, (float)elem.Images[i].Points[j].Color.B / 255, (float)elem.Images[i].Points[j].Color.A / 255);
                    }
                }

                manual.End();

                textnode.AttachObject(manual);
            }

            for (int i = 0; i < elem.Texts.Length; i++)
            {
                SceneNode strnode = node.CreateChildSceneNode(name + "_str" + i.ToString() + "_node", new Vector3(elem.Texts[i].Position.X * 200, -elem.Texts[i].Position.Y * 200, -elem.Texts[i].Position.Z * 10));

                ManualObject manual = mgr.CreateManualObject(name + "_str" + i.ToString());
                manual.Begin("String", RenderOperation.OperationTypes.OT_TRIANGLE_STRIP);

                float left   = 0;
                float right  = elem.Texts[i].Size.X * 200;
                float bottom = -elem.Texts[i].Size.Y * 200.0f;
                float top    = 0;
                manual.Position(left, bottom, 0);
                manual.Position(right, bottom, 0);
                manual.Position(left, top, 0);
                manual.Position(right, top, 0);

                manual.End();

                strnode.AttachObject(manual);
            }

            for (int i = 0; i < elem.Icons.Length; i++)
            {
                SceneNode flagnode = node.CreateChildSceneNode(name + "_flag" + i.ToString() + "_node", new Vector3(elem.Icons[i].Position.X * 200, -elem.Icons[i].Position.Y * 200, -elem.Icons[i].Position.Z * 10));

                ManualObject manual = mgr.CreateManualObject(name + "_flag" + i.ToString());
                manual.Begin("Flag", RenderOperation.OperationTypes.OT_TRIANGLE_STRIP);

                float left   = 0;
                float right  = elem.Icons[i].Size.X * 200;
                float bottom = -elem.Icons[i].Size.Y * 200.0f;
                float top    = 0;
                if (elem.Icons[i].WTF == 0)
                {
                    left   = -elem.Icons[i].Size.X / 2 * 200;
                    right  = elem.Icons[i].Size.X / 2 * 200;
                    bottom = -elem.Icons[i].Size.Y / 2 * 200.0f;
                    top    = elem.Icons[i].Size.Y / 2 * 200.0f;
                }
                manual.Position(left, bottom, 0);
                manual.Position(right, bottom, 0);
                manual.Position(left, top, 0);
                manual.Position(right, top, 0);

                manual.End();

                flagnode.AttachObject(manual);
            }

            return(node);
        }
Esempio n. 3
0
        public DPOWObject(Stream thefile)
        {
            int imageoff, elementsoff, animoff, unknownoff, eventsoff, tempoff1, tempoff2;

            int[] imageoffs;

            BinaryReader binfile = new BinaryReader(thefile);

            //Read basic block offsets
            thefile.Seek(8, SeekOrigin.Begin);
            imageoff    = binfile.ReadInt32();
            elementsoff = binfile.ReadInt32();
            animoff     = binfile.ReadInt32();
            unknownoff  = binfile.ReadInt32();
            eventsoff   = binfile.ReadInt32();

            //Read images
            thefile.Seek(imageoff, SeekOrigin.Begin);
            textures  = new string[binfile.ReadInt32()];
            imageoffs = new int[textures.Length];
            thefile.Seek(binfile.ReadInt32(), SeekOrigin.Begin);
            for (int i = 0; i < textures.Length; i++)
            {
                imageoffs[i] = binfile.ReadInt32();
            }
            for (int i = 0; i < textures.Length; i++)
            {
                thefile.Seek(imageoffs[i], SeekOrigin.Begin);
                textures[i] = loadstring(thefile);
            }

            //Read elements
            thefile.Seek(elementsoff, SeekOrigin.Begin);
            Elements = new DPOW.Reader.Element[binfile.ReadInt32()];
            int[] eloffset = new int[Elements.Length];
            thefile.Seek(binfile.ReadInt32(), SeekOrigin.Begin);
            for (int i = 0; i < Elements.Length; i++)
            {
                eloffset[i] = binfile.ReadInt32();
            }

            //Fill the elements
            for (int i = 0; i < Elements.Length; i++)
            {
                thefile.Seek(eloffset[i], SeekOrigin.Begin);

                Elements[i] = new DPOW.Reader.Element(thefile);
            }

            //ANIMATIONS
            thefile.Seek(animoff, SeekOrigin.Begin);

            Animations = new DPOW.Reader.Animation[binfile.ReadInt32()];
            int[] anoffset = new int[Animations.Length];
            tempoff1 = binfile.ReadInt32();
            tempoff2 = binfile.ReadInt32();

            thefile.Seek(tempoff1, SeekOrigin.Begin);
            for (int i = 0; i < Animations.Length; i++)
            {
                anoffset[i] = binfile.ReadInt32();
            }

            for (int i = 0; i < Animations.Length; i++)
            {
                thefile.Seek(anoffset[i], SeekOrigin.Begin);

                Animations[i] = new DPOW.Reader.Animation(thefile, this);
            }

            for (int i = 0; i < Animations.Length; i++)
            {
                thefile.Seek(tempoff2 + i * 4, SeekOrigin.Begin);
                thefile.Seek(binfile.ReadInt32(), SeekOrigin.Begin);

                Animations[i].Name = loadstring(thefile);
            }

            thefile.Seek(unknownoff, SeekOrigin.Begin);
            unknowntable = new int[binfile.ReadInt32()];
            tempoff1     = binfile.ReadInt32();
            for (int i = 0; i < unknowntable.Length; i++)
            {
                thefile.Seek(tempoff1 + i * 4, SeekOrigin.Begin);
                thefile.Seek(binfile.ReadInt32(), SeekOrigin.Begin);
                unknowntable[i] = binfile.ReadInt32();
            }

            // EVENTS
            thefile.Seek(eventsoff, SeekOrigin.Begin);
            variables = new Variable[binfile.ReadInt32()];
            tempoff1  = binfile.ReadInt32();
            tempoff2  = binfile.ReadInt32();

            thefile.Seek(tempoff1, SeekOrigin.Begin);
            for (int i = 0; i < variables.Length; i++)
            {
                variables[i]         = new Variable();
                variables[i].Enabled = binfile.ReadBoolean();
            }

            for (int i = 0; i < variables.Length; i++)
            {
                thefile.Seek(tempoff2 + i * 4, SeekOrigin.Begin);
                thefile.Seek(binfile.ReadInt32(), SeekOrigin.Begin);
                variables[i].Name = loadstring(thefile);
            }
        }