Exemplo n.º 1
0
        public override void Draw(ILRenderProperties props, ILShape shape, int[] indices)
        {
            System.Diagnostics.Debug.Assert(indices != null);
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha,
                         BlendingFactorDest.OneMinusSrcAlpha);
            ILShape <C4bV3f> cShape = (shape as ILShape <C4bV3f>);

            if (cShape is ILLines)
            {
                ILOGLPanel.SetupLineStyle((cShape as ILLines).Properties);
                GL.Disable(EnableCap.DepthTest);
            }

            fixed(int *pIndices = indices)
            fixed(C4bV3f * pVertices = cShape.Vertices)
            {
                GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices);
                if (cShape.Shading == ShadingStyles.Interpolate)
                {
                    GL.ShadeModel(ShadingModel.Smooth);
                }
                else
                {
                    GL.ShadeModel(ShadingModel.Flat);
                    GL.DisableClientState(EnableCap.ColorArray);
                }
                GL.DrawElements(BeginMode.Lines, indices.Length,
                                DrawElementsType.UnsignedInt, (IntPtr)pIndices);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// add a shape to the root node
        /// </summary>
        /// <param name="shape"></param>
        public void AddNode(ILShape shape)
        {
            ILSceneGraphShapedLeaf node = new ILSceneGraphShapedLeaf(m_panel);

            node.Shape = shape;
            AddNode(node, m_root);
        }
Exemplo n.º 3
0
        public override void Draw(ILRenderProperties props, ILShape shape)
        {
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha,
                         BlendingFactorDest.OneMinusSrcAlpha);
            GL.Enable(EnableCap.DepthTest);
            ILLines lines = (shape as ILLines);

            ILOGLPanel.SetupLineStyle(lines.Properties);
            fixed(C4bV3f *pVertices = lines.Vertices)
            {
                GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices);
                if (lines.Shading == ShadingStyles.Interpolate)
                {
                    GL.ShadeModel(ShadingModel.Smooth);
                }
                else
                {
                    GL.ShadeModel(ShadingModel.Flat);
                    GL.DisableClientState(EnableCap.ColorArray);
                    GL.Color4(lines.FillColor);
                }
                GL.DrawArrays(BeginMode.LineStrip, 0, lines.VertexCount);
            }
        }
 public override void Draw(ILRenderProperties props, ILShape shape) {
     if (shape.VertexCount == 0) return; 
     GL.Enable(EnableCap.Blend);
     GL.BlendFunc (BlendingFactorSrc.SrcAlpha,
                   BlendingFactorDest.OneMinusSrcAlpha); 
     GL.Enable(EnableCap.DepthTest);
     //GL.Disable(EnableCap.PolygonOffsetFill); 
     ILShape<C4fN3fV3f> cShape = (shape as ILShape<C4fN3fV3f>);
     fixed (C4fN3fV3f* pVertices = cShape.Vertices) {
         if (UseLight && (cShape is IILSupportsLight)) {
             setupLight(cShape as IILSupportsLight);  
         } else {
             GL.Disable(EnableCap.Lighting); 
         }
         GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices);
         if (cShape.Shading == ShadingStyles.Interpolate)
             GL.ShadeModel(ShadingModel.Smooth);
         else {
             GL.ShadeModel(ShadingModel.Flat);
             GL.DisableClientState(EnableCap.ColorArray);
             GL.Color4(shape.FillColor);  
         }
         GL.DrawArrays(m_primitiveType, 0, cShape.VertexCount);
     }
     GL.Disable(EnableCap.Lighting); 
     ILBorderedShape<C4fN3fV3f> bShape = (shape as ILBorderedShape<C4fN3fV3f>); 
     if (bShape != null && bShape.Border.Visible) {
         fixed (C4fN3fV3f* pVertices = bShape.Vertices) {
             ILOGLPanel.SetupLineStyle(bShape.Border);
             GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices);
             GL.DisableClientState(EnableCap.ColorArray);
             GL.DrawArrays(BeginMode.LineLoop, 0, bShape.VertexCount);
         }
     }
 }
