Example #1
0
 public override void Init(ObjectData data, string name)
 {
     mesh     = Mesh.Box(1f, 1f, 1f);
     material = new NJS_MATERIAL
     {
         DiffuseColor = Color.FromArgb(180, 180, 180, 180),
         UseAlpha     = true
     };
 }
Example #2
0
 public override void Init(ObjectData data, string name)
 {
     mesh     = Mesh.Box(0.5f, 0.5f, 0.5f);
     material = new NJS_MATERIAL
     {
         DiffuseColor = Color.FromArgb(127, 178, 178, 178),
         UseAlpha     = false
     };
 }
Example #3
0
        public static void Init()
        {
            VolumeMesh = Mesh.Box(2f, 2f, 2f);
            Material   = new NJS_MATERIAL
            {
                DiffuseColor   = Color.FromArgb(200, Color.Purple),
                SpecularColor  = Color.Black,
                UseAlpha       = true,
                DoubleSided    = false,
                Exponent       = 10,
                IgnoreSpecular = false,
                UseTexture     = false
            };

            pointHelperA = new PointHelper {
                BoxTexture = Gizmo.ATexture, DrawCube = true
            };
            pointHelperB = new PointHelper {
                BoxTexture = Gizmo.BTexture, DrawCube = true
            };
        }
Example #4
0
        public override List <RenderInfo> Render(Device dev, EditorCamera camera, MatrixStack transform)
        {
            if (!camera.SphereInFrustum(Bounds))
            {
                return(EmptyRenderInfo);
            }

            List <RenderInfo> result = new List <RenderInfo>();

            transform.Push();
            transform.NJTranslate(Position);
            transform.NJRotateY(Rotation.Y);

            switch (CollisionType)
            {
            case (SADXCamColType.CamCol_Sphere):
                VolumeMesh = Mesh.Sphere(2f, 6, 8);
                Material   = new NJS_MATERIAL
                {
                    DiffuseColor   = Color.FromArgb(200, Color.Blue),
                    SpecularColor  = Color.Black,
                    UseAlpha       = true,
                    DoubleSided    = false,
                    Exponent       = 10,
                    IgnoreSpecular = false,
                    UseTexture     = false
                };
                transform.NJScale((Scale.X), (Scale.X), (Scale.X));
                break;

            case (SADXCamColType.CamCol_Plane):
                VolumeMesh = Mesh.Box(2f, 2f, 0f);
                Material   = new NJS_MATERIAL
                {
                    DiffuseColor   = Color.FromArgb(200, Color.Green),
                    SpecularColor  = Color.Black,
                    UseAlpha       = true,
                    DoubleSided    = false,
                    Exponent       = 10,
                    IgnoreSpecular = false,
                    UseTexture     = false
                };
                transform.NJScale((Scale.X), (Scale.Y), (1f));
                break;

            case (SADXCamColType.CamCol_Block):
                VolumeMesh = Mesh.Box(2f, 2f, 2f);
                Material   = new NJS_MATERIAL
                {
                    DiffuseColor   = Color.FromArgb(200, Color.Purple),
                    SpecularColor  = Color.Black,
                    UseAlpha       = true,
                    DoubleSided    = false,
                    Exponent       = 10,
                    IgnoreSpecular = false,
                    UseTexture     = false
                };
                transform.NJScale((Scale.X), (Scale.Y), (Scale.Z));
                break;

            default:
                VolumeMesh = Mesh.Sphere(2f, 6, 8);
                Material   = new NJS_MATERIAL
                {
                    DiffuseColor   = Color.FromArgb(200, Color.Blue),
                    SpecularColor  = Color.Black,
                    UseAlpha       = true,
                    DoubleSided    = false,
                    Exponent       = 10,
                    IgnoreSpecular = false,
                    UseTexture     = false
                };
                transform.NJScale((Scale.X), (Scale.X), (Scale.X));
                break;
            }

            RenderInfo outputInfo = new RenderInfo(VolumeMesh, 0, transform.Top, Material, null, FillMode.Solid, Bounds);

            if (Selected)
            {
                NJS_MATERIAL mat = new NJS_MATERIAL
                {
                    DiffuseColor   = Color.White,
                    IgnoreLighting = true,
                    UseAlpha       = false
                };
                result.Add(new RenderInfo(VolumeMesh, 0, transform.Top, mat, null, FillMode.Wireframe, Bounds));
            }

            result.Add(outputInfo);

            transform.Pop();
            return(result);
        }
