コード例 #1
0
 public ModelMesh(string _name)
 {
     Name = _name.ToLowerFast();
     if (Name.EndsWith(".001"))
     {
         Name = Name.Substring(0, Name.Length - ".001".Length);
     }
     Faces = new List <ModelFace>();
     vbo   = new VBO();
 }
コード例 #2
0
 void GenerateLineVBO()
 {
     Vector3[] vecs  = new Vector3[2];
     uint[]    inds  = new uint[2];
     Vector3[] norms = new Vector3[2];
     Vector3[] texs  = new Vector3[2];
     Vector4[] cols  = new Vector4[2];
     Vector3[] tangs = new Vector3[2];
     for (uint u = 0; u < 2; u++)
     {
         inds[u]  = u;
         tangs[u] = new Vector3(0f, 0f, 0f);
     }
     for (int n = 0; n < 2; n++)
     {
         norms[n] = new Vector3(0, 0, 1);
     }
     for (int c = 0; c < 2; c++)
     {
         cols[c] = new Vector4(1, 1, 1, 1);
     }
     Vector4[] BoneIDs      = new Vector4[2];
     Vector4[] BoneWeights  = new Vector4[2];
     Vector4[] BoneIDs2     = new Vector4[2];
     Vector4[] BoneWeights2 = new Vector4[2];
     for (int n = 0; n < 2; n++)
     {
         BoneIDs[n]      = new Vector4(0, 0, 0, 0);
         BoneWeights[n]  = new Vector4(0, 0, 0, 0);
         BoneIDs2[n]     = new Vector4(0, 0, 0, 0);
         BoneWeights2[n] = new Vector4(0, 0, 0, 0);
     }
     vecs[0] = new Vector3(0, 0, 0);
     texs[0] = new Vector3(0, 0, 0);
     vecs[1] = new Vector3(1, 0, 0);
     texs[1] = new Vector3(1, 0, 0);
     Line    = new VBO()
     {
         Vertices     = vecs.ToList(),
         Indices      = inds.ToList(),
         Normals      = norms.ToList(),
         TexCoords    = texs.ToList(),
         Colors       = cols.ToList(),
         BoneIDs      = BoneIDs.ToList(),
         BoneWeights  = BoneWeights.ToList(),
         BoneIDs2     = BoneIDs2.ToList(),
         BoneWeights2 = BoneWeights2.ToList()
     };
     Line.GenerateVBO();
 }
コード例 #3
0
 void GenerateSquareVBO()
 {
     Vector3[] vecs         = new Vector3[6];
     uint[]    inds         = new uint[6];
     Vector3[] norms        = new Vector3[6];
     Vector3[] texs         = new Vector3[6];
     Vector4[] cols         = new Vector4[6];
     Vector4[] BoneIDs      = new Vector4[6];
     Vector4[] BoneWeights  = new Vector4[6];
     Vector4[] BoneIDs2     = new Vector4[6];
     Vector4[] BoneWeights2 = new Vector4[6];
     for (uint n = 0; n < 6; n++)
     {
         inds[n]         = n;
         norms[n]        = new Vector3(0, 0, 1);
         cols[n]         = new Vector4(1, 1, 1, 1);
         BoneIDs[n]      = new Vector4(0, 0, 0, 0);
         BoneWeights[n]  = new Vector4(0, 0, 0, 0);
         BoneIDs2[n]     = new Vector4(0, 0, 0, 0);
         BoneWeights2[n] = new Vector4(0, 0, 0, 0);
     }
     vecs[0] = new Vector3(1, 0, 0);
     texs[0] = new Vector3(1, 0, 0);
     vecs[1] = new Vector3(1, 1, 0);
     texs[1] = new Vector3(1, 1, 0);
     vecs[2] = new Vector3(0, 1, 0);
     texs[2] = new Vector3(0, 1, 0);
     vecs[3] = new Vector3(1, 0, 0);
     texs[3] = new Vector3(1, 0, 0);
     vecs[4] = new Vector3(0, 1, 0);
     texs[4] = new Vector3(0, 1, 0);
     vecs[5] = new Vector3(0, 0, 0);
     texs[5] = new Vector3(0, 0, 0);
     Square  = new VBO()
     {
         Vertices     = vecs.ToList(),
         Indices      = inds.ToList(),
         Normals      = norms.ToList(),
         TexCoords    = texs.ToList(),
         Colors       = cols.ToList(),
         BoneIDs      = BoneIDs.ToList(),
         BoneWeights  = BoneWeights.ToList(),
         BoneIDs2     = BoneIDs2.ToList(),
         BoneWeights2 = BoneWeights2.ToList()
     };
     Square.GenerateVBO();
 }
コード例 #4
0
ファイル: BlockItemEntity.cs プロジェクト: Morphan1/Voxalia
 public void GenVBO()
 {
     vbo = new VBO();
     List<BEPUutilities.Vector3> vecs = BlockShapeRegistry.BSD[Dat].GetVertices(new BEPUutilities.Vector3(0, 0, 0), false, false, false, false, false, false);
     List<BEPUutilities.Vector3> norms = BlockShapeRegistry.BSD[Dat].GetNormals(new BEPUutilities.Vector3(0, 0, 0), false, false, false, false, false, false);
     List<BEPUutilities.Vector3> tcoord = BlockShapeRegistry.BSD[Dat].GetTCoords(new BEPUutilities.Vector3(0, 0, 0), Mat, false, false, false, false, false, false);
     vbo.Vertices = new List<OpenTK.Vector3>();
     vbo.Normals = new List<OpenTK.Vector3>();
     vbo.TexCoords = new List<OpenTK.Vector3>();
     vbo.Indices = new List<uint>();
     vbo.Colors = new List<Vector4>();
     vbo.TCOLs = new List<Vector4>();
     vbo.Tangents = new List<Vector3>();
     vbo.THVs = new List<Vector4>();
     vbo.THWs = new List<Vector4>();
     System.Drawing.Color tcol = Voxalia.Shared.Colors.ForByte(Paint);
     for (int i = 0; i < vecs.Count; i++)
     {
         vbo.Vertices.Add(new OpenTK.Vector3((float)vecs[i].X, (float)vecs[i].Y, (float)vecs[i].Z));
         vbo.Normals.Add(new OpenTK.Vector3((float)norms[i].X, (float)norms[i].Y, (float)norms[i].Z));
         vbo.TexCoords.Add(new OpenTK.Vector3((float)tcoord[i].X, (float)tcoord[i].Y, (float)tcoord[i].Z));
         vbo.Indices.Add((uint)i);
         vbo.Colors.Add(new Vector4(1, 1, 1, 1));
         vbo.TCOLs.Add(TheClient.Rendering.AdaptColor(vbo.Vertices[i], tcol));
     }
     for (int i = 0; i < vecs.Count; i += 3)
     {
         int basis = i;
         OpenTK.Vector3 v1 = vbo.Vertices[basis];
         OpenTK.Vector3 dv1 = vbo.Vertices[basis + 1] - v1;
         OpenTK.Vector3 dv2 = vbo.Vertices[basis + 2] - v1;
         OpenTK.Vector3 t1 = vbo.TexCoords[basis];
         OpenTK.Vector3 dt1 = vbo.TexCoords[basis + 1] - t1;
         OpenTK.Vector3 dt2 = vbo.TexCoords[basis + 2] - t1;
         OpenTK.Vector3 tangent = (dv1 * dt2.Y - dv2 * dt1.Y) * 1f / (dt1.X * dt2.Y - dt1.Y * dt2.X);
         OpenTK.Vector3 normal = vbo.Normals[basis];
         tangent = (tangent - normal * OpenTK.Vector3.Dot(normal, tangent)).Normalized();
         for (int x = 0; x < 3; x++)
         {
             vbo.Tangents.Add(tangent);
             vbo.THVs.Add(new Vector4(0, 0, 0, 0));
             vbo.THWs.Add(new Vector4(0, 0, 0, 0));
         }
     }
     vbo.GenerateVBO();
 }