Exemplo n.º 5
0
        public override void Draw(ILRenderProperties props, ILShape shape, int[] indices) {
            System.Diagnostics.Debug.Assert(indices != null); 
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc (BlendingFactorSrc.SrcAlpha,
                          BlendingFactorDest.OneMinusSrcAlpha); 
            ILShape<C4bV3f> cShape = (shape as ILShape<C4bV3f>);
            if (cShape is ILLines) {
                ILOGLPanel.SetupLineStyle((cShape as ILLines).Properties);
                GL.Disable(EnableCap.DepthTest); 
            } 
            fixed (int* pIndices = indices) 
            fixed (C4bV3f* pVertices = cShape.Vertices) {
                GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices);
                if (cShape.Shading == ShadingStyles.Interpolate)
                    GL.ShadeModel(ShadingModel.Smooth);
                else {
                    GL.ShadeModel(ShadingModel.Flat);
                    GL.DisableClientState(EnableCap.ColorArray);
                }
                GL.DrawElements(BeginMode.Lines, indices.Length,
                                DrawElementsType.UnsignedInt, (IntPtr)pIndices);
            }

        }
Exemplo n.º 6
0
        protected ILShapeWrapper(ILShape source, ILPanelEditor editor, string path, string name = null, string label = null)
            : base(source, editor, path, BuildName(name, editor.Panel, source, "Shape"), label)
        {
            this.source = source;

            // Subscribe mouse events on SceneSyncRoot (instead of Scene)
            sourceSync = GetSyncNode(source);
            sourceSync.MouseDoubleClick += OnMouseDoubleClick;
        }
Exemplo n.º 7
0
        public virtual void Add(ILShape shape)
        {
            ILSceneGraphShapedLeaf node = new ILSceneGraphShapedLeaf(m_panel);

            node.Parent = this;
            node.Shape  = shape;
            m_childs.Add(node);
            Invalidate();
            OnNodeAdded(node);
        }
Exemplo n.º 8
0
        public override void Draw(ILRenderProperties props, ILShape shape)
        {
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha,
                         BlendingFactorDest.OneMinusSrcAlpha);
            GL.Enable(EnableCap.DepthTest);
            ILLine line = (shape as ILLine);

            if (line != null && line.Border.Visible)
            {
                fixed(C4bV3f *pVertices = line.Vertices)
                {
                    ILOGLPanel.SetupLineStyle(line.Border);
                    GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices);
                    GL.DisableClientState(EnableCap.ColorArray);
                    if (line.OldestVertexID == 0)
                    {
                        GL.DrawArrays(BeginMode.LineStrip, 0, line.VertexCount);
                    }
                    else
                    {
                        GL.DrawArrays(BeginMode.LineStrip, line.OldestVertexID, line.VertexCount - line.OldestVertexID);
                        GL.DrawElements(BeginMode.Lines, 2, DrawElementsType.UnsignedInt, m_closeLoopIndices);
                        GL.DrawArrays(BeginMode.LineStrip, 0, line.OldestVertexID);
                    }
                }
            }
            ILOGLPanel.SetupLineStyle(line.Properties);
            fixed(C4bV3f *pVertices = line.Vertices)
            {
                GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices);
                if (line.Shading == ShadingStyles.Interpolate)
                {
                    GL.ShadeModel(ShadingModel.Smooth);
                }
                else
                {
                    GL.ShadeModel(ShadingModel.Flat);
                    GL.DisableClientState(EnableCap.ColorArray);
                    GL.Color4(line.FillColor);
                }
                if (line.OldestVertexID == 0)
                {
                    GL.DrawArrays(BeginMode.LineStrip, 0, line.VertexCount);
                }
                else
                {
                    GL.DrawArrays(BeginMode.LineStrip, line.OldestVertexID, line.VertexCount - line.OldestVertexID);
                    GL.DrawElements(BeginMode.Lines, 2, DrawElementsType.UnsignedInt, m_closeLoopIndices);
                    GL.DrawArrays(BeginMode.LineStrip, 0, line.OldestVertexID);
                }
            }
        }
        public override void Draw(ILRenderProperties props, ILShape shape)
        {
            if (shape.VertexCount == 0)
            {
                return;
            }
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha,
                         BlendingFactorDest.OneMinusSrcAlpha);
            GL.Enable(EnableCap.DepthTest);
            //GL.Disable(EnableCap.PolygonOffsetFill);
            ILShape <C4fN3fV3f> cShape = (shape as ILShape <C4fN3fV3f>);

            fixed(C4fN3fV3f *pVertices = cShape.Vertices)
            {
                if (UseLight && (cShape is IILSupportsLight))
                {
                    setupLight(cShape as IILSupportsLight);
                }
                else
                {
                    GL.Disable(EnableCap.Lighting);
                }
                GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices);
                if (cShape.Shading == ShadingStyles.Interpolate)
                {
                    GL.ShadeModel(ShadingModel.Smooth);
                }
                else
                {
                    GL.ShadeModel(ShadingModel.Flat);
                    GL.DisableClientState(EnableCap.ColorArray);
                    GL.Color4(shape.FillColor);
                }
                GL.DrawArrays(m_primitiveType, 0, cShape.VertexCount);
            }

            GL.Disable(EnableCap.Lighting);
            ILBorderedShape <C4fN3fV3f> bShape = (shape as ILBorderedShape <C4fN3fV3f>);

            if (bShape != null && bShape.Border.Visible)
            {
                fixed(C4fN3fV3f *pVertices = bShape.Vertices)
                {
                    ILOGLPanel.SetupLineStyle(bShape.Border);
                    GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices);
                    GL.DisableClientState(EnableCap.ColorArray);
                    GL.DrawArrays(BeginMode.LineLoop, 0, bShape.VertexCount);
                }
            }
        }