Example #5
0
        public static void InitGizmo(Device d3dDevice)
        {
            Attach attach = new ModelFile(Resources.x_null).Model.Attach;

            attach.ProcessVertexData();
            XNullMesh = attach.CreateD3DMesh();

            attach = new ModelFile(Resources.y_null).Model.Attach;
            attach.ProcessVertexData();
            YNullMesh = attach.CreateD3DMesh();

            attach = new ModelFile(Resources.z_null).Model.Attach;
            attach.ProcessVertexData();
            ZNullMesh = attach.CreateD3DMesh();

            attach = new ModelFile(Resources.x_move).Model.Attach;
            attach.ProcessVertexData();
            XMoveMesh = attach.CreateD3DMesh();
            XMaterial = ((BasicAttach)attach).Material[0];

            attach = new ModelFile(Resources.y_move).Model.Attach;
            attach.ProcessVertexData();
            YMoveMesh = attach.CreateD3DMesh();
            YMaterial = ((BasicAttach)attach).Material[0];

            attach = new ModelFile(Resources.z_move).Model.Attach;
            attach.ProcessVertexData();
            ZMoveMesh = attach.CreateD3DMesh();
            ZMaterial = ((BasicAttach)attach).Material[0];

            attach = new ModelFile(Resources.xy_move).Model.Attach;
            attach.ProcessVertexData();
            XYMoveMesh         = attach.CreateD3DMesh();
            DoubleAxisMaterial = ((BasicAttach)attach).Material[0];

            attach = new ModelFile(Resources.zx_move).Model.Attach;
            attach.ProcessVertexData();
            ZXMoveMesh = attach.CreateD3DMesh();

            attach = new ModelFile(Resources.zy_move).Model.Attach;
            attach.ProcessVertexData();
            ZYMoveMesh = attach.CreateD3DMesh();

            attach = new ModelFile(Resources.x_rotation).Model.Attach;
            attach.ProcessVertexData();
            XRotateMesh = attach.CreateD3DMesh();

            attach = new ModelFile(Resources.y_rotation).Model.Attach;
            attach.ProcessVertexData();
            YRotateMesh = attach.CreateD3DMesh();

            attach = new ModelFile(Resources.z_rotation).Model.Attach;
            attach.ProcessVertexData();
            ZRotateMesh = attach.CreateD3DMesh();

            attach = new ModelFile(Resources.x_scale).Model.Attach;
            attach.ProcessVertexData();
            XScaleMesh = attach.CreateD3DMesh();

            attach = new ModelFile(Resources.y_scale).Model.Attach;
            attach.ProcessVertexData();
            YScaleMesh = attach.CreateD3DMesh();

            attach = new ModelFile(Resources.z_scale).Model.Attach;
            attach.ProcessVertexData();
            ZScaleMesh = attach.CreateD3DMesh();

            BoxMesh = Mesh.Box(1, 1, 1);

            HighlightMaterial = new NJS_MATERIAL()
            {
                DiffuseColor = Color.LightGoldenrodYellow, Exponent = 0f, UseTexture = false, IgnoreLighting = true, IgnoreSpecular = true
            };

            ATexture         = Resources.PointATexture.ToTexture(d3dDevice);
            BTexture         = Resources.PointBTexture.ToTexture(d3dDevice);
            StandardMaterial = new NJS_MATERIAL()
            {
                DiffuseColor = Color.Gray, IgnoreLighting = true, IgnoreSpecular = true, UseAlpha = false, UseTexture = true, Exponent = 100f
            };
        }