コード例 #5
0
ファイル: ChunkRendering.cs プロジェクト: Morphan1/Voxalia
 void VBOHInternal(Chunk c_zp, Chunk c_zm, Chunk c_yp, Chunk c_ym, Chunk c_xp, Chunk c_xm, Chunk c_zpxp, Chunk c_zpxm, Chunk c_zpyp, Chunk c_zpym, List<Chunk> potentials)
 {
     try
     {
         bool shaped = OwningRegion.TheClient.CVars.r_noblockshapes.ValueB;
         Object locky = new Object();
         ChunkRenderHelper rh;
         lock (locky)
         {
             rh = new ChunkRenderHelper();
         }
         if (DENIED)
         {
             return;
         }
         //bool light = OwningRegion.TheClient.CVars.r_fallbacklighting.ValueB
         BlockInternal t_air = new BlockInternal((ushort)Material.AIR, 0, 0, 255);
         List<Vector3> poses = new List<Vector3>();
         List<Vector4> colorses = new List<Vector4>();
         for (int x = 0; x < CSize; x++)
         {
             for (int y = 0; y < CSize; y++)
             {
                 for (int z = 0; z < CSize; z++)
                 {
                     BlockInternal c = GetBlockAt(x, y, z);
                     if ((c.Material).RendersAtAll())
                     {
                         BlockInternal zp = z + 1 < CSize ? GetBlockAt(x, y, z + 1) : (c_zp == null ? t_air : GetLODRelative(c_zp, x, y, z + 1 - CSize));
                         BlockInternal zm = z > 0 ? GetBlockAt(x, y, z - 1) : (c_zm == null ? t_air : GetLODRelative(c_zm, x, y, z - 1 + CSize));
                         BlockInternal yp = y + 1 < CSize ? GetBlockAt(x, y + 1, z) : (c_yp == null ? t_air : GetLODRelative(c_yp, x, y + 1 - CSize, z));
                         BlockInternal ym = y > 0 ? GetBlockAt(x, y - 1, z) : (c_ym == null ? t_air : GetLODRelative(c_ym, x, y - 1 + CSize, z));
                         BlockInternal xp = x + 1 < CSize ? GetBlockAt(x + 1, y, z) : (c_xp == null ? t_air : GetLODRelative(c_xp, x + 1 - CSize, y, z));
                         BlockInternal xm = x > 0 ? GetBlockAt(x - 1, y, z) : (c_xm == null ? t_air : GetLODRelative(c_xm, x - 1 + CSize, y, z));
                         bool rAS = !((Material)c.BlockMaterial).GetCanRenderAgainstSelf();
                         bool pMatters = !c.IsOpaque();
                         bool zps = (zp.IsOpaque() || (rAS && (zp.BlockMaterial == c.BlockMaterial && (pMatters || zp.BlockPaint == c.BlockPaint)))) && BlockShapeRegistry.BSD[shaped ? 0 : zp.BlockData].OccupiesBOTTOM();
                         bool zms = (zm.IsOpaque() || (rAS && (zm.BlockMaterial == c.BlockMaterial && (pMatters || zm.BlockPaint == c.BlockPaint)))) && BlockShapeRegistry.BSD[shaped ? 0 : zm.BlockData].OccupiesTOP();
                         bool xps = (xp.IsOpaque() || (rAS && (xp.BlockMaterial == c.BlockMaterial && (pMatters || xp.BlockPaint == c.BlockPaint)))) && BlockShapeRegistry.BSD[shaped ? 0 : xp.BlockData].OccupiesXM();
                         bool xms = (xm.IsOpaque() || (rAS && (xm.BlockMaterial == c.BlockMaterial && (pMatters || xm.BlockPaint == c.BlockPaint)))) && BlockShapeRegistry.BSD[shaped ? 0 : xm.BlockData].OccupiesXP();
                         bool yps = (yp.IsOpaque() || (rAS && (yp.BlockMaterial == c.BlockMaterial && (pMatters || yp.BlockPaint == c.BlockPaint)))) && BlockShapeRegistry.BSD[shaped ? 0 : yp.BlockData].OccupiesYM();
                         bool yms = (ym.IsOpaque() || (rAS && (ym.BlockMaterial == c.BlockMaterial && (pMatters || ym.BlockPaint == c.BlockPaint)))) && BlockShapeRegistry.BSD[shaped ? 0 : ym.BlockData].OccupiesYP();
                         if (zps && zms && xps && xms && yps && yms)
                         {
                             continue;
                         }
                         BlockInternal zpyp;
                         BlockInternal zpym;
                         BlockInternal zpxp;
                         BlockInternal zpxm;
                         if (z + 1 >= CSize)
                         {
                             zpyp = y + 1 < CSize ? (c_zp == null ? t_air : GetLODRelative(c_zp, x, y + 1, z + 1 - CSize)) : (c_zpyp == null ? t_air : GetLODRelative(c_zpyp, x, y + 1 - CSize, z + 1 - CSize));
                             zpym = y > 0 ? (c_zp == null ? t_air : GetLODRelative(c_zp, x, y - 1, z + 1 - CSize)) : (c_zpym == null ? t_air : GetLODRelative(c_zpym, x, y - 1 + CSize, z + 1 - CSize));
                             zpxp = x + 1 < CSize ? (c_zp == null ? t_air : GetLODRelative(c_zp, x + 1, y, z + 1 - CSize)) : (c_zpxp == null ? t_air : GetLODRelative(c_zpxp, x + 1 - CSize, y, z + 1 - CSize));
                             zpxm = x > 0 ? (c_zp == null ? t_air : GetLODRelative(c_zp, x - 1, y, z + 1 - CSize)) : (c_zpxm == null ? t_air : GetLODRelative(c_zpxm, x - 1 + CSize, y, z + 1 - CSize));
                         }
                         else
                         {
                             zpyp = y + 1 < CSize ? GetBlockAt(x, y + 1, z + 1) : (c_yp == null ? t_air : GetLODRelative(c_yp, x, y + 1 - CSize, z + 1));
                             zpym = y > 0 ? GetBlockAt(x, y - 1, z + 1) : (c_ym == null ? t_air : GetLODRelative(c_ym, x, y - 1 + CSize, z + 1));
                             zpxp = x + 1 < CSize ? GetBlockAt(x + 1, y, z + 1) : (c_xp == null ? t_air : GetLODRelative(c_xp, x + 1 - CSize, y, z + 1));
                             zpxm = x > 0 ? GetBlockAt(x - 1, y, z + 1) : (c_xm == null ? t_air : GetLODRelative(c_xm, x - 1 + CSize, y, z + 1));
                         }
                         int index_bssd = (xps ? 1 : 0) | (xms ? 2 : 0) | (yps ? 4 : 0) | (yms ? 8 : 0) | (zps ? 16 : 0) | (zms ? 32 : 0);
                         List<BEPUutilities.Vector3> vecsi = BlockShapeRegistry.BSD[shaped ? 0 : c.BlockData].BSSD.Verts[index_bssd];
                         List<BEPUutilities.Vector3> normsi = BlockShapeRegistry.BSD[shaped ? 0 : c.BlockData].BSSD.Norms[index_bssd];
                         BEPUutilities.Vector3[] tci = BlockShapeRegistry.BSD[shaped ? 0 : c.BlockData].GetTCoordsQuick(index_bssd, c.Material);
                         KeyValuePair<List<BEPUutilities.Vector4>, List<BEPUutilities.Vector4>> ths = !c.BlockShareTex ? default(KeyValuePair<List<BEPUutilities.Vector4>, List<BEPUutilities.Vector4>>) :
                             BlockShapeRegistry.BSD[shaped ? 0 : c.BlockData].GetStretchData(new BEPUutilities.Vector3(x, y, z), vecsi, xp, xm, yp, ym, zp, zm, xps, xms, yps, yms, zps, zms);
                         for (int i = 0; i < vecsi.Count; i++)
                         {
                             Vector3 vt = new Vector3((float)(x + vecsi[i].X) * PosMultiplier, (float)(y + vecsi[i].Y) * PosMultiplier, (float)(z + vecsi[i].Z) * PosMultiplier);
                             rh.Vertices.Add(vt);
                             Vector3 nt = new Vector3((float)normsi[i].X, (float)normsi[i].Y, (float)normsi[i].Z);
                             rh.Norms.Add(nt);
                             rh.TCoords.Add(new Vector3((float)tci[i].X, (float)tci[i].Y, (float)tci[i].Z));
                             byte reldat = 255;
                             if (nt.X > 0.6)
                             {
                                 reldat = zpxp.BlockLocalData;
                             }
                             else if (nt.X < -0.6)
                             {
                                 reldat = zpxm.BlockLocalData;
                             }
                             else if (nt.Y > 0.6)
                             {
                                 reldat = zpyp.BlockLocalData;
                             }
                             else if (nt.Y < -0.6)
                             {
                                 reldat = zpym.BlockLocalData;
                             }
                             else if (nt.Z < 0)
                             {
                                 reldat = c.BlockLocalData;
                             }
                             else
                             {
                                 reldat = zp.BlockLocalData;
                             }
                             Location lcol = OwningRegion.GetLightAmountForSkyValue(ClientUtilities.Convert(vt) + WorldPosition.ToLocation() * CHUNK_SIZE, ClientUtilities.Convert(nt), potentials, reldat / 255f);
                             rh.Cols.Add(new Vector4((float)lcol.X, (float)lcol.Y, (float)lcol.Z, 1));
                             rh.TCols.Add(OwningRegion.TheClient.Rendering.AdaptColor(ClientUtilities.ConvertD(WorldPosition.ToLocation()) * CHUNK_SIZE + ClientUtilities.ConvertToD(vt), Colors.ForByte(c.BlockPaint)));
                             if (ths.Key != null)
                             {
                                 rh.THVs.Add(new Vector4((float)ths.Key[i].X, (float)ths.Key[i].Y, (float)ths.Key[i].Z, (float)ths.Key[i].W));
                                 rh.THWs.Add(new Vector4((float)ths.Value[i].X, (float)ths.Value[i].Y, (float)ths.Value[i].Z, (float)ths.Value[i].W));
                             }
                             else
                             {
                                 rh.THVs.Add(new Vector4(0, 0, 0, 0));
                                 rh.THWs.Add(new Vector4(0, 0, 0, 0));
                             }
                         }
                         if (!c.IsOpaque() && BlockShapeRegistry.BSD[shaped ? 0 : c.BlockData].BackTextureAllowed)
                         {
                             int tf = rh.Cols.Count - vecsi.Count;
                             for (int i = vecsi.Count - 1; i >= 0; i--)
                             {
                                 Vector3 vt = new Vector3((float)(x + vecsi[i].X) * PosMultiplier, (float)(y + vecsi[i].Y) * PosMultiplier, (float)(z + vecsi[i].Z) * PosMultiplier);
                                 rh.Vertices.Add(vt);
                                 int tx = tf + i;
                                 rh.Cols.Add(rh.Cols[tx]);
                                 rh.TCols.Add(rh.TCols[tx]);
                                 rh.Norms.Add(new Vector3((float)-normsi[i].X, (float)-normsi[i].Y, (float)-normsi[i].Z));
                                 rh.TCoords.Add(new Vector3((float)tci[i].X, (float)tci[i].Y, (float)tci[i].Z));
                                 if (ths.Key != null)
                                 {
                                     rh.THVs.Add(new Vector4((float)ths.Key[i].X, (float)ths.Key[i].Y, (float)ths.Key[i].Z, (float)ths.Key[i].W));
                                     rh.THWs.Add(new Vector4((float)ths.Value[i].X, (float)ths.Value[i].Y, (float)ths.Value[i].Z, (float)ths.Value[i].W));
                                 }
                                 else
                                 {
                                     rh.THVs.Add(new Vector4(0, 0, 0, 0));
                                     rh.THWs.Add(new Vector4(0, 0, 0, 0));
                                 }
                             }
                         }
                         if (PosMultiplier == 1 && c.Material.GetPlant() != null && !zp.Material.RendersAtAll() && zp.Material.GetSolidity() == MaterialSolidity.NONSOLID)
                         {
                             if (BlockShapeRegistry.BSD[c.BlockData].Coll == null)
                             {
                                 // TODO: BSD-level precompute this?
                                 Location offset;
                                 BEPUphysics.CollisionShapes.EntityShape es = BlockShapeRegistry.BSD[c.BlockData].GetShape(c.Damage, out offset, false);
                                 BlockShapeRegistry.BSD[c.BlockData].Coll = es.GetCollidableInstance();
                                 BlockShapeRegistry.BSD[c.BlockData].Coll.LocalPosition = -offset.ToBVector();
                             }
                             Location skylight = OwningRegion.GetLightAmountForSkyValue(new Location(WorldPosition.X * Chunk.CHUNK_SIZE + x + 0.5, WorldPosition.Y * Chunk.CHUNK_SIZE + y + 0.5,
                                 WorldPosition.Z * Chunk.CHUNK_SIZE + z + 1.0), Location.UnitZ, potentials, zp.BlockLocalData / 255f);
                             for (int plx = 0; plx < 3; plx++)
                             {
                                 for (int ply = 0; ply < 3; ply++)
                                 {
                                     BEPUutilities.RayHit rayhit;
                                     if (!BlockShapeRegistry.BSD[c.BlockData].Coll.RayCast(new BEPUutilities.Ray(new BEPUutilities.Vector3(0.3333f * plx, 0.3333f * ply, 3), new BEPUutilities.Vector3(0, 0, -1)), 5, out rayhit))
                                     {
                                         rayhit.Location = new BEPUutilities.Vector3(0.3333 * plx, 0.3333 * ply, 1.0);
                                     }
                                     poses.Add(new Vector3(x + (float)rayhit.Location.X, y + (float)rayhit.Location.Y, z + (float)rayhit.Location.Z));
                                     colorses.Add(new Vector4((float)skylight.X, (float)skylight.Y, (float)skylight.Z, 1.0f));
                                 }
                             }
                         }
                     }
                 }
             }
         }
         for (int i = 0; i < rh.Vertices.Count; i += 3)
         {
             Vector3 v1 = rh.Vertices[i];
             Vector3 dv1 = rh.Vertices[i + 1] - v1;
             Vector3 dv2 = rh.Vertices[i + 2] - v1;
             Vector3 t1 = rh.TCoords[i];
             Vector3 dt1 = rh.TCoords[i + 1] - t1;
             Vector3 dt2 = rh.TCoords[i + 2] - t1;
             Vector3 tangent = (dv1 * dt2.Y - dv2 * dt1.Y) / (dt1.X * dt2.Y - dt1.Y * dt2.X);
             Vector3 normal = rh.Norms[i];
             tangent = (tangent - normal * Vector3.Dot(normal, tangent)).Normalized(); // TODO: Necessity of this correction?
             rh.Tangs.Add(tangent);
             rh.Tangs.Add(tangent);
             rh.Tangs.Add(tangent);
         }
         if (rh.Vertices.Count == 0)
         {
             OwningRegion.TheClient.Schedule.ScheduleSyncTask(() =>
             {
                 if (_VBO != null)
                 {
                     VBO tV = _VBO;
                     lock (OwningRegion.TheClient.vbos)
                     {
                         if (OwningRegion.TheClient.vbos.Count < 40)
                         {
                             OwningRegion.TheClient.vbos.Push(tV);
                         }
                         else
                         {
                             tV.Destroy();
                         }
                     }
                 }
                 IsAir = true;
                 _VBO = null;
             });
             OwningRegion.DoneRendering(this);
             return;
         }
         uint[] inds = new uint[rh.Vertices.Count];
         for (uint i = 0; i < rh.Vertices.Count; i++)
         {
             inds[i] = i;
         }
         VBO tVBO;
         lock (locky)
         {
             lock (OwningRegion.TheClient.vbos)
             {
                 if (OwningRegion.TheClient.vbos.Count > 0)
                 {
                     tVBO = OwningRegion.TheClient.vbos.Pop();
                 }
                 else
                 {
                     tVBO = new VBO();
                     //tVBO.BufferMode = OpenTK.Graphics.OpenGL4.BufferUsageHint.StreamDraw;
                 }
             }
             tVBO.indices = inds;
             tVBO.Vertices = rh.Vertices;
             tVBO.Normals = rh.Norms;
             tVBO.TexCoords = rh.TCoords;
             tVBO.Colors = rh.Cols;
             tVBO.TCOLs = rh.TCols;
             tVBO.THVs = rh.THVs;
             tVBO.THWs = rh.THWs;
             tVBO.Tangents = rh.Tangs;
             tVBO.BoneWeights = null;
             tVBO.BoneIDs = null;
             tVBO.BoneWeights2 = null;
             tVBO.BoneIDs2 = null;
             tVBO.oldvert();
         }
         Vector3[] posset = poses.ToArray();
         Vector4[] colorset = colorses.ToArray();
         uint[] posind = new uint[posset.Length];
         for (uint i = 0; i < posind.Length; i++)
         {
             posind[i] = i;
         }
         OwningRegion.TheClient.Schedule.ScheduleSyncTask(() =>
         {
             if (DENIED)
             {
                 if (tVBO.generated)
                 {
                     tVBO.Destroy();
                 }
                 return;
             }
             lock (locky)
             {
                 if (tVBO.verts == null)
                 {
                     SysConsole.Output(OutputType.WARNING, "Something went wrong! : tVBO.verts==null while rh.Vertice==" + (rh.Vertices == null ? "null" : rh.Vertices.Count + "_vertices"));
                     // TODO: What even happened here?!
                     tVBO.indices = inds;
                     tVBO.Vertices = rh.Vertices;
                     tVBO.Normals = rh.Norms;
                     tVBO.TexCoords = rh.TCoords;
                     tVBO.Colors = rh.Cols;
                     tVBO.TCOLs = rh.TCols;
                     tVBO.THVs = rh.THVs;
                     tVBO.THWs = rh.THWs;
                     tVBO.Tangents = rh.Tangs;
                 }
             }
             VBO tV = _VBO;
             if (tV != null)
             {
                 lock (OwningRegion.TheClient.vbos)
                 {
                     if (OwningRegion.TheClient.vbos.Count < 40)
                     {
                         OwningRegion.TheClient.vbos.Push(tV);
                     }
                     else
                     {
                         tV.Destroy();
                     }
                 }
             }
             if (DENIED)
             {
                 if (tVBO.generated)
                 {
                     tVBO.Destroy();
                 }
                 return;
             }
             _VBO = tVBO;
             lock (locky)
             {
                 tVBO.GenerateOrUpdate();
                 tVBO.CleanLists();
             }
             DestroyPlants();
             Plant_VAO = GL.GenVertexArray();
             Plant_VBO_Ind = GL.GenBuffer();
             Plant_VBO_Pos = GL.GenBuffer();
             Plant_VBO_Col = GL.GenBuffer();
             Plant_C = posind.Length;
             GL.BindBuffer(BufferTarget.ArrayBuffer, Plant_VBO_Pos);
             GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(posset.Length * OpenTK.Vector3.SizeInBytes), posset, BufferUsageHint.StaticDraw);
             GL.BindBuffer(BufferTarget.ArrayBuffer, Plant_VBO_Col);
             GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(colorset.Length * OpenTK.Vector4.SizeInBytes), colorset, BufferUsageHint.StaticDraw);
             GL.BindBuffer(BufferTarget.ElementArrayBuffer, Plant_VBO_Ind);
             GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(posind.Length * sizeof(uint)), posind, BufferUsageHint.StaticDraw);
             GL.BindVertexArray(Plant_VAO);
             GL.BindBuffer(BufferTarget.ArrayBuffer, Plant_VBO_Pos);
             GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
             GL.EnableVertexAttribArray(0);
             GL.BindBuffer(BufferTarget.ArrayBuffer, Plant_VBO_Col);
             GL.VertexAttribPointer(4, 4, VertexAttribPointerType.Float, false, 0, 0);
             GL.EnableVertexAttribArray(4);
             GL.BindBuffer(BufferTarget.ElementArrayBuffer, Plant_VBO_Ind);
             GL.BindVertexArray(0);
             OnRendered?.Invoke();
         });
         OwningRegion.DoneRendering(this);
     }
     catch (Exception ex)
     {
         SysConsole.Output(OutputType.ERROR, "Generating ChunkVBO...: " + ex.ToString());
         OwningRegion.DoneRendering(this);
     }
 }
