Esempio n. 1
0
        public static void Export(List <RawPart> parts, Stream stream)
        {
            StreamWriter w = new StreamWriter(stream);

            w.WriteLine("# ClassicalSharp raw model");

            for (int i = 0; i < parts.Count; i++)
            {
                RawPart p = parts[i];
                w.WriteLine(i + " name " + p.Name);
                w.WriteLine(i + " p1 " + p.X1 + " " + p.Y1 + " " + p.Z1);
                w.WriteLine(i + " p2 " + p.X2 + " " + p.Y2 + " " + p.Z2);
                w.WriteLine(i + " rot " + p.RotX + " " + p.RotY + " " + p.RotZ);
                w.WriteLine(i + " tex " + p.TexX + " " + p.TexY);
                w.WriteLine(i + " alpha " + p.AlphaTest);
                w.WriteLine(i + " rotated " + p.Rotated);
                if (p.XAnim != "")
                {
                    w.WriteLine(i + " xanim " + p.XAnim);
                }
                if (p.YAnim != "")
                {
                    w.WriteLine(i + " yanim " + p.YAnim);
                }
                if (p.ZAnim != "")
                {
                    w.WriteLine(i + " zanim " + p.ZAnim);
                }
                w.WriteLine();
            }
            w.Close();
        }
Esempio n. 2
0
        protected override void DrawPlayerModel(Player p)
        {
            Gfx.Texturing = true;
            Gfx.BindTexture(texId);

            for (int i = 0; i < RawParts.Count; i++)
            {
                RawPart raw = RawParts[i];
                Gfx.AlphaTest = raw.AlphaTest;

                if (raw.Wireframe)
                {
                    GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
                }
                DrawRotate(p, raw, parts[i]);
                if (raw.Wireframe)
                {
                    GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
                }
            }

            /*
             * DrawRotate( 0, 24/16f, 0, -p.PitchRadians, 0, 0, model.Head );
             * DrawPart( model.Torso );
             * DrawRotate( 0, 12/16f, 0, p.leftLegXRot, 0, 0, model.LeftLeg );
             * DrawRotate( 0, 12/16f, 0, p.rightLegXRot, 0, 0, model.RightLeg );
             * DrawRotate( -6/16f, 22/16f, 0, p.leftArmXRot, 0, p.leftArmZRot, model.LeftArm );
             * DrawRotate( 6/16f, 22/16f, 0, p.rightArmXRot, 0, p.rightArmZRot, model.RightArm );
             *
             * Gfx.AlphaTest = true;
             * DrawRotate( 0, 24f/16f, 0, -p.PitchRadians, 0, 0, model.Hat );
             */
        }
Esempio n. 3
0
        void LbModelsSelectedIndexChanged(object sender, System.EventArgs e)
        {
            cur = null;
            if (lbModels.SelectedIndex == -1)
            {
                return;
            }
            RawPart p = parts[lbModels.SelectedIndex];

            numP1_X.Value = p.X1;   numP1_Y.Value = p.Y1;   numP1_Z.Value = p.Z1;
            numP2_X.Value = p.X2;   numP2_Y.Value = p.Y2;   numP2_Z.Value = p.Z2;
            numRotX.Value = p.RotX; numRotY.Value = p.RotY; numRotZ.Value = p.RotZ;

            numTexX.Value = p.TexX; numTexY.Value = p.TexY;

            txtName.Text  = p.Name;
            txtXAnim.Text = p.XAnim;
            txtYAnim.Text = p.YAnim;
            txtZAnim.Text = p.ZAnim;

            cbWireframe.Checked    = p.Wireframe;
            cbAlphaTesting.Checked = p.AlphaTest;
            cbRotate.Checked       = p.Rotated;
            cbAxisLines.Checked    = p.AxisLines;

            cur = p;
        }
