public void SetDefaultCell(LTEX tex) { ResetColorsAndNormals(); texBanks.Clear(); TextureBank tb = new TextureBank(); tb.SetSingleTexture(tex); texBanks.Add(tb); }
public void SetCell(LAND cell) { //Write the new colors and normals into the color buffer DataStream ColorNormalData = colorBuffer.Lock(0, 0, LockFlags.None); NormalColorVertex ncv; for (int y = 0; y <= 64; y++) { for (int x = 0; x <= 64; x++) { ncv.r = cell.Color[x, y].r; ncv.g = cell.Color[x, y].g; ncv.b = cell.Color[x, y].b; ncv.a = 255; ncv.nx = cell.Normals[x, y].X; ncv.ny = cell.Normals[x, y].Y; ncv.nz = cell.Normals[x, y].Z; ColorNormalData.Write(ncv); } } colorBuffer.Unlock(); //Dispose of any current texture banks texBanks.Clear(); //Group the unique textures in this cell in fours //Find all te uniqe textures in this cell System.Collections.Generic.Dictionary <string, LTEX> tex_dict = new System.Collections.Generic.Dictionary <string, LTEX>(); for (int x = 0; x <= 64; ++x) { for (int y = 0; y <= 64; ++y) { int cell_x = cell.xpos; int cell_y = cell.ypos; int tex_x = (int)Math.Floor(((float)y - 1.0f) / 4.0f); //-2.0f int tex_y = (int)Math.Floor(((float)x - 3.0f) / 4.0f); //-2.0f DistantLandForm.ModCell(ref cell_x, ref tex_x); DistantLandForm.ModCell(ref cell_y, ref tex_y); LTEX tmp = DistantLandForm.GetTex(cell_x, cell_y, tex_x, tex_y); string idx = tmp.FilePath; tex_dict[idx] = tmp; } } //Create one bank for each group of 4 textures int index = 0; TextureBank tb = new TextureBank(); foreach (LTEX tex in tex_dict.Values) { switch (index) { case 0: tb.t1 = tex; ++index; break; case 1: tb.t2 = tex; ++index; break; case 2: tb.t3 = tex; ++index; break; case 3: tb.t4 = tex; texBanks.Add(tb); tb = new TextureBank(); index = 0; break; } } if (index != 0) { texBanks.Add(tb); } if (texBanks.Count > 1) { int blah = 4; int blu = 7; int blablu = blah + blu; } //Calculate weights for all banks foreach (TextureBank bank in texBanks) { bank.CalcWeights(cell); } }
public void SetCell( LAND cell ) { //Write the new colors and normals into the color buffer NormalColorVertex[] ColorNormalData = (NormalColorVertex[])colorBuffer.Lock(0, LockFlags.None); for (int y = 0; y <= 64; y++) { for (int x = 0; x <= 64; x++) { //Figure out which index to use int i = y * 65 + x; //Write values ColorNormalData[i].r = cell.Color[x, y].r; ColorNormalData[i].g = cell.Color[x, y].g; ColorNormalData[i].b = cell.Color[x, y].b; ColorNormalData[i].a = 255; ColorNormalData[i].nx = cell.Normals[x, y].X; ColorNormalData[i].ny = cell.Normals[x, y].Y; ColorNormalData[i].nz = cell.Normals[x, y].Z; } } colorBuffer.Unlock(); //Dispose of any current texture banks texBanks.Clear(); //Group the unique textures in this cell in fours //Find all te uniqe textures in this cell System.Collections.Generic.Dictionary<string, LTEX> tex_dict = new System.Collections.Generic.Dictionary<string, LTEX>(); for (int x = 0; x <= 64; ++x) { for (int y = 0; y <= 64; ++y) { int cell_x = cell.xpos; int cell_y = cell.ypos; int tex_x = (int)Math.Floor(((float)y - 1.0f) / 4.0f);//-2.0f int tex_y = (int)Math.Floor(((float)x - 3.0f) / 4.0f);//-2.0f DistantLandForm.ModCell(ref cell_x, ref tex_x); DistantLandForm.ModCell(ref cell_y, ref tex_y); LTEX tmp = DistantLandForm.GetTex(cell_x, cell_y, tex_x, tex_y); string idx = tmp.FilePath; tex_dict[idx] = tmp; } } //Create one bank for each group of 4 textures int index = 0; TextureBank tb = new TextureBank(); foreach (LTEX tex in tex_dict.Values) { switch (index) { case 0: tb.t1 = tex; ++index; break; case 1: tb.t2 = tex; ++index; break; case 2: tb.t3 = tex; ++index; break; case 3: tb.t4 = tex; texBanks.Add(tb); tb = new TextureBank(); index = 0; break; } } if (index != 0) { texBanks.Add(tb); } if ( texBanks.Count > 1 ) { int blah = 4; int blu = 7; int blablu = blah + blu; } //Calculate weights for all banks foreach (TextureBank bank in texBanks) { bank.CalcWeights(cell); } }