コード例 #6
0
        void GenerateBoxVBO()
        {
            // TODO: Optimize?
            Vector3[] vecs  = new Vector3[24];
            uint[]    inds  = new uint[24];
            Vector3[] norms = new Vector3[24];
            Vector3[] texs  = new Vector3[24];
            Vector4[] cols  = new Vector4[24];
            Vector3[] tangs = new Vector3[24];
            for (uint u = 0; u < 24; u++)
            {
                inds[u]  = u;
                tangs[u] = new Vector3(1f, 0f, 0f);
            }
            for (int t = 0; t < 24; t++)
            {
                texs[t] = new Vector3(0, 0, 0);
            }
            for (int n = 0; n < 24; n++)
            {
                norms[n] = new Vector3(0, 0, 1); // TODO: Accurate normals somehow? Do lines even have normals?
            }
            for (int c = 0; c < 24; c++)
            {
                cols[c] = new Vector4(1, 1, 1, 1);
            }
            Vector4[] BoneIDs      = new Vector4[24];
            Vector4[] BoneWeights  = new Vector4[24];
            Vector4[] BoneIDs2     = new Vector4[24];
            Vector4[] BoneWeights2 = new Vector4[24];
            for (int n = 0; n < 24; n++)
            {
                BoneIDs[n]      = new Vector4(0, 0, 0, 0);
                BoneWeights[n]  = new Vector4(0, 0, 0, 0);
                BoneIDs2[n]     = new Vector4(0, 0, 0, 0);
                BoneWeights2[n] = new Vector4(0, 0, 0, 0);
            }
            int i    = 0;
            int zero = -1; // Ssh.

            vecs[i] = new Vector3(zero, zero, zero); i++;
            vecs[i] = new Vector3(1, zero, zero); i++;
            vecs[i] = new Vector3(1, zero, zero); i++;
            vecs[i] = new Vector3(1, 1, zero); i++;
            vecs[i] = new Vector3(1, 1, zero); i++;
            vecs[i] = new Vector3(zero, 1, zero); i++;
            vecs[i] = new Vector3(zero, 1, zero); i++;
            vecs[i] = new Vector3(zero, zero, zero); i++;
            vecs[i] = new Vector3(zero, zero, 1); i++;
            vecs[i] = new Vector3(1, zero, 1); i++;
            vecs[i] = new Vector3(1, zero, 1); i++;
            vecs[i] = new Vector3(1, 1, 1); i++;
            vecs[i] = new Vector3(1, 1, 1); i++;
            vecs[i] = new Vector3(zero, 1, 1); i++;
            vecs[i] = new Vector3(zero, 1, 1); i++;
            vecs[i] = new Vector3(zero, zero, 1); i++;
            vecs[i] = new Vector3(zero, zero, zero); i++;
            vecs[i] = new Vector3(zero, zero, 1); i++;
            vecs[i] = new Vector3(1, zero, zero); i++;
            vecs[i] = new Vector3(1, zero, 1); i++;
            vecs[i] = new Vector3(1, 1, zero); i++;
            vecs[i] = new Vector3(1, 1, 1); i++;
            vecs[i] = new Vector3(zero, 1, zero); i++;
            vecs[i] = new Vector3(zero, 1, 1); i++;
            Box     = new VBO()
            {
                Vertices     = vecs.ToList(),
                Indices      = inds.ToList(),
                Normals      = norms.ToList(),
                TexCoords    = texs.ToList(),
                Colors       = cols.ToList(),
                BoneIDs      = BoneIDs.ToList(),
                BoneWeights  = BoneWeights.ToList(),
                BoneIDs2     = BoneIDs2.ToList(),
                BoneWeights2 = BoneWeights2.ToList()
            };
            Box.GenerateVBO();
        }
