示例#1
0
        //public static Buffer<StudGridCell> StudGridBuffer { get; private set; }

        #endregion

        public static void InitializeResources()
        {
            ColorShader          = ProgramFactory.Create <ColorShaderProgram>();
            WireframeShader      = ProgramFactory.Create <WireframeShaderProgram>();
            ModelShader          = ProgramFactory.Create <ModelShaderProgram>();
            WireframeShader2     = ProgramFactory.Create <WireframeShader2Program>();
            StudConnectionShader = ProgramFactory.Create <StudConnectionShaderProgram>();
            SimpleTextureShader  = ProgramFactory.Create <SimpleTextureShaderProgram>();

            BoundingBoxBufffer = new IndexedVertexBuffer <Vector3>();
            var box = BBox.FromCenterSize(Vector3.Zero, Vector3.One);

            BoundingBoxBufffer.SetVertices(box.GetCorners());
            var bboxIndices = new List <int>();

            for (int i = 0; i < 4; i++)
            {
                bboxIndices.Add((i * 2));
                bboxIndices.Add((i * 2) + 1);
                bboxIndices.Add((i * 2));
                bboxIndices.Add(((i + 1) * 2) % 8);
                bboxIndices.Add((i * 2) + 1);
                bboxIndices.Add((((i + 1) * 2) + 1) % 8);
            }

            BoundingBoxBufffer.SetIndices(bboxIndices);

            //StudGridBuffer = new Buffer<StudGridCell>();


            CollisionMaterial = new MaterialInfo
            {
                Diffuse   = new Vector4(1f, 0.05f, 0.05f, 1f),
                Specular  = new Vector3(1f),
                Shininess = 2f
            };

            ConnectionMaterial = new MaterialInfo
            {
                Diffuse   = new Vector4(0.95f, 0.95f, 0.05f, 1f),
                Specular  = new Vector3(1f),
                Shininess = 2f
            };

            MaleConnectorMaterial = new MaterialInfo
            {
                Diffuse   = new Vector4(0.05f, 0.05f, 0.95f, 1f),
                Specular  = new Vector3(1f),
                Shininess = 2f
            };

            FemaleConnectorMaterial = new MaterialInfo
            {
                Diffuse   = new Vector4(0.05f, 0.95f, 0.05f, 1f),
                Specular  = new Vector3(1f),
                Shininess = 2f
            };

            WireframeColor        = new Vector4(0, 0, 0, 1f);
            WireframeColorAlt     = new Vector4(0.85f, 0.85f, 0.85f, 1f);
            SelectionOutlineColor = new Vector4(1f);
        }
示例#2
0
 public static void BeginDrawColorModel(IVertexBuffer vertexBuffer, Matrix4 transform, MaterialInfo material)
 {
     BeginDrawColor(vertexBuffer, transform, material.Diffuse);
 }
示例#3
0
 public static void BeginDrawModel(PartialModel model, Matrix4 transform, MaterialInfo material)
 {
     BeginDrawModel(model.VertexBuffer, transform, material);
 }
示例#4
0
        public static void BeginDrawModel(IVertexBuffer vertexBuffer, Matrix4 transform, MaterialInfo material)
        {
            ModelShader.Use();
            ModelShader.ModelMatrix.Set(transform);
            ModelShader.Material.Set(material);

            vertexBuffer.Bind();
            vertexBuffer.BindAttribute(ModelShader.Position, 0);
            vertexBuffer.BindAttribute(ModelShader.Normal, 12);
            vertexBuffer.BindAttribute(ModelShader.TexCoord, 24);
        }
示例#5
0
        private void RenderPartialMesh(MeshRenderMode renderMode, SurfaceModelMesh model, MaterialInfo material)
        {
            if (renderMode == MeshRenderMode.Wireframe && model.IsSelected)
            {
                //in wireframe mode, disable depth and color mask
                //but still write in stencil mask, this is needed for drawing the selection outline correctly
                GL.ColorMask(false, false, false, false);
                GL.DepthMask(false);
            }

            if (renderMode != MeshRenderMode.Wireframe || model.IsSelected)
            {
                DrawSolidModel(model, material);
            }

            if (model.IsSelected)
            {
                RenderHelper.DisableStencilMask();
            }

            if (renderMode == MeshRenderMode.Wireframe && model.IsSelected)
            {
                GL.ColorMask(true, true, true, true);
                GL.DepthMask(true);
            }

            if (renderMode == MeshRenderMode.Wireframe || renderMode == MeshRenderMode.SolidWireframe)
            {
                var wireColor = model.IsSelected && renderMode == MeshRenderMode.SolidWireframe ? RenderHelper.WireframeColorAlt : RenderHelper.WireframeColor;
                DrawWireframeModel(model, wireColor, 1f);
            }
        }