Esempio n. 4
0
        void BtnAddClick(object sender, EventArgs e)
        {
            RawPart part = new RawPart();

            part.Name = "Part #" + (parts.Count + 1);
            parts.Add(part);
            lbModels.Items.Add(part.Name);
            RebuildModel();
        }
Esempio n. 5
0
        protected void DrawRotate(Player p, RawPart raw, ModelPart part)
        {
            GL.Begin(BeginMode.Quads);
            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex model = vertices[part.Offset + i];
                Vector3     pos   = RotatePoint(p, raw, new Vector3(model.X, model.Y, model.Z));

                float vScale = _64x64 ? 64f : 32f;
                GL.TexCoord2((float)model.U / 64f, (float)model.V / vScale);
                GL.Vertex3(pos);
            }
            GL.End();
        }
Esempio n. 6
0
        public Vector3 RotatePoint(Player p, RawPart raw, Vector3 pos)
        {
            float angleX = ModelAnim.Animate(p, raw.XAnim);
            float angleY = ModelAnim.Animate(p, raw.YAnim);
            float angleZ = ModelAnim.Animate(p, raw.ZAnim);

            float cosX = (float)Math.Cos(-angleX), sinX = (float)Math.Sin(-angleX);
            float cosY = (float)Math.Cos(-angleY), sinY = (float)Math.Sin(-angleY);
            float cosZ = (float)Math.Cos(-angleZ), sinZ = (float)Math.Sin(-angleZ);
            float x = raw.RotX / 16f, y = raw.RotY / 16f, z = raw.RotZ / 16f;

            Vector3 loc = new Vector3(pos.X - x, pos.Y - y, pos.Z - z);

            loc = Utils.RotateZ(loc.X, loc.Y, loc.Z, cosZ, sinZ);
            loc = Utils.RotateY(loc.X, loc.Y, loc.Z, cosY, sinY);
            loc = Utils.RotateX(loc.X, loc.Y, loc.Z, cosX, sinX);

            return(Utils.RotateY(loc.X + x, loc.Y + y, loc.Z + z, cosA, sinA) + this.pos);
        }
Esempio n. 7
0
        public static List <RawPart> Import(Stream stream)
        {
            StreamReader   r = new StreamReader(stream);
            string         line;
            List <RawPart> parts = new List <RawPart>();

            while ((line = r.ReadLine()) != null)
            {
                line = line.Trim();
                if (line.Length == 0 || line[0] == '#')
                {
                    continue;
                }
                string[] bits = Split(line);

                int i = int.Parse(bits[0]);
                if (i >= parts.Count)
                {
                    parts.Add(new RawPart());
                }
                RawPart part = parts[i];

                string type = bits[1].ToLower(), value = bits[2];
                if (type == "name")
                {
                    part.Name = value;
                }
                else if (type == "xanim")
                {
                    part.XAnim = value;
                }
                else if (type == "yanim")
                {
                    part.YAnim = value;
                }
                else if (type == "zanim")
                {
                    part.ZAnim = value;
                }
                else if (type == "p1")
                {
                    int[] xyz = SplitXYZ(value);
                    part.X1 = xyz[0]; part.Y1 = xyz[1]; part.Z1 = xyz[2];
                }
                else if (type == "p2")
                {
                    int[] xyz = SplitXYZ(value);
                    part.X2 = xyz[0]; part.Y2 = xyz[1]; part.Z2 = xyz[2];
                }
                else if (type == "rot")
                {
                    int[] xyz = SplitXYZ(value);
                    part.RotX = xyz[0]; part.RotY = xyz[1]; part.RotZ = xyz[2];
                }
                else if (type == "tex")
                {
                    string[] xy = Split(value);
                    part.TexX = int.Parse(xy[0]); part.TexY = int.Parse(xy[1]);
                }
                else if (type == "alpha")
                {
                    part.AlphaTest = bool.Parse(value);
                }
                else if (type == "rotated")
                {
                    part.Rotated = bool.Parse(value);
                }
            }
            return(parts);
        }