当前位置: 首页>>代码示例>>C#>>正文


C# OpenGL.Material方法代码示例

本文整理汇总了C#中SharpGL.OpenGL.Material方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.Material方法的具体用法?C# OpenGL.Material怎么用?C# OpenGL.Material使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SharpGL.OpenGL的用法示例。


在下文中一共展示了OpenGL.Material方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        public void Draw(OpenGL gl)
        {
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, TextureID);

            int[] amb_diff = { Colour.A, Colour.B, Colour.G, Colour.A };
            gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_AMBIENT_AND_DIFFUSE, amb_diff);

            gl.Begin(OpenGL.GL_TRIANGLES);

            for (int i = 0; i < 3; i++)
            {
                Position point = Verts[i].Point;
                UV uv = Verts[i].UV;

                if (uv != null)
                    gl.TexCoord(uv.U, uv.V);

                gl.Vertex(point.X, point.Y, point.Z);
            }

            gl.End();
            gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
        }
开发者ID:Kruithne,项目名称:W3DT,代码行数:23,代码来源:Face.cs

示例2: ApplyMaterial

        private void ApplyMaterial(Material mat, ref OpenGL gl)
        {
            if (mat.GetMaterialTextureCount(TextureType.Diffuse) > 0)
            {
                TextureSlot tex = new TextureSlot();
                mat.GetMaterialTexture(TextureType.Diffuse, 0, out tex);
                LoadModelAsset(tex.FilePath, ref gl);
            }

            Color4 color = new Color4(.8f, .8f, .8f, 1.0f);
            if (mat.HasColorDiffuse)
            {
                // color = FromColor(mat.ColorDiffuse);
            }
            var colorf = new float[4];
            color4_to_float4(color, colorf);
            gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_DIFFUSE, colorf);

            color = new Color4(0, 0, 0, 1.0f);
            if (mat.HasColorSpecular)
            {
                color = FromColor(mat.ColorSpecular);
            }
            gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_SPECULAR, colorf);

            color = new Color4(.2f, .2f, .2f, 1.0f);
            if (mat.HasColorAmbient)
            {
                color = FromColor(mat.ColorAmbient);
            }
            gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_AMBIENT, colorf);

            color = new Color4(0, 0, 0, 1.0f);
            if (mat.HasColorEmissive)
            {
                color = FromColor(mat.ColorEmissive);
            }
            gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_EMISSION, colorf);

            float shininess = 1;
            float strength = 1;
            if (mat.HasShininess)
            {
                shininess = mat.Shininess;
            }
            if (mat.HasShininessStrength)
            {
                strength = mat.ShininessStrength;
            }

            gl.Material(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_SHININESS, shininess * strength);
        }
开发者ID:EternalEnvy,项目名称:SmackBrosClient,代码行数:52,代码来源:GameplayScreen.cs

示例3: DrawDataTriangles

        private void DrawDataTriangles(OpenGL gl)
        {
            // draw samples
            //  Draw
            gl.Begin(OpenGL.GL_TRIANGLES);

            int x, z;
            float fCurrent;

            uint nType = OpenGL.GL_AMBIENT_AND_DIFFUSE;

            for (x = 0; x < m_nSweepSteps - 1; x++)
            {
                for (z = 0; z < m_nTotalSweeps - 1; z++)
                {
                    // Current value, I need one more, to create triangles
                    fCurrent = m_arrSweepData[x, z] / (float)m_nTotalSweeps;
                    //gl.Color(ColorMap(fCurrent));
                    gl.Material(OpenGL.GL_FRONT, nType, ColorMap(fCurrent));
                    gl.Vertex(-(float)x / (float)m_nSweepSteps, fCurrent, (float)z / (float)m_nTotalSweeps);
                    fCurrent = m_arrSweepData[x, z + 1] / (float)m_nTotalSweeps;
                    gl.Material(OpenGL.GL_FRONT, nType, ColorMap(fCurrent));
                    gl.Vertex(-(float)x / (float)m_nSweepSteps, fCurrent, (float)(z + 1) / (float)m_nTotalSweeps);
                    fCurrent = m_arrSweepData[x + 1, z] / (float)m_nTotalSweeps;
                    gl.Material(OpenGL.GL_FRONT, nType, ColorMap(fCurrent));
                    gl.Vertex(-(float)(x + 1) / (float)m_nSweepSteps, fCurrent, (float)z / (float)m_nTotalSweeps);
                    // done 1st triangle
                    fCurrent = m_arrSweepData[x, z + 1] / (float)m_nTotalSweeps;
                    gl.Material(OpenGL.GL_FRONT, nType, ColorMap(fCurrent));
                    gl.Vertex(-(float)x / (float)m_nSweepSteps, fCurrent, (float)(z + 1) / (float)m_nTotalSweeps);
                    fCurrent = m_arrSweepData[x + 1, z] / (float)m_nTotalSweeps;
                    gl.Material(OpenGL.GL_FRONT, nType, ColorMap(fCurrent));
                    gl.Vertex(-(float)(x + 1) / (float)m_nSweepSteps, fCurrent, (float)z / (float)m_nTotalSweeps);
                    fCurrent = m_arrSweepData[x + 1, z + 1] / (float)m_nTotalSweeps;
                    gl.Material(OpenGL.GL_FRONT, nType, ColorMap(fCurrent));
                    gl.Vertex(-(float)(x + 1) / (float)m_nSweepSteps, fCurrent, (float)(z + 1) / (float)m_nTotalSweeps);
                }
            }

            gl.End();
        }
开发者ID:RFExplorer,项目名称:rfexplorer-1,代码行数:41,代码来源:SharpGLForm.cs


注:本文中的SharpGL.OpenGL.Material方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。