Exemplo n.º 10
0
        public override void Draw(ILRenderProperties props, ILShape shape) {
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc (BlendingFactorSrc.SrcAlpha,
                          BlendingFactorDest.OneMinusSrcAlpha); 
            GL.Enable(EnableCap.DepthTest);
            ILLines lines = (shape as ILLines);
            ILOGLPanel.SetupLineStyle(lines.Properties);
            fixed (C4bV3f* pVertices = lines.Vertices) {
                GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices);
                if (lines.Shading == ShadingStyles.Interpolate)
                    GL.ShadeModel(ShadingModel.Smooth);
                else {
                    GL.ShadeModel(ShadingModel.Flat);
                    GL.DisableClientState(EnableCap.ColorArray);
                    GL.Color4(lines.FillColor);  
                }
                GL.DrawArrays(BeginMode.LineStrip, 0, lines.VertexCount);
            }

        }
Exemplo n.º 11
0
        public virtual void Remove(ILShape shape)
        {
            ILSceneGraphNode node = null;

            foreach (ILSceneGraphNode n in m_childs)
            {
                if (n is ILSceneGraphShapedLeaf)
                {
                    if (object.Equals((n as ILSceneGraphShapedLeaf).Shape, shape))
                    {
                        node = n;
                        break;
                    }
                }
            }
            if (node != null)
            {
                m_childs.Remove(node);
                OnNodeRemoved(node);
            }
        }
        public override void Draw(ILRenderProperties props, ILShape shape)
        {
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha,
                         BlendingFactorDest.OneMinusSrcAlpha);
            GL.Enable(EnableCap.DepthTest);
            ILPoints points = (shape as ILPoints);

            fixed(C4bV3f *pVertices = points.Vertices)
            {
                GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices);
                if (points.Shading == ShadingStyles.Flat)
                {
                    GL.DisableClientState(EnableCap.ColorArray);
                    GL.Color4(points.FillColor);
                }
                GL.Enable(EnableCap.PointSmooth);
                GL.PointSize(points.Width);
                GL.DrawArrays(BeginMode.Points, 0, points.VertexCount);
            }
        }
Exemplo n.º 13
0
        public override void Draw(ILRenderProperties props, ILShape shape) {
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc (BlendingFactorSrc.SrcAlpha,
                          BlendingFactorDest.OneMinusSrcAlpha); 
            GL.Enable(EnableCap.DepthTest);
            ILLine line = (shape as ILLine);
            if (line != null && line.Border.Visible) {
                fixed (C4bV3f* pVertices = line.Vertices) {
                    ILOGLPanel.SetupLineStyle(line.Border);
                    GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices);
                    GL.DisableClientState(EnableCap.ColorArray);
                    if (line.OldestVertexID == 0) {
                        GL.DrawArrays(BeginMode.LineStrip, 0, line.VertexCount);
                    } else {
                        GL.DrawArrays(BeginMode.LineStrip, line.OldestVertexID, line.VertexCount - line.OldestVertexID);
                        GL.DrawElements(BeginMode.Lines,2,DrawElementsType.UnsignedInt, m_closeLoopIndices);
                        GL.DrawArrays(BeginMode.LineStrip, 0, line.OldestVertexID);
                    }
                }
            }
            ILOGLPanel.SetupLineStyle(line.Properties);
            fixed (C4bV3f* pVertices = line.Vertices) {
                GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices);
                if (line.Shading == ShadingStyles.Interpolate)
                    GL.ShadeModel(ShadingModel.Smooth);
                else {
                    GL.ShadeModel(ShadingModel.Flat);
                    GL.DisableClientState(EnableCap.ColorArray);
                    GL.Color4(line.FillColor);  
                }
                if (line.OldestVertexID == 0) {
                    GL.DrawArrays(BeginMode.LineStrip, 0, line.VertexCount);
                } else {
                    GL.DrawArrays(BeginMode.LineStrip, line.OldestVertexID, line.VertexCount - line.OldestVertexID);
                    GL.DrawElements(BeginMode.Lines, 2, DrawElementsType.UnsignedInt, m_closeLoopIndices);
                    GL.DrawArrays(BeginMode.LineStrip, 0, line.OldestVertexID);
                }
            }

        }