コード例 #7
0
ファイル: ClientRender.cs プロジェクト: Morphan1/Voxalia
 void InitRendering()
 {
     MainWorldView.CameraModifier = () => Player.GetRelativeQuaternion();
     ShadersCheck();
     View3D.CheckError("Load - Rendering - Shaders");
     generateMapHelpers();
     View3D.CheckError("Load - Rendering - Map");
     MainWorldView.ShadowingAllowed = true;
     MainWorldView.ShadowTexSize = () => CVars.r_shadowquality.ValueI;
     MainWorldView.Render3D = Render3D;
     MainWorldView.PostFirstRender = ReverseEntitiesOrder;
     MainWorldView.LLActive = CVars.r_transpll.ValueB; // TODO: CVar edit call back
     View3D.CheckError("Load - Rendering - Settings");
     MainWorldView.Generate(this, Window.Width, Window.Height);
     View3D.CheckError("Load - Rendering - ViewGen");
     skybox = new VBO[6];
     for (int i = 0; i < 6; i++)
     {
         skybox[i] = new VBO();
         skybox[i].Prepare();
     }
     skybox[0].AddSide(-Location.UnitZ, new TextureCoordinates());
     skybox[1].AddSide(Location.UnitZ, new TextureCoordinates());
     skybox[2].AddSide(-Location.UnitX, new TextureCoordinates());
     skybox[3].AddSide(Location.UnitX, new TextureCoordinates());
     skybox[4].AddSide(-Location.UnitY, new TextureCoordinates());
     skybox[5].AddSide(Location.UnitY, new TextureCoordinates());
     View3D.CheckError("Load - Rendering - VBO Prep");
     for (int i = 0; i < 6; i++)
     {
         skybox[i].GenerateVBO();
     }
     View3D.CheckError("Load - Rendering - Final");
 }
