예제 #1
0
        /// <summary>
        /// The render.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="flags">
        /// The flags.
        /// </param>
        /// <returns>
        /// The render.
        /// </returns>
        public override uint Render(CIwModel model, uint flags)
        {
            CIwMaterial material = model.GetMaterial(this.m_MaterialID);

            if (material != null)
            {
                material.Enable();
            }

            S3E.CheckOpenGLStatus();
            GL.Begin(BeginMode.Triangles);

            var verts     = model.ResolveBlock <CIwModelBlockVerts>();
            var colors    = model.ResolveBlock <CIwModelBlockCols>();
            var normals   = model.ResolveBlock <CIwModelBlockNorms>();
            var indGroups = model.ResolveBlock <CIwModelBlockIndGroups>();

            if (verts != null)
            {
                foreach (var iwModelPrim in this.prims)
                {
                    iwModelPrim.Render(model, flags, verts, indGroups, colors);
                }
            }

            GL.End();
            if (material != null)
            {
                material.Disable();
            }

            S3E.CheckOpenGLStatus();

            return(0);
        }
        /// <summary>
        /// The render.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="flags">
        /// The flags.
        /// </param>
        /// <returns>
        /// The render.
        /// </returns>
        public override uint Render(CIwModel model, uint flags)
        {
            base.Render(model, flags);
            var verts   = model.ResolveBlock <CIwModelBlockVerts>();
            var colors  = model.ResolveBlock <CIwModelBlockCols>();
            var normals = model.ResolveBlock <CIwModelBlockNorms>();
            var uvs     = model.ResolveBlock <CIwModelBlockGLUVs>();
            var uvs2    = model.ResolveBlock <CIwModelBlockGLUVs2>();

            if (verts != null)
            {
                foreach (var index in this.inds)
                {
                    if (colors != null)
                    {
                        GL.Color4(colors.Colors[index]);
                    }

                    if (normals != null)
                    {
                        GL.Normal3(normals.Normal[index]);
                    }

                    if (uvs != null)
                    {
                        GL.TexCoord2(uvs.UVs[index]);
                        GL.MultiTexCoord2(TextureUnit.Texture0, ref uvs.UVs[index]);
                    }

                    GL.Vertex3(verts.Verts[index]);
                }
            }

            return(0);
        }