159 lines
5.7 KiB
C#
159 lines
5.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
namespace Aiwaz.Contracts
|
|
{
|
|
public struct VertexElement
|
|
{
|
|
public enum Format
|
|
{
|
|
Position,
|
|
PositionT,
|
|
Normal,
|
|
Binormal,
|
|
Tangent,
|
|
Color,
|
|
BlendWeight,
|
|
BlendIndices,
|
|
Texture2D,
|
|
Texture3D,
|
|
Texture4D,
|
|
PointSize
|
|
};
|
|
|
|
public VertexElement(Format argFormat)
|
|
: this(argFormat, 0)
|
|
{
|
|
|
|
}
|
|
public VertexElement(Format argFormat, int argNameIndex)
|
|
{
|
|
NameIndex = argNameIndex;
|
|
WellKnownFormat = argFormat;
|
|
switch (argFormat)
|
|
{
|
|
case Format.PositionT:
|
|
{
|
|
SemanticName = "POSITIONT";
|
|
ElementFormat = SlimDX.DXGI.Format.R32G32B32A32_Float;
|
|
Size = 4 * sizeof(float);
|
|
break;
|
|
}
|
|
case Format.Normal:
|
|
{
|
|
SemanticName = "NORMAL";
|
|
ElementFormat = SlimDX.DXGI.Format.R32G32B32_Float;
|
|
Size = 3 * sizeof(float);
|
|
break;
|
|
}
|
|
case Format.Binormal:
|
|
{
|
|
SemanticName = "BINORMAL";
|
|
ElementFormat = SlimDX.DXGI.Format.R32G32B32_Float;
|
|
Size = 3 * sizeof(float);
|
|
break;
|
|
}
|
|
case Format.Tangent:
|
|
{
|
|
SemanticName = "TANGENT";
|
|
ElementFormat = SlimDX.DXGI.Format.R32G32B32_Float;
|
|
Size = 3 * sizeof(float);
|
|
break;
|
|
}
|
|
case Format.Color:
|
|
{
|
|
SemanticName = "COLOR";
|
|
ElementFormat = SlimDX.DXGI.Format.R8G8B8A8_UNorm;
|
|
Size = 4 * sizeof(byte);
|
|
break;
|
|
}
|
|
case Format.BlendWeight:
|
|
{
|
|
SemanticName = "BLENDWEIGHT";
|
|
ElementFormat = SlimDX.DXGI.Format.R32G32B32A32_Float;
|
|
Size = 4 * sizeof(float);
|
|
break;
|
|
}
|
|
case Format.BlendIndices:
|
|
{
|
|
SemanticName = "BLENDINDICES";
|
|
ElementFormat = SlimDX.DXGI.Format.R32G32B32A32_SInt;
|
|
Size = 4 * sizeof(int);
|
|
break;
|
|
}
|
|
case Format.Texture2D:
|
|
{
|
|
SemanticName = "TEXCOORD";
|
|
ElementFormat = SlimDX.DXGI.Format.R32G32_Float;
|
|
Size = 2 * sizeof(float);
|
|
break;
|
|
}
|
|
case Format.Texture3D:
|
|
{
|
|
SemanticName = "TEXCOORD";
|
|
ElementFormat = SlimDX.DXGI.Format.R32G32B32_Float;
|
|
Size = 3 * sizeof(float);
|
|
break;
|
|
}
|
|
case Format.Texture4D:
|
|
{
|
|
SemanticName = "TEXCOORD";
|
|
ElementFormat = SlimDX.DXGI.Format.R32G32B32A32_Float;
|
|
Size = 4 * sizeof(float);
|
|
break;
|
|
}
|
|
case Format.PointSize:
|
|
{
|
|
SemanticName = "PSIZE";
|
|
ElementFormat = SlimDX.DXGI.Format.R32_Float;
|
|
Size = 1 * sizeof(float);
|
|
break;
|
|
}
|
|
case Format.Position:
|
|
default:
|
|
{
|
|
SemanticName = "POSITION";
|
|
ElementFormat = SlimDX.DXGI.Format.R32G32B32_Float;
|
|
Size = 3 * sizeof(float);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string SemanticName;
|
|
public SlimDX.DXGI.Format ElementFormat;
|
|
public Format WellKnownFormat;
|
|
public int NameIndex;
|
|
public int Size;
|
|
};
|
|
|
|
public interface IGeometryBuffer
|
|
{
|
|
void ConvertToAdjacency();
|
|
void DeleteIndexData();
|
|
void DeleteVertexData();
|
|
|
|
int IndexBufferLength { get; }
|
|
int IndexBufferOffset { get; set; }
|
|
int IndexBufferUsableLength { get; set; }
|
|
|
|
void SetIndexData(IEnumerable<uint> argIndexData, bool argNeedsDynamicAccess);
|
|
void SetIndexData(int argIndexCount, SlimDX.DataStream argIndexData, bool argNeedsDynamicAccess);
|
|
void SetVertexData<TVertex>(IEnumerable<TVertex> argVertexData, VertexElement[] argVertexElements, bool argNeedsDynamicAccess) where TVertex : struct;
|
|
void SetVertexData(int argVertexCount, SlimDX.DataStream argVertexData, VertexElement[] argVertexElements, bool argNeedsDynamicAccess);
|
|
|
|
SlimDX.DataStream MapIndexBufferRaw(SlimDX.Direct3D10.MapMode argAccessMode);
|
|
uint[] MapIndexBuffer(SlimDX.Direct3D10.MapMode argAccessMode);
|
|
SlimDX.DataStream MapVertexBufferRaw(SlimDX.Direct3D10.MapMode argAccessMode);
|
|
TVertex[] MapVertexBuffer<TVertex>(SlimDX.Direct3D10.MapMode argAccessMode) where TVertex : struct;
|
|
|
|
void UnmapIndexBuffer();
|
|
void UnmapVertexBuffer();
|
|
|
|
SlimDX.Direct3D10.PrimitiveTopology PrimitiveTopology { get; set; }
|
|
|
|
int VertexBufferLength { get; }
|
|
bool IsPickable { get; set; }
|
|
IPickHull PickHull { get; }
|
|
}
|
|
}
|