コード例 #8
0
ファイル: BlockGroupEntity.cs プロジェクト: Morphan1/Voxalia
 // TODO: Make asyncable!
 public void SetupVBO()
 {
     List<OpenTK.Vector3> Vertices = new List<OpenTK.Vector3>(XWidth * YWidth * ZWidth);
     List<OpenTK.Vector3> Normals = new List<OpenTK.Vector3>(XWidth * YWidth * ZWidth);
     List<OpenTK.Vector3> TexCoords = new List<OpenTK.Vector3>(XWidth * YWidth * ZWidth);
     List<OpenTK.Vector4> Colrs = new List<OpenTK.Vector4>(XWidth * YWidth * ZWidth);
     List<OpenTK.Vector4> TCOLs = new List<OpenTK.Vector4>(XWidth * YWidth * ZWidth);
     List<OpenTK.Vector3> Tangs = new List<OpenTK.Vector3>(XWidth * YWidth * ZWidth);
     for (int x = 0; x < XWidth; x++)
     {
         for (int y = 0; y < YWidth; y++)
         {
             for (int z = 0; z < ZWidth; z++)
             {
                 BlockInternal c = GetBlockAt(x, y, z);
                 if (((Material)c.BlockMaterial).RendersAtAll())
                 {
                     BlockInternal def = new BlockInternal(0, 0, 0, 0);
                     BlockInternal zp = z + 1 < ZWidth ? GetBlockAt(x, y, z + 1) : def;
                     BlockInternal zm = z > 0 ? GetBlockAt(x, y, z - 1) : def;
                     BlockInternal yp = y + 1 < YWidth ? GetBlockAt(x, y + 1, z) : def;
                     BlockInternal ym = y > 0 ? GetBlockAt(x, y - 1, z) : def;
                     BlockInternal xp = x + 1 < XWidth ? GetBlockAt(x + 1, y, z) : def;
                     BlockInternal xm = x > 0 ? GetBlockAt(x - 1, y, z) : def;
                     bool rAS = !((Material)c.BlockMaterial).GetCanRenderAgainstSelf();
                     bool zps = (zp.IsOpaque() || (rAS && (zp.BlockMaterial == c.BlockMaterial))) && BlockShapeRegistry.BSD[zp.BlockData].OccupiesBOTTOM();
                     bool zms = (zm.IsOpaque() || (rAS && (zm.BlockMaterial == c.BlockMaterial))) && BlockShapeRegistry.BSD[zm.BlockData].OccupiesTOP();
                     bool xps = (xp.IsOpaque() || (rAS && (xp.BlockMaterial == c.BlockMaterial))) && BlockShapeRegistry.BSD[xp.BlockData].OccupiesXM();
                     bool xms = (xm.IsOpaque() || (rAS && (xm.BlockMaterial == c.BlockMaterial))) && BlockShapeRegistry.BSD[xm.BlockData].OccupiesXP();
                     bool yps = (yp.IsOpaque() || (rAS && (yp.BlockMaterial == c.BlockMaterial))) && BlockShapeRegistry.BSD[yp.BlockData].OccupiesYM();
                     bool yms = (ym.IsOpaque() || (rAS && (ym.BlockMaterial == c.BlockMaterial))) && BlockShapeRegistry.BSD[ym.BlockData].OccupiesYP();
                     Vector3 pos = new Vector3(x, y, z);
                     List<BEPUutilities.Vector3> vecsi = BlockShapeRegistry.BSD[c.BlockData].GetVertices(pos, xps, xms, yps, yms, zps, zms);
                     List<BEPUutilities.Vector3> normsi = BlockShapeRegistry.BSD[c.BlockData].GetNormals(pos, xps, xms, yps, yms, zps, zms);
                     List<BEPUutilities.Vector3> tci = BlockShapeRegistry.BSD[c.BlockData].GetTCoords(pos, (Material)c.BlockMaterial, xps, xms, yps, yms, zps, zms);
                     int vertcount = Vertices.Count;
                     for (int i = 0; i < vecsi.Count; i++)
                     {
                         // TODO: is PosMultiplier used correctly here?
                         OpenTK.Vector3 vt = new OpenTK.Vector3((float)vecsi[i].X, (float)vecsi[i].Y, (float)vecsi[i].Z);
                         Vertices.Add(vt);
                         OpenTK.Vector3 nt = new OpenTK.Vector3((float)normsi[i].X, (float)normsi[i].Y, (float)normsi[i].Z);
                         Normals.Add(nt);
                         TexCoords.Add(new OpenTK.Vector3((float)tci[i].X, (float)tci[i].Y, (float)tci[i].Z));
                         Colrs.Add(new OpenTK.Vector4(1, 1, 1, 1));
                         TCOLs.Add(TheClient.Rendering.AdaptColor(vt, Colors.ForByte(c.BlockPaint)));
                     }
                     for (int i = 0; i < vecsi.Count; i += 3)
                     {
                         int basis = vertcount + i;
                         OpenTK.Vector3 v1 = Vertices[basis];
                         OpenTK.Vector3 dv1 = Vertices[basis + 1] - v1;
                         OpenTK.Vector3 dv2 = Vertices[basis + 2] - v1;
                         OpenTK.Vector3 t1 = TexCoords[basis];
                         OpenTK.Vector3 dt1 = TexCoords[basis + 1] - t1;
                         OpenTK.Vector3 dt2 = TexCoords[basis + 2] - t1;
                         OpenTK.Vector3 tangent = (dv1 * dt2.Y - dv2 * dt1.Y) * 1f / (dt1.X * dt2.Y - dt1.Y * dt2.X);
                         OpenTK.Vector3 normal = Normals[basis];
                         tangent = (tangent - normal * OpenTK.Vector3.Dot(normal, tangent)).Normalized();
                         Tangs.Add(tangent);
                         Tangs.Add(tangent);
                         Tangs.Add(tangent);
                     }
                     if (!c.IsOpaque() && BlockShapeRegistry.BSD[c.BlockData].BackTextureAllowed)
                     {
                         int tf = Colrs.Count - vecsi.Count;
                         for (int i = vecsi.Count - 1; i >= 0; i--)
                         {
                             Vertices.Add(new OpenTK.Vector3((float)vecsi[i].X, (float)vecsi[i].Y, (float)vecsi[i].Z));
                             int tx = tf + i;
                             Colrs.Add(Colrs[tx]);
                             TCOLs.Add(TCOLs[tx]);
                             Normals.Add(new OpenTK.Vector3(-(float)normsi[i].X, -(float)normsi[i].Y, -(float)normsi[i].Z));
                             TexCoords.Add(new OpenTK.Vector3((float)tci[i].X, (float)tci[i].Y, (float)tci[i].Z));
                         }
                     }
                 }
             }
         }
     }
     if (vbo != null)
     {
         vbo.Destroy();
         vbo = null;
     }
     if (Vertices.Count == 0)
     {
         return;
     }
     vbo = new VBO();
     vbo.THVs = new List<OpenTK.Vector4>();
     vbo.THWs = new List<OpenTK.Vector4>();
     List<uint> Indices = new List<uint>(Vertices.Count);
     for (uint i = 0; i < Vertices.Count; i++)
     {
         Indices.Add(i);
         vbo.THVs.Add(new OpenTK.Vector4(0, 0, 0, 0));
         vbo.THWs.Add(new OpenTK.Vector4(0, 0, 0, 0));
     }
     vbo.Vertices = Vertices;
     vbo.Normals = Normals;
     vbo.TexCoords = TexCoords;
     vbo.Colors = Colrs;
     vbo.TCOLs = TCOLs;
     vbo.Tangents = Tangs;
     vbo.Indices = Indices;
     vbo.GenerateVBO();
 }