Exemplo n.º 14
0
        public override void Draw(ILRenderProperties props, ILShape shape, int[] indices) {
            System.Diagnostics.Debug.Assert(indices != null); 
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc (BlendingFactorSrc.SrcAlpha,
                          BlendingFactorDest.OneMinusSrcAlpha); 
            // draw shape
            ILShape<C4fN3fV3f> cShape = (shape as ILShape<C4fN3fV3f>);
            fixed (int* pIndices = indices) 
            fixed (C4fN3fV3f* pVertices = cShape.Vertices) {
                if (UseLight && (cShape is ILLitCompositeShape<C4fN3fV3f>)) {
                    setupLight(cShape as ILLitCompositeShape<C4fN3fV3f>);
                } else {
                    GL.Disable(EnableCap.Lighting);
                }
                GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices);
                if (cShape.Shading == ShadingStyles.Interpolate)
                    GL.ShadeModel(ShadingModel.Smooth);
                else {
                    GL.ShadeModel(ShadingModel.Flat);
                    GL.DisableClientState(EnableCap.ColorArray);
                    GL.Color4(shape.FillColor); 
                }
                GL.DrawElements(m_primitiveType, indices.Length,DrawElementsType.UnsignedInt, (IntPtr)pIndices);
                //IntPtr pObj = Glu.NewQuadric();
                //GL.MatrixMode(MatrixMode.Modelview);
                //GL.PushMatrix();
                //GL.Translate(cShape.Vertices[0].Position.X, cShape.Vertices[0].Position.Y, cShape.Vertices[0].Position.Z);
                //Glu.QuadricDrawStyle(pObj, QuadricDrawStyle.Fill);
                //Glu.Sphere(pObj, 2, 20, 10);
                //GL.PopMatrix(); 
            }
            // draw border 
            ILBorderedShape<C4fN3fV3f> bShape = (shape as ILBorderedShape<C4fN3fV3f>); 
            if (bShape != null && bShape.Border.Visible) {
                fixed (int* pIndices = indices) 
                fixed (C4fN3fV3f* pVertices = bShape.Vertices) {
                    ILOGLPanel.SetupLineStyle(bShape.Border);
                    GL.InterleavedArrays(
                                    InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices);
                    GL.DisableClientState(EnableCap.ColorArray);
                    GL.DrawElements(BeginMode.LineLoop, indices.Length, 
                                    DrawElementsType.UnsignedInt, (IntPtr)pIndices);
                }
            }

#if RENDERER_DRAW_NORMALS
            #region DEBUG_DRAW_NORMALS 
            GL.Color3(0,0,0); 
            GL.Begin(BeginMode.Lines);
            for (int i = 0; i < shape.VertexCount; i++) {
                GL.Vertex3(cShape.Vertices[i].XPosition,cShape.Vertices[i].YPosition,cShape.Vertices[i].ZPosition); 
                GL.Vertex3( cShape.Vertices[i].XPosition+cShape.Vertices[i].Normal.X,
                            cShape.Vertices[i].YPosition+cShape.Vertices[i].Normal.Y,
                            cShape.Vertices[i].ZPosition+cShape.Vertices[i].Normal.Z); 
            }
            GL.End(); 
            #endregion
#endif
            GL.Disable(EnableCap.Lighting); 

        }
