Exemplo n.º 1
0
        public override void DrawWaterPolyLightmap(GLPoly p, double time, bool blend = false)
        {
            GL.Color3(1f, 1f, 1f);

            if (blend)
            {
                GL.Enable(EnableCap.Blend);
            }

            this.Device.DisableMultitexture( );

            GL.Enable(EnableCap.Texture2D);
            var nv = new float[3];

            GL.Begin(PrimitiveType.TriangleFan);

            for (var i = 0; i < p.numverts; i++)
            {
                var v = p.verts[i];
                GL.TexCoord2(v[5], v[6]);

                nv[0] = ( float )(v[0] + 8 * Math.Sin(v[1] * 0.05 + time) * Math.Sin(v[2] * 0.05 + time));
                nv[1] = ( float )(v[1] + 8 * Math.Sin(v[0] * 0.05 + time) * Math.Sin(v[2] * 0.05 + time));
                nv[2] = v[2];

                GL.Vertex3(nv);
            }
            GL.End( );
            GL.Disable(EnableCap.Texture2D);

            if (blend)
            {
                GL.Disable(EnableCap.Blend);
            }
        }
Exemplo n.º 2
0
        public override void DrawWaterPoly(GLPoly p, Double time)
        {
            GL.Color3(1f, 1f, 1f);

            Device.DisableMultitexture( );
            GL.Enable(EnableCap.Texture2D);

            var nv = new Single[3];

            GL.Begin(PrimitiveType.TriangleFan);
            for (var i = 0; i < p.numverts; i++)
            {
                var v = p.verts[i];

                GL.TexCoord2(v[3], v[4]);

                nv[0] = ( Single )(v[0] + 8 * Math.Sin(v[1] * 0.05 + time) * Math.Sin(v[2] * 0.05 + time));
                nv[1] = ( Single )(v[1] + 8 * Math.Sin(v[0] * 0.05 + time) * Math.Sin(v[2] * 0.05 + time));
                nv[2] = v[2];

                GL.Vertex3(nv);
            }
            GL.End( );
            GL.Disable(EnableCap.Texture2D);
        }
Exemplo n.º 3
0
        /// <summary>
        /// EmitSkyPolys
        /// </summary>
        public override void EmitSkyPolys(GLPoly polys, Vector3 origin, float speed, bool blend = false)
        {
            GL.Color3(1f, 1f, 1f);

            if (blend)
            {
                GL.Enable(EnableCap.Blend);
            }

            GL.Enable(EnableCap.Texture2D);

            for (var p = polys; p != null; p = p.next)
            {
                GL.Begin(PrimitiveType.Polygon);
                for (var i = 0; i < p.numverts; i++)
                {
                    var v   = p.verts[i];
                    var dir = new Vector3(v[0] - origin.X, v[1] - origin.Y, v[2] - origin.Z);
                    dir.Z *= 3; // flatten the sphere

                    dir  = Vector3.Normalize(dir);
                    dir *= 6 * 63;

                    var s = (speed + dir.X) / 128.0f;
                    var t = (speed + dir.Y) / 128.0f;

                    GL.TexCoord2(s, t);
                    GL.Vertex3(v);
                }
                GL.End( );
            }

            GL.Disable(EnableCap.Texture2D);

            if (blend)
            {
                GL.Disable(EnableCap.Blend);
            }
        }
Exemplo n.º 4
0
        public override void DrawPoly(GLPoly p, float scaleX = 1f, float scaleY = 1f, bool isLightmap = false)
        {
            GL.Color3(1f, 1f, 1f);
            GL.Enable(EnableCap.Texture2D);
            GL.Begin(PrimitiveType.Polygon);
            for (var i = 0; i < p.numverts; i++)
            {
                var v = p.verts[i];
                if (isLightmap)
                {
                    GL.TexCoord2(v[5], v[6]);
                }
                else
                {
                    GL.TexCoord2(v[3] * scaleX, v[4] * scaleY);
                }

                GL.Vertex3(v);
            }
            GL.End( );
            GL.Disable(EnableCap.Texture2D);
            GL.UseProgram(0);
        }
Exemplo n.º 5
0
 public virtual void DrawWaterPolyLightmap(GLPoly p, double time, bool blend = false)
 {
     throw new NotImplementedException( );
 }
Exemplo n.º 6
0
 public virtual void DrawWaterPoly(GLPoly p, double time)
 {
     throw new NotImplementedException( );
 }
Exemplo n.º 7
0
 /// <summary>
 /// EmitWaterPolys
 /// Does a water warp on the pre-fragmented glpoly_t chain
 /// </summary>
 public virtual void EmitWaterPolys(ref float[] turbSin, double time, double turbScale, GLPoly polys)
 {
     throw new NotImplementedException( );
 }
Exemplo n.º 8
0
 public virtual void DrawPoly(GLPoly p, float scaleX = 1f, float scaleY = 1f, bool isLightmap = false)
 {
     throw new NotImplementedException( );
 }