コード例 #9
0
ファイル: ModelEngine.cs プロジェクト: Morphan1/Voxalia
 public ModelMesh(string _name)
 {
     Name = _name.ToLowerFast();
     if (Name.EndsWith(".001"))
     {
         Name = Name.Substring(0, Name.Length - ".001".Length);
     }
     Faces = new List<ModelFace>();
     vbo = new VBO();
 }
コード例 #10
0
        /// <summary>
        /// Fully renders colorful/fancy text (unless the text is not marked as fancy, or fancy rendering is disabled)
        /// </summary>
        /// <param name="Text">The text to render.</param>
        /// <param name="Position">Where to render the text at.</param>
        /// <param name="MaxY">The maximum Y location to render text at.</param>
        /// <param name="transmod">Transparency modifier (EG, 0.5 = half opacity) (0.0 - 1.0).</param>
        /// <param name="extrashadow">Whether to always have a mini drop-shadow.</param>
        public void DrawColoredText(string Text, Location Position, int MaxY = int.MaxValue, float transmod = 1, bool extrashadow = false, string bcolor = "^r^7",
                                    int color  = DefaultColor, bool bold  = false, bool italic       = false, bool underline    = false, bool strike = false, bool overline = false, bool highlight = false, bool emphasis = false,
                                    int ucolor = DefaultColor, int scolor = DefaultColor, int ocolor = DefaultColor, int hcolor = DefaultColor, int ecolor = DefaultColor,
                                    bool super = false, bool sub          = false, bool flip = false, bool pseudo = false, bool jello = false, bool obfu = false, bool random = false, bool shadow = false, GLFont font = null)
        {
            r_depth++;
            if (r_depth >= 100 && Text != "{{Recursion error}}")
            {
                r_depth--;
                DrawColoredText("{{Recursion error}}", Position);
                return;
            }
            Text = Text.Replace("^B", bcolor);
            string[] lines   = Text.Replace('\r', ' ').Replace(' ', (char)0x00A0).Replace("^q", "\"").SplitFast('\n');
            int      trans   = (int)(255 * transmod);
            int      otrans  = (int)(255 * transmod);
            int      etrans  = (int)(255 * transmod);
            int      htrans  = (int)(255 * transmod);
            int      strans  = (int)(255 * transmod);
            int      utrans  = (int)(255 * transmod);
            float    X       = (float)Position.X;
            float    Y       = (float)Position.Y;
            Color    bccolor = Color.FromArgb(0, 0, 0, 0);
            Color    ccolor  = bccolor;

            if (font == null)
            {
                font = font_default;
            }
            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];
                if (line.Length == 0)
                {
                    Y += font_default.Height;
                    continue;
                }
                int start = 0;
                for (int x = 0; x < line.Length; x++)
                {
                    if ((line[x] == '^' && x + 1 < line.Length && (IsColorSymbol(line[x + 1]) || line[x + 1] == '[')) || (x + 1 == line.Length))
                    {
                        string drawme = line.Substring(start, (x - start) + ((x + 1 < line.Length) ? 0 : 1));
                        start = x + 2;
                        x++;
                        if (drawme.Length > 0 && Y >= -font.Height && Y - (sub ? font.Height : 0) <= MaxY)
                        {
                            float width = font.MeasureString(drawme);
                            if (highlight)
                            {
                                DrawRectangle(X, Y, width, font_default.Height, font, ColorFor(hcolor, htrans));
                            }
                            if (underline)
                            {
                                DrawRectangle(X, Y + ((float)font.Height * 4f / 5f), width, 2, font, ColorFor(ucolor, utrans));
                            }
                            if (overline)
                            {
                                DrawRectangle(X, Y + 2f, width, 2, font, ColorFor(ocolor, otrans));
                            }
                            if (extrashadow)
                            {
                                foreach (Point point in ShadowPoints)
                                {
                                    RenderBaseText(X + point.X, Y + point.Y, drawme, font, 0, trans / 2, flip);
                                }
                            }
                            if (shadow)
                            {
                                foreach (Point point in ShadowPoints)
                                {
                                    RenderBaseText(X + point.X, Y + point.Y, drawme, font, 0, trans / 2, flip);
                                }
                                foreach (Point point in BetterShadowPoints)
                                {
                                    RenderBaseText(X + point.X, Y + point.Y, drawme, font, 0, trans / 4, flip);
                                }
                            }
                            if (emphasis)
                            {
                                foreach (Point point in EmphasisPoints)
                                {
                                    RenderBaseText(X + point.X, Y + point.Y, drawme, font, ecolor, etrans, flip);
                                }
                                foreach (Point point in BetterEmphasisPoints)
                                {
                                    RenderBaseText(X + point.X, Y + point.Y, drawme, font, ecolor, etrans, flip);
                                }
                            }
                            RenderBaseText(X, Y, drawme, font, color, trans, flip, pseudo, random, jello, obfu, ccolor);
                            if (strike)
                            {
                                DrawRectangle(X, Y + (font.Height / 2), width, 2, font, ColorFor(scolor, strans));
                            }
                            X += width;
                        }
                        if (x < line.Length)
                        {
                            switch (line[x])
                            {
                            case '[':
                            {
                                StringBuilder sb = new StringBuilder();
                                x++;
                                int c = 0;
                                while (x < line.Length)
                                {
                                    if (line[x] == '[')
                                    {
                                        c++;
                                    }
                                    if (line[x] == ']')
                                    {
                                        c--;
                                        if (c == -1)
                                        {
                                            break;
                                        }
                                    }
                                    sb.Append(line[x]);
                                    x++;
                                }
                                bool   highl = true;
                                string ttext;
                                if (x == line.Length)
                                {
                                    ttext = "^[" + sb.ToString();
                                }
                                else
                                {
                                    string sbt = sb.ToString();
                                    string sbl = sbt.ToLowerFast();
                                    if (sbl.StartsWith("lang="))
                                    {
                                        string   langinfo = sbl.After("lang=");
                                        string[] subdats  = csplit(langinfo).ToArray();
                                        ttext = Client.Central.Languages.GetText(Engine.TheClient.Files, subdats);
                                        highl = false;
                                    }
                                    else if (sbl.StartsWith("color="))
                                    {
                                        string[] coldat = sbl.After("color=").SplitFast(',');
                                        if (coldat.Length == 4)
                                        {
                                            int r = Utilities.StringToInt(coldat[0]);
                                            int g = Utilities.StringToInt(coldat[1]);
                                            int b = Utilities.StringToInt(coldat[2]);
                                            int a = Utilities.StringToInt(coldat[3]);
                                            ccolor = Color.FromArgb((byte)a, (byte)r, (byte)g, (byte)b);
                                            ttext  = "";
                                            highl  = false;
                                        }
                                        else
                                        {
                                            ttext = "^[" + sb.ToString();
                                        }
                                    }
                                    else if (sbl == "lb")
                                    {
                                        ttext = "[";
                                        highl = false;
                                    }
                                    else if (sbl == "rb")
                                    {
                                        ttext = "]";
                                        highl = false;
                                    }
                                    else
                                    {
                                        ttext = sbt.After("|");
                                    }
                                }
                                if (highl)
                                {
                                    float widt = font_default.MeasureString(ttext);
                                    DrawRectangle(X, Y, widt, font_default.Height, font_default, Color.Black);
                                    RenderBaseText(X, Y, ttext, font_default, 5);
                                    DrawRectangle(X, Y + ((float)font_default.Height * 4f / 5f), widt, 2, font_default, Color.Blue);
                                    X += widt;
                                }
                                else
                                {
                                    float widt = MeasureFancyText(ttext);
                                    DrawColoredText(ttext, new Location(X, Y, 0), MaxY, transmod, extrashadow, bcolor,
                                                    color, bold, italic, underline, strike, overline, highlight, emphasis, ucolor, scolor, ocolor, hcolor, ecolor, super,
                                                    sub, flip, pseudo, jello, obfu, random, shadow, font);
                                    X += widt;
                                }
                                start = x + 1;
                            }
                            break;

                            case '1': color = 1; ccolor = bccolor;  break;

                            case '!': color = 11; ccolor = bccolor; break;

                            case '2': color = 2; ccolor = bccolor; break;

                            case '@': color = 12; ccolor = bccolor; break;

                            case '3': color = 3; ccolor = bccolor; break;

                            case '#': color = 13; ccolor = bccolor; break;

                            case '4': color = 4; ccolor = bccolor; break;

                            case '$': color = 14; ccolor = bccolor; break;

                            case '5': color = 5; ccolor = bccolor; break;

                            case '%': color = 15; ccolor = bccolor; break;

                            case '6': color = 6; ccolor = bccolor; break;

                            case '-': color = 16; ccolor = bccolor; break;

                            case '7': color = 7; ccolor = bccolor; break;

                            case '&': color = 17; ccolor = bccolor; break;

                            case '8': color = 8; ccolor = bccolor; break;

                            case '*': color = 18; ccolor = bccolor; break;

                            case '9': color = 9; ccolor = bccolor; break;

                            case '(': color = 19; ccolor = bccolor; break;

                            case '0': color = 0; ccolor = bccolor; break;

                            case ')': color = 20; ccolor = bccolor; break;

                            case 'a': color = 10; ccolor = bccolor; break;

                            case 'A': color = 21; ccolor = bccolor; break;

                            case 'i':
                            {
                                italic = true;
                                GLFont nfont = (super || sub) ? (bold ? font_bolditalichalf : font_italichalf) :
                                               (bold ? font_bolditalic : font_italic);
                                if (nfont != font)
                                {
                                    font = nfont;
                                }
                            }
                            break;

                            case 'b':
                            {
                                bold = true;
                                GLFont nfont = (super || sub) ? (italic ? font_bolditalichalf : font_boldhalf) :
                                               (italic ? font_bolditalic : font_bold);
                                if (nfont != font)
                                {
                                    font = nfont;
                                }
                            }
                            break;

                            case 'u': utrans = trans; underline = true; ucolor = color; break;

                            case 's': strans = trans; strike = true; scolor = color; break;

                            case 'h': htrans = trans; highlight = true; hcolor = color; break;

                            case 'e': etrans = trans; emphasis = true; ecolor = color; break;

                            case 'O': otrans = trans; overline = true; ocolor = color; break;

                            case 't': trans = (int)(128 * transmod); break;

                            case 'T': trans = (int)(64 * transmod); break;

                            case 'o': trans = (int)(255 * transmod); break;

                            case 'S':
                                if (!super)
                                {
                                    if (sub)
                                    {
                                        sub = false;
                                        Y  -= font.Height / 2;
                                    }
                                    GLFont nfont = bold && italic ? font_bolditalichalf : bold ? font_boldhalf :
                                                   italic ? font_italichalf : font_half;
                                    if (nfont != font)
                                    {
                                        font = nfont;
                                    }
                                }
                                super = true;
                                break;

                            case 'l':
                                if (!sub)
                                {
                                    if (super)
                                    {
                                        super = false;
                                    }
                                    Y += font_default.Height / 2;
                                    GLFont nfont = bold && italic ? font_bolditalichalf : bold ? font_boldhalf :
                                                   italic ? font_italichalf : font_half;
                                    if (nfont != font)
                                    {
                                        font = nfont;
                                    }
                                }
                                sub = true;
                                break;

                            case 'd': shadow = true; break;

                            case 'j': jello = true; break;

                            case 'k': obfu = true; break;

                            case 'R': random = true; break;

                            case 'p': pseudo = true; break;

                            case 'f': flip = true; break;

                            case 'n':
                                break;

                            case 'r':
                            {
                                GLFont nfont = font_default;
                                if (nfont != font)
                                {
                                    font = nfont;
                                }
                                if (sub)
                                {
                                    Y -= font_default.Height / 2;
                                }
                                sub       = false;
                                super     = false;
                                flip      = false;
                                random    = false;
                                pseudo    = false;
                                jello     = false;
                                obfu      = false;
                                shadow    = false;
                                bold      = false;
                                italic    = false;
                                underline = false;
                                strike    = false;
                                emphasis  = false;
                                highlight = false;
                                trans     = (int)(255 * transmod);
                                overline  = false;
                                break;
                            }

                            default:
                                break;
                            }
                        }
                    }
                }
                Y += font_default.Height;
                X  = (float)Position.X;
            }
            Engine.GLFonts.Shaders.TextCleanerShader.Bind();
            GL.UniformMatrix4(1, false, ref Client.Central.Ortho); // TODO: Pass Client reference
            Matrix4 ident = Matrix4.Identity;

            GL.UniformMatrix4(2, false, ref ident);
            Vector3 col = new Vector3(1, 1, 1);

            GL.Uniform3(3, ref col);
            VBO.Build();
            VBO.Render();
            Engine.GLFonts.Shaders.ColorMultShader.Bind();
            r_depth--;
        }
