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


C# OpenGL.PushMatrix方法代码示例

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


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

示例1: Push

        /// <summary>
        /// Pushes the effect onto the specified parent element.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="parentElement">The parent element.</param>
        public override void Push(OpenGL gl, Core.SceneElement parentElement)
        {
            //  Push the stack.
            gl.PushMatrix();

            //  Perform the transformation.
            arcBall.TransformMatrix(gl);
        }
开发者ID:cvanherk,项目名称:3d-engine,代码行数:13,代码来源:ArcBallTransformationEffect.cs

示例2: CreatePolygon

        /// <summary>
        /// This is the main function of the class, it'll create a triangulated polygon
        /// from and SceneObject.
        /// </summary>
        /// <param name="gl">The gl.</param>
        /// <param name="sourceObject">The object to convert.</param>
        /// <param name="guarenteedView">A camera that can see the whole object.</param>
        /// <returns>
        /// A polygon created from 'sourceObject'.
        /// </returns>
        public Polygon CreatePolygon(OpenGL gl, IRenderable sourceObject, Camera guarenteedView)
        {
            //	Save the current camera data.
            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.PushMatrix();

            //	Look through the camera that can see the object.
            guarenteedView.Project(gl);

            //	Start triangulation.
            Begin(gl);

            //	Draw the object.
            sourceObject.Render(gl, RenderMode.Design);

            //	End triangulation.
            End(gl);

            Polygon newPoly = Triangle;
            newPoly.Name = (sourceObject is SceneElement ? ((SceneElement)sourceObject).Name : "Object") + " (Triangulated Poly)";
            return newPoly;
        }
开发者ID:cvanherk,项目名称:3d-engine,代码行数:32,代码来源:Polygonator.cs

示例3: CreatePolygon

            /// <summary>
            /// This is the main function of the class, it'll create a triangulated polygon
            /// from and SceneObject.
            /// </summary>
            /// <param name="sourceObject">The object to convert.</param>
            /// <param name="guarenteedView">A camera that can see the whole object.</param>
            /// <returns>A polygon created from 'sourceObject'.</returns>
            public Polygon CreatePolygon(OpenGL gl, SceneObject sourceObject, Cameras.Camera guarenteedView)
            {
                //	Save the current camera data.
                gl.MatrixMode(OpenGL.PROJECTION);
                gl.PushMatrix();

                //	Look through the camera that can see the object.
                guarenteedView.Project(gl);

                //	Start triangulation.
                Begin(gl);

                //	Draw the object.
                sourceObject.Draw(gl);

                //	End triangulation.
                End(gl);

                Polygon newPoly = Triangle;
                newPoly.Name = sourceObject.Name + " (Triangulated Poly)";
                return newPoly;
            }
开发者ID:nromik,项目名称:sharpgl,代码行数:29,代码来源:Feedback.cs

示例4: DrawCircle3D

        public virtual void DrawCircle3D(OpenGL gl)
        {
            gl.PushAttrib(OpenGL.ENABLE_BIT);
            gl.Disable(OpenGL.LIGHTING);

            //	Draw three circles.
            gl.PushMatrix();
            DrawCircle(gl);
            gl.Rotate(90, 1, 0, 0);
            DrawCircle(gl);
            gl.Rotate(90, 0, 0, 1);
            DrawCircle(gl);
            gl.PopMatrix();

            gl.PopAttrib();
        }
开发者ID:nromik,项目名称:sharpgl,代码行数:16,代码来源:StockDrawing.cs

