本文整理汇总了C#中Vector3D.AssertIsValid方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3D.AssertIsValid方法的具体用法?C# Vector3D.AssertIsValid怎么用?C# Vector3D.AssertIsValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3D
的用法示例。
在下文中一共展示了Vector3D.AssertIsValid方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPointBillboard
internal static void AddPointBillboard(string material,
Color color, Vector3D origin, float radius, float angle, int priority = 0, int customViewProjection = -1)
{
Debug.Assert(material != null);
origin.AssertIsValid();
angle.AssertIsValid();
MyQuadD quad;
if (MyUtils.GetBillboardQuadAdvancedRotated(out quad, origin, radius, angle, MyEnvironment.CameraPosition) != false)
{
MyBillboard billboard = SpawnBillboard();
if (billboard == null)
return;
billboard.Priority = priority;
billboard.CustomViewProjection = customViewProjection;
CreateBillboard(billboard, ref quad, material, ref color, ref origin);
}
}
示例2: AddLineBillboard
// Add billboard for one frame only. This billboard isn't particle (it doesn't survive this frame, doesn't have update/draw methods, etc).
// It's used by other classes when they want to draw some billboard (e.g. rocket thrusts, reflector glare).
public static void AddLineBillboard(string material,
Color color, Vector3D origin, Vector3 directionNormalized, float length, float thickness, int priority = 0, bool near = false, int customViewProjection = -1)
{
Debug.Assert(material != null);
if (!IsEnabled) return;
origin.AssertIsValid();
length.AssertIsValid();
MyDebug.AssertDebug(length > 0);
MyDebug.AssertDebug(thickness > 0);
VRageRender.MyBillboard billboard = m_billboardOncePool.Allocate();
if (billboard == null)
return;
billboard.Priority = priority;
billboard.CustomViewProjection = customViewProjection;
MyPolyLineD polyLine;
polyLine.LineDirectionNormalized = directionNormalized;
polyLine.Point0 = origin;
polyLine.Point1 = origin + directionNormalized * length;
polyLine.Thickness = thickness;
MyQuadD quad;
MyUtilsRender9.GetPolyLineQuad(out quad, ref polyLine);
CreateBillboard(billboard, ref quad, material, ref color, ref origin, false, near);
m_billboardsOnce.Add(billboard);
}
示例3: AddBillboardOriented
// Add billboard for one frame only. This billboard isn't particle (it doesn't survive this frame, doesn't have update/draw methods, etc).
// This billboard isn't facing the camera. It's always oriented in specified direction. May be used as thrusts, or inner light of reflector.
// It's used by other classes when they want to draw some billboard (e.g. rocket thrusts, reflector glare).
public static void AddBillboardOriented(string material,
Color color, Vector3D origin, Vector3 leftVector, Vector3 upVector, float radius, int priority = 0, bool colorize = false, int customViewProjection = -1)
{
Debug.Assert(material != null);
if (!IsEnabled) return;
origin.AssertIsValid();
leftVector.AssertIsValid();
upVector.AssertIsValid();
radius.AssertIsValid();
MyDebug.AssertDebug(radius > 0);
MyBillboard billboard = m_billboardOncePool.Allocate();
if (billboard == null)
return;
billboard.Priority = priority;
billboard.CustomViewProjection = customViewProjection;
MyQuadD quad;
MyUtils.GetBillboardQuadOriented(out quad, ref origin, radius, ref leftVector, ref upVector);
CreateBillboard(billboard, ref quad, material, ref color, ref origin, colorize);
m_billboardsOnce.Add(billboard);
}
示例4: AddPointBillboard
// Add billboard for one frame only. This billboard isn't particle (it doesn't survive this frame, doesn't have update/draw methods, etc).
// It's used by other classes when they want to draw some billboard (e.g. rocket thrusts, reflector glare).
public static void AddPointBillboard(string material,
Color color, Vector3D origin, float radius, float angle, int priority = 0, bool colorize = false, bool near = false, bool lowres = false, int customViewProjection = -1,bool cullwithStencil = false)
{
Debug.Assert(material != null);
if (!IsEnabled) return;
origin.AssertIsValid();
angle.AssertIsValid();
MyQuadD quad;
if (MyUtils.GetBillboardQuadAdvancedRotated(out quad, origin, radius, angle, MyRenderCamera.Position) != false)
{
VRageRender.MyBillboard billboard = m_billboardOncePool.Allocate();
if (billboard == null)
return;
billboard.CullWithStencil = cullwithStencil;
billboard.Priority = priority;
billboard.CustomViewProjection = customViewProjection;
CreateBillboard(billboard, ref quad, material, ref color, ref origin, colorize, near, lowres);
// TODO: OP! Nothing should add into BillboardsRead, especially when it may be used for more than one rendering frame
m_billboardsOnce.Add(billboard);
}
}
示例5: ApplyImpulse
/// <summary>
/// Applies the impulse.
/// </summary>
/// <param name="impulse">The dir.</param>
/// <param name="pos">The pos.</param>
public override void ApplyImpulse(Vector3 impulse, Vector3D pos)
{
impulse.AssertIsValid();
pos.AssertIsValid();
System.Diagnostics.Debug.Assert(IsInWorld == true);
var offset = MyPhysics.Clusters.GetObjectOffset(ClusterObjectID);
var posF = (Vector3)(pos - offset);
RigidBody.ApplyPointImpulse(impulse, posF);
}
示例6: AddForce
/// <summary>
/// Applies external force to the physics object.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="force">The force.</param>
/// <param name="position">The position.</param>
/// <param name="torque">The torque.</param>
public override void AddForce(MyPhysicsForceType type, Vector3? force, Vector3D? position, Vector3? torque)
{
force.AssertIsValid();
position.AssertIsValid();
torque.AssertIsValid();
System.Diagnostics.Debug.Assert(IsInWorld == true);
if (IsStatic)
return;
switch (type)
{
case MyPhysicsForceType.ADD_BODY_FORCE_AND_BODY_TORQUE:
{
if (RigidBody != null)
{
Matrix tempM = RigidBody.GetRigidBodyMatrix();
tempM.Translation = Vector3.Zero;
if (force != null && !MyUtils.IsZero(force.Value))
{
Vector3 tmpForce = Vector3.Transform(force.Value, tempM);
//RigidBody.Activate(true);
//RigidBody.ApplyForce(MyEngineConstants.PHYSICS_STEP_SIZE_IN_SECONDS, tmpForce * 0.0001f);
RigidBody.ApplyLinearImpulse(tmpForce * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS * MyFakes.SIMULATION_SPEED);
//RigidBody.ApplyCentralImpulse(tmpForce);
}
if (torque != null && !MyUtils.IsZero(torque.Value))
{
Vector3 tmpTorque = Vector3.Transform(torque.Value, tempM);
//SharpDX.Vector3 tmpTorque = SharpDXHelper.ToSharpDX(torque.Value);
// RigidBody.Activate(true);
//RigidBody.UpdateInertiaTensor();
//RigidBody.ApplyTorque(MyEngineConstants.PHYSICS_STEP_SIZE_IN_SECONDS, tmpTorque * 0.0001f);
RigidBody.ApplyAngularImpulse(tmpTorque * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS * MyFakes.SIMULATION_SPEED);
//RigidBody.ApplyTorqueImpulse(tmpTorque);
}
}
if (CharacterProxy != null)
{
Matrix tempM = Entity.WorldMatrix;
tempM.Translation = Vector3.Zero;
if (force != null && !MyUtils.IsZero(force.Value))
{
Vector3 tmpForce = Vector3.Transform(force.Value, tempM);
CharacterProxy.ApplyLinearImpulse(tmpForce * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS * MyFakes.SIMULATION_SPEED);
}
if (torque != null && !MyUtils.IsZero(torque.Value))
{
Vector3 tmpTorque = Vector3.Transform(torque.Value, tempM);
CharacterProxy.ApplyAngularImpulse(tmpTorque * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS * MyFakes.SIMULATION_SPEED);
}
}
if (Ragdoll != null && Ragdoll.IsAddedToWorld && !Ragdoll.IsKeyframed)
{
foreach (var rigidBody in Ragdoll.RigidBodies)
{
if (rigidBody != null)
{
Matrix tempM = rigidBody.GetRigidBodyMatrix();
tempM.Translation = Vector3.Zero;
if (force != null && !MyUtils.IsZero(force.Value))
{
Vector3 tmpForce = Vector3.Transform(force.Value, tempM) * rigidBody.Mass / Ragdoll.Mass;
//RigidBody.Activate(true);
//RigidBody.ApplyForce(MyEngineConstants.PHYSICS_STEP_SIZE_IN_SECONDS, tmpForce * 0.0001f);
rigidBody.ApplyLinearImpulse(tmpForce * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS * MyFakes.SIMULATION_SPEED);
//RigidBody.ApplyCentralImpulse(tmpForce);
}
if (torque != null && !MyUtils.IsZero(torque.Value))
{
Vector3 tmpTorque = Vector3.Transform(torque.Value, tempM) * rigidBody.Mass / Ragdoll.Mass;
//SharpDX.Vector3 tmpTorque = SharpDXHelper.ToSharpDX(torque.Value);
// RigidBody.Activate(true);
//RigidBody.UpdateInertiaTensor();
//RigidBody.ApplyTorque(MyEngineConstants.PHYSICS_STEP_SIZE_IN_SECONDS, tmpTorque * 0.0001f);
rigidBody.ApplyAngularImpulse(tmpTorque * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS * MyFakes.SIMULATION_SPEED);
//RigidBody.ApplyTorqueImpulse(tmpTorque);
}
}
}
//.........这里部分代码省略.........
示例7: AddBillboardOriented
internal static void AddBillboardOriented(string material,
Color color, Vector3D origin, Vector3 leftVector, Vector3 upVector, float radius, int priority = 0, int customViewProjection = -1)
{
Debug.Assert(material != null);
origin.AssertIsValid();
leftVector.AssertIsValid();
upVector.AssertIsValid();
radius.AssertIsValid();
MyDebug.AssertDebug(radius > 0);
MyBillboard billboard = SpawnBillboard();
if (billboard == null)
return;
billboard.Priority = priority;
billboard.CustomViewProjection = customViewProjection;
MyQuadD quad;
MyUtils.GetBillboardQuadOriented(out quad, ref origin, radius, ref leftVector, ref upVector);
CreateBillboard(billboard, ref quad, material, ref color, ref origin);
}
示例8: AddForce
/// <summary>
/// Applies external force to the physics object.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="force">The force.</param>
/// <param name="position">The position.</param>
/// <param name="torque">The torque.</param>
public override void AddForce(MyPhysicsForceType type, Vector3? force, Vector3D? position, Vector3? torque)
{
force.AssertIsValid();
position.AssertIsValid();
torque.AssertIsValid();
System.Diagnostics.Debug.Assert(IsInWorld == true || IsWelded);
if (IsStatic)
return;
Matrix transform;
switch (type)
{
case MyPhysicsForceType.ADD_BODY_FORCE_AND_BODY_TORQUE:
{
if (RigidBody != null)
{
transform = RigidBody.GetRigidBodyMatrix();
AddForceTorqueBody(force, torque, RigidBody, ref transform);
}
if (CharacterProxy != null)
{
transform = Entity.WorldMatrix;
AddForceTorqueBody(force, torque, CharacterProxy.GetHitRigidBody(), ref transform);
}
if (Ragdoll != null && Ragdoll.IsAddedToWorld && !Ragdoll.IsKeyframed)
{
transform = Entity.WorldMatrix;
ApplyForceTorqueOnRagdoll(force, torque, Ragdoll, ref transform);
}
}
break;
case MyPhysicsForceType.APPLY_WORLD_IMPULSE_AND_WORLD_ANGULAR_IMPULSE:
{
ApplyImplusesWorld(force, position, torque, RigidBody);
if (CharacterProxy != null && force.HasValue && position.HasValue)
{
CharacterProxy.ApplyLinearImpulse(force.Value);
}
if (Ragdoll != null && Ragdoll.IsAddedToWorld && !Ragdoll.IsKeyframed)
{
ApplyImpuseOnRagdoll(force, position, torque, Ragdoll);
}
}
break;
case MyPhysicsForceType.APPLY_WORLD_FORCE:
{
ApplyForceWorld(force, position, RigidBody);
if (Ragdoll != null && Ragdoll.IsAddedToWorld && !Ragdoll.IsKeyframed)
{
ApplyForceOnRagdoll(force, position, Ragdoll);
}
}
break;
default:
{
Debug.Fail("Unhandled enum!");
}
break;
}
}
示例9: SetPositionAndLookAt
private void SetPositionAndLookAt(Vector3D lookAt)
{
m_lookAt = lookAt;
m_transformedLookAt = Vector3D.Transform(lookAt, m_targetOrientation);
m_positionSafe = m_target + m_transformedLookAt;
m_desiredPosition = m_positionSafe;
m_position = m_positionSafe;
m_velocity = Vector3.Zero;
m_positionSafe.AssertIsValid();
}
示例10: SetCameraViewMatrix
public static void SetCameraViewMatrix(MatrixD viewMatrix, Matrix projectionMatrix, Matrix nearProjectionMatrix, float safenear, float nearFov, float fov,
float nearPlane, float farPlane, float nearObjectsNearPlane, float nearObjectsFarPlane,
Vector3D cameraPosition)
{
var message = MessagePool.Get<MyRenderMessageSetCameraViewMatrix>(MyRenderMessageEnum.SetCameraViewMatrix);
cameraPosition.AssertIsValid();
message.ViewMatrix = viewMatrix;
message.ProjectionMatrix = projectionMatrix;
message.NearProjectionMatrix = nearProjectionMatrix;
message.SafeNear = safenear;
message.NearFOV = nearFov;
message.FOV = fov;
message.NearPlane = nearPlane;
message.FarPlane = farPlane;
message.NearObjectsNearPlane = nearObjectsNearPlane;
message.NearObjectsFarPlane = nearObjectsFarPlane;
message.CameraPosition = cameraPosition;
EnqueueMessage(message);
}
示例11: SetPositionAndLookAt
private void SetPositionAndLookAt(Vector3D lookAt)
{
double dist = lookAt.Length();
m_lookAt = (MySession.Static == null || !(MySession.Static.CameraController is MyCharacter) ? m_lookAtDirection : m_lookAtDirectionCharacter) * dist;
m_transformedLookAt = Vector3D.Transform(lookAt, m_targetOrientation);
m_positionSafe = m_target + m_transformedLookAt;
m_desiredPosition = m_positionSafe;
m_position = m_positionSafe;
m_velocity = Vector3.Zero;
m_positionSafe.AssertIsValid();
}
示例12: ProcessSpringCalculation
private void ProcessSpringCalculation()
{
Vector3D stretch = m_position - m_desiredPosition;
Vector3D force = -m_currentSpring.Stiffness * stretch - m_currentSpring.Dampening * m_velocity;
force.AssertIsValid();
// Apply acceleration
Vector3 acceleration = (Vector3) force / m_currentSpring.Mass;
m_velocity += acceleration * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
m_velocity.AssertIsValid();
// Apply velocity
m_position += m_velocity * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
m_position.AssertIsValid();
}
示例13: SetPosition
public void SetPosition(Vector3D position)
{
if (Vector3D.DistanceSquared(Position, position) > 0.0001)
{
position.AssertIsValid();
Position = position;
m_spotParamsDirty = true;
UpdatePositionWithOffset();
m_pointBoundingSphere.Center = PositionWithOffset;
}
}
示例14: AddBillboardOriented
internal static void AddBillboardOriented(string material,
Color color, Vector3D origin, Vector3 leftVector, Vector3 upVector, float radius, int priority = 0, float softParticleDistanceScale = 1.0f,
int customViewProjection = -1)
{
if (!MyRender11.DebugOverrides.BillboardsDynamic)
return;
Debug.Assert(material != null);
origin.AssertIsValid();
leftVector.AssertIsValid();
upVector.AssertIsValid();
radius.AssertIsValid();
MyDebug.AssertDebug(radius > 0);
MyBillboard billboard = MyBillboardRenderer.AddBillboardOnce();
if (billboard == null)
return;
billboard.Priority = priority;
billboard.CustomViewProjection = customViewProjection;
MyQuadD quad;
MyUtils.GetBillboardQuadOriented(out quad, ref origin, radius, ref leftVector, ref upVector);
CreateBillboard(billboard, ref quad, material, ref color, ref origin, softParticleDistanceScale);
}