Exemplo n.º 9
0
 /// <summary>
 /// EmitSkyPolys
 /// </summary>
 public virtual void EmitSkyPolys(GLPoly polys, Vector3 origin, float speed, bool blend = false)
 {
     throw new NotImplementedException( );
 }
Exemplo n.º 10
0
        public override void DrawWaterPolyMultiTexture(byte[] lightMapData, BaseTexture texture, BaseTexture lightMapTexture, int lightMapTextureNumber, GLPoly p, double time)
        {
            GL.Enable(EnableCap.Texture2D);

            texture.Bind( );

            GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, ( int )TextureEnvMode.Replace);

            this.Device.EnableMultitexture( );

            lightMapTexture.BindLightmap((( GLTextureDesc )lightMapTexture.Desc).TextureNumber + lightMapTextureNumber);
            var i = lightMapTextureNumber;

            if (lightMapTexture.LightMapModified[i])
            {
                lightMapTexture.CommitLightmap(lightMapData, i);
            }

            GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, ( int )TextureEnvMode.Blend);
            GL.Begin(PrimitiveType.TriangleFan);

            var nv = new float[3];

            for (i = 0; i < p.numverts; i++)
            {
                var v = p.verts[i];
                GL.MultiTexCoord2(TextureUnit.Texture0, v[3], v[4]);
                GL.MultiTexCoord2(TextureUnit.Texture1, v[5], v[6]);

                nv[0] = ( float )(v[0] + 8 * Math.Sin(v[1] * 0.05 + time) * Math.Sin(v[2] * 0.05 + time));
                nv[1] = ( float )(v[1] + 8 * Math.Sin(v[0] * 0.05 + time) * Math.Sin(v[2] * 0.05 + time));
                nv[2] = v[2];

                GL.Vertex3(nv);
            }
            GL.End( );

            GL.Disable(EnableCap.Texture2D);
        }
Exemplo n.º 11
0
        public override void DrawSequentialPolyMultiTexture(BaseTexture texture, BaseTexture lightMapTexture, byte[] lightMapData, GLPoly p, int lightMapNumber)
        {
            GL.Enable(EnableCap.Texture2D);
            // Binds world to texture env 0
            texture.Bind( );
            GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, ( int )TextureEnvMode.Replace);

            // Binds lightmap to texenv 1
            this.Device.EnableMultitexture( ); // Same as SelectTexture (TEXTURE1).
            lightMapTexture.BindLightmap((( GLTextureDesc )lightMapTexture.Desc).TextureNumber + lightMapNumber);
            var i = lightMapNumber;

            if (lightMapTexture.LightMapModified[i])
            {
                lightMapTexture.CommitLightmap(lightMapData, i);
            }

            GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, ( int )TextureEnvMode.Blend);
            GL.Begin(PrimitiveType.Polygon);
            for (i = 0; i < p.numverts; i++)
            {
                var v = p.verts[i];
                GL.MultiTexCoord2(TextureUnit.Texture0, v[3], v[4]);
                GL.MultiTexCoord2(TextureUnit.Texture1, v[5], v[6]);
                GL.Vertex3(v);
            }
            GL.End( );
            GL.Disable(EnableCap.Texture2D);
        }
Exemplo n.º 12
0
        /// <summary>
        /// BuildSurfaceDisplayList
        /// </summary>
        private void BuildSurfaceDisplayList(MemorySurface fa)
        {
            var BrushModelData = ( BrushModelData )_CurrentModel;
            // reconstruct the polygon
            var pedges    = BrushModelData.Edges;
            var lnumverts = fa.numedges;

            //
            // draw texture
            //
            var poly = new GLPoly( );

            poly.AllocVerts(lnumverts);
            poly.next  = fa.polys;
            poly.flags = fa.flags;
            fa.polys   = poly;

            UInt16[] r_pedge_v;
            Vector3  vec;

            for (var i = 0; i < lnumverts; i++)
            {
                var lindex = BrushModelData.SurfEdges[fa.firstedge + i];
                if (lindex > 0)
                {
                    r_pedge_v = pedges[lindex].v;
                    vec       = _CurrentVertBase[r_pedge_v[0]].position;
                }
                else
                {
                    r_pedge_v = pedges[-lindex].v;
                    vec       = _CurrentVertBase[r_pedge_v[1]].position;
                }
                var s = MathLib.DotProduct(ref vec, ref fa.texinfo.vecs[0]) + fa.texinfo.vecs[0].W;
                s /= fa.texinfo.texture.width;

                var t = MathLib.DotProduct(ref vec, ref fa.texinfo.vecs[1]) + fa.texinfo.vecs[1].W;
                t /= fa.texinfo.texture.height;

                poly.verts[i][0] = vec.X;
                poly.verts[i][1] = vec.Y;
                poly.verts[i][2] = vec.Z;
                poly.verts[i][3] = s;
                poly.verts[i][4] = t;

                //
                // lightmap texture coordinates
                //
                s  = MathLib.DotProduct(ref vec, ref fa.texinfo.vecs[0]) + fa.texinfo.vecs[0].W;
                s -= fa.texturemins[0];
                s += fa.light_s * 16;
                s += 8;
                s /= RenderDef.BLOCK_WIDTH * 16;

                t  = MathLib.DotProduct(ref vec, ref fa.texinfo.vecs[1]) + fa.texinfo.vecs[1].W;
                t -= fa.texturemins[1];
                t += fa.light_t * 16;
                t += 8;
                t /= RenderDef.BLOCK_HEIGHT * 16;

                poly.verts[i][5] = s;
                poly.verts[i][6] = t;
            }

            //
            // remove co-linear points - Ed
            //
            if (!Host.Cvars.glKeepTJunctions.Get <Boolean>( ) && (fa.flags & ( Int32 )Q1SurfaceFlags.Underwater) == 0)
            {
                for (var i = 0; i < lnumverts; ++i)
                {
                    if (Utilities.IsCollinear(poly.verts[(i + lnumverts - 1) % lnumverts],
                                              poly.verts[i],
                                              poly.verts[(i + 1) % lnumverts]))
                    {
                        Int32 j;
                        for (j = i + 1; j < lnumverts; ++j)
                        {
                            //int k;
                            for (var k = 0; k < ModelDef.VERTEXSIZE; ++k)
                            {
                                poly.verts[j - 1][k] = poly.verts[j][k];
                            }
                        }
                        --lnumverts;
                        ++_ColinElim;
                        // retry next vertex next time, which is now current vertex
                        --i;
                    }
                }
            }
            poly.numverts = lnumverts;
        }