Exemplo n.º 15
0
 public ILVertexRenderer CreateVertexRenderer(Type vertexType, ILShape shape)
 {
     if (vertexType == typeof(C4bV3f))
     {
         ILVertexRenderer ret;
         if (shape is ILQuads)
         {
             ret = new ILOGLVertexRendererC4bV3f(BeginMode.Quads);
         }
         else if (shape is ILPolygon)
         {
             ret = new ILOGLVertexRendererC4bV3f(BeginMode.Polygon);
         }
         else if (shape is ILLine)
         {
             ret            = new ILOGLLineRendererC4bV3f(shape.VertexCount);
             ret.CloseLines = false;
         }
         else if (shape is ILTriangle)
         {
             ret = new ILOGLVertexRendererC4bV3f(BeginMode.Triangles);
         }
         else if (shape is ILQuad)
         {
             ret = new ILOGLVertexRendererC4bV3f(BeginMode.Quads);
         }
         else if (shape is ILLines)
         {
             ret = new ILOGLLinesRendererC4bV3f();
         }
         else if (shape is ILTriangles)
         {
             ret = new ILOGLVertexRendererC4bV3f(BeginMode.Triangles);
         }
         else if (shape is ILPoints)
         {
             ret = new ILOGLPointsRendererC4bV3f();
         }
         else
         {
             throw new NotSupportedException("Shape of type " + shape.GetType().Name + " is not supported!");
         }
         return(ret);
     }
     else if (vertexType == typeof(C4fN3fV3f))
     {
         ILOGLVertexRendererC4fN3fV3f ret;
         if (shape is ILLitQuads)
         {
             ret          = new ILOGLVertexRendererC4fN3fV3f(BeginMode.Quads);
             ret.UseLight = true;
         }
         else if (shape is ILLitPolygon)
         {
             ret          = new ILOGLVertexRendererC4fN3fV3f(BeginMode.Polygon);
             ret.UseLight = true;
         }
         else if (shape is ILLitQuad)
         {
             ret          = new ILOGLVertexRendererC4fN3fV3f(BeginMode.Quads);
             ret.UseLight = true;
         }
         else if (shape is ILLitTriangle)
         {
             ret          = new ILOGLVertexRendererC4fN3fV3f(BeginMode.Triangles);
             ret.UseLight = true;
         }
         else if (shape is ILLitSphere)
         {
             ret          = new ILOGLVertexRendererC4fN3fV3f(BeginMode.Triangles);
             ret.UseLight = true;
         }
         else if (shape is ILLitTriangles)
         {
             ret          = new ILOGLVertexRendererC4fN3fV3f(BeginMode.Triangles);
             ret.UseLight = true;
         }
         else
         {
             throw new NotSupportedException("Shape of type " + shape.GetType().Name + " is not supported for vertex type " + vertexType.Name + "!");
         }
         return(ret);
     }
     else
     {
         throw new NotSupportedException("VertexType is not supported!");
     }
 }
Exemplo n.º 16
0
 public abstract void Draw(ILRenderProperties props, ILShape shape, int[] indices); 
Exemplo n.º 17
0
 public abstract void Draw(ILRenderProperties props, ILShape shape); 
