本文整理汇总了C#中Index3类的典型用法代码示例。如果您正苦于以下问题:C# Index3类的具体用法?C# Index3怎么用?C# Index3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Index3类属于命名空间,在下文中一共展示了Index3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public void Draw(Matrix view, Matrix projection, Index3 shift)
{
if (!loaded)
return;
Matrix worldViewProj = Matrix.CreateTranslation(
shift.X * Chunk.CHUNKSIZE_X,
shift.Y * Chunk.CHUNKSIZE_Y,
shift.Z * Chunk.CHUNKSIZE_Z) * view * projection;
simple.Parameters["WorldViewProj"].SetValue(worldViewProj);
simple.Parameters["BlockTextures"].SetValue(textures);
simple.Parameters["AmbientIntensity"].SetValue(0.4f);
simple.Parameters["AmbientColor"].SetValue(Color.White.ToVector4());
lock (this)
{
if (vb == null)
return;
graphicsDevice.SetVertexBuffer(vb);
graphicsDevice.Indices = ib;
foreach (var pass in simple.CurrentTechnique.Passes)
{
pass.Apply();
graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertexCount, 0, indexCount / 3);
}
}
}
示例2: GeneratePlanet
public IPlanet GeneratePlanet(int universe, int seed)
{
Index3 size = new Index3(12, 12, 3);
ComplexPlanet planet = new ComplexPlanet(0, universe, size, this, seed);
return planet;
}
示例3: Populate
public override void Populate(IDefinitionManager definitionManager, IPlanet planet, IChunkColumn column00, IChunkColumn column10, IChunkColumn column01, IChunkColumn column11)
{
// Tree Definitions initialisieren
if (treeDefinitions == null)
{
treeDefinitions = definitionManager.GetDefinitions<ITreeDefinition>().OrderBy(d => d.Order).ToArray();
foreach (var treeDefinition in treeDefinitions)
treeDefinition.Init(definitionManager);
}
int salt = (column00.Index.X & 0xffff) + ((column00.Index.Y & 0xffff) << 16);
Random random = new Random(planet.Seed + salt);
Index3 sample = new Index3(column00.Index.X * Chunk.CHUNKSIZE_X, column00.Index.Y * Chunk.CHUNKSIZE_Y, column00.Heights[0, 0]);
foreach (var treeDefinition in treeDefinitions)
{
int density = treeDefinition.GetDensity(planet, sample);
if (density <= 0) continue;
for (int i = 0; i < density; i++)
{
int x = random.Next(Chunk.CHUNKSIZE_X / 2, Chunk.CHUNKSIZE_X * 3 / 2);
int y = random.Next(Chunk.CHUNKSIZE_Y / 2, Chunk.CHUNKSIZE_Y * 3 / 2);
int z = LocalBuilder.GetSurfaceHeight(column00, column10, column01, column11, x, y);
LocalBuilder builder = new LocalBuilder(x, y, z + 1, column00, column10, column01, column11);
treeDefinition.PlantTree(definitionManager, planet, new Index3(x, y, z), builder, random.Next(int.MaxValue));
}
}
}
示例4: Index3ConstructorTest
public void Index3ConstructorTest()
{
// Parameterlos
Index3 i1 = new Index3();
Assert.AreEqual(0, i1.X);
Assert.AreEqual(0, i1.Y);
Assert.AreEqual(0, i1.Z);
// Simpler Parameter
Index3 i2 = new Index3(21, 32, 99);
Assert.AreEqual(21, i2.X);
Assert.AreEqual(32, i2.Y);
Assert.AreEqual(99, i2.Z);
// Index2-Parameter
Index3 i3 = new Index3(new Index2(-2, 80), 76);
Assert.AreEqual(-2, i3.X);
Assert.AreEqual(80, i3.Y);
Assert.AreEqual(76, i3.Z);
// Index3 Parameter
Index3 i4 = new Index3(new Index3(int.MinValue, int.MaxValue, 3));
Assert.AreEqual(int.MinValue, i4.X);
Assert.AreEqual(int.MaxValue, i4.Y);
Assert.AreEqual(3, i4.Z);
}
示例5: ComplexPlanet
public ComplexPlanet(int id, int universe, Index3 size, IMapGenerator generator, int seed)
: base(id, universe, size, seed)
{
BiomeGenerator = new SurfaceBiomeGenerator(this, 40);
this.Heightmap = null;
ClimateMap = new Climate.ComplexClimateMap(this);
}
示例6: Index3ComparerTest
public void Index3ComparerTest()
{
Index3 i1 = new Index3(12, 13, 14);
Index3 i2 = new Index3(12, 15, 33);
Index3 i3 = new Index3(22, 13, 2);
Index3 i4 = new Index3(22, 11, 14);
Index3 i5 = new Index3(12, 13, 0);
Index3 i6 = new Index3(0, 13, 14);
Index3 i7 = new Index3(12, 0, 14);
Index3 i8 = new Index3(12, 13, 14);
Assert.AreEqual(i1, i1);
Assert.AreEqual(i1, i8);
Assert.AreNotEqual(i1, i2);
Assert.AreNotEqual(i1, i3);
Assert.AreNotEqual(i1, i4);
Assert.AreNotEqual(i1, i5);
Assert.AreNotEqual(i1, i6);
Assert.AreNotEqual(i1, i7);
Assert.IsTrue(i1 == i1);
Assert.IsTrue(i1 == i8);
Assert.IsTrue(i1 != i2);
Assert.IsTrue(i1 != i3);
Assert.IsTrue(i1 != i4);
Assert.IsTrue(i1 != i5);
Assert.IsTrue(i1 != i6);
Assert.IsTrue(i1 != i7);
}
示例7: GetCornerSet
//public static Slb.Ocean.Petrel.DomainObject.PillarGrid.Zone GetZone(Index3 cellIndex, List<Slb.Ocean.Petrel.DomainObject.PillarGrid.Zone> Zones)//List<Slb.Ocean.Petrel.DomainObject.PillarGrid.Zone> TopZone)
//{
// foreach (Slb.Ocean.Petrel.DomainObject.PillarGrid.Zone zone in Zones)
// {
// if (cellIndex.K > zone.BaseK && cellIndex.K)
// {
// }
// }
//}
public static Point3[] GetCornerSet(CellSide SideOfCell, Grid gridInContext, Index3 CellIndex)
{
CellCorner[] CellCorners = new CellCorner[4];
Point3[] CellCornerPoints = new Point3[4];
switch (SideOfCell)
{
case CellSide.Up:
CellCorners[0] = CellCorner.TopNorthWest; CellCorners[1] = CellCorner.TopNorthEast; CellCorners[2] = CellCorner.TopSouthWest;
CellCorners[3] = CellCorner.TopSouthEast;
CellCornerPoints = gridInContext.GetCellCorners(CellIndex, CellCorners);
break;
case CellSide.East:
CellCorners[0] = CellCorner.TopSouthEast; CellCorners[1] = CellCorner.TopNorthEast; CellCorners[2] = CellCorner.BaseSouthEast;
CellCorners[3] = CellCorner.BaseNorthEast;
CellCornerPoints = gridInContext.GetCellCorners(CellIndex, CellCorners);
break;
case CellSide.West:
CellCorners[0] = CellCorner.TopSouthWest; CellCorners[1] = CellCorner.TopNorthWest; CellCorners[2] = CellCorner.BaseSouthWest;
CellCorners[3] = CellCorner.BaseNorthWest;
CellCornerPoints = gridInContext.GetCellCorners(CellIndex, CellCorners);
break;
case CellSide.South:
CellCorners[0] = CellCorner.TopSouthWest; CellCorners[1] = CellCorner.TopSouthEast; CellCorners[2] = CellCorner.BaseSouthWest;
CellCorners[3] = CellCorner.BaseSouthEast;
CellCornerPoints = gridInContext.GetCellCorners(CellIndex, CellCorners);
break;
case CellSide.North:
CellCorners[0] = CellCorner.TopNorthWest; CellCorners[1] = CellCorner.TopNorthEast; CellCorners[2] = CellCorner.BaseNorthWest;
CellCorners[3] = CellCorner.BaseNorthEast;
CellCornerPoints = gridInContext.GetCellCorners(CellIndex, CellCorners);
break;
case CellSide.Down:
CellCorners[0] = CellCorner.BaseNorthWest; CellCorners[1] = CellCorner.BaseNorthEast; CellCorners[2] = CellCorner.BaseSouthWest;
CellCorners[3] = CellCorner.BaseSouthEast;
CellCornerPoints = gridInContext.GetCellCorners(CellIndex, CellCorners);
break;
default:
CellCornerPoints = null;
break;
}
return CellCornerPoints;
}
示例8: Chunk
/// <summary>
/// Erzeugt eine neue Instanz der Klasse Chunk
/// </summary>
/// <param name="pos">Position des Chunks</param>
/// <param name="planet">Index des Planeten</param>
public Chunk(Index3 pos, int planet)
{
Blocks = new ushort[CHUNKSIZE_X * CHUNKSIZE_Y * CHUNKSIZE_Z];
MetaData = new int[CHUNKSIZE_X * CHUNKSIZE_Y * CHUNKSIZE_Z];
Resources = new ushort[CHUNKSIZE_X * CHUNKSIZE_Y * CHUNKSIZE_Z][];
Index = pos;
Planet = planet;
ChangeCounter = 0;
}
示例9: PlantTree
public override void PlantTree(IDefinitionManager definitionManager, IPlanet planet, Index3 index, LocalBuilder builder, int seed)
{
ushort ground = builder.GetBlock(0, 0, -1);
if (ground == water) return;
Random rand = new Random(seed);
int height = rand.Next(2, 4);
for (int i = 0; i < height; i++)
builder.SetBlock(0, 0, i, cactus);
}
示例10: GetPrecipitation
public int GetPrecipitation(Index3 blockIndex)
{
int maxPrecipitation = 100;
float rawValue = planet.BiomeGenerator.BiomeNoiseGenerator.GetTileableNoise2D(blockIndex.X, blockIndex.Y, Planet.Size.X * Chunk.CHUNKSIZE_X, Planet.Size.Y * Chunk.CHUNKSIZE_Y);
int height = blockIndex.Z - planet.BiomeGenerator.SeaLevel;
float precipitationDecreasePerBlock = 1;
return (int)(((1 - rawValue) * maxPrecipitation) - (Math.Max(height, 0) * precipitationDecreasePerBlock));
}
示例11: SetChunk
public void SetChunk(ILocalChunkCache manager, int x, int y, int z)
{
var newPosition = new Index3(x, y, z);
if (_manager == manager && newPosition == ChunkPosition)
return;
_manager = manager;
ChunkPosition = newPosition;
chunk = null;
loaded = false;
}
示例12: Load
public IChunk Load(int universe, int planet, Index3 index)
{
var root = GetRoot();
string filename = planet.ToString() + "_" + index.X + "_" + index.Y + "_" + index.Z + ".chunk";
if (!File.Exists(root.FullName + Path.DirectorySeparatorChar + filename))
return null;
using (Stream stream = File.Open(root.FullName + Path.DirectorySeparatorChar + filename, FileMode.Open, FileAccess.Read))
{
return serializer.Deserialize(stream, new PlanetIndex3(planet, index));
}
}
示例13: Load
public IChunk Load(int universe, int planet, Index3 index)
{
var root = GetRoot();
string filename = planet.ToString() + "_" + index.X + "_" + index.Y + "_" + index.Z + ".chunk";
if (!File.Exists(root.FullName + Path.DirectorySeparatorChar + filename))
return null;
using (Stream stream = File.Open(root.FullName + Path.DirectorySeparatorChar + filename, FileMode.Open, FileAccess.Read))
{
IChunk chunk = new Chunk(index, planet);
chunk.Deserialize(stream, BlockDefinitionManager.GetBlockDefinitions());
return chunk;
}
}
示例14: GetTemperature
public float GetTemperature(Index3 blockIndex)
{
int equator = (Planet.Size.Y * Chunk.CHUNKSIZE_Y) / 2;
float equatorTemperature = 40f;
float poleTemperature = -10f;
float tempFluctuation = tempFluctuationGenerator.GetTileableNoise2D(blockIndex.X, blockIndex.Y, Planet.Size.X * Chunk.CHUNKSIZE_X, Planet.Size.Y * Chunk.CHUNKSIZE_Y) * 5f;
float temperatureDifference = poleTemperature - equatorTemperature;
float temperatureDecreasePerBlock = 0.1f;
float distance = Math.Abs(blockIndex.Y - equator);
float temperature = tempFluctuation + equatorTemperature + temperatureDifference * (float)Math.Sin((Math.PI / 2) * distance / equator); //equatorTemperature + distance * temperatureDifference / equator;
float height = (blockIndex.Z - planet.BiomeGenerator.SeaLevel) / (Planet.Size.Z * Chunk.CHUNKSIZE_Z - planet.BiomeGenerator.SeaLevel);
height = Math.Max(height, 0);
height *= height;
return temperature - height * temperatureDecreasePerBlock;
}
示例15: PlantTree
public override void PlantTree(IDefinitionManager definitionManager, IPlanet planet, Index3 index, LocalBuilder builder, int seed)
{
ushort ground = builder.GetBlock(0, 0, -1);
if (ground == water) return;
Random rand = new Random(seed);
int height = rand.Next(3, 5);
int radius = rand.Next(3, height);
builder.FillSphere(0, 0, height, radius, leave);
for (int i = 0; i < height + 2; i++)
{
builder.SetBlock(0, 0, 0 + i, wood);
}
}