コード例 #1
0
ファイル: V-Modifier.cs プロジェクト: NaTure77/CubeWorld
        public void FollowObject(Object o, XYZ_d target, double speed)
        {
            XYZ_d vector = new XYZ_d(target).Sub(o.Position);

            vector.Div(vector.Length()).Mul(speed);
            MoveObject(o, vector);
        }
コード例 #2
0
ファイル: V-Modifier.cs プロジェクト: NaTure77/CubeWorld
        public void SpinObject(Object o, XYZ_d degree, Matrix matrix)
        {
            XYZ_d next  = new XYZ_d();
            XYZ_d delta = new XYZ_d(0, 0, o.size.z - 1);
            XYZ_d axis  = new XYZ_d(o.axis);
            Pixel p     = null;

            matrix(axis, degree);
            matrix(delta, degree);
            delta.Div(o.size.z);

            for (int i = 0; i < o.size.x; i++)
            {
                for (int j = 0; j < o.size.y; j++)
                {
                    p = null;
                    int temp = -1;
                    while (p == null && temp < o.size.z)
                    {
                        temp++;
                        p = o.GetPixel(i, j, temp);
                    }
                    if (p == null)
                    {
                        continue;
                    }
                    next.Set(i, j, 0);
                    matrix(next, degree);
                    for (int k = temp; k < o.size.z; k++)
                    {
                        p = o.GetPixel(i, j, k);
                        if (p == null)
                        {
                            continue;
                        }
                        if (world.GetPixel(p.Position) == p)
                        {
                            world.ReSetPixel(p);
                        }
                        p.Position.Set(delta).Mul(k + 1).Add(next).Sub(axis).Add(o.Position);
                        world.SetPixel(p);
                    }
                }
            }
            DrawObject(o);
        }
コード例 #3
0
ファイル: V-Controller.cs プロジェクト: NaTure77/CubeWorld
        public void Falling()
        {
            Vector.z += 4;
            if (!Check_Wall(Vector))
            {
                Position.Add(Vector);
                world.ConvertToInfinity(Position);
            }
            else if (Vector.Length() != 0)
            {
                XYZ index = new XYZ();
                world.GetFrameIndex(new XYZ_d(Position).Add(Vector), index);

                double vLength = Vector.Length();
                if (vLength > 90)
                {
                    // if(world.IsInFrame(index))
                    //   CrushFrame((int)(vLength / 4));
                    Vector.Div(4);
                    return;
                }
                else
                {
                    isJumpable = true;
                }

                world.ConvertIndexToPosition(index);
                if (Vector.z > 0)
                {
                    Position.z = index.z - world.frameLength / 2 - 1;
                }
                else
                {
                    Position.z = index.z + world.frameLength / 2 + 4;
                    isJumpable = false;
                }
                Vector.Set(0);
            }
        }
