private static void Draw3DObject(msg3DObject obj3D, RenderingMode mode, bool selSubObjects, bool asHot) { msgAllTrianglesStruct trngls = obj3D.GetTriangles(); bool Tex = false; if (mode == RenderingMode.GL_RENDER) { OpenGLControl.glPushAttrib(OpenGLControl.GL_ENABLE_BIT | OpenGLControl.GL_LINE_BIT | OpenGLControl.GL_CURRENT_BIT | OpenGLControl.GL_LIGHTING_BIT | OpenGLControl.GL_TEXTURE_BIT); OpenGLControl.glPushMatrix(); if (obj3D.GetTempMatrix() != null) { double[] transData = GetDoubles(obj3D.GetTempMatrix().GetTransparentData().values); unsafe { fixed(double *matrixPtr = transData) { OpenGLControl.glMultMatrixd(matrixPtr); } } } unsafe { double[] worldData = GetDoubles(obj3D.GetWorldMatrixData().values); fixed(double *matrixPtr = worldData) { OpenGLControl.glMultMatrixd(matrixPtr); } } if (trngls != null && (draw_triangles_regime || (obj3D.GetAttribute(msgObjectAttrEnum.SG_OA_DRAW_STATE) & (ushort)SG_OA_DRAW_STATEValuesEnum.SGDS_FULL) > 0)) { uint Face = 0; if (obj3D.Get3DObjectType() == msg3DObjectTypeEnum.SG_BODY) { Face = OpenGLControl.GL_FRONT; OpenGLControl.glEnable(OpenGLControl.GL_CULL_FACE); OpenGLControl.glLightModelf(OpenGLControl.GL_LIGHT_MODEL_TWO_SIDE, OpenGLControl.GL_FALSE); } else if (obj3D.Get3DObjectType() == msg3DObjectTypeEnum.SG_SURFACE) { Face = OpenGLControl.GL_FRONT_AND_BACK; OpenGLControl.glDisable(OpenGLControl.GL_CULL_FACE); OpenGLControl.glLightModelf(OpenGLControl.GL_LIGHT_MODEL_TWO_SIDE, OpenGLControl.GL_TRUE); } float[] c_mat = new float[4]; float[] clrs = GetColorByIndex(obj3D.GetAttribute(msgObjectAttrEnum.SG_OA_COLOR)); c_mat[0] = clrs[0]; //0.0f; c_mat[1] = clrs[1]; //0.5f; c_mat[2] = clrs[2]; //0.75f; c_mat[3] = 1.0f; OpenGLControl.glMaterialfv(Face, OpenGLControl.GL_AMBIENT, c_mat); c_mat[0] = clrs[0]; //0.0f; c_mat[1] = clrs[1]; //0.5f; c_mat[2] = clrs[2]; //1.0f; c_mat[3] = 1.0f; OpenGLControl.glMaterialfv(Face, OpenGLControl.GL_DIFFUSE, c_mat); c_mat[0] = 0.6f; //0.2f; c_mat[1] = 0.6f; //0.2f; c_mat[2] = 0.6f; //0.2f; c_mat[3] = 1.0f; OpenGLControl.glMaterialfv(Face, OpenGLControl.GL_SPECULAR, c_mat); OpenGLControl.glMaterialf(Face, OpenGLControl.GL_SHININESS, 128); c_mat[0] = 0.0f; c_mat[1] = 0.0f; c_mat[2] = 0.0f; c_mat[3] = 1.0f; OpenGLControl.glMaterialfv(Face, OpenGLControl.GL_EMISSION, c_mat); OpenGLControl.glHint(OpenGLControl.GL_LINE_SMOOTH_HINT, OpenGLControl.GL_NICEST); OpenGLControl.glEnable(OpenGLControl.GL_NORMALIZE); OpenGLControl.glEnable(OpenGLControl.GL_LIGHTING); if (draw_triangles_regime) { OpenGLControl.glPolygonMode(OpenGLControl.GL_FRONT_AND_BACK, OpenGLControl.GL_LINE); } OpenGLControl.glBegin(OpenGLControl.GL_TRIANGLES); OpenGLControl.glBegin(OpenGLControl.GL_TRIANGLES); for (int i = 0; i < trngls.allVertex.Length; i += 3) { OpenGLControl.glNormal3d(trngls.allNormals[i].x, trngls.allNormals[i].y, trngls.allNormals[i].z); OpenGLControl.glVertex3d(trngls.allVertex[i].x, trngls.allVertex[i].y, trngls.allVertex[i].z); OpenGLControl.glNormal3d(trngls.allNormals[i + 1].x, trngls.allNormals[i + 1].y, trngls.allNormals[i + 1].z); OpenGLControl.glVertex3d(trngls.allVertex[i + 1].x, trngls.allVertex[i + 1].y, trngls.allVertex[i + 1].z); OpenGLControl.glNormal3d(trngls.allNormals[i + 2].x, trngls.allNormals[i + 2].y, trngls.allNormals[i + 2].z); OpenGLControl.glVertex3d(trngls.allVertex[i + 2].x, trngls.allVertex[i + 2].y, trngls.allVertex[i + 2].z); } OpenGLControl.glEnd(); if (draw_triangles_regime) { OpenGLControl.glPolygonMode(OpenGLControl.GL_FRONT_AND_BACK, OpenGLControl.GL_FILL); } } } }