Exemplo n.º 18
0
 public ILVertexRenderer CreateVertexRenderer(Type vertexType, ILShape shape) {
     if (vertexType == typeof(C4bV3f)) {
         ILVertexRenderer ret;  
         if (shape is ILQuads) {
             ret = new ILOGLVertexRendererC4bV3f(BeginMode.Quads); 
         } else if (shape is ILPolygon) {
             ret = new ILOGLVertexRendererC4bV3f(BeginMode.Polygon); 
         } else if (shape is ILLine) {
             ret = new ILOGLLineRendererC4bV3f(shape.VertexCount); 
             ret.CloseLines = false; 
         } else if (shape is ILTriangle) {
             ret = new ILOGLVertexRendererC4bV3f(BeginMode.Triangles); 
         } else if (shape is ILQuad) {
             ret = new ILOGLVertexRendererC4bV3f(BeginMode.Quads); 
         } else if (shape is ILLines) {
             ret = new ILOGLLinesRendererC4bV3f(); 
         } else if (shape is ILTriangles) {
             ret = new ILOGLVertexRendererC4bV3f(BeginMode.Triangles); 
         } else if (shape is ILPoints) {
             ret = new ILOGLPointsRendererC4bV3f(); 
         } else 
             throw new NotSupportedException ("Shape of type " + shape.GetType().Name + " is not supported!"); 
         return ret; 
     } else if (vertexType == typeof(C4fN3fV3f)) {
         ILOGLVertexRendererC4fN3fV3f ret; 
         if (shape is ILLitQuads) {
             ret = new ILOGLVertexRendererC4fN3fV3f(BeginMode.Quads); 
             ret.UseLight = true;
         } else if (shape is ILLitPolygon) {
             ret = new ILOGLVertexRendererC4fN3fV3f(BeginMode.Polygon);
             ret.UseLight = true;
         } else if (shape is ILLitQuad) {
             ret = new ILOGLVertexRendererC4fN3fV3f(BeginMode.Quads);
             ret.UseLight = true;
         } else if (shape is ILLitTriangle) {
             ret = new ILOGLVertexRendererC4fN3fV3f(BeginMode.Triangles);
             ret.UseLight = true;
         } else if (shape is ILLitSphere) {
             ret = new ILOGLVertexRendererC4fN3fV3f(BeginMode.Triangles);
             ret.UseLight = true;
         } else if (shape is ILLitTriangles) {
             ret = new ILOGLVertexRendererC4fN3fV3f(BeginMode.Triangles);
             ret.UseLight = true;
         } else {
             throw new NotSupportedException("Shape of type " + shape.GetType().Name + " is not supported for vertex type " + vertexType.Name + "!"); 
         }
         return ret; 
     } else {
         throw new NotSupportedException("VertexType is not supported!"); 
     }
 } 
        public override void Draw(ILRenderProperties props, ILShape shape, int[] indices)
        {
            System.Diagnostics.Debug.Assert(indices != null);
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha,
                         BlendingFactorDest.OneMinusSrcAlpha);
            // draw shape
            ILShape <C4fN3fV3f> cShape = (shape as ILShape <C4fN3fV3f>);

            fixed(int *pIndices = indices)
            fixed(C4fN3fV3f * pVertices = cShape.Vertices)
            {
                if (UseLight && (cShape is ILLitCompositeShape <C4fN3fV3f>))
                {
                    setupLight(cShape as ILLitCompositeShape <C4fN3fV3f>);
                }
                else
                {
                    GL.Disable(EnableCap.Lighting);
                }
                GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices);
                if (cShape.Shading == ShadingStyles.Interpolate)
                {
                    GL.ShadeModel(ShadingModel.Smooth);
                }
                else
                {
                    GL.ShadeModel(ShadingModel.Flat);
                    GL.DisableClientState(EnableCap.ColorArray);
                    GL.Color4(shape.FillColor);
                }
                GL.DrawElements(m_primitiveType, indices.Length, DrawElementsType.UnsignedInt, (IntPtr)pIndices);
                //IntPtr pObj = Glu.NewQuadric();
                //GL.MatrixMode(MatrixMode.Modelview);
                //GL.PushMatrix();
                //GL.Translate(cShape.Vertices[0].Position.X, cShape.Vertices[0].Position.Y, cShape.Vertices[0].Position.Z);
                //Glu.QuadricDrawStyle(pObj, QuadricDrawStyle.Fill);
                //Glu.Sphere(pObj, 2, 20, 10);
                //GL.PopMatrix();
            }
            // draw border
            ILBorderedShape <C4fN3fV3f> bShape = (shape as ILBorderedShape <C4fN3fV3f>);

            if (bShape != null && bShape.Border.Visible)
            {
                fixed(int *pIndices = indices)
                fixed(C4fN3fV3f * pVertices = bShape.Vertices)
                {
                    ILOGLPanel.SetupLineStyle(bShape.Border);
                    GL.InterleavedArrays(
                        InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices);
                    GL.DisableClientState(EnableCap.ColorArray);
                    GL.DrawElements(BeginMode.LineLoop, indices.Length,
                                    DrawElementsType.UnsignedInt, (IntPtr)pIndices);
                }
            }

#if RENDERER_DRAW_NORMALS
            #region DEBUG_DRAW_NORMALS
            GL.Color3(0, 0, 0);
            GL.Begin(BeginMode.Lines);
            for (int i = 0; i < shape.VertexCount; i++)
            {
                GL.Vertex3(cShape.Vertices[i].XPosition, cShape.Vertices[i].YPosition, cShape.Vertices[i].ZPosition);
                GL.Vertex3(cShape.Vertices[i].XPosition + cShape.Vertices[i].Normal.X,
                           cShape.Vertices[i].YPosition + cShape.Vertices[i].Normal.Y,
                           cShape.Vertices[i].ZPosition + cShape.Vertices[i].Normal.Z);
            }
            GL.End();
            #endregion
#endif
            GL.Disable(EnableCap.Lighting);
        }
Exemplo n.º 20
0
 /// <summary>
 /// add a shape to the root node
 /// </summary>
 /// <param name="shape"></param>
 public void AddNode(ILShape shape) {
     ILSceneGraphShapedLeaf node = new ILSceneGraphShapedLeaf(m_panel);
     node.Shape = shape; 
     AddNode(node, m_root);
 }