Exemplo n.º 13
0
 public virtual void DrawSequentialPolyMultiTexture(BaseTexture texture, BaseTexture lightMapTexture, byte[] lightMapData, GLPoly p, int lightMapNumber)
 {
     throw new NotImplementedException( );
 }
Exemplo n.º 14
0
        /// <summary>
        /// EmitWaterPolys
        /// </summary>
        public override void EmitWaterPolys(ref float[] turbSin, double time, double turbScale, GLPoly polys)
        {
            GL.Color3(1f, 1f, 1f);
            GL.Enable(EnableCap.Texture2D);

            //texture.Bind( );

            for (var p = polys; p != null; p = p.next)
            {
                GL.Begin(PrimitiveType.Polygon);
                for (var i = 0; i < p.numverts; i++)
                {
                    var v  = p.verts[i];
                    var os = v[3];
                    var ot = v[4];

                    var s = os + turbSin[( int )((ot * 0.125 + time) * turbScale) & 255];
                    s *= 1.0f / 64;

                    var t = ot + turbSin[( int )((os * 0.125 + time) * turbScale) & 255];
                    t *= 1.0f / 64;

                    GL.TexCoord2(s, t);
                    GL.Vertex3(v);
                }
                GL.End( );
            }
            GL.Disable(EnableCap.Texture2D);
        }
Exemplo n.º 15
0
 public virtual void DrawSequentialPoly(BaseTexture texture, BaseTexture lightMapTexture, GLPoly p, Int32 lightMapNumber)
 {
     throw new NotImplementedException( );
 }
Exemplo n.º 16
0
 public virtual void DrawPoly(GLPoly p, Single scaleX = 1f, Single scaleY = 1f, Boolean isLightmap = false)
 {
     throw new NotImplementedException( );
 }
Exemplo n.º 17
0
 /// <summary>
 /// EmitSkyPolys
 /// </summary>
 public virtual void EmitSkyPolys(GLPoly polys, Vector3 origin, Single speed, Boolean blend = false)
 {
     throw new NotImplementedException( );
 }
Exemplo n.º 18
0
 public virtual void DrawWaterPolyMultiTexture(byte[] lightMapData, BaseTexture texture, BaseTexture lightMapTexture, int lightMapTextureNumber, GLPoly p, double time)
 {
     throw new NotImplementedException( );
 }
Exemplo n.º 19
0
        public override void DrawSequentialPoly(BaseTexture texture, BaseTexture lightMapTexture, GLPoly p, int lightMapNumber)
        {
            GL.Enable(EnableCap.Texture2D);
            texture.Bind( );
            GL.Begin(PrimitiveType.Polygon);
            for (var i = 0; i < p.numverts; i++)
            {
                var v = p.verts[i];
                GL.TexCoord2(v[3], v[4]);
                GL.Vertex3(v);
            }
            GL.End( );

            lightMapTexture.BindLightmap((( GLTextureDesc )lightMapTexture.Desc).TextureNumber + lightMapNumber);
            GL.Enable(EnableCap.Blend);
            GL.Begin(PrimitiveType.Polygon);
            for (var i = 0; i < p.numverts; i++)
            {
                var v = p.verts[i];
                GL.TexCoord2(v[5], v[6]);
                GL.Vertex3(v);
            }
            GL.End( );

            GL.Disable(EnableCap.Blend);
            GL.Disable(EnableCap.Texture2D);
        }