1 using SiliconStudio.Core;
2 using SiliconStudio.Core.Mathematics;
3 using SiliconStudio.Core.Serialization.Converters;
4 using SiliconStudio.Paradox.Engine;
5 using SiliconStudio.Paradox.EntityModel;
43 public string LinkedBoneName {
get; set; }
123 public float StepHeight {
get; set; }
135 public bool Sprite {
get; set; }
137 #region Ignore or Private/Internal
146 if (mCollider == null)
148 throw new Exception(
"Collider is null, please make sure that you are trying to access this object after it is added to the game entities ( Entities.Add(entity) ).");
153 internal set { mCollider = value; }
168 internal Matrix BoneWorldMatrix;
170 internal int BoneIndex;
174 #endregion Ignore or Private/Internal
182 internal Matrix DerivePhysicsTransformation()
189 if (!entity.Transformation.UseTRS)
193 entity.Transformation.WorldMatrix.Decompose(out scale, out rotation, out translation);
197 rotation = entity.Transformation.Rotation;
198 translation = entity.Transformation.Translation;
204 translation.Y = -translation.Y;
207 var physicsTransform = Matrix.RotationQuaternion(rotation) *
Matrix.
Translation(translation);
212 physicsTransform = Matrix.Multiply(Shape.Shape.PositiveCenterMatrix, physicsTransform);
215 return physicsTransform;
222 internal void UpdateTransformationComponent(
Matrix physicsTransform)
224 var entity = (
Entity)Collider.EntityObject;
228 physicsTransform = Matrix.Multiply(Shape.Shape.NegativeCenterMatrix, physicsTransform);
231 var rotation = Quaternion.RotationMatrix(physicsTransform);
232 var translation = physicsTransform.TranslationVector;
237 translation.Y = -translation.Y;
240 if (entity.Transformation.UseTRS)
242 entity.Transformation.Translation = translation;
243 entity.Transformation.Rotation = rotation;
247 var worldMatrix = entity.Transformation.WorldMatrix;
250 scale.X = (float)Math.Sqrt((worldMatrix.M11 * worldMatrix.M11) + (worldMatrix.M12 * worldMatrix.M12) + (worldMatrix.M13 * worldMatrix.M13));
251 scale.Y = (float)Math.Sqrt((worldMatrix.M21 * worldMatrix.M21) + (worldMatrix.M22 * worldMatrix.M22) + (worldMatrix.M23 * worldMatrix.M23));
252 scale.Z = (float)Math.Sqrt((worldMatrix.M31 * worldMatrix.M31) + (worldMatrix.M32 * worldMatrix.M32) + (worldMatrix.M33 * worldMatrix.M33));
254 TransformationComponent.CreateMatrixTRS(ref translation, ref rotation, ref scale, out entity.Transformation.WorldMatrix);
255 if (entity.Transformation.Parent == null)
257 entity.Transformation.LocalMatrix = entity.Transformation.WorldMatrix;
262 var inverseParent = entity.Transformation.Parent.WorldMatrix;
263 inverseParent.Invert();
264 entity.Transformation.LocalMatrix = Matrix.Multiply(entity.Transformation.WorldMatrix, inverseParent);
276 Collider.PhysicsWorldTransform = DerivePhysicsTransformation();
Game entity. It usually aggregates multiple EntityComponent
void UpdatePhysicsTransformation()
Forces an update from the TransformationComponent to the Collider.PhysicsWorldTransform. Useful to manually force movements. In the case of dynamic rigidbodies a velocity reset should be applied first.
Base class for converters to/from a data type.
Represents a three dimensional mathematical vector.
static void Translation(ref Vector3 value, out Matrix result)
Creates a translation matrix using the specified offsets.
static readonly Vector3 Zero
A SiliconStudio.Core.Mathematics.Vector3 with all of its components set to zero.
static readonly Quaternion Identity
The identity SiliconStudio.Core.Mathematics.Quaternion (0, 0, 0, 1).
Represents a four dimensional mathematical quaternion.
object EntityObject
Gets or sets the entity object. Should always cast this as an Entity
using SiliconStudio.Paradox. Physics
Represents a 4x4 mathematical matrix.