本文整理匯總了C#中SlimDX.Color4.ToArgb方法的典型用法代碼示例。如果您正苦於以下問題:C# Color4.ToArgb方法的具體用法?C# Color4.ToArgb怎麽用?C# Color4.ToArgb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SlimDX.Color4
的用法示例。
在下文中一共展示了Color4.ToArgb方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DrawLine
public static void DrawLine(Location from, Location to, Color4 color)
{
var vertices = new PositionColored[2];
vertices[0] = new PositionColored(from.ToVector3(), color.ToArgb());
vertices[1] = new PositionColored(to.ToVector3(), color.ToArgb());
Device.DrawUserPrimitives(PrimitiveType.LineList, 1, vertices);
}
示例2: VertexPositonNormalColorTexture
public VertexPositonNormalColorTexture(Vector3 Position, Vector3 normal, Color4 Color, Vector2 texcoords)
{
this.Position = Position;
this.Color = Color.ToArgb();
this.texcoords = texcoords;
this.Normal = normal;
}
示例3: DrawLine
public override void DrawLine(ref Vector3 from, ref Vector3 to, Color4 fromColor, Color4 toColor)
{
PositionColored[] vertices = new PositionColored[2];
vertices[0] = new PositionColored(from, fromColor.ToArgb());
vertices[1] = new PositionColored(to, toColor.ToArgb());
device.DrawUserPrimitives(PrimitiveType.LineList, 1, vertices);
}
示例4: DrawBox
public override void DrawBox(ref Vector3 bbMin, ref Vector3 bbMax, Color4 color)
{
var p1 = bbMin;
var p2 = new Vector3(bbMax.X, bbMin.Y, bbMin.Z);
var p3 = new Vector3(bbMax.X, bbMax.Y, bbMin.Z);
var p4 = new Vector3(bbMin.X, bbMax.Y, bbMin.Z);
var p5 = new Vector3(bbMin.X, bbMin.Y, bbMax.Z);
var p6 = new Vector3(bbMax.X, bbMin.Y, bbMax.Z);
var p7 = bbMax;
var p8 = new Vector3(bbMin.X, bbMax.Y, bbMax.Z);
int intColor = color.ToArgb();
PositionColored[] vertices = new PositionColored[] {
new PositionColored(p1, intColor), new PositionColored(p2, intColor),
new PositionColored(p2, intColor), new PositionColored(p3, intColor),
new PositionColored(p3, intColor), new PositionColored(p4, intColor),
new PositionColored(p4, intColor), new PositionColored(p1, intColor),
new PositionColored(p1, intColor), new PositionColored(p5, intColor),
new PositionColored(p2, intColor), new PositionColored(p6, intColor),
new PositionColored(p3, intColor), new PositionColored(p7, intColor),
new PositionColored(p4, intColor), new PositionColored(p8, intColor),
new PositionColored(p5, intColor), new PositionColored(p6, intColor),
new PositionColored(p6, intColor), new PositionColored(p7, intColor),
new PositionColored(p7, intColor), new PositionColored(p8, intColor),
new PositionColored(p8, intColor), new PositionColored(p5, intColor),
};
device.DrawUserPrimitives(PrimitiveType.LineList, 12, vertices);
}
示例5: DrawContactPoint
public override void DrawContactPoint(ref Vector3 pointOnB, ref Vector3 normalOnB, float distance, int lifeTime, Color4 color)
{
int intColor = color.ToArgb();
PositionColored[] vertices = new PositionColored[2];
vertices[0] = new PositionColored(pointOnB, intColor);
vertices[1] = new PositionColored(pointOnB + normalOnB, intColor);
device.DrawUserPrimitives(PrimitiveType.LineList, 1, vertices);
}
示例6: toDX9
/// <summary>
/// Convert an Assimp aiColour4D into an integer.
/// </summary>
/// <param name="vValue">The assimp value.</param>
/// <returns>The equivilant DX value.</returns>
public static int toDX9(aiColor4D vValue)
{
Color4 pColour = new Color4(vValue.a, vValue.r, vValue.g, vValue.b);
return pColour.ToArgb();
}
示例7: FillVertexBuffer
private void FillVertexBuffer(Mesh animationMesh, List<odfVertex> vertexList, float[][] vertexWeights, int selectedBoneIdx)
{
using (DataStream vertexStream = animationMesh.LockVertexBuffer(LockFlags.None))
{
Color4 col = new Color4(1f, 1f, 1f);
for (int j = 0; j < vertexList.Count; j++)
{
odfVertex vertex = vertexList[j];
#if !DONT_MIRROR
Vector3 position = new Vector3(vertex.Position.X, vertex.Position.Y, -vertex.Position.Z);
Vector3 normal = new Vector3(vertex.Normal.X, vertex.Normal.Y, -vertex.Normal.Z);
#else
Vector3 position = vertex.Position;
Vector3 normal = vertex.Normal;
#endif
float[] boneWeights = vertexWeights[j];
vertexStream.Write(position.X);
vertexStream.Write(position.Y);
vertexStream.Write(position.Z);
vertexStream.Write(boneWeights[0]);
vertexStream.Write(boneWeights[1]);
vertexStream.Write(boneWeights[2]);
vertexStream.Write(vertex.BoneIndices[0]);
vertexStream.Write(vertex.BoneIndices[1]);
vertexStream.Write(vertex.BoneIndices[2]);
vertexStream.Write(vertex.BoneIndices[3]);
vertexStream.Write(normal.X);
vertexStream.Write(normal.Y);
vertexStream.Write(normal.Z);
if (selectedBoneIdx >= 0)
{
col.Red = 0f; col.Green = 0f; col.Blue = 0f;
byte[] boneIndices = vertex.BoneIndices;
for (int k = 0; k < boneIndices.Length; k++)
{
if (boneIndices[k] == 0xFF)
{
continue;
}
byte boneIdx = boneIndices[k];
if (boneIdx == selectedBoneIdx)
{
/* switch (cols)
{
case WeightsColourPreset.Greyscale:
col.r = col.g = col.b = boneWeights[k];
break;
case WeightsColourPreset.Metal:
col.r = boneWeights[k] > 0.666f ? 1f : boneWeights[k] * 1.5f;
col.g = boneWeights[k] * boneWeights[k] * boneWeights[k];
break;
case WeightsColourPreset.Rainbow:*/
if (boneWeights[k] > 0.75f)
{
col.Red = 1f;
col.Green = (1f - boneWeights[k]) * 2f;
col.Blue = 0f;
}
else if (boneWeights[k] > 0.5f)
{
col.Red = 1f;
col.Green = (1f - boneWeights[k]) * 2f;
col.Blue = 0f;
}
else if (boneWeights[k] > 0.25f)
{
col.Red = (boneWeights[k] - 0.25f) * 4f;
col.Green = 1f;
col.Blue = 0f;
}
else
{
col.Green = boneWeights[k] * 4f;
col.Blue = 1f - boneWeights[k] * 4f;
}
/* break;
}*/
break;
}
}
}
vertexStream.Write(col.ToArgb());
vertexStream.Write(vertex.UV[0]);
vertexStream.Write(vertex.UV[1]);
}
animationMesh.UnlockVertexBuffer();
}
}
示例8: RenderLine
/// <summary>
/// Renders a line.
/// </summary>
/// <param name="x0">The X coordinate of the first point.</param>
/// <param name="y0">The Y coordinate of the first point.</param>
/// <param name="color0">The color of the first point.</param>
/// <param name="x1">The X coordinate of the second point.</param>
/// <param name="y1">The Y coordinate of the second point.</param>
/// <param name="color1">The color of the second point.</param>
internal override void RenderLine(int x0, int y0, Color4 color0, int x1, int y1, Color4 color1) {
lineBuffer.Add(new ColoredVertex(
new Vector3(x0, y0, 0.0f),
color0.ToArgb()
));
lineBuffer.Add(new ColoredVertex(
new Vector3(x1, y1, 0.0f),
color1.ToArgb()
));
}
示例9: SetRenderState
private void SetRenderState(RenderState state, Color4 val)
{
var oldVal = ActiveD3D9Device.GetRenderState<Color4>(state);
if (oldVal != val)
ActiveD3D9Device.SetRenderState(state, val.ToArgb());
}
示例10: VertexPositionColor
public VertexPositionColor(Vector3 Position, Color4 Color)
{
this.Position = Position;
this.Color = Color.ToArgb();
}
示例11: FillVertexBuffer
private void FillVertexBuffer(SlimDX.Direct3D9.Mesh animationMesh, List<Operations.vVertex> vertexList, int selectedBoneIdx)
{
using (DataStream vertexStream = animationMesh.LockVertexBuffer(LockFlags.None))
{
Color4 col = new Color4(1f, 1f, 1f);
for (int i = 0; i < vertexList.Count; i++)
{
Operations.vVertex vertex = vertexList[i];
vertexStream.Write(vertex.position.X);
vertexStream.Write(vertex.position.Y);
vertexStream.Write(vertex.position.Z);
if (vertex.boneIndices != null)
{
vertexStream.Write(vertex.weights[0]);
vertexStream.Write(vertex.weights[1]);
vertexStream.Write(vertex.weights[2]);
vertexStream.Write((byte)vertex.boneIndices[0]);
vertexStream.Write((byte)vertex.boneIndices[1]);
vertexStream.Write((byte)vertex.boneIndices[2]);
vertexStream.Write((byte)vertex.boneIndices[3]);
}
else
{
vertexStream.Write((float)0);
vertexStream.Write((float)0);
vertexStream.Write((float)0);
vertexStream.Write((byte)0);
vertexStream.Write((byte)0);
vertexStream.Write((byte)0);
vertexStream.Write((byte)0);
}
vertexStream.Write(vertex.normal.X);
vertexStream.Write(vertex.normal.Y);
vertexStream.Write(vertex.normal.Z);
if (selectedBoneIdx >= 0)
{
col.Red = 0f; col.Green = 0f; col.Blue = 0f;
int[] boneIndices = vertex.boneIndices;
float[] boneWeights = vertex.weights;
for (int j = 0; j < boneIndices.Length; j++)
{
if (boneIndices[j] == 0 && boneWeights[j] == 0)
{
continue;
}
int boneIdx = boneIndices[j];
if (boneIdx == selectedBoneIdx)
{
/* switch (cols)
{
case WeightsColourPreset.Greyscale:
col.r = col.g = col.b = boneWeights[j];
break;
case WeightsColourPreset.Metal:
col.r = boneWeights[j] > 0.666f ? 1f : boneWeights[j] * 1.5f;
col.g = boneWeights[j] * boneWeights[j] * boneWeights[j];
break;
WeightsColourPreset.Rainbow:*/
if (boneWeights[j] > 0.75f)
{
col.Red = 1f;
col.Green = (1f - boneWeights[j]) * 2f;
col.Blue = 0f;
}
else if (boneWeights[j] > 0.5f)
{
col.Red = 1f;
col.Green = (1f - boneWeights[j]) * 2f;
col.Blue = 0f;
}
else if (boneWeights[j] > 0.25f)
{
col.Red = (boneWeights[j] - 0.25f) * 4f;
col.Green = 1f;
col.Blue = 0f;
}
else
{
col.Green = boneWeights[j] * 4f;
col.Blue = 1f - boneWeights[j] * 4f;
}
/* break;
}*/
break;
}
}
}
vertexStream.Write(col.ToArgb());
vertexStream.Write(vertex.uv[0]);
vertexStream.Write(vertex.uv[1]);
}
animationMesh.UnlockVertexBuffer();
}
}
示例12: DrawTriangle
public override void DrawTriangle(ref Vector3 v0, ref Vector3 v1, ref Vector3 v2, Color4 color, float __unnamed004)
{
int intColor = color.ToArgb();
PositionColored[] vertices = new PositionColored[4];
vertices[0].Position = v0;
vertices[0].Color = intColor;
vertices[1].Position = v1;
vertices[1].Color = intColor;
vertices[2].Position = v2;
vertices[2].Color = intColor;
vertices[3].Position = v0;
vertices[3].Color = intColor;
device.DrawUserPrimitives(PrimitiveType.LineStrip, 3, vertices);
}
示例13: FillVertexBuffer
private void FillVertexBuffer(Mesh animationMesh, List<xxVertex> vertexList, int selectedBoneIdx)
{
using (DataStream vertexStream = animationMesh.LockVertexBuffer(LockFlags.None))
{
Color4 col = new Color4(1f, 1f, 1f);
for (int i = 0; i < vertexList.Count; i++)
{
xxVertex vertex = vertexList[i];
vertexStream.Write(vertex.Position.X);
vertexStream.Write(vertex.Position.Y);
vertexStream.Write(vertex.Position.Z);
vertexStream.Write(vertex.Weights3[0]);
vertexStream.Write(vertex.Weights3[1]);
vertexStream.Write(vertex.Weights3[2]);
vertexStream.Write(vertex.BoneIndices[0]);
vertexStream.Write(vertex.BoneIndices[1]);
vertexStream.Write(vertex.BoneIndices[2]);
vertexStream.Write(vertex.BoneIndices[3]);
vertexStream.Write(vertex.Normal.X);
vertexStream.Write(vertex.Normal.Y);
vertexStream.Write(vertex.Normal.Z);
if (selectedBoneIdx >= 0)
{
col.Red = 0f; col.Green = 0f; col.Blue = 0f;
byte[] boneIndices = vertex.BoneIndices;
float[] boneWeights = vertex.Weights4(true);
for (int j = 0; j < boneIndices.Length; j++)
{
if (boneIndices[j] == 0xFF)
{
continue;
}
byte boneIdx = boneIndices[j];
if (boneIdx == selectedBoneIdx)
{
/* switch (cols)
{
case WeightsColourPreset.Greyscale:
col.r = col.g = col.b = boneWeights[j];
break;
case WeightsColourPreset.Metal:
col.r = boneWeights[j] > 0.666f ? 1f : boneWeights[j] * 1.5f;
col.g = boneWeights[j] * boneWeights[j] * boneWeights[j];
break;
WeightsColourPreset.Rainbow:*/
if (boneWeights[j] > 0.75f)
{
col.Red = 1f;
col.Green = (1f - boneWeights[j]) * 2f;
col.Blue = 0f;
}
else if (boneWeights[j] > 0.5f)
{
col.Red = 1f;
col.Green = (1f - boneWeights[j]) * 2f;
col.Blue = 0f;
}
else if (boneWeights[j] > 0.25f)
{
col.Red = (boneWeights[j] - 0.25f) * 4f;
col.Green = 1f;
col.Blue = 0f;
}
else
{
col.Green = boneWeights[j] * 4f;
col.Blue = 1f - boneWeights[j] * 4f;
}
/* break;
}*/
break;
}
}
}
vertexStream.Write(col.ToArgb());
vertexStream.Write(vertex.UV[0]);
vertexStream.Write(vertex.UV[1]);
}
animationMesh.UnlockVertexBuffer();
}
}
示例14: VertexPositionColorTex
public VertexPositionColorTex(Vector3 Position, Color4 Color, Vector2 texcoords)
{
this.Position = Position;
this.Color = Color.ToArgb();
this.texcoords = texcoords;
}
示例15: CreateTexture
// Create a systemmem texture, fill with the given color and copy it to a more hardware-friendly memory pool
public static Texture CreateTexture(int w, int h, Format format, Color4 color)
{
Texture texture = new Texture(Renderer.Instance.device, w, h, 1, Usage.None, format, Pool.SystemMemory);
DataRectangle drect = texture.LockRectangle(0, LockFlags.None);
DataStream ds = drect.Data;
// pixelsize in bytes
int fieldsize = 8;
switch (format)
{
case Format.A8R8G8B8:
fieldsize = 4;
break;
case Format.A16B16G16R16F:
fieldsize = 8;
break;
}
// Fill texture with color
for (int j = 0; j < (w * h); j++)
{
int x = ((j) % (w));
int y = ((j) / (w));
ds.Seek((long)(y * fieldsize) + (long)(x * fieldsize), System.IO.SeekOrigin.Begin);
switch (format)
{
case Format.A8R8G8B8:
ds.Write<int>(color.ToArgb());
break;
case Format.A16B16G16R16F:
Half[] half = Half.ConvertToHalf(new float[] { color.Red, color.Green, color.Blue, color.Alpha });
ds.Write<Half4>(new Half4(half[0], half[1], half[2], half[3]));
break;
}
}
texture.UnlockRectangle(0);
Texture realtexture = new Texture(Renderer.Instance.device, w, h, 1, Usage.None, format, Pool.Default);
Renderer.Instance.device.UpdateTexture(texture, realtexture);
texture.Dispose();
return realtexture;
}