コード例 #11
0
ファイル: Renderer.cs プロジェクト: Morphan1/Voxalia
 void GenerateSquareVBO()
 {
     Vector3[] vecs = new Vector3[6];
     uint[] inds = new uint[6];
     Vector3[] norms = new Vector3[6];
     Vector3[] texs = new Vector3[6];
     Vector4[] cols = new Vector4[6];
     Vector4[] BoneIDs = new Vector4[6];
     Vector4[] BoneWeights = new Vector4[6];
     Vector4[] BoneIDs2 = new Vector4[6];
     Vector4[] BoneWeights2 = new Vector4[6];
     for (uint n = 0; n < 6; n++)
     {
         inds[n] = n;
         norms[n] = new Vector3(0, 0, 1);
         cols[n] = new Vector4(1, 1, 1, 1);
         BoneIDs[n] = new Vector4(0, 0, 0, 0);
         BoneWeights[n] = new Vector4(0, 0, 0, 0);
         BoneIDs2[n] = new Vector4(0, 0, 0, 0);
         BoneWeights2[n] = new Vector4(0, 0, 0, 0);
     }
     vecs[0] = new Vector3(1, 0, 0);
     texs[0] = new Vector3(1, 0, 0);
     vecs[1] = new Vector3(1, 1, 0);
     texs[1] = new Vector3(1, 1, 0);
     vecs[2] = new Vector3(0, 1, 0);
     texs[2] = new Vector3(0, 1, 0);
     vecs[3] = new Vector3(1, 0, 0);
     texs[3] = new Vector3(1, 0, 0);
     vecs[4] = new Vector3(0, 1, 0);
     texs[4] = new Vector3(0, 1, 0);
     vecs[5] = new Vector3(0, 0, 0);
     texs[5] = new Vector3(0, 0, 0);
     Square = new VBO();
     Square.Vertices = vecs.ToList();
     Square.Indices = inds.ToList();
     Square.Normals = norms.ToList();
     Square.TexCoords = texs.ToList();
     Square.Colors = cols.ToList();
     Square.BoneIDs = BoneIDs.ToList();
     Square.BoneWeights = BoneWeights.ToList();
     Square.BoneIDs2 = BoneIDs2.ToList();
     Square.BoneWeights2 = BoneWeights2.ToList();
     Square.GenerateVBO();
 }
