예제 #1
0
        private void RenderBoundingBox(RenderingContext rc)
        {
            rc.PushMatricies();

            bbox.Render(this, rc);

            rc.PopMatricies();
        }
예제 #2
0
        private void RenderSkybox(RenderingContext rc)
        {
            rc.PushMatricies();

            // Inner cubemapped skybox
            //this._shapeInnerCube.Render(rc);

            _shaderInnerCube.Use();
#if APPLY_BACKDROP
            Matrix4 mat4 = rc.cam.GetWorldOrientation();
            _shaderInnerCube.SetFieldValue("modelview", ref mat4);
#endif
            _shaderInnerCube.SetFieldValue("scale", scaleCube);
            _shaderInnerCube.SetFieldValue("size", size);
            _shaderInnerCube.SetFieldValue("coloringEnabled", 0);
            _shaderInnerCube.SetFieldValue("texturingEnabled", 1);
            _shaderInnerCube.SetFieldValue("lightingEnabled", 0);

            _shaderInnerCube.SetFieldValue("projection", ref rc.matricies.projection);
            _shaderInnerCube.SetFieldValue("camscale", rc.cam.Scale.X);
            _shaderInnerCube.SetFieldValue("X3DScale", rc.matricies.Scale);


            texture2d = GL.IsEnabled(EnableCap.Texture2D);

            if (!texture2d)
            {
                GL.Enable(EnableCap.Texture2D);
            }

#if APPLY_BACKDROP
            GL.DepthMask(false);
#endif

            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.TextureCubeMap, tex_cube);
            GL.BindBuffer(BufferTarget.ArrayBuffer, cubeHandle.vbo3);
            Buffering.ApplyBufferPointers(_shaderInnerCube);
            GL.DrawArrays(PrimitiveType.Triangles, 0, cubeHandle.NumVerticies3);

#if APPLY_BACKDROP
            GL.DepthMask(true);
#endif

            if (!texture2d)
            {
                GL.Disable(EnableCap.Texture2D);
            }

            rc.PopMatricies();
        }
예제 #3
0
        public override void PostRender(RenderingContext rc)
        {
            base.PostRender(rc);

            CurrentShader.Deactivate();

            this.DecendantsByType <ImageTexture>().ForEach(TeXtUrE => TeXtUrE.Deactivate());

            if (typeof(Text).IsInstanceOfType(geometry))
            {
                Text txt = (Text)geometry;
                txt.UnbindTextures(rc);
            }

            rc.PopMatricies();
        }
예제 #4
0
        public override void PostRender(RenderingContext rc)
        {
            base.PostRender(rc);

            rc.PopMatricies();
        }
예제 #5
0
        private void RenderSkydome(RenderingContext rc)
        {
            rc.PushMatricies();

            texture2d = GL.IsEnabled(EnableCap.Texture2D);

            if (texture2d)
            {
                GL.Disable(EnableCap.Texture2D);
            }

            Matrix4 mat4;

            // Outer sky Sphere
            //this._shapeOuter.Render(rc);

            _shaderOuter.Use();



#if APPLY_BACKDROP
            mat4 = rc.cam.GetWorldOrientation();
            _shaderOuter.SetFieldValue("modelview", ref mat4);
#endif
            //_shaderOuter.SetFieldValue("scale", scaleSky);
            _shaderOuter.SetFieldValue("scale", size);
            _shaderOuter.SetFieldValue("size", size);
            if (skydomeColors != null && skydomeColors.Length > 0)
            {
                _shaderOuter.SetFieldValue("skyColors", this.skydomeColors.Length);//_shaderOuter.SetFieldValue("skyColors", this.colors.Length);
                _shaderOuter.SetFieldValue("skyColor", this.skydomeColors, 255 * 3);
            }
            //_shaderOuter.SetFieldValue("skyColor", this.colors, 255 * 3);
            _shaderOuter.SetFieldValue("skyAngle", this.angles, 255);

            _shaderOuter.SetFieldValue("isGround", 0);
            _shaderOuter.SetFieldValue("bbox", bboxOuter);
            _shaderOuter.SetFieldValue("max", max);
            _shaderOuter.SetFieldValue("min", min);

            _shaderOuter.SetFieldValue("projection", ref rc.matricies.projection);
            _shaderOuter.SetFieldValue("camscale", rc.cam.Scale.X);
            _shaderOuter.SetFieldValue("X3DScale", rc.matricies.Scale);

#if APPLY_BACKDROP
            GL.DepthMask(false);
#endif
            if (skydomeComputed)
            {
                GL.BindTexture(TextureTarget.Texture2D, skydomeTexture);
            }

            GL.BindBuffer(BufferTarget.ArrayBuffer, outerHandle.vbo4);
            Buffering.ApplyBufferPointers(_shaderOuter);
            GL.DrawArrays(PrimitiveType.Quads, 0, outerHandle.NumVerticies4);

            if (skydomeComputed)
            {
                GL.BindTexture(TextureTarget.Texture2D, 0);
            }

#if APPLY_BACKDROP
            GL.DepthMask(true);
#endif
            rc.PopMatricies();


            //            rc.PushMatricies();

            //            // Inner ground Hemisphere
            //            //RenderCube(rc);

            //            _shaderInner.Use();
            //#if APPLY_BACKDROP
            //            mat4 = rc.cam.GetWorldOrientation();
            //            _shaderInner.SetFieldValue("modelview", ref mat4);
            //#endif
            //            _shaderInner.SetFieldValue("scale", scaleGround);
            //            _shaderInner.SetFieldValue("size", size);
            //            _shaderOuter.SetFieldValue("skyColor", this.skydomeColors, 255 * 3);
            //            //_shaderInner.SetFieldValue("skyColor", this.colors, 255 * 3);
            //            _shaderInner.SetFieldValue("skyAngle", this.angles, 255);
            //            _shaderInner.SetFieldValue("skyColors", this.colors.Length);
            //            _shaderInner.SetFieldValue("isGround", 1);
            //            _shaderInner.SetFieldValue("bbox", bboxInner);

            //            _shaderInner.SetFieldValue("projection", ref rc.matricies.projection);
            //            _shaderInner.SetFieldValue("camscale", rc.cam.Scale.X);
            //            _shaderInner.SetFieldValue("X3DScale", rc.matricies.Scale);

            //#if APPLY_BACKDROP
            //            GL.DepthMask(false);
            //#endif
            //            GL.BindBuffer(BufferTarget.ArrayBuffer, innerHandle.vbo4);
            //            Buffering.ApplyBufferPointers(_shaderInner);
            //            GL.DrawArrays(PrimitiveType.Quads, 0, innerHandle.NumVerticies4);

            //#if APPLY_BACKDROP
            //            GL.DepthMask(true);
            //#endif


            //            rc.PopMatricies();

            if (texture2d)
            {
                GL.Enable(EnableCap.Texture2D);
            }
        }
