本文整理汇总了C#中System.Vector4类的典型用法代码示例。如果您正苦于以下问题:C# Vector4类的具体用法?C# Vector4怎么用?C# Vector4使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vector4类属于System命名空间,在下文中一共展示了Vector4类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecreateControls
public override void RecreateControls(bool constructor)
{
base.RecreateControls(constructor);
BackgroundColor = new Vector4(1f, 1f, 1f, 0.5f);
m_instance = this;
m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.13f);
//AddCheckBox("Enable frozen seas ", null, MemberHelper.GetMember(() => MyFakes.ENABLE_PLANET_FROZEN_SEA));
//AddSlider("Sea level : ", 0f, 200f, null, MemberHelper.GetMember(() => MyCsgHeightmapHelpers.FROZEN_OCEAN_LEVEL));
AddCheckBox("Debug draw areas: ", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_FLORA_BOXES));
AddCheckBox("Massive", this, MemberHelper.GetMember(() => m_massive));
m_lodRanges = new float[MyRenderConstants.RenderQualityProfile.LodClipmapRanges[(int)ScaleGroup].Length];
for (int i = 0; i < m_lodRanges.Length; i++)
{
m_lodRanges[i] = MyClipmap.LodRangeGroups[(int)ScaleGroup][i];
}
for (int i = 0; i < m_lodRanges.Length; i++)
{
int lod = i;
AddSlider("LOD " + i, m_lodRanges[i], 0, (i < 4 ? 1000 : i < 7 ? 10000 : 300000), (s) => { ChangeValue(s.Value, lod); });
}
}
示例2: Terrain
public Terrain(Device device, String texture, int pitch, Renderer renderer)
{
HeightMap = new System.Drawing.Bitmap(@"Data/Textures/"+texture);
WaterShader = new WaterShader(device);
TerrainShader = new TerrainShader(device);
_width = HeightMap.Width-1;
_height = HeightMap.Height-1;
_pitch = pitch;
_terrainTextures = new ShaderResourceView[4];
_terrainTextures[0] = new Texture(device, "Sand.png").TextureResource;
_terrainTextures[1] = new Texture(device, "Grass.png").TextureResource;
_terrainTextures[2] = new Texture(device, "Ground.png").TextureResource;
_terrainTextures[3] = new Texture(device, "Rock.png").TextureResource;
_reflectionClippingPlane = new Vector4(0.0f, 1.0f, 0.0f, 0.0f);
_refractionClippingPlane = new Vector4(0.0f, -1.0f, 0.0f, 0.0f);
_noClippingPlane = new Vector4(0.0f, 1.0f, 0.0f, 10000);
_reflectionTexture = new RenderTexture(device, renderer.ScreenSize);
_refractionTexture = new RenderTexture(device, renderer.ScreenSize);
_renderer = renderer;
_bitmap = new Bitmap(device,_refractionTexture.ShaderResourceView,renderer.ScreenSize, new Vector2I(100, 100), 0);
_bitmap.Position = new Vector2I(renderer.ScreenSize.X - 100, 0);
_bitmap2 = new Bitmap(device, _reflectionTexture.ShaderResourceView, renderer.ScreenSize, new Vector2I(100, 100), 0);
_bitmap2.Position = new Vector2I(renderer.ScreenSize.X - 100, 120);
_bumpMap = _renderer.TextureManager.Create("OceanWater.png");
_skydome = new ObjModel(device, "skydome.obj", renderer.TextureManager.Create("Sky.png"));
BuildBuffers(device);
WaveTranslation = new Vector2(0,0);
}
示例3: CompressPosition
/// <summary>
/// Compresses a position so that its components are between 0 and 1.
/// </summary>
/// <param name="pos">The position to compress.</param>
/// <returns>The compressed position.</returns>
public Vector4 CompressPosition(Vector4 pos)
{
var newX = (pos.X - _info.PositionMinX) / _xScale;
var newY = (pos.Y - _info.PositionMinY) / _yScale;
var newZ = (pos.Z - _info.PositionMinZ) / _zScale;
return new Vector4(newX, newY, newZ, pos.W);
}
示例4: Compare
public static double Compare(JointRotation firstJoint, JointRotation secondJoint)
{
Vector4 mainQuaternion = new Vector4();
mainQuaternion.X = firstJoint.X;
mainQuaternion.Y = firstJoint.Y;
mainQuaternion.Z = firstJoint.Z;
mainQuaternion.W = firstJoint.W;
Vector4 secondaryQuaternion = new Vector4();
secondaryQuaternion.X = secondJoint.X;
secondaryQuaternion.Y = secondJoint.Y;
secondaryQuaternion.Z = secondJoint.Z;
secondaryQuaternion.W = secondJoint.W;
double distanceX = mainQuaternion.X - secondaryQuaternion.X;
double distanceY = mainQuaternion.Y - secondaryQuaternion.Y;
double distanceZ = mainQuaternion.Z - secondaryQuaternion.Z;
double distanceW = mainQuaternion.W - secondaryQuaternion.W;
double similarity = distanceX*distanceX +
distanceY * distanceY +
distanceZ * distanceZ +
distanceW * distanceW;
return similarity;
}
示例5: OrientedJoint
/// <summary>
/// Initializes a new instance of the <see cref="Trame.Implementation.Skeleton.OrientedJoint"/> class.
/// </summary>
/// <param name="type">Type.</param>
/// <param name="valid">If set to <c>true</c> valid.</param>
public OrientedJoint(JointType type, bool valid)
{
this.type = type;
this.isValid = valid;
orientation = new Vector4();
point = new Vector3();
}
示例6: LightManager
public LightManager(ProjectGame game)
{
packedLights = new PackedLight[MAX_LIGHTS];
// Set the ambient color equal to the Cosmic latte
ambientCol = new Vector4(1, 0.9725f, 0.9059f, 1.0f);
this.game = game;
}
示例7: ConvertToFromVector4
public static object ConvertToFromVector4(ITypeDescriptorContext context, CultureInfo culture, Vector4 value, Type destinationType)
{
if (destinationType == typeof(float))
{
return value.X;
}
if (destinationType == typeof(Vector2))
{
return new Vector2(value.X, value.Y);
}
if (destinationType == typeof(Vector3))
{
return new Vector3(value.X, value.Y, value.Z);
}
if (destinationType == typeof(Vector4))
{
return new Vector4(value.X, value.Y, value.Z, value.W);
}
if (destinationType.GetInterface("IPackedVector") != null)
{
IPackedVector packedVec = (IPackedVector) Activator.CreateInstance(destinationType);
packedVec.PackFromVector4(value);
return packedVec;
}
return null;
}
示例8: UnProject
public static Vector4 UnProject(ref Matrix4 projection, Matrix4 view, Size viewport, MouseDevice mouse)
{
Vector4 vec;
if (mouse.X > 0)
{
vec = new Vector4();
}
vec.X = 2.0f * mouse.X / (float)viewport.Width -1;
vec.Y = -(2.0f * mouse.Y / (float)viewport.Height -1);
vec.Z = 0;
vec.W = 1.0f;
Matrix4 viewInv = Matrix4.Invert(view);
Matrix4 projInv = Matrix4.Invert(projection);
Vector4.Transform(ref vec, ref projInv, out vec);
Vector4.Transform(ref vec, ref viewInv, out vec);
if (vec.W > float.Epsilon || vec.W < float.Epsilon)
{
vec.X /= vec.W;
vec.Y /= vec.W;
vec.Z /= vec.W;
}
return (vec);
}
示例9: CalcPlane
public static void CalcPlane(ref Vector3 v1, ref Vector3 v2, ref Vector3 v3, out Vector4 outv)
{
outv.X = (v1.Y * (v2.Z - v3.Z)) + (v2.Y * (v3.Z - v1.Z)) + (v3.Y * (v1.Z - v2.Z));
outv.Y = (v1.Z * (v2.X - v3.X)) + (v2.Z * (v3.X - v1.X)) + (v3.Z * (v1.X - v2.X));
outv.Z = (v1.X * (v2.Y - v3.Y)) + (v2.X * (v3.Y - v1.Y)) + (v3.X * (v1.Y - v2.Y));
outv.W = -((v1.X * ((v2.Y * v3.Z) - (v3.Y * v2.Z))) + (v2.X * ((v3.Y * v1.Z) - (v1.Y * v3.Z))) + (v3.X * ((v1.Y * v2.Z) - (v2.Y * v1.Z))));
}
示例10: AddQuad
public void AddQuad(Vector2 min, Vector2 max, Vector2 tmin, Vector2 tmax, Vector4 color, int tex)
{
Norms.Add(new Vector3(0, 0, 1));
Texs.Add(new Vector3(tmin.X, tmin.Y, tex));
Vecs.Add(new Vector3(min.X, min.Y, 0));
Inds.Add((uint)(Vecs.Count - 1));
Cols.Add(color);
Norms.Add(new Vector3(0, 0, 1));
Texs.Add(new Vector3(tmax.X, tmin.Y, tex));
Vecs.Add(new Vector3(max.X, min.Y, 0));
Inds.Add((uint)(Vecs.Count - 1));
Cols.Add(color);
Norms.Add(new Vector3(0, 0, 1));
Texs.Add(new Vector3(tmax.X, tmax.Y, tex));
Vecs.Add(new Vector3(max.X, max.Y, 0));
Inds.Add((uint)(Vecs.Count - 1));
Cols.Add(color);
Norms.Add(new Vector3(0, 0, 1));
Texs.Add(new Vector3(tmin.X, tmin.Y, tex));
Vecs.Add(new Vector3(min.X, min.Y, 0));
Inds.Add((uint)(Vecs.Count - 1));
Cols.Add(color);
Norms.Add(new Vector3(0, 0, 1));
Texs.Add(new Vector3(tmax.X, tmax.Y, tex));
Vecs.Add(new Vector3(max.X, max.Y, 0));
Inds.Add((uint)(Vecs.Count - 1));
Cols.Add(color);
Norms.Add(new Vector3(0, 0, 1));
Texs.Add(new Vector3(tmin.X, tmax.Y, tex));
Vecs.Add(new Vector3(min.X, max.Y, 0));
Inds.Add((uint)(Vecs.Count - 1));
Cols.Add(color);
}
示例11: apply
public Vector4 apply(Vector4 v)
{
Matrix mt = _matrix; mt.Transpose();
Vector4 v4 = Vector4.Transform(v, mt);
return new Vector4(v4.X+_vector.X, v4.Y+_vector.Y, v4.Z+_vector.Z, 1);
}
示例12: Run
public static void Run()
{
// ExStart:SetupNormalsOnCube
// Raw normal data
Vector4[] normals = new Vector4[]
{
new Vector4(-0.577350258,-0.577350258, 0.577350258, 1.0),
new Vector4( 0.577350258,-0.577350258, 0.577350258, 1.0),
new Vector4( 0.577350258, 0.577350258, 0.577350258, 1.0),
new Vector4(-0.577350258, 0.577350258, 0.577350258, 1.0),
new Vector4(-0.577350258,-0.577350258,-0.577350258, 1.0),
new Vector4( 0.577350258,-0.577350258,-0.577350258, 1.0),
new Vector4( 0.577350258, 0.577350258,-0.577350258, 1.0),
new Vector4(-0.577350258, 0.577350258,-0.577350258, 1.0)
};
// Call Common class create mesh using polygon builder method to set mesh instance
Mesh mesh = Common.CreateMeshUsingPolygonBuilder();
VertexElementNormal elementNormal = mesh.CreateElement(VertexElementType.Normal, MappingMode.ControlPoint, ReferenceMode.Direct) as VertexElementNormal;
// Copy the data to the vertex element
elementNormal.Data.AddRange(normals);
// ExEnd:SetupNormalsOnCube
Console.WriteLine("\nNormals has been setup successfully on cube.");
}
示例13: BeginRenderObject
public override void BeginRenderObject( Gas.Graphics.Material material )
{
effect.SetValue( "world", renderer.WorldMatrix );
effect.SetValue( "worldViewProj", renderer.WorldViewProjectionMatrix );
effect.SetValue( "diffuseMap", material.Textures[ 0 ] );
Vector4[] lightPos = new Vector4[ 4 ];
Vector4[] lightColor = new Vector4[ 4 ];
float[] range = new float[ 4 ];
for ( int i = 0; i < renderer.Lights.Count && i < 4; ++i )
{
lightPos[ i ] = new Vector4( renderer.Lights[ i ].Position.X,
renderer.Lights[ i ].Position.Y, 1.0f, 1.0f );
lightColor[ i ] = new Vector4( ( float )renderer.Lights[ i ].Color.R / 255.0f,
( float )renderer.Lights[ i ].Color.G / 255.0f,
( float )renderer.Lights[ i ].Color.B / 255.0f,
( float )renderer.Lights[ i ].Color.A / 255.0f );
range[ i ] = renderer.Lights[ i ].Range;
}
effect.SetValue( "lightPos", lightPos );
effect.SetValue( "lightColor", lightColor );
effect.SetValue( "range", range );
effect.SetValue( "numActiveLights", renderer.Lights.Count );
effect.CommitChanges();
}
示例14: Write
public void Write(Vector4 value)
{
this.Write(value.X);
this.Write(value.Y);
this.Write(value.Z);
this.Write(value.W);
}
示例15: GraphSystem
/// <summary>
///
/// </summary>
/// <param name="game"></param>
public GraphSystem( Game game )
: base(game)
{
Config = new ParticleConfig();
HighlightNodeColor = new Vector4(0, 1, 0, 1);
HighlightEdgeColor = new Vector4(0, 1, 0, 1);
}