コード例 #12
0
ファイル: Renderer.cs プロジェクト: Morphan1/Voxalia
 void GenerateLineVBO()
 {
     Vector3[] vecs = new Vector3[2];
     uint[] inds = new uint[2];
     Vector3[] norms = new Vector3[2];
     Vector3[] texs = new Vector3[2];
     Vector4[] cols = new Vector4[2];
     for (uint u = 0; u < 2; u++)
     {
         inds[u] = u;
     }
     for (int n = 0; n < 2; n++)
     {
         norms[n] = new Vector3(0, 0, 1);
     }
     for (int c = 0; c < 2; c++)
     {
         cols[c] = new Vector4(1, 1, 1, 1);
     }
     Vector4[] BoneIDs = new Vector4[2];
     Vector4[] BoneWeights = new Vector4[2];
     Vector4[] BoneIDs2 = new Vector4[2];
     Vector4[] BoneWeights2 = new Vector4[2];
     for (int n = 0; n < 2; n++)
     {
         BoneIDs[n] = new Vector4(0, 0, 0, 0);
         BoneWeights[n] = new Vector4(0, 0, 0, 0);
         BoneIDs2[n] = new Vector4(0, 0, 0, 0);
         BoneWeights2[n] = new Vector4(0, 0, 0, 0);
     }
     vecs[0] = new Vector3(0, 0, 0);
     texs[0] = new Vector3(0, 0, 0);
     vecs[1] = new Vector3(1, 0, 0);
     texs[1] = new Vector3(1, 0, 0);
     Line = new VBO();
     Line.Vertices = vecs.ToList();
     Line.Indices = inds.ToList();
     Line.Normals = norms.ToList();
     Line.TexCoords = texs.ToList();
     Line.Colors = cols.ToList();
     Line.BoneIDs = BoneIDs.ToList();
     Line.BoneWeights = BoneWeights.ToList();
     Line.BoneIDs2 = BoneIDs2.ToList();
     Line.BoneWeights2 = BoneWeights2.ToList();
     Line.GenerateVBO();
 }
コード例 #13
0
ファイル: Renderer.cs プロジェクト: Morphan1/Voxalia
 void GenerateBoxVBO()
 {
     // TODO: Optimize?
     Vector3[] vecs = new Vector3[24];
     uint[] inds = new uint[24];
     Vector3[] norms = new Vector3[24];
     Vector3[] texs = new Vector3[24];
     Vector4[] cols = new Vector4[24];
     for (uint u = 0; u < 24; u++)
     {
         inds[u] = u;
     }
     for (int t = 0; t < 24; t++)
     {
         texs[t] = new Vector3(0, 0, 0);
     }
     for (int n = 0; n < 24; n++)
     {
         norms[n] = new Vector3(0, 0, 1); // TODO: Accurate normals somehow? Do lines even have normals?
     }
     for (int c = 0; c < 24; c++)
     {
         cols[c] = new Vector4(1, 1, 1, 1);
     }
     Vector4[] BoneIDs = new Vector4[24];
     Vector4[] BoneWeights = new Vector4[24];
     Vector4[] BoneIDs2 = new Vector4[24];
     Vector4[] BoneWeights2 = new Vector4[24];
     for (int n = 0; n < 24; n++)
     {
         BoneIDs[n] = new Vector4(0, 0, 0, 0);
         BoneWeights[n] = new Vector4(0, 0, 0, 0);
         BoneIDs2[n] = new Vector4(0, 0, 0, 0);
         BoneWeights2[n] = new Vector4(0, 0, 0, 0);
     }
     int i = 0;
     int zero = -1; // Ssh.
     vecs[i] = new Vector3(zero, zero, zero); i++;
     vecs[i] = new Vector3(1, zero, zero); i++;
     vecs[i] = new Vector3(1, zero, zero); i++;
     vecs[i] = new Vector3(1, 1, zero); i++;
     vecs[i] = new Vector3(1, 1, zero); i++;
     vecs[i] = new Vector3(zero, 1, zero); i++;
     vecs[i] = new Vector3(zero, 1, zero); i++;
     vecs[i] = new Vector3(zero, zero, zero); i++;
     vecs[i] = new Vector3(zero, zero, 1); i++;
     vecs[i] = new Vector3(1, zero, 1); i++;
     vecs[i] = new Vector3(1, zero, 1); i++;
     vecs[i] = new Vector3(1, 1, 1); i++;
     vecs[i] = new Vector3(1, 1, 1); i++;
     vecs[i] = new Vector3(zero, 1, 1); i++;
     vecs[i] = new Vector3(zero, 1, 1); i++;
     vecs[i] = new Vector3(zero, zero, 1); i++;
     vecs[i] = new Vector3(zero, zero, zero); i++;
     vecs[i] = new Vector3(zero, zero, 1); i++;
     vecs[i] = new Vector3(1, zero, zero); i++;
     vecs[i] = new Vector3(1, zero, 1); i++;
     vecs[i] = new Vector3(1, 1, zero); i++;
     vecs[i] = new Vector3(1, 1, 1); i++;
     vecs[i] = new Vector3(zero, 1, zero); i++;
     vecs[i] = new Vector3(zero, 1, 1); i++;
     Box = new VBO();
     Box.Vertices = vecs.ToList();
     Box.Indices = inds.ToList();
     Box.Normals = norms.ToList();
     Box.TexCoords = texs.ToList();
     Box.Colors = cols.ToList();
     Box.BoneIDs = BoneIDs.ToList();
     Box.BoneWeights = BoneWeights.ToList();
     Box.BoneIDs2 = BoneIDs2.ToList();
     Box.BoneWeights2 = BoneWeights2.ToList();
     Box.GenerateVBO();
 }