예제 #6
0
        private void RenderShape(RenderingContext rc)
        {
            // Refactor tessellation
            var shader = CurrentShader;

            if (shader != null)
            {
                shader.Use();

                if (bbox != null)
                {
                    shader.SetFieldValue("bboxMaxWidth", bbox.Width);
                    shader.SetFieldValue("bboxMaxHeight", bbox.Height);
                    shader.SetFieldValue("bboxMaxDepth", bbox.Depth);

                    shader.SetFieldValue("bbox_x", bbox.Width);
                    shader.SetFieldValue("bbox_y", bbox.Height);
                    shader.SetFieldValue("bbox_z", bbox.Depth);
                }

                shader.SetFieldValue("coloringEnabled", coloring ? 1 : 0);

                if (typeof(ElevationGrid).IsInstanceOfType(geometry))
                {
                    shader.SetFieldValue("lightingEnabled", 0);
                    shader.SetFieldValue("texturingEnabled", 1);
                }

                Vector3 tmp = rc.matricies.Scale;
                if (typeof(Text).IsInstanceOfType(geometry))
                {
                    rc.PushMatricies();
                    rc.matricies.Scale *= 200f;
                }

                if (depthMask == false)
                {
                    //REFACTOR!!
                    Matrix4 mat4 = Matrix4.Identity;
                    //Quaternion qRotFix = QuaternionExtensions.EulerToQuat(rc.cam.calibOrient.X, rc.cam.calibOrient.Y, rc.cam.calibOrient.Z);
                    //mat4 *= Matrix4.CreateTranslation(rc.cam.calibTrans) * Matrix4.CreateFromQuaternion(qRotFix);
                    Quaternion qRotFix = QuaternionExtensions.EulerToQuat(0.15f, 3.479997f, 0f);
                    mat4 *= Matrix4.CreateTranslation(new Vector3(0f, 0f, -0.29f)) * Matrix4.CreateFromQuaternion(qRotFix);
                    // test weapon/gun rendering fixed in front of player
                    //TODO: port this to X3D

                    shader.SetFieldValue("modelview", ref mat4);
                    if (quadShader != null)
                    {
                        quadShader.SetFieldValue("modelview", ref mat4);
                    }
                    //GL.DepthMask(false);
                }

                shader.SetFieldValue("size", size);
                shader.SetFieldValue("scale", scale);

                if (loadedGeometry)
                {
                    if (shader.IsTessellator)
                    {
                        RenderTessellator(rc);
                    }
                    else
                    {
                        if (typeof(PointSet).IsInstanceOfType(geometry))
                        {
                            RenderPoints(rc);
                        }
                        else if (typeof(IndexedLineSet).IsInstanceOfType(geometry) || typeof(LineSet).IsInstanceOfType(geometry))
                        {
                            RenderLines(rc);
                        }
                        else
                        {
                            RenderTriangles(rc);
                            RenderQuads(rc);
                        }
                    }
                }


                if (depthMask == false)
                {
                    //GL.DepthMask(true);
                }

                if (typeof(Text).IsInstanceOfType(geometry))
                {
                    rc.PopMatricies();
                    rc.matricies.Scale = tmp;
                }
            }
        }