Example #1
0
        // type 4, 4 point poly processor
        private void type4(String[] data, bool inverted)
        {
            // Create and initalize values.
            int         color;
            int         pd1, pd2, pd3, pd4;
            Vector3     p1, p2, p3, p4;
            LdrawMatrix top = (LdrawMatrix)matrices.Peek();

            p1 = new Vector3(Double.Parse(data[2]), Double.Parse(data[3]), Double.Parse(data[4]));
            p2 = new Vector3(Double.Parse(data[5]), Double.Parse(data[6]), Double.Parse(data[7]));
            p3 = new Vector3(Double.Parse(data[8]), Double.Parse(data[9]), Double.Parse(data[10]));
            p4 = new Vector3(Double.Parse(data[11]), Double.Parse(data[12]), Double.Parse(data[13]));

            // Get color to proper format
            color = Int32.Parse(data[1]);
            // Is color "previous color"? If so, use it.
            if (color == 16 || color == 24)
            {
                color = top.color;
            }

            // Done! Now transform it into current coorditate system
            p1 = top.transformPoint(p1);
            p2 = top.transformPoint(p2);
            p3 = top.transformPoint(p3);
            p4 = top.transformPoint(p4);

            // now save points into list.
            pd1 = PM.addOrNearest(p1);
            pd2 = PM.addOrNearest(p2);
            pd3 = PM.addOrNearest(p3);
            pd4 = PM.addOrNearest(p4);

            // order of points?
            if (!inverted)
            {
                polylist.Add(new PolyShape(4, color, linecount, stepcount, pd1, pd2, pd3, pd4));
            }
            else
            {
                polylist.Add(new PolyShape(4, color, linecount, stepcount, pd1, pd4, pd3, pd2));
            }

            //Debug.WriteLine("polylist added one - TYPE 4");
        }
Example #2
0
        private void addStack(int color, double x, double y, double z, double a, double b,
                              double c, double d, double e, double f, double g, double h,
                              double i)
        {
            // Create a new stack with those paramaters.
            LdrawMatrix newone = new LdrawMatrix(color, x, y, z, a, b, c, d, e, f, g, h, i);

            if (matrices.Count != 0)
            {
                double  aa, bb, cc, dd, ee, ff, gg, hh, ii;
                Vector3 p = new Vector3(x, y, z);

                LdrawMatrix top = (LdrawMatrix)matrices.Peek();

                // Trandform matrix to last coordate system
                // Creating new matrix that does both transformations in one step.

                aa = (top.a * newone.a) + (top.b * newone.d) + (top.c * newone.g);
                dd = (top.d * newone.a) + (top.e * newone.d) + (top.f * newone.g);
                gg = (top.g * newone.a) + (top.h * newone.d) + (top.i * newone.g);

                bb = (top.a * newone.b) + (top.b * newone.e) + (top.c * newone.h);
                ee = (top.d * newone.b) + (top.e * newone.e) + (top.f * newone.h);
                hh = (top.g * newone.b) + (top.h * newone.e) + (top.i * newone.h);

                cc = (top.a * newone.c) + (top.b * newone.f) + (top.c * newone.i);
                ff = (top.d * newone.c) + (top.e * newone.f) + (top.f * newone.i);
                ii = (top.g * newone.c) + (top.h * newone.f) + (top.i * newone.i);

                //Now transform point into stack current coord...
                p = top.transformPoint(p);

                // All finished. Now fill in results into matrix then push it in.
                newone.x = p.X;
                newone.y = p.Y;
                newone.z = p.Z;
                newone.a = aa;
                newone.b = bb;
                newone.c = cc;
                newone.d = dd;
                newone.e = ee;
                newone.f = ff;
                newone.g = gg;
                newone.h = hh;
                newone.i = ii;
                matrices.Push(newone);
            }
        }