예제 #1
0
        //camera.PositionIndex
        public void CrushFrame(int scale, XYZ positionIndex)
        {
            XYZ temp = Vector.ToXYZ();

            temp.Div((int)(temp.Length() / (scale / 4 * 3)));
            XYZ brokePos = new XYZ(positionIndex).Sub(temp);
            XYZ lightPos = new XYZ(positionIndex);
            int maxScale = 60;

            if (scale > maxScale)
            {
                scale = maxScale;
            }
            int lightScale = scale + 2;
            XYZ color      = new XYZ(255 * scale / 30, 0, 0);
            XYZ gap        = new XYZ();

            for (int i = -lightScale; i < lightScale; i++)
            {
                for (int j = -lightScale; j < lightScale; j++)
                {
                    for (int k = -lightScale; k < lightScale; k++)
                    {
                        temp.Set(brokePos).Add(i, j, k);
                        world.ConvertToInfinity(temp);
                        //if (!world.IsInFrame(temp)) continue;
                        if (Math.Sqrt(i * i + j * j + k * k) < scale)
                        {
                            world.SetFrame(temp, false);
                        }
                        //double distance = lightPos.Distance(temp);
                        //if (distance < scale)
                        //{
                        //    XYZ_b c = world.GetColor(temp);
                        //    if (world.isFrameEnabled(temp))
                        //    {
                        //        gap.x = (int)color.x - (int)c.x;
                        //        gap.y = (int)color.y - (int)c.y;
                        //        gap.z = (int)color.z - (int)c.z;
                        //        gap.Mul((int)(maxScale - distance)).Div(maxScale);
                        //        c.x = (byte)(c.x + gap.x);
                        //        c.y = (byte)(c.y + gap.y);
                        //        c.z = (byte)(c.z + gap.z);
                        //    }
                        //}
                    }
                }
            }
        }
예제 #2
0
 public void GetFrameIndex(XYZ_d p, XYZ i)
 {
     i.Set(p.ToXYZ().Div(frameLength));
     //ConvertToInfinity(i);
 }
예제 #3
0
 public void GetFrameIndex(XYZ_d p, XYZ_d i)
 {
     i.Set(p.ToXYZ().Div(frameLength));
 }
예제 #4
0
        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);
                        }
                    }
                }
            }
        }