コード例 #4
0
ファイル: V-World.cs プロジェクト: NaTure77/CubeWorld
        public void MakeCone(XYZ_d pos, int radius, int height)
        {
            XYZ    frameIndex = new XYZ();
            XYZ_d  temp       = new XYZ_d();
            XYZ_d  temp2      = new XYZ_d();
            XYZ_d  temp3      = new XYZ_d();
            double distance   = 0;

            pos.z += height;
            XYZ_b color  = new XYZ_b(1, 1, 1);
            XYZ_b color2 = new XYZ_b(color).Mul(30);

            double degreeX = 30 * -Math.PI / 180d;
            double degreeY = 0 * Math.PI / 180d;
            double sinX    = Math.Sin(degreeX);
            double sinY    = Math.Sin(degreeY);
            double cosX    = Math.Cos(degreeX);
            double cosY    = Math.Cos(degreeY);
            XYZ_d  basisX  = new XYZ_d(cosY, -sinY, 0);
            XYZ_d  basisY  = new XYZ_d(cosX * sinY, cosX * cosY, -sinX);
            XYZ_d  basisZ  = new XYZ_d(sinX * sinY, sinX * cosY, cosX);

            for (int i = -radius - 1; i < radius + 1; i++)
            {
                for (int j = -radius - 1; j < radius + 1; j++)
                {
                    for (int k = -height - 1; k < -height / 2 + 1; k++)
                    {
                        temp.Set(pos).Add(i, j, k);
                        frameIndex = temp.ToXYZ();
                        ConvertToInfinity(frameIndex);
                        SetBlock(frameIndex, true);
                        SetColor(frameIndex, 0, 0, 0);
                        SetRender(frameIndex, renderer_block);
                        //SetColor(frameIndex,1,0,0);
                    }
                }
            }

            for (int i = -radius; i < radius; i++)
            {
                for (int j = -radius; j < radius; j++)
                {
                    for (int k = -height; k < -height / 2; k++)
                    {
                        temp.Set(pos).Add(i, j, k);
                        frameIndex = temp.ToXYZ();
                        ConvertToInfinity(frameIndex);
                        SetBlock(frameIndex, false);
                        SetRender(frameIndex, renderer_air);
                        //SetColor(frameIndex,1,0,0);
                    }
                }
            }
            //frameIndex = pos.ToXYZ();
            //ConvertToInfinity(frameIndex);
            //frameIndex.z -= height - 10;

            temp.Set(pos).Sub(0, 10, height - 10);
            for (int i = -2; i <= 2; i++)
            {
                for (int j = -2; j <= 2; j++)
                {
                    for (int k = -2; k <= 2; k++)
                    {
                        temp2.Set(temp).Add(i, j, k);
                        frameIndex = temp2.ToXYZ();
                        ConvertToInfinity(frameIndex);
                        SetBlock(frameIndex, true);
                        SetRender(frameIndex, renderer_block);
                    }
                }
            }

            for (int i = -radius; i < radius; i++)
            {
                for (int j = -radius; j < radius; j++)
                {
                    temp.Set(pos).Add(i, j, 0);
                    distance = pos.Distance(temp);
                    if (distance < radius)
                    {
                        frameIndex = temp.ToXYZ();
                        ConvertToInfinity(frameIndex);
                        //SetColor(frameIndex,color);

                        temp2.Set(temp).Sub(pos).Add(0, 0, height).Div(height);
                        temp2.Set(basisX.x * temp2.x + basisY.x * temp2.y + basisZ.x * temp2.z,
                                  basisX.y * temp2.x + basisY.y * temp2.y + basisZ.y * temp2.z,
                                  basisX.z * temp2.x + basisY.z * temp2.y + basisZ.z * temp2.z);
                        temp2.Div(temp2.Length());
                        //temp2.Set(temp3);
                        temp.Set(pos).Add(0, 0, -height);

                        /*******************************************************************************/

                        /*  frameIndex = temp.ToXYZ();
                         * XYZ deltaSign = new XYZ(Math.Sign(temp2.x),Math.Sign(temp2.y),Math.Sign(temp2.z));
                         * int nextDir = 0;
                         * XYZ_d maxNumOfDelta = new XYZ_d(frameLength).Mul(deltaSign).Div(temp2);
                         * XYZ_d target = new XYZ_d(halfFrameLength);
                         * target.Mul(deltaSign);//delta벡터 방향으로 이동시 접촉가능한 경계면들 구하기.
                         * target.Div(temp2);
                         */
                        //XYZ gap = new XYZ(frameIndex);

                        //color.Set(2,2,2);
                        //byte code = 0;
                        for (int k = 0; k < height * 1.5f; k++)
                        {
                            temp.Add(temp2);
                            frameIndex = temp.ToXYZ();

                            /* if (target.x < target.y)
                             *      if(target.x < target.z) nextDir = 0;
                             *      else nextDir = 2;
                             * else
                             *      if(target.y < target.z) nextDir = 1;
                             *      else nextDir = 2; */

                            //target.element[nextDir] += maxNumOfDelta.element[nextDir];
                            //frameIndex.element[nextDir] += deltaSign.element[nextDir];
                            ConvertToInfinity(frameIndex);
                            if (isFrameEnabled(frameIndex))
                            {
                                AddColor(frameIndex, color2);
                                break;
                            }
                            else
                            {
                                AddColor(frameIndex, color);
                            }
                            //SetBlock(frameIndex,code);

                            //gap.Set(frameIndex);

                            //Console.WriteLine(nextDir);
                        }
                    }
                }
            }
        }