Example #6
0
        public void RebuildMesh(Device device)
        {
            List <FVF_PositionColored> vertList = new List <FVF_PositionColored>();
            List <short> faceIndexList          = new List <short>();

            Vector3 up = new Vector3(0, 1, 0);

            #region Segment vert/face creation
            short highestFaceIndex = 0;

            for (int i = 0; i < splineData.Path.Count - 1; i++)             // don't process the last knot
            {
                Vector3 thisKnot = new Vector3(splineData.Path[i].Position.X, splineData.Path[i].Position.Y, splineData.Path[i].Position.Z);
                Vector3 nextKnot = new Vector3(splineData.Path[i + 1].Position.X, splineData.Path[i + 1].Position.Y, splineData.Path[i + 1].Position.Z);

                Vector3 directionToNextKnot    = Vector3.Normalize(nextKnot - thisKnot);
                Vector3 perpendicularDirection = Vector3.Cross(directionToNextKnot, up);

                // verts for knot 1
                FVF_PositionColored vert1_1;                 // top vert 1 (0)
                FVF_PositionColored vert1_2;                 // top vert 2 (1)
                FVF_PositionColored vert1_3;                 // bottom vert 1 (2)
                FVF_PositionColored vert1_4;                 // bottom vert 2 (3)

                // verts for knot 2
                FVF_PositionColored vert2_1;                 // top vert 1 (4)
                FVF_PositionColored vert2_2;                 // top vert 2 (5)
                FVF_PositionColored vert2_3;                 // bottom vert 1 (6)
                FVF_PositionColored vert2_4;                 // bottom vert 2 (7)

                // move top verts
                vert1_1 = new FVF_PositionColored((thisKnot + (perpendicularDirection * splineMeshRadius)), Color.White);
                vert1_2 = new FVF_PositionColored((thisKnot + (perpendicularDirection * (splineMeshRadius * -1))), Color.White);

                vert2_1 = new FVF_PositionColored((nextKnot + (perpendicularDirection * splineMeshRadius)), Color.White);
                vert2_2 = new FVF_PositionColored((nextKnot + (perpendicularDirection * (splineMeshRadius * -1))), Color.White);

                // move bottom verts
                vert1_3 = new FVF_PositionColored(vert1_1.Position - (up * splineMeshRadius), Color.White);
                vert1_4 = new FVF_PositionColored(vert1_2.Position - (up * splineMeshRadius), Color.White);

                vert2_3 = new FVF_PositionColored(vert2_1.Position - (up * splineMeshRadius), Color.White);
                vert2_4 = new FVF_PositionColored(vert2_2.Position - (up * splineMeshRadius), Color.White);

                List <short> thisKnotFaceIndexes = new List <short>
                {
                    // far side
                    4, 0, 6,
                    6, 2, 0,

                    // bottom
                    6, 2, 3,
                    3, 7, 6,

                    // our side
                    7, 3, 1,
                    7, 5, 1,

                    // top
                    1, 5, 4,
                    4, 0, 1
                };

                for (int faceIndx = 0; faceIndx < thisKnotFaceIndexes.Count(); faceIndx++)
                {
                    thisKnotFaceIndexes[faceIndx] += (short)vertList.Count();                     // this is the wrong approach because it's the verts we're indexing, not the faces!
                    if (thisKnotFaceIndexes[faceIndx] > highestFaceIndex)
                    {
                        highestFaceIndex = thisKnotFaceIndexes[faceIndx];
                    }
                }

                // add verts to vert list and faces to face list
                vertList.Add(vert1_1);
                vertList.Add(vert1_2);
                vertList.Add(vert1_3);
                vertList.Add(vert1_4);
                vertList.Add(vert2_1);
                vertList.Add(vert2_2);
                vertList.Add(vert2_3);
                vertList.Add(vert2_4);

                faceIndexList.AddRange(thisKnotFaceIndexes);
            }
            #endregion

            vertices    = vertList.ToArray();
            faceIndeces = faceIndexList.ToArray();

            // build bounding sphere
            bounds = SharpDX.BoundingSphere.FromPoints(vertices.Select(a => a.Position).ToArray()).ToSAModel();

            // build actual mesh from face index array and vbuf
            mesh = new Mesh <FVF_PositionColored>(vertices, new short[][] { faceIndeces });

            // create a vertexHandle
            if (vertexHandleMesh == null)
            {
                vertexHandleMesh = Mesh.Box(1, 1, 1);
            }

            textSprite = new Sprite(device);             // todo: do we really have to create this so often? Look into storing a cache list statically?
        }