Esempio n. 1
0
        public override List <RenderInfo> Render(SETItem item, Device dev, EditorCamera camera, MatrixStack transform)
        {
            List <RenderInfo> result = new List <RenderInfo>();

            for (int i = 0; i < Math.Min(item.Scale.X + 1, 8); i++)
            {
                transform.Push();
                if (item.Scale.Z == 1)                 // circle
                {
                    double  v4 = i * 360.0;
                    Vector3 v7 = new Vector3(
                        ObjectHelper.ConvertBAMS((int)(v4 / item.Scale.X * 65536.0 * 0.002777777777777778)) * item.Scale.Y,
                        0,
                        ObjectHelper.ConvertBAMSInv((int)(v4 / item.Scale.X * 65536.0 * 0.002777777777777778)) * item.Scale.Y);
                    transform.Push();
                    transform.NJTranslate(item.Position);
                    transform.NJRotateObject(item.Rotation);
                    Vector3 pos = Vector3.TransformCoordinate(v7, transform.Top);
                    transform.Pop();
                    transform.NJTranslate(pos);
                    result.AddRange(model.DrawModelTree(dev, transform, ObjectHelper.GetTextures("OBJ_REGULAR"), meshes));
                    if (item.Selected)
                    {
                        result.AddRange(model.DrawModelTreeInvert(transform, meshes));
                    }
                }
                else                 // line
                {
                    transform.Push();
                    transform.NJTranslate(item.Position);
                    transform.NJRotateObject(item.Rotation);
                    double v5;
                    if (i % 2 == 1)
                    {
                        v5 = i * item.Scale.Y * -0.5;
                    }
                    else
                    {
                        v5 = Math.Ceiling(i * 0.5) * item.Scale.Y;
                    }
                    Vector3 pos = Vector3.TransformCoordinate(new Vector3(0, 0, (float)v5), transform.Top);
                    transform.Pop();
                    transform.NJTranslate(pos);
                    result.AddRange(model.DrawModelTree(dev, transform, ObjectHelper.GetTextures("OBJ_REGULAR"), meshes));
                    if (item.Selected)
                    {
                        result.AddRange(model.DrawModelTreeInvert(transform, meshes));
                    }
                }
                transform.Pop();
            }
            return(result);
        }
Esempio n. 2
0
        public override HitResult CheckHit(SETItem item, Vector3 Near, Vector3 Far, Viewport Viewport, Matrix Projection, Matrix View, MatrixStack transform)
        {
            HitResult result = HitResult.NoHit;

            for (int i = 0; i < Math.Min(item.Scale.X + 1, 8); i++)
            {
                transform.Push();
                if (item.Scale.Z == 1)                 // circle
                {
                    double  v4 = i * 360.0;
                    Vector3 v7 = new Vector3(
                        ObjectHelper.ConvertBAMS((int)(v4 / item.Scale.X * 65536.0 * 0.002777777777777778)) * item.Scale.Y,
                        0,
                        ObjectHelper.ConvertBAMSInv((int)(v4 / item.Scale.X * 65536.0 * 0.002777777777777778)) * item.Scale.Y);
                    transform.Push();
                    transform.NJTranslate(item.Position);
                    transform.NJRotateObject(item.Rotation);
                    Vector3 pos = Vector3.TransformCoordinate(v7, transform.Top);
                    transform.Pop();
                    transform.NJTranslate(pos);
                    result = HitResult.Min(result, model.CheckHit(Near, Far, Viewport, Projection, View, transform, meshes));
                }
                else                 // line
                {
                    transform.Push();
                    transform.NJTranslate(item.Position);
                    transform.NJRotateObject(item.Rotation);
                    double v5;
                    if (i % 2 == 1)
                    {
                        v5 = i * item.Scale.Y * -0.5;
                    }
                    else
                    {
                        v5 = Math.Ceiling(i * 0.5) * item.Scale.Y;
                    }
                    Vector3 pos = Vector3.TransformCoordinate(new Vector3(0, 0, (float)v5), transform.Top);
                    transform.Pop();
                    transform.NJTranslate(pos);
                    result = HitResult.Min(result, model.CheckHit(Near, Far, Viewport, Projection, View, transform, meshes));
                }
                transform.Pop();
            }
            return(result);
        }
Esempio n. 3
0
        public override BoundingSphere GetBounds(SETItem item)
        {
            MatrixStack    transform = new MatrixStack();
            BoundingSphere result    = new BoundingSphere();

            for (int i = 0; i < Math.Min(item.Scale.X + 1, 8); i++)
            {
                transform.Push();
                if (item.Scale.Z == 1)                 // circle
                {
                    double  v4 = i * 360.0;
                    Vector3 v7 = new Vector3(
                        ObjectHelper.ConvertBAMS((int)(v4 / item.Scale.X * 65536.0 * 0.002777777777777778)) * item.Scale.Y,
                        0,
                        ObjectHelper.ConvertBAMSInv((int)(v4 / item.Scale.X * 65536.0 * 0.002777777777777778)) * item.Scale.Y);
                    transform.Push();
                    transform.NJTranslate(item.Position);
                    transform.NJRotateObject(item.Rotation);
                    Vector3 pos = Vector3.TransformCoordinate(v7, transform.Top);
                    transform.Pop();
                    transform.NJTranslate(pos);
                }
                else                 // line
                {
                    transform.Push();
                    transform.NJTranslate(item.Position);
                    transform.NJRotateObject(item.Rotation);
                    double v5;
                    if (i % 2 == 1)
                    {
                        v5 = i * item.Scale.Y * -0.5;
                    }
                    else
                    {
                        v5 = Math.Ceiling(i * 0.5) * item.Scale.Y;
                    }
                    Vector3 pos = Vector3.TransformCoordinate(new Vector3(0, 0, (float)v5), transform.Top);
                    transform.Pop();
                    transform.NJTranslate(pos);
                }
                result = SonicRetro.SAModel.Direct3D.Extensions.Merge(result, ObjectHelper.GetModelBounds(model, transform));
                transform.Pop();
            }
            return(result);
        }