本文整理汇总了C#中Byte4类的典型用法代码示例。如果您正苦于以下问题:C# Byte4类的具体用法?C# Byte4怎么用?C# Byte4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Byte4类属于命名空间,在下文中一共展示了Byte4类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDiamond
//////////////////////////////////////////////////////////////////////////
/// <summary>
/// 返回一个菱形Texture2D
/// </summary>
public static Texture2D GetDiamond(int width, int height, Color color, Game game)
{
Texture2D ttDmd = new Texture2D(game.GraphicsDevice, width, height);
Byte4[] btDmd = new Byte4[width * height];
Vector2 vtO = new Vector2(width / 2f, height / 2f);
// Point ptPos = new Point(i / ttRound.Width, i % ttRound.Width);
// ptPos.X = Row number, ptPos.Y = Col number
for (int x = 0; x <= width / 2; x++)
{
for (int y = 0; y <= height / 2; y++)
{
if (width / 2f * y + height / 2f * x >= width * height / 4f)
{
uint packed = (uint)(
(color.A << 24) +
(color.B << 16) +
(color.G << 8) +
color.R
);
btDmd[Vector2ToIndex(new Vector2(x, y), width)].PackedValue = packed;
if (x != 0)
btDmd[Vector2ToIndex(new Vector2(width - x, y), width)].PackedValue = packed;
if (y != 0)
btDmd[Vector2ToIndex(new Vector2(x, height - y), width)].PackedValue = packed;
if (x != 0 && y != 0)
btDmd[Vector2ToIndex(new Vector2(width - x, height - y), width)].PackedValue = packed;
}
}
}
ttDmd.SetData<Byte4>(btDmd);
return ttDmd;
}
示例2: processTexture
private Texture2D processTexture(Texture2D texture)
{
//Some programs such as Photoshop save PNG and other RGBA images without premultiplied alpha
if (!Constants.Instance.PremultipliedAlpha)
{
//XNA 4.0+ assumes that all RGBA images have premultiplied alpha channels.
//Code snippet borrowed from http://xboxforums.create.msdn.com/forums/p/62320/383015.aspx#485897
Byte4[] data = new Byte4[texture.Width * texture.Height];
texture.GetData<Byte4>(data);
for (int i = 0; i < data.Length; i++)
{
Vector4 vec = data[i].ToVector4();
float alpha = vec.W / 255.0f;
int a = (int)(vec.W);
int r = (int)(alpha * vec.X);
int g = (int)(alpha * vec.Y);
int b = (int)(alpha * vec.Z);
uint packed = (uint)(
(a << 24) +
(b << 16) +
(g << 8) +
r
);
data[i].PackedValue = packed;
}
texture.SetData<Byte4>(data);
}
return texture;
}
示例3: PackNormalB4
static public Byte4 PackNormalB4(ref Vector3 normal)
{
uint packedValue = PackNormal(ref normal);
Byte4 b4 = new Byte4();
b4.PackedValue = packedValue;
return b4;
}
示例4: AddSprite
internal void AddSprite(Vector2 clipOffset, Vector2 clipScale, Vector2 texOffset, Vector2 texScale, Byte4 color)
{
MySpritesRenderer.m_spriteInstanceList.Add(new MyVertexFormatSpritePositionTextureColor(
new HalfVector4(clipOffset.X, clipOffset.Y, clipScale.X, clipScale.Y),
new HalfVector4(texOffset.X, texOffset.Y, texScale.X, texScale.Y),
color));
}
示例5: AddSprite
internal void AddSprite(Vector2 clipOffset, Vector2 clipScale, Vector2 texOffset, Vector2 texScale,
Vector2 origin, Vector2 tangent, Byte4 color)
{
MySpritesRenderer.StackTop().m_instances.Add(new MyVertexFormatSpritePositionTextureRotationColor(
new HalfVector4(clipOffset.X, clipOffset.Y, clipScale.X, clipScale.Y),
new HalfVector4(texOffset.X, texOffset.Y, texScale.X, texScale.Y),
new HalfVector4(origin.X, origin.Y, tangent.X, tangent.Y),
color));
}
示例6: VertexPositionNormalBlendable
/// <summary>
/// Initializes a new instance of the <see cref="VertexPositionNormalBlendable"/> struct.
/// </summary>
/// <param name="position">
/// The position of the vertex.
/// </param>
/// <param name="normal">
/// The normal of the vertex.
/// </param>
/// <param name="boneWeight">
/// The bone weightings that apply to the vertex.
/// </param>
/// <param name="boneIndices">
/// The bone IDs that apply to the vertex.
/// </param>
public VertexPositionNormalBlendable(
Vector3 position,
Vector3 normal,
Vector4 boneWeight,
Byte4 boneIndices)
{
this.Position = position;
this.Normal = normal;
this.BoneWeights = boneWeight;
this.BoneIndices = boneIndices;
}
示例7: InstancedVertexPositionNormalTextureBumpSkin
public InstancedVertexPositionNormalTextureBumpSkin(VertexPositionNormalTextureBumpSkin source, Matrix meshToObject, byte index)
{
Position = source.Position;
Normal = source.Normal;
TextureCoordinate1 = source.TextureCoordinate;
TextureCoordinate2 = source.TextureCoordinate;
Tangent = source.Tangent;
Binormal = source.Binormal;
BoneIndices = new Byte4(source.BoneIndex0, source.BoneIndex1, source.BoneIndex2, source.BoneIndex3);
BoneWeights = source.BoneWeights;
}
示例8: AddQuad
internal void AddQuad(Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3, Color color)
{
var bcolor = new Byte4(color.R, color.G, color.B, color.A);
Add(new MyVertexFormatPositionColor(v0, bcolor));
Add(new MyVertexFormatPositionColor(v1, bcolor));
Add(new MyVertexFormatPositionColor(v1, bcolor));
Add(new MyVertexFormatPositionColor(v2, bcolor));
Add(new MyVertexFormatPositionColor(v2, bcolor));
Add(new MyVertexFormatPositionColor(v3, bcolor));
Add(new MyVertexFormatPositionColor(v3, bcolor));
Add(new MyVertexFormatPositionColor(v0, bcolor));
}
示例9: MultiplyAlpha
private static void MultiplyAlpha(Texture2D ret)
{
var data = new Byte4[ret.Width*ret.Height];
ret.GetData(data);
for (int i = 0; i < data.Length; i++)
{
Vector4 vec = data[i].ToVector4();
float alpha = vec.W/255.0f;
var a = (int) (vec.W);
var r = (int) (alpha*vec.X);
var g = (int) (alpha*vec.Y);
var b = (int) (alpha*vec.Z);
var packed = (uint) ((a << 24) + (b << 16) + (g << 8) + r);
data[i].PackedValue = packed;
}
ret.SetData(data);
}
示例10: AddBoundingBox
internal void AddBoundingBox(BoundingBox bb, Color color)
{
var v0 = bb.Center - bb.HalfExtents;
var v1 = v0 + new Vector3(bb.HalfExtents.X * 2, 0, 0);
var v2 = v0 + new Vector3(bb.HalfExtents.X * 2, bb.HalfExtents.Y * 2, 0);
var v3 = v0 + new Vector3(0, bb.HalfExtents.Y * 2, 0);
var v4 = v0 + new Vector3(0, 0, bb.HalfExtents.Z * 2);
var v5 = v4 + new Vector3(bb.HalfExtents.X * 2, 0, 0);
var v6 = v4 + new Vector3(bb.HalfExtents.X * 2, bb.HalfExtents.Y * 2, 0);
var v7 = v4 + new Vector3(0, bb.HalfExtents.Y * 2, 0);
var bcolor = new Byte4(color.R, color.G, color.B, color.A);
Add(new MyVertexFormatPositionColor(v0, bcolor));
Add(new MyVertexFormatPositionColor(v1, bcolor));
Add(new MyVertexFormatPositionColor(v1, bcolor));
Add(new MyVertexFormatPositionColor(v2, bcolor));
Add(new MyVertexFormatPositionColor(v2, bcolor));
Add(new MyVertexFormatPositionColor(v3, bcolor));
Add(new MyVertexFormatPositionColor(v0, bcolor));
Add(new MyVertexFormatPositionColor(v3, bcolor));
Add(new MyVertexFormatPositionColor(v4, bcolor));
Add(new MyVertexFormatPositionColor(v5, bcolor));
Add(new MyVertexFormatPositionColor(v5, bcolor));
Add(new MyVertexFormatPositionColor(v6, bcolor));
Add(new MyVertexFormatPositionColor(v6, bcolor));
Add(new MyVertexFormatPositionColor(v7, bcolor));
Add(new MyVertexFormatPositionColor(v4, bcolor));
Add(new MyVertexFormatPositionColor(v7, bcolor));
Add(new MyVertexFormatPositionColor(v0, bcolor));
Add(new MyVertexFormatPositionColor(v4, bcolor));
Add(new MyVertexFormatPositionColor(v1, bcolor));
Add(new MyVertexFormatPositionColor(v5, bcolor));
Add(new MyVertexFormatPositionColor(v2, bcolor));
Add(new MyVertexFormatPositionColor(v6, bcolor));
Add(new MyVertexFormatPositionColor(v3, bcolor));
Add(new MyVertexFormatPositionColor(v7, bcolor));
}
示例11: ModelVertex
public ModelVertex(
Vector3? position,
Vector3? normal,
Vector3? tangent,
Vector3? bitangent,
Color[] colors,
Vector2[] texCoordsUV,
Vector3[] texCoordsUVW,
Byte4? boneIndicies,
Vector4? boneWeights)
{
Position = position;
Normal = normal;
Tangent = tangent;
BiTangent = bitangent;
Colors = colors;
TexCoordsUV = texCoordsUV;
TexCoordsUVW = texCoordsUVW;
BoneIndices = boneIndicies;
BoneWeights = boneWeights;
}
示例12: PreMultiplyAlphas
// by 火必烈
public static void PreMultiplyAlphas(Texture2D ret)
{
Byte4[] data = new Byte4[ret.Width * ret.Height];
ret.GetData<Byte4>(data);
for (int i = 0; i < data.Length; i++)
{
Vector4 vec = data[i].ToVector4();
float alpha = vec.W / 255.0f;
int a = (int)(vec.W);
int r = (int)(alpha * vec.X);
int g = (int)(alpha * vec.Y);
int b = (int)(alpha * vec.Z);
uint packed = (uint)(
(a << 24) +
(b << 16) +
(g << 8) +
r
);
data[i].PackedValue = packed;
}
ret.SetData<Byte4>(data);
}
示例13: MyVertexFormatNormal
internal MyVertexFormatNormal(Byte4 normal, Byte4 normalMorph)
{
Normal = normal;
NormalMorph = normalMorph;
}
示例14: MyVertexFormatTexcoordNormalTangentTexindices
internal MyVertexFormatTexcoordNormalTangentTexindices(Vector2 texcoord, Vector3 normal, Vector3 tangent, Byte4 texIndices)
{
Texcoord = new HalfVector2(texcoord.X, texcoord.Y);
Normal = VF_Packer.PackNormalB4(ref normal);
Vector4 T = new Vector4(tangent, 1);
Tangent = VF_Packer.PackTangentSignB4(ref T);
TexIndices = texIndices;
}
示例15: MyVertexFormatTexcoordNormalTangent
internal MyVertexFormatTexcoordNormalTangent(HalfVector2 texcoord, Byte4 normal, Byte4 tangent)
{
Texcoord = texcoord;
Normal = normal;
Tangent = tangent;
}