示例5: CastShadow

        /// <summary>
        /// Casts a real time 3D shadow.
        /// </summary>
        /// <param name="gl">The OpenGL object.</param>
        /// <param name="light">The source light.</param>
        public void CastShadow(OpenGL gl, Collections.LightCollection lights)
        {
            //	Set the connectivity, (calculate the neighbours of each face).
            SetConnectivity();

            //	Go through every light in the scene.
            foreach(Lights.Light light in lights)
            {
                //	Skip null lights.
                if(light == null)
                    continue;

                //	Skip turned off lights and non shadow lights.
                if(light.On == false || light.CastShadow == false)
                    continue;

                //	Every face will have a visibility setting.
                bool[] facesVisible = new bool[faces.Count];

                //	Get the light position relative to the polygon.
                Vertex lightPos = light.Translate;
                lightPos = lightPos - Translate;

                //	Go through every face, finding out whether it's visible to the light.
                for(int nFace = 0; nFace < faces.Count; nFace++)
                {
                    //	Get a reference to the face.
                    Face face = faces[nFace];

                    //	Is this face facing the light?
                    float[] planeEquation = face.GetPlaneEquation(this);
                    float side = planeEquation[0] * lightPos.X +
                        planeEquation[1] * lightPos.Y +
                        planeEquation[2] * lightPos.Z + planeEquation[3];
                    facesVisible[nFace] = (side > 0) ? true : false;
                }

                //	Save all the attributes.
                gl.PushAttrib(OpenGL.ALL_ATTRIB_BITS);

                //	Turn off lighting.
                gl.Disable(OpenGL.LIGHTING);

                //	Turn off writing to the depth mask.
                gl.DepthMask(0);
                gl.DepthFunc(OpenGL.LEQUAL);

                //	Turn on stencil buffer testing.
                gl.Enable(OpenGL.STENCIL_TEST);

                //	Translate our shadow volumes.
                gl.PushMatrix();
                Transform(gl);

                //	Don't draw to the color buffer.
                gl.ColorMask(0, 0, 0, 0);
                gl.StencilFunc(OpenGL.ALWAYS, 1, 0xFFFFFFFF);

                gl.Enable(OpenGL.CULL_FACE);

                //	First Pass. Increase Stencil Value In The Shadow
                gl.FrontFace(OpenGL.CCW);
                gl.StencilOp(OpenGL.KEEP, OpenGL.KEEP, OpenGL.INCR);
                DoShadowPass(gl, lightPos, facesVisible);

                //	Second Pass. Decrease Stencil Value In The Shadow
                gl.FrontFace(OpenGL.CW);
                gl.StencilOp(OpenGL.KEEP, OpenGL.KEEP, OpenGL.DECR);
                DoShadowPass(gl, lightPos, facesVisible);

                gl.FrontFace(OpenGL.CCW);

                gl.PopMatrix();

                //	Enable writing to the color buffer.
                gl.ColorMask(1, 1, 1, 1);

                // Draw A Shadowing Rectangle Covering The Entire Screen
                gl.Color(light.ShadowColor);
                gl.Enable(OpenGL.BLEND);
                gl.BlendFunc(OpenGL.SRC_ALPHA, OpenGL.ONE_MINUS_SRC_ALPHA);
                gl.StencilFunc(OpenGL.NOTEQUAL, 0, 0xFFFFFFF);
                gl.StencilOp(OpenGL.KEEP, OpenGL.KEEP, OpenGL.KEEP);

                Quadrics.Sphere shadow = new Quadrics.Sphere();
                shadow.Scale.Set(shadowSize, shadowSize, shadowSize);
                shadow.Draw(gl);

                gl.PopAttrib();
            }
        }
开发者ID:nromik,项目名称:sharpgl,代码行数:96,代码来源:Polygon.cs

示例6: DoPreDraw

        /// <summary>
        /// Classes derived from SceneObject can call this to perform common drawing
        /// operations, it pushes the modelview stack, set's attributes etc.
        /// </summary>
        /// <param name="gl"></param>
        /// <returns>True if the object must be drawn.</returns>
        protected internal virtual bool DoPreDraw(OpenGL gl)
        {
            //	DoPreDraw can go one of two ways.
            //	1. There is a valid displaylist, and 'modified' is false.
            //	This is ace, just call the display list. Fast as hell.
            //	2. There is no display list or 'modified' is true.
            //	This is OK, we do the slower version of the drawing while
            //	compiling a display list at the same time. As long as the object
            //	doesn't get modified again, it'll just call the list next time.

            //  TODO: this generates a stack overflow...
            /*	if(displayList != 0 && modified != true)
            {
                gl.CallList(displayList);
                return false;
            }

            //	If we have a list, destroy it. Then create a new one.
            if(displayList != 0)
                gl.DeleteLists(displayList, 1);
            displayList = gl.GenLists(1);

            //	From now on we are compiling the display list...
            gl.NewList(displayList, OpenGL.COMPILE_AND_EXECUTE);*/

            //	Push the matrix.
            gl.PushMatrix();

            //	Transform the matrix.
            Transform(gl);

            //  Set the material for drawing.
            material.Set(gl);

            return true;
        }
开发者ID:nromik,项目名称:sharpgl,代码行数:42,代码来源:SceneObject.cs


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