Пример #1
0
        private bool OpTeapot()
        {
            PCObj mul;
            PCObj res;

            try
            {
                mul = Stack.Pop();
            }
            catch (InvalidOperationException)
            {
                throw new PCEmptyStackException();
            }
            if (!(mul is PCVector3))
            {
                Stack.Push(mul);
                throw new PCTypeCheckException();
            }
            try
            {
                res = Stack.Pop();
            }
            catch (InvalidOperationException)
            {
                throw new PCEmptyStackException();
            }
            if (!(res is PCVector2))
            {
                Stack.Push(res);
                throw new PCTypeCheckException();
            }

            int npatch = 32;
            int ru = (int)((PCVector2)res).val.X;
            int rv = (int)((PCVector2)res).val.Y;
            int i, j, p;
            PCArray lines;

            lines = new PCArray();
            for (p = 0; p < npatch; p++)
            {
                Vector3[,] r = GenPatch(p, ru, rv, ((PCVector3)mul).val);
                PCArray patch = new PCArray();
                for (i = 0; i <= ru; i++)
                {
                    PCArray line = new PCArray();
                    for (j = 0; j <= rv; j++)
                    {
                        Vector3 v = r[i, j];
                        line.Add(new PCVector3(v));
                    }
                    patch.Add(line);
                }
                lines.Add(patch);
            }
            Stack.Push(lines);

            lines = new PCArray();
            for (p = 0; p < npatch; p++)
            {
                Vector3[,] r = GenPatch(p, ru, rv, ((PCVector3)mul).val);
                PCArray patch = new PCArray();
                for (j = 0; j <= rv; j++)
                {
                    PCArray line = new PCArray();
                    for (i = 0; i <= ru; i++)
                    {
                        Vector3 v = r[i, j];
                        line.Add(new PCVector3(v));
                    }
                    patch.Add(line);
                }
                lines.Add(patch);
            }
            Stack.Push(lines);

            PCArray vertex = new PCArray();
            for (p = 0; p < npatch; p++)
            {
                Vector3[] vs = GenVertex(p, ru, rv, ((PCVector3)mul).val);
                PCArray patch = new PCArray();
                foreach (Vector3 v in vs)
                {
                    patch.Add(new PCVector3(v));
                }
                vertex.Add(patch);
            }
            Stack.Push(vertex);
            return true;
        }
Пример #2
0
        private bool OpLoadScene()
        {
            PCArray o = new PCArray();

            foreach (PCSceneObjectPart part in m_shownSceneObjectPart)
            {
                o.Add(part);
            }
            Stack.Push(o);
            return true;
        }
Пример #3
0
        private bool OpLoadSnapshot()
        {
            PCObj snapshot;

            try
            {
                snapshot = Stack.Pop();
            }
            catch (InvalidOperationException)
            {
                throw new PCEmptyStackException();
            }
            if (!(snapshot is PCSceneSnapshot))
            {
                Stack.Push(snapshot);
                throw new PCTypeCheckException();
            }

            PCArray o = new PCArray();
            foreach (PCSceneSnapshot.SnapshotItem item in ((PCSceneSnapshot)snapshot).val)
            {
                o.Add(item.PCSceneObjectPart);
            }
            Stack.Push(o);
            return true;
        }
Пример #4
0
        private bool OpBanner()
        {
            PCObj pt;
            PCObj str;

            try
            {
                pt = Stack.Pop();
            }
            catch (InvalidOperationException)
            {
                throw new PCEmptyStackException();
            }
            if (!(pt is PCVector2))
            {
                Stack.Push(pt);
                throw new PCTypeCheckException();
            }
            try
            {
                str = Stack.Pop();
            }
            catch (InvalidOperationException)
            {
                throw new PCEmptyStackException();
            }
            if (!(str is PCStr))
            {
                Stack.Push(str);
                throw new PCTypeCheckException();
            }
            PCArray glyphs = new PCArray();
            float ptx = ((PCVector2)pt).val.X;
            float pty = ((PCVector2)pt).val.Y;
            float cursor = 0f;

            foreach (char ch in ((PCStr)str).val)
            {
                PCArray glyph = new PCArray();

                foreach (PCObj o in m_banner[Convert.ToInt32(ch)].val)
                {
                    float x = ((PCVector2)o).val.X * ptx / m_banner_width;
                    float y = ((PCVector2)o).val.Y * pty / m_banner_height;
                    glyph.Add(new PCVector3(x + cursor, y, 0));
                }
                glyphs.Add(glyph);
                cursor += ptx;
            }
            Stack.Push(glyphs);
            return true;
        }