public virtual void DrawGLPolyChain(glpoly_t p, Single soffset, Single toffset) { if (soffset == 0 && toffset == 0) { for ( ; p != null; p = p.chain) { GL.Begin(PrimitiveType.Polygon); for (var j = 0; j < p.numverts; j++) { GL.TexCoord2(p.S2(j), p.T2(j)); GL.Vertex3(p.X(j), p.Y(j), p.Z(j)); } GL.End(); } } else { for ( ; p != null; p = p.chain) { GL.Begin(PrimitiveType.Polygon); for (var j = 0; j < p.numverts; j++) { GL.TexCoord2(p.S2(j) - soffset, p.T2(j) - toffset); GL.Vertex3(p.X(j), p.Y(j), p.Z(j)); } GL.End(); } } }
public virtual void R_DrawTriangleOutlines( ) { if (gl_showtris.value == 0) { return; } GL.Disable(EnableCap.Texture2D); GL.Disable(EnableCap.DepthTest); GL.Color4(1, 1, 1, 1); for (var i = 0; i < MAX_LIGHTMAPS; i++) { msurface_t surf; for (surf = gl_lms.lightmap_surfaces[i]; surf != null; surf = surf.lightmapchain) { glpoly_t p = surf.polys; for ( ; p != null; p = p.chain) { for (var j = 2; j < p.numverts; j++) { GL.Begin(PrimitiveType.LineStrip); GL.Vertex3(p.X(0), p.Y(0), p.Z(0)); GL.Vertex3(p.X(j - 1), p.Y(j - 1), p.Z(j - 1)); GL.Vertex3(p.X(j), p.Y(j), p.Z(j)); GL.Vertex3(p.X(0), p.Y(0), p.Z(0)); GL.End(); } } } } GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Texture2D); }
public virtual void DrawGLPoly(glpoly_t p) { GL.Begin(PrimitiveType.Polygon); for (var i = 0; i < p.numverts; i++) { GL.TexCoord2(p.S1(i), p.T1(i)); GL.Vertex3(p.X(i), p.Y(i), p.Z(i)); } GL.End(); }
public virtual void GL_BuildPolygonFromSurface(msurface_t fa) { medge_t[] pedges = currentmodel.edges; var lnumverts = fa.numedges; glpoly_t poly = Polygon.Create(lnumverts); poly.next = fa.polys; poly.flags = fa.flags; fa.polys = poly; Int32 lindex; Single[] vec; medge_t r_pedge; Single s, t; for (var i = 0; i < lnumverts; i++) { lindex = currentmodel.surfedges[fa.firstedge + i]; if (lindex > 0) { r_pedge = pedges[lindex]; vec = currentmodel.vertexes[r_pedge.v[0]].position; } else { r_pedge = pedges[-lindex]; vec = currentmodel.vertexes[r_pedge.v[1]].position; } s = Math3D.DotProduct(vec, fa.texinfo.vecs[0]) + fa.texinfo.vecs[0][3]; s /= fa.texinfo.image.width; t = Math3D.DotProduct(vec, fa.texinfo.vecs[1]) + fa.texinfo.vecs[1][3]; t /= fa.texinfo.image.height; poly.X(i, vec[0]); poly.Y(i, vec[1]); poly.Z(i, vec[2]); poly.S1(i, s); poly.T1(i, t); s = Math3D.DotProduct(vec, fa.texinfo.vecs[0]) + fa.texinfo.vecs[0][3]; s -= fa.texturemins[0]; s += fa.light_s * 16; s += 8; s /= BLOCK_WIDTH * 16; t = Math3D.DotProduct(vec, fa.texinfo.vecs[1]) + fa.texinfo.vecs[1][3]; t -= fa.texturemins[1]; t += fa.light_t * 16; t += 8; t /= BLOCK_HEIGHT * 16; poly.S2(i, s); poly.T2(i, t); } }
public override void R_AddSkySurface(msurface_t fa) { for (glpoly_t p = fa.polys; p != null; p = p.next) { for (int i = 0; i < p.numverts; i++) { verts[i][0] = p.X(i) - r_origin[0]; verts[i][1] = p.Y(i) - r_origin[1]; verts[i][2] = p.Z(i) - r_origin[2]; } ClipSkyPolygon(p.numverts, verts, 0); } }
public virtual void DrawGLFlowingPoly(msurface_t fa) { var scroll = -64 * ((r_newrefdef.time / 40F) - ( Int32 )(r_newrefdef.time / 40F)); if (scroll == 0F) { scroll = -64F; } GL.Begin(PrimitiveType.Polygon); glpoly_t p = fa.polys; for (var i = 0; i < p.numverts; i++) { GL.TexCoord2(p.S1(i) + scroll, p.T1(i)); GL.Vertex3(p.X(i), p.Y(i), p.Z(i)); } GL.End(); }
public virtual void SubdividePolygon(int numverts, float[][] verts) { int i, j, k; float[] mins = new float[] { 0, 0, 0 }; float[] maxs = new float[] { 0, 0, 0 }; float m; float[] v = new float[] { 0, 0, 0 }; float[][] front = Lib.CreateJaggedArray <float[][]>(64, 3); float[][] back = Lib.CreateJaggedArray <float[][]>(64, 3); int f, b; float[] dist = new float[64]; float frac; float s, t; float[] total = new float[] { 0, 0, 0 }; float total_s, total_t; if (numverts > 60) { Com.Error(Defines.ERR_DROP, "numverts = " + numverts); } BoundPoly(numverts, verts, mins, maxs); for (i = 0; i < 3; i++) { m = (mins[i] + maxs[i]) * 0.5F; m = SUBDIVIDE_SIZE * (float)Math.Floor(m / SUBDIVIDE_SIZE + 0.5F); if (maxs[i] - m < 8) { continue; } if (m - mins[i] < 8) { continue; } for (j = 0; j < numverts; j++) { dist[j] = verts[j][i] - m; } dist[j] = dist[0]; Math3D.VectorCopy(verts[0], verts[numverts]); f = b = 0; for (j = 0; j < numverts; j++) { v = verts[j]; if (dist[j] >= 0) { Math3D.VectorCopy(v, front[f]); f++; } if (dist[j] <= 0) { Math3D.VectorCopy(v, back[b]); b++; } if (dist[j] == 0 || dist[j + 1] == 0) { continue; } if ((dist[j] > 0) != (dist[j + 1] > 0)) { frac = dist[j] / (dist[j] - dist[j + 1]); for (k = 0; k < 3; k++) { front[f][k] = back[b][k] = v[k] + frac * (verts[j + 1][k] - v[k]); } f++; b++; } } SubdividePolygon(f, front); SubdividePolygon(b, back); return; } glpoly_t poly = Polygon.Create(numverts + 2); poly.next = warpface.polys; warpface.polys = poly; Math3D.VectorClear(total); total_s = 0; total_t = 0; for (i = 0; i < numverts; i++) { poly.X(i + 1, verts[i][0]); poly.Y(i + 1, verts[i][1]); poly.Z(i + 1, verts[i][2]); s = Math3D.DotProduct(verts[i], warpface.texinfo.vecs[0]); t = Math3D.DotProduct(verts[i], warpface.texinfo.vecs[1]); total_s += s; total_t += t; Math3D.VectorAdd(total, verts[i], total); poly.S1(i + 1, s); poly.T1(i + 1, t); } float scale = 1F / numverts; poly.X(0, total[0] * scale); poly.Y(0, total[1] * scale); poly.Z(0, total[2] * scale); poly.S1(0, total_s * scale); poly.T1(0, total_t * scale); poly.X(i + 1, poly.X(1)); poly.Y(i + 1, poly.Y(1)); poly.Z(i + 1, poly.Z(1)); poly.S1(i + 1, poly.S1(1)); poly.T1(i + 1, poly.T1(1)); poly.S2(i + 1, poly.S2(1)); poly.T2(i + 1, poly.T2(1)); }