/// <summary> /// renderoi yhden billboardin. /// </summary> public void RenderBillboard(float x, float y, float z, float zrot, float size, bool blend) { billBoard.Bind(0); GL.Disable(EnableCap.CullFace); if (blend) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); } GLExt.PushMatrix(); { GLExt.Translate(x, y, z); size *= 0.1f; GLExt.Scale(size, size, size); GLExt.RotateZ(zrot); Matrix4 matrix = Matrix4.Identity; matrix.Row3 = GLExt.ModelViewMatrix.Row3; GLExt.ModelViewMatrix = matrix; GLExt.SetLighting(false); billBoard.Vbo.Render(); GLExt.SetLighting(true); } GLExt.PopMatrix(); if (blend) { GL.Disable(EnableCap.Blend); } }
protected override void RenderModel() { if (VBO.FastRenderPass) { return; } GameClass.NumOfObjects++; GL.Disable(EnableCap.DepthTest); GL.DepthMask(false); // ei kirjoiteta z-bufferiin GLExt.SetLighting(false); GLExt.PushMatrix(); GLExt.ModelViewMatrix.Row3.X = GLExt.ModelViewMatrix.Row3.Y = GLExt.ModelViewMatrix.Row3.Z = 0; GLExt.Scale(10, 10, 10); for (int q = 0; q < 6; q++) { OgreMesh m = skyboxSides[q]; m.Material.SetMaterial(); m.Vbo.Render(); } GLExt.PopMatrix(); GLExt.SetLighting(true); GL.DepthMask(true); GL.Enable(EnableCap.DepthTest); }
public void Draw(int x, int y, float z, float rotate, float sx, float sy, bool blend) { if (Vbo == null) { CreateVBO(false); } Bind(0); GLExt.PushMatrix(); { GLExt.Translate(x, y, z); GLExt.RotateZ(rotate); GLExt.Scale(sx, sy, 1); if (blend) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); Vbo.Render(); GL.Disable(EnableCap.Blend); } else { Vbo.Render(); } } GLExt.PopMatrix(); }
/// <summary> /// aseta texturematriisit shadowmapping shaderia varten /// </summary> static void SetTextureMatrix() { Matrix4 projMatrix = GLExt.ProjectionMatrix, modelMatrix = GLExt.ModelViewMatrix; GLExt.MatrixMode(MatrixMode.Texture); GLExt.LoadIdentity(); GLExt.Translate(0.5f, 0.5f, 0.5f); // remap from [-1,1]^2 to [0,1]^2 GLExt.Scale(0.5f, 0.5f, 0.5f); GLExt.MultMatrix(ref projMatrix); GLExt.MultMatrix(ref modelMatrix); GLExt.MatrixMode(MatrixMode.Modelview); }
void Translate(Node node) { Node obj = node; if (node == null) { obj = this; } GLExt.Translate(obj.Position.X, obj.Position.Y, obj.Position.Z); GLExt.RotateZ(Rotation.Z); GLExt.RotateY(Rotation.Y); GLExt.RotateX(Rotation.X); GLExt.MultMatrix(ref OrigOrientationMatrix); GLExt.Scale(obj.Scale.X, obj.Scale.Y, obj.Scale.Z); }
public void DrawFullScreen(int x, int y) { float sx = (float)Settings.Width / (float)RealWidth; float sy = (float)Settings.Height / (float)RealHeight; if (Vbo == null) { CreateVBO(false); } Bind(0); GLExt.PushMatrix(); { GLExt.Translate(sx * x, Settings.Height + sy * (y - RealHeight), 0); GLExt.Scale(sx, sy, 1); Vbo.Render(); } GLExt.PopMatrix(); }
/// <summary> /// renderoi partikkelit, sorttaa läpinäkyvät. /// </summary> public static new void Render() { GLExt.Color4(1f, 1, 1, 1f); GLExt.PushMatrix(); GLExt.SetLighting(false); List <SortedList_Particles> slist = new List <SortedList_Particles>(); GL.Disable(EnableCap.CullFace); int c = 0; // järjestetään taulukko kauimmaisesta lähimpään. pitää rendata siinä järjestyksessä. // vain läpikuultavat pitää järjestää. täysin näkyvät renderoidaan samantien. for (int q = 0; q < ParticleGroups.Count; q++) { Particles curpar = ParticleGroups[q]; if (curpar.particles.Count <= 0) { continue; } if (VBO.FastRenderPass == true) { if (curpar.CastShadow == false) { continue; } } curpar.particles[0].partTex.Bind(0); GLExt.PushMatrix(); GLExt.MultMatrix(ref curpar.WorldMatrix); for (int w = 0; w < curpar.NumOfParticles; w++) { Particle p = curpar.particles[w]; GLExt.PushMatrix(); GLExt.Translate(p.pos.X, p.pos.Y, p.pos.Z); Matrix4 matrix = Matrix4.Identity; matrix.Row3 = GLExt.ModelViewMatrix.Row3; GLExt.ModelViewMatrix = matrix; Vector3 v = curpar.WorldMatrix.Row3.Xyz + curpar.Position + p.pos; if (Frustum.SphereInFrustum(v.X, v.Y, v.Z, 10) != 0) { if (VBO.FastRenderPass == true) // renderoi partikkeli depthbufferiin (varjostusta varten) { GLExt.Scale(p.size, p.size, p.size); GLExt.RotateZ(p.zrot); p.partTex.RenderBillboard(); } else { c++; if (p.isTransparent == true) // listaan renderoitavaks myöhemmin { float len = (Camera.cam.Position - matrix.Row3.Xyz).LengthSquared; slist.Add(new SortedList_Particles(len, p, matrix)); } else // rendataan se nyt, ei lisätä sortattavaks { GLExt.Scale(p.size, p.size, p.size); GLExt.RotateZ(p.zrot); GLExt.Color4(p.color.X, p.color.Y, p.color.Z, p.color.W);; if (p.callBack != null) { p.callBack(p); } p.partTex.RenderBillboard(); } } } GLExt.PopMatrix(); } GLExt.PopMatrix(); } if (VBO.FastRenderPass == false) { slist.Sort(delegate(SortedList_Particles z1, SortedList_Particles z2) { return(z2.Len.CompareTo(z1.Len)); }); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One); // rendataan läpikuultavat GL.DepthMask(false); // ei kirjoiteta zbufferiin for (int q = 0; q < slist.Count; q++) { Particle p = slist[q].Part; if (VBO.FastRenderPass == false) { p.partTex.Bind(0); GLExt.Color4(p.color.X, p.color.Y, p.color.Z, p.color.W); if (p.callBack != null) { p.callBack(p); } } GLExt.LoadMatrix(ref slist[q].Matrix); GLExt.Scale(p.size, p.size, p.size); GLExt.RotateZ(p.zrot); p.partTex.RenderBillboard(); } GL.DepthMask(true); GL.Disable(EnableCap.Blend); } GLExt.PopMatrix(); GL.Enable(EnableCap.CullFace); GLExt.Color4(1, 1, 1, 1); GLExt.SetLighting(true); GameClass.NumOfObjects += c; }