本文整理汇总了C#中Vector2I类的典型用法代码示例。如果您正苦于以下问题:C# Vector2I类的具体用法?C# Vector2I怎么用?C# Vector2I使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector2I类属于命名空间,在下文中一共展示了Vector2I类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Triangle
public Triangle(Vector2I a, Vector2I b, Vector2I c)
{
Points[0] = a;
Points[1] = b;
Points[2] = c;
Id = AutoIncrement++;
}
示例2: Contains
public bool Contains(Vector2I point)
{
bool b1 = Sign(point, Points[0], Points[1]) < 0.0f;
bool b2 = Sign(point, Points[1], Points[2]) < 0.0f;
bool b3 = Sign(point, Points[2], Points[0]) < 0.0f;
return ((b1 == b2) && (b2 == b3));
}
示例3: Init
internal void Init(string name, Texture2DDescription desc, Vector2I size, int bytes)
{
m_name = name;
m_size = size;
m_desc = desc;
m_bytes = bytes;
}
示例4: SerializeChunk
/// <summary>
/// Serialize a chunk.
/// </summary>
/// <param name="chunk">The chunk to serialize.</param>
/// <param name="chunkIndex">The chunk index.</param>
public void SerializeChunk(Chunk chunk, Vector2I chunkIndex)
{
// NOTE: This should occur in a seperate thread, since terrain serialization isn't high priority.
// However, care should be taken to consider the situation when a terrain is being serialized in another thread
// and then a new deserialization request comes in for that chunk. In this case the deserialization thread
// should block
}
示例5: GenerateChunk
/// <summary>
/// Generate a chunk and return it. The terrain object remains unmodified.
/// </summary>
/// <param name="terrain">The terrain.</param>
/// <param name="chunkIndex">The chunk index.</param>
/// <returns>The chunk.</returns>
public Chunk GenerateChunk(Terrain terrain, Vector2I chunkIndex)
{
Chunk chunk = new Chunk();
// Calculate the position of the chunk in world coordinates
var chunkPos = new Vector2I(chunkIndex.X * Chunk.SizeX, chunkIndex.Y * Chunk.SizeY);
// Get the surface heights for this chunk
int[] surfaceHeights = this.GenerateSurfaceHeights(chunkPos);
// For now, fill the terrain with mud under the surface
for (int x = 0; x < Chunk.SizeX; x++)
{
int surfaceHeight = surfaceHeights[x];
if (surfaceHeight > 0)
{
for (int y = 0; y < surfaceHeight; y++)
{
chunk[x, y] = new Block(BlockType.Dirt);
}
}
}
return chunk;
}
示例6: RenderTexture
public RenderTexture(Device device, Vector2I screenSize)
{
var textureDesc = new Texture2DDescription()
{
Width = screenSize.X,
Height = screenSize.Y,
MipLevels = 1,
ArraySize = 1,
Format = Format.R32G32B32A32_Float,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.None
};
_renderTargetTexture = new Texture2D(device, textureDesc);
_renderTargetView = new RenderTargetView(device, _renderTargetTexture,
new RenderTargetViewDescription
{
Format = textureDesc.Format,
Dimension = RenderTargetViewDimension.Texture2D,
Texture2D = {MipSlice = 0},
});
// Create the render target view.
ShaderResourceView = new ShaderResourceView(device, _renderTargetTexture,
new ShaderResourceViewDescription
{
Format = textureDesc.Format,
Dimension = ShaderResourceViewDimension.Texture2D,
Texture2D = { MipLevels = 1, MostDetailedMip = 0 },
});
}
示例7: DuplicatedCubeGrid
public DuplicatedCubeGrid(Vector2I dimensions)
{
Dimensions = dimensions;
this[VboPosition.Vertices] = StaticVboFactory.GetDuplicatedCubeGridVertices(dimensions);
EnableAttrib(VboPosition.Vertices);
}
示例8: TexturedExtensibleRectangle
public TexturedExtensibleRectangle(IContext context, Vector2I size, Texture texture, int fixedBorderRadius)
{
DeviceContext = context.DirectX.DeviceContext;
_shader = context.Shaders.Get<TextureShader>();
_texture = texture;
_fixedBorderRadius = fixedBorderRadius;
const int vertexCount = 16;
_vertices = new VertexDefinition.PositionTexture[vertexCount];
VertexBuffer = Buffer.Create(context.DirectX.Device, _vertices,
new BufferDescription
{
Usage = ResourceUsage.Dynamic,
SizeInBytes = Utilities.SizeOf<VertexDefinition.PositionTexture>() * vertexCount,
BindFlags = BindFlags.VertexBuffer,
CpuAccessFlags = CpuAccessFlags.Write,
OptionFlags = ResourceOptionFlags.None,
StructureByteStride = 0
});
IndexCount = 54;
uint[] indices = new uint[IndexCount];
for(uint i=0; i< 3; i++)
for (uint j = 0; j < 3; j++)
{
indices[(i * 3 + j) * 6] = (i + 1) * 4 + j + 1;
indices[(i * 3 + j) * 6 + 1] = i * 4 + j + 1;
indices[(i * 3 + j) * 6 + 2] = i * 4 + j;
indices[(i * 3 + j) * 6 + 3] = (i + 1) * 4 + j;
indices[(i * 3 + j) * 6 + 4] = (i + 1) * 4 + j + 1;
indices[(i * 3 + j) * 6 + 5] = i * 4 + j;
}
IndexBuffer = Buffer.Create(context.DirectX.Device, BindFlags.IndexBuffer, indices);
Size = size;
}
示例9: Clear
internal void Clear()
{
m_deviceContext.ClearState();
m_inputLayout = null;
m_primitiveTopology = PrimitiveTopology.Undefined;
m_indexBufferRef = null;
m_indexBufferFormat = 0;
m_indexBufferOffset = 0;
for (int i = 0; i < m_vertexBuffers.Length; i++)
m_vertexBuffers[i] = null;
for (int i = 0; i < m_vertexBuffersStrides.Length; i++)
m_vertexBuffersStrides[i] = 0;
m_blendState = null;
m_stencilRef = 0;
m_depthStencilState = null;
m_rtvsCount = 0;
for (int i = 0; i < m_rtvs.Length; i++)
m_rtvs[i] = null;
m_dsv = null;
m_rasterizerState = null;
m_scissorLeftTop = new Vector2I(-1, -1);
m_scissorRightBottom = new Vector2I(-1, -1);
m_viewport = default(RawViewportF);
m_targetBuffer = null;
m_targetOffsets = 0;
m_statistics.ClearStates++;
}
示例10: Init
public void Init(
string name,
int width,
int height,
Format resourceFormat,
Format srvFormat,
BindFlags bindFlags,
int samplesCount,
int samplesQuality,
ResourceOptionFlags roFlags,
ResourceUsage ru,
int mipmapLevels,
CpuAccessFlags cpuAccessFlags)
{
m_name = name;
m_size = new Vector2I(width, height);
m_resourceFormat = resourceFormat;
m_srvFormat = srvFormat;
m_bindFlags = bindFlags;
m_samplesCount = samplesCount;
m_samplesQuality = samplesQuality;
m_roFlags = roFlags;
m_resourceUsage = ru;
m_mipmapLevels = mipmapLevels;
m_cpuAccessFlags = cpuAccessFlags;
}
示例11: ChebyshevNeighborhood
public static IEnumerable<Vector2I> ChebyshevNeighborhood(Vector2I position, int range = 1)
{
for (int i = -range; i <= range; ++i)
for (int j = -range; j <= range; ++j)
if (!(i == 0 && j == 0)) // omit center position
yield return new Vector2I(position.X + i, position.Y + j);
}
示例12: Rectangle
public Rectangle(Renderer renderer, Vector2I screenSize, Vector2I position, Vector2I size, Vector4 color, float depth = 0.0f)
{
_shader = renderer.ColorShader;
Position = position;
ScreenSize = screenSize;
Size = size;
_color = color;
_changed = true;
Depth = depth;
int vertexCount = 4;
_indexCount = 6;
_vertices = new VertexDefinition.PositionColor[vertexCount];
UInt32[] indices = { 0, 1, 2, 0, 3, 1 };
_vertexBuffer = Buffer.Create(renderer.DirectX.Device, _vertices,
new BufferDescription
{
Usage = ResourceUsage.Dynamic,
SizeInBytes = Utilities.SizeOf<VertexDefinition.PositionColor>() * vertexCount,
BindFlags = BindFlags.VertexBuffer,
CpuAccessFlags = CpuAccessFlags.Write,
OptionFlags = ResourceOptionFlags.None,
StructureByteStride = 0
});
_indexBuffer = Buffer.Create(renderer.DirectX.Device, BindFlags.IndexBuffer, indices);
}
示例13: TilesetImage
public TilesetImage(string imagePath, Vector2I tileSize, Vector2I tileMargin, Vector2I tileBorder)
{
ImagePath = imagePath;
TileSize = tileSize;
TileMargin = tileMargin;
TileBorder = tileBorder;
}
示例14: Bitmap
public Bitmap(Device device, ShaderResourceView texture, Vector2I screenSize, Vector2I size, float depth = 0.0f)
{
Texture = texture;
ScreenSize = screenSize;
Size = size;
_changed = true;
Depth = depth;
VertexCount = 4;
IndexCount = 6;
_vertices = new TranslateShader.Vertex[VertexCount];
UInt32[] indices = {0, 1, 2, 0, 3, 1};
VertexBuffer = Buffer.Create(device, _vertices,
new BufferDescription
{
Usage = ResourceUsage.Dynamic,
SizeInBytes = Utilities.SizeOf<TranslateShader.Vertex>() * VertexCount,
BindFlags = BindFlags.VertexBuffer,
CpuAccessFlags = CpuAccessFlags.Write,
OptionFlags = ResourceOptionFlags.None,
StructureByteStride = 0
});
IndexBuffer = Buffer.Create(device, BindFlags.IndexBuffer, indices);
}
示例15: Create
public Text Create(string fontName, int fontSize, string content, Vector2I size, Color color,
HorizontalAlignment horizontalAligment, VerticalAlignment verticalAlignment, Padding padding)
{
string fontKey = fontName + "-" + size;
if (!_fontDictionary.ContainsKey(fontKey))
_fontDictionary.Add(fontKey, new Font(_context, fontName, fontSize));
return new Text(_context, content, _fontDictionary[fontKey], size, color, horizontalAligment, verticalAlignment, padding);
}