本文整理汇总了C#中Vector3F类的典型用法代码示例。如果您正苦于以下问题:C# Vector3F类的具体用法?C# Vector3F怎么用?C# Vector3F使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector3F类属于命名空间,在下文中一共展示了Vector3F类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SceneWithStaticMeshLODandVisObj
public void SceneWithStaticMeshLODandVisObj()
{
TestManager.Helpers.OpenSceneFromFile(TestManager.Helpers.TestDataDir + @"\VisibilityTests\VisibilityObjLinking.scene");
TestManager.Helpers.ProcessEvents();
// Start the simulation
EditorManager.EditorMode = EditorManager.Mode.EM_ANIMATING; // update view
TestManager.Helpers.ProcessEvents();
// Let the simulation run for some seconds
DateTime timeBefore = DateTime.Now;
EditorManager.ActiveView.SetCameraRotation(new Vector3F(90, 0, 0));
while (true)
{
TimeSpan passedTime = DateTime.Now - timeBefore;
if (passedTime.TotalSeconds > 5)
break;
Vector3F pos = new Vector3F(50.0f,(float)passedTime.TotalSeconds * -150.0f-150.0f, 120.0f);
EditorManager.ActiveView.SetCameraPosition(pos);
TestManager.Helpers.ProcessEvents();
}
// Stop simulation, set back
EditorManager.EditorMode = EditorManager.Mode.EM_NONE;
TextToWrite = null;
TestManager.Helpers.CloseActiveProject();
}
示例2: MatrixLookAtLH
public static Matrix4x4F MatrixLookAtLH(Vector3F eye, Vector3F at, Vector3F up)
{
Vector3F right, vec;
vec = at - eye;
vec.NormalizeInPlace();
right = Vector3F.Cross(up, vec);
up = Vector3F.Cross(vec, right);
right.NormalizeInPlace();
up.NormalizeInPlace();
return new Matrix4x4F(
right.X,
up.X,
vec.X,
0.0f,
right.Y,
up.Y,
vec.Y,
0.0f,
right.Z,
up.Z,
vec.Z,
0.0f,
-Vector3F.Dot(right, eye),
-Vector3F.Dot(up, eye),
-Vector3F.Dot(vec, eye),
1.0f
);
}
示例3: AdditionOperator
public void AdditionOperator()
{
Vector3F a = new Vector3F(1.0f, 2.0f, 3.0f);
Vector3F b = new Vector3F(2.0f, 3.0f, 4.0f);
Vector3F c = a + b;
Assert.AreEqual(new Vector3F(3.0f, 5.0f, 7.0f), c);
}
示例4: Construct01
public void Construct01()
{
Vector3F v = new Vector3F(new Vector2F(1.0f, 2.0f), 3.0f);
Assert.AreEqual(1.0f, v.X);
Assert.AreEqual(2.0f, v.Y);
Assert.AreEqual(3.0f, v.Z);
}
示例5: SkyboxNode
/// <summary>
/// Initializes a new instance of the <see cref="SkyboxNode" /> class.
/// </summary>
/// <param name="texture">The cube map texture (using premultiplied alpha).</param>
public SkyboxNode(TextureCube texture)
{
Texture = texture;
Color = new Vector3F(1, 1, 1);
Alpha = 1.0f;
Encoding = ColorEncoding.SRgb;
}
示例6: PlanarReflectionNode
//--------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the <see cref="PlanarReflectionNode" /> class.
/// </summary>
/// <param name="renderToTexture">The render texture target.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="renderToTexture"/> is <see langword="null"/>.
/// </exception>
public PlanarReflectionNode(RenderToTexture renderToTexture)
: base(renderToTexture)
{
CameraNode = new CameraNode(new Camera(new PerspectiveProjection()));
FieldOfViewScale = 1;
_normalLocal = new Vector3F(0, 0, 1);
}
示例7: Update
public override void Update(GameTime gameTime)
{
float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;
// ----- Move target if <NumPad4-9> are pressed.
Vector3F translation = new Vector3F();
if (InputService.IsDown(Keys.NumPad4))
translation.X -= 1;
if (InputService.IsDown(Keys.NumPad6))
translation.X += 1;
if (InputService.IsDown(Keys.NumPad8))
translation.Y += 1;
if (InputService.IsDown(Keys.NumPad5))
translation.Y -= 1;
if (InputService.IsDown(Keys.NumPad9))
translation.Z += 1;
if (InputService.IsDown(Keys.NumPad7))
translation.Z -= 1;
translation = translation * deltaTime;
_targetPosition += translation;
// Convert target world space position to model space. - The IK solvers work in model space.
Vector3F localTargetPosition = _pose.ToLocalPosition(_targetPosition);
// Reset the affected bones. This is optional. It removes unwanted twist from the bones.
_skeletonPose.ResetBoneTransforms(_ikSolver.RootBoneIndex, _ikSolver.TipBoneIndex);
// Let IK solver update the bones.
_ikSolver.Target = localTargetPosition;
_ikSolver.Solve(deltaTime);
base.Update(gameTime);
}
示例8: DiagonalizeInertia
/// <summary>
/// Diagonalizes the inertia matrix.
/// </summary>
/// <param name="inertia">The inertia matrix.</param>
/// <param name="inertiaDiagonal">The inertia of the principal axes.</param>
/// <param name="rotation">
/// The rotation that rotates from principal axis space to parent/world space.
/// </param>
/// <remarks>
/// All valid inertia matrices can be transformed into a coordinate space where all elements
/// non-diagonal matrix elements are 0. The axis of this special space are the principal axes.
/// </remarks>
internal static void DiagonalizeInertia(Matrix33F inertia, out Vector3F inertiaDiagonal, out Matrix33F rotation)
{
// Alternatively we could use Jacobi transformation (iterative method, see Bullet/btMatrix3x3.diagonalize()
// and Numerical Recipes book) or we could find the eigenvalues using the characteristic
// polynomial which is a cubic polynomial and then solve for the eigenvectors (see Numeric
// Recipes and "Mathematics for 3D Game Programming and Computer Graphics" chapter ray-tracing
// for cubic equations and computation of bounding boxes.
// Perform eigenvalue decomposition.
var eigenValueDecomposition = new EigenvalueDecompositionF(inertia.ToMatrixF());
inertiaDiagonal = eigenValueDecomposition.RealEigenvalues.ToVector3F();
rotation = eigenValueDecomposition.V.ToMatrix33F();
if (!rotation.IsRotation)
{
// V is orthogonal but not necessarily a rotation. If it is no rotation
// we have to swap two columns.
MathHelper.Swap(ref inertiaDiagonal.Y, ref inertiaDiagonal.Z);
Vector3F dummy = rotation.GetColumn(1);
rotation.SetColumn(1, rotation.GetColumn(2));
rotation.SetColumn(2, dummy);
Debug.Assert(rotation.IsRotation);
}
}
示例9: PoseTest
public void PoseTest()
{
CameraInstance cameraInstance = new CameraInstance(new Camera(new PerspectiveProjection()));
Assert.IsNotNull(cameraInstance.PoseWorld);
Assert.AreEqual(Vector3F.Zero, cameraInstance.PoseWorld.Position);
Assert.AreEqual(Matrix33F.Identity, cameraInstance.PoseWorld.Orientation);
// Set new Pose
Vector3F position = new Vector3F(1, 2, 3);
QuaternionF orientation = QuaternionF.CreateRotation(new Vector3F(3, 4, 5), 0.123f);
cameraInstance.PoseWorld = new Pose(position, orientation);
Assert.AreEqual(position, cameraInstance.PoseWorld.Position);
Assert.AreEqual(orientation.ToRotationMatrix33(), cameraInstance.PoseWorld.Orientation);
Assert.IsTrue(Matrix44F.AreNumericallyEqual(cameraInstance.PoseWorld.ToMatrix44F(), cameraInstance.ViewInverse));
Assert.IsTrue(Matrix44F.AreNumericallyEqual(cameraInstance.PoseWorld.Inverse.ToMatrix44F(), cameraInstance.View));
// Set Position and Orientation
position = new Vector3F(5, 6, 7);
orientation = QuaternionF.CreateRotation(new Vector3F(1, -1, 6), -0.123f);
cameraInstance.PoseWorld = new Pose(position, orientation);
Assert.AreEqual(position, cameraInstance.PoseWorld.Position);
Assert.AreEqual(orientation.ToRotationMatrix33(), cameraInstance.PoseWorld.Orientation);
Assert.IsTrue(Matrix44F.AreNumericallyEqual(cameraInstance.PoseWorld.Inverse.ToMatrix44F(), cameraInstance.View));
Assert.IsTrue(Matrix44F.AreNumericallyEqual(cameraInstance.PoseWorld.ToMatrix44F(), cameraInstance.ViewInverse));
}
示例10: KinectWrapper
//--------------------------------------------------------------
public KinectWrapper(Game game)
: base(game)
{
Offset = new Vector3F(0, 0, 0);
Scale = new Vector3F(1, 1, 1);
InitializeSkeletonPoses();
}
示例11: RedSquareObject
public RedSquareObject(Vector3F position)
{
_position = position;
_color = new Vector4(1.0f, 0.0f, 0.0f, 1.0f);
var graphicsService = ServiceLocator.Current.GetInstance<IGraphicsService>();
var screen = ((GameScreen)graphicsService.Screens["Default"]);
var contentManager = ServiceLocator.Current.GetInstance<ContentManager>();
_model = contentManager.Load<ModelNode>("redSquare").Clone();
screen.Scene.Children.Add(_model);
_model.PoseWorld = new Pose(_position);
foreach (var meshNode in _model.GetSubtree().OfType<MeshNode>())
{
Mesh mesh = meshNode.Mesh;
foreach (var material in mesh.Materials)
{
var effectBinding = material["Default"];
effectBinding.Set("DiffuseColor", _color);
((BasicEffectBinding)effectBinding).LightingEnabled = false;
}
}
InUse = true;
}
示例12: GetClosestPointCandidates
public void GetClosestPointCandidates(Vector3F scale, Pose pose, ISpatialPartition<int> otherPartition, Vector3F otherScale, Pose otherPose, Func<int, int, float> callback)
{
if (otherPartition == null)
throw new ArgumentNullException("otherPartition");
if (callback == null)
throw new ArgumentNullException("callback");
// Make sure we are up-to-date.
var otherBasePartition = otherPartition as BasePartition<int>;
if (otherBasePartition != null)
otherBasePartition.UpdateInternal();
else
otherPartition.Update(false);
Update(false);
if (_numberOfItems == 0)
return;
if (otherPartition is ISupportClosestPointQueries<int>)
{
// ----- CompressedAabbTree vs. ISupportClosestPointQueries<int>
GetClosestPointCandidatesImpl(scale, pose, (ISupportClosestPointQueries<int>)otherPartition, otherScale, otherPose, callback);
}
else
{
// ----- CompressedAabbTree vs. *
GetClosestPointCandidatesImpl(otherPartition, callback);
}
}
示例13: Addition
public void Addition()
{
Vector3F a = new Vector3F(1.0f, 2.0f, 3.0f);
Vector3F b = new Vector3F(2.0f, 3.0f, 4.0f);
Vector3F c = Vector3F.Add(a, b);
Assert.AreEqual(new Vector3F(3.0f, 5.0f, 7.0f), c);
}
示例14: Normalize
public void Normalize()
{
Vector3F v, n1, n2;
float magnitude;
v = new Vector3F(3.0f, 4.0f, 0.0f);
n1 = v.Normalize();
n2 = v.Normalize(out magnitude);
Assert.AreEqual(1.0f, n1.Magnitude, 1e-7);
Assert.AreEqual(1.0f, n2.Magnitude, 1e-7);
Assert.AreEqual(5.0f, magnitude, 1e-7);
v = new Vector3F(3.0f, 0.0f, 4.0f);
n1 = v.Normalize();
n2 = v.Normalize(out magnitude);
Assert.AreEqual(1.0f, n1.Magnitude, 1e-7);
Assert.AreEqual(1.0f, n2.Magnitude, 1e-7);
Assert.AreEqual(5.0f, magnitude, 1e-7);
v = new Vector3F(0.0f, 3.0f, 4.0f);
n1 = v.Normalize();
n2 = v.Normalize(out magnitude);
Assert.AreEqual(1.0f, n1.Magnitude, 1e-7);
Assert.AreEqual(1.0f, n2.Magnitude, 1e-7);
Assert.AreEqual(5.0f, magnitude, 1e-7);
}
示例15: GodRayFilter
//--------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the <see cref="GodRayFilter"/> class.
/// </summary>
/// <param name="graphicsService">The graphics service.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="graphicsService"/> is <see langword="null"/>.
/// </exception>
public GodRayFilter(IGraphicsService graphicsService)
: base(graphicsService)
{
Effect effect = GraphicsService.Content.Load<Effect>("DigitalRune/PostProcessing/GodRayFilter");
_viewportSizeParameter = effect.Parameters["ViewportSize"];
_parameters0Parameter = effect.Parameters["Parameters0"];
_parameters1Parameter = effect.Parameters["Parameters1"];
_intensityParameter = effect.Parameters["Intensity"];
_numberOfSamplesParameter = effect.Parameters["NumberOfSamples"];
_sourceTextureParameter = effect.Parameters["SourceTexture"];
_gBuffer0Parameter = effect.Parameters["GBuffer0"];
_rayTextureParameter = effect.Parameters["RayTexture"];
_createMaskPass = effect.CurrentTechnique.Passes["CreateMask"];
_blurPass = effect.CurrentTechnique.Passes["Blur"];
_combinePass = effect.CurrentTechnique.Passes["Combine"];
_downsampleFilter = graphicsService.GetDownsampleFilter();
Scale = 1;
LightDirection = new Vector3F(0, -1, 0);
LightRadius = 0.2f;
Intensity = new Vector3F(1, 1, 1);
DownsampleFactor = 4;
NumberOfSamples = 8;
NumberOfPasses = 2;
Softness = 1;
}