public MD2(string fileName, string textureName) { Texture2D.EnableMipMaping = false; tex = TextureMgr.Load(textureName); Texture2D.EnableMipMaping = true; transform = new Matrix(); loadMD2(fileName); }
public Target(Vector3 pos) { position = pos; sommets = new Vector3[4]; sommets[0] = new Vector3(0, -1, 1); sommets[1] = new Vector3(0, 1, 1); sommets[2] = new Vector3(0, 1, -1); sommets[3] = new Vector3(0, -1, -1); tex = TextureMgr.Load("Textures/target.jpg"); }
public static Texture2D Load(string name, float gamma) { Texture2D tex = null; if (!Textures.ContainsKey(name)) { tex = new Texture2D(name,gamma); Textures.Add(name, tex); } else tex = Textures[name]; return tex; }
public Sky(string name, string ext) { m_name = name; Texture2D.EnableMipMaping = false; Texture2D[] cubemap = new Texture2D[6]; for (int i = 0; i < 6; i++) { cubemap[i] = TextureMgr.Load("Sky/" + name + "/" + i + ext); cubemap[i].Bind(); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP_TO_EDGE); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP_TO_EDGE); cubemap[i].Unbind(); } Texture2D.EnableMipMaping = true; Instance = this; }
public override void Render() { Texture2D[] cubemap = new Texture2D[6]; for (int i = 0; i < 6; i++) cubemap[i] = TextureMgr.Load("Sky/" + m_name + "/" + i + ".bmp"); Gl.glDepthMask(Gl.GL_FALSE); Gl.glShadeModel(Gl.GL_SMOOTH); Gl.glPushMatrix(); Gl.glTranslatef(Camera.Position.X, Camera.Position.Y, Camera.Position.Z); Gl.glScalef(5, 5, 5); cubemap[(int)Orient.NORTH].Bind(); Gl.glBegin(Gl.GL_QUADS); Gl.glTexCoord2i(0, 0); Gl.glVertex3i(-1, -1, 1); Gl.glTexCoord2i(0, 1); Gl.glVertex3i(-1, -1, -1); Gl.glTexCoord2i(1, 1); Gl.glVertex3i(1, -1, -1); Gl.glTexCoord2i(1, 0); Gl.glVertex3i(1, -1, 1); Gl.glEnd(); cubemap[(int)Orient.NORTH].Unbind(); cubemap[(int)Orient.EAST].Bind(); Gl.glBegin(Gl.GL_QUADS); Gl.glTexCoord2i(0, 0); Gl.glVertex3i(1, -1, 1); Gl.glTexCoord2i(0, 1); Gl.glVertex3i(1, -1, -1); Gl.glTexCoord2i(1, 1); Gl.glVertex3i(1, 1, -1); Gl.glTexCoord2i(1, 0); Gl.glVertex3i(1, 1, 1); Gl.glEnd(); cubemap[(int)Orient.EAST].Unbind(); cubemap[(int)Orient.SOUTH].Bind(); Gl.glBegin(Gl.GL_QUADS); Gl.glTexCoord2i(0, 0); Gl.glVertex3i(1, 1, 1); Gl.glTexCoord2i(0, 1); Gl.glVertex3i(1, 1, -1); Gl.glTexCoord2i(1, 1); Gl.glVertex3i(-1, 1, -1); Gl.glTexCoord2i(1, 0); Gl.glVertex3i(-1, 1, 1); Gl.glEnd(); cubemap[(int)Orient.SOUTH].Unbind(); cubemap[(int)Orient.WEST].Bind(); Gl.glBegin(Gl.GL_QUADS); Gl.glTexCoord2i(0, 0); Gl.glVertex3i(-1, 1, 1); Gl.glTexCoord2i(0, 1); Gl.glVertex3i(-1, 1, -1); Gl.glTexCoord2i(1, 1); Gl.glVertex3i(-1, -1, -1); Gl.glTexCoord2i(1, 0); Gl.glVertex3i(-1, -1, 1); Gl.glEnd(); cubemap[(int)Orient.WEST].Unbind(); cubemap[(int)Orient.UP].Bind(); Gl.glBegin(Gl.GL_QUADS); Gl.glTexCoord2i(0, 0); Gl.glVertex3i(1, -1, 1); Gl.glTexCoord2i(0, 1); Gl.glVertex3i(1, 1, 1); Gl.glTexCoord2i(1, 1); Gl.glVertex3i(-1, 1, 1); Gl.glTexCoord2i(1, 0); Gl.glVertex3i(-1, -1, 1); Gl.glEnd(); cubemap[(int)Orient.UP].Unbind(); cubemap[(int)Orient.DOWN].Bind(); Gl.glBegin(Gl.GL_QUADS); Gl.glTexCoord2i(0, 0); Gl.glVertex3i(1, 1, -1); Gl.glTexCoord2i(0, 1); Gl.glVertex3i(1, -1, -1); Gl.glTexCoord2i(1, 1); Gl.glVertex3i(-1, -1, -1); Gl.glTexCoord2i(1, 0); Gl.glVertex3i(-1, 1, -1); Gl.glEnd(); cubemap[(int)Orient.DOWN].Unbind(); Gl.glPopMatrix(); Gl.glShadeModel(Gl.GL_FLAT); Gl.glDepthMask(Gl.GL_TRUE); }
void LoadLightMaps(BinaryReader br, int offset, int n) { br.BaseStream.Seek(offset, SeekOrigin.Begin); m_lightmaps = new Q3LightMap[n]; m_lmTextures = new Texture2D[n]; for (int i = 0; i < n; i++) { byte[] buff = br.ReadBytes(Marshal.SizeOf(typeof(Q3LightMap))); GCHandle handle = GCHandle.Alloc(buff, GCHandleType.Pinned); m_lightmaps[i] = (Q3LightMap)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Q3LightMap)); handle.Free(); m_lmTextures[i] = new Texture2D(128, 128, 3, m_lightmaps[i].Data, 1f); } }