private static Matrix RotateToFace(Vector3 o, Vector3 p, Vector3 u) { var d = Vector3.Normalize(o - p); var s = Vector3.Normalize(Vector3.Cross(Vector3.Normalize(u), d)); var v = Vector3.Normalize(Vector3.Cross(d, s)); return(SlimDxExtension.ToMatrix( v.X, v.Y, v.Z, 0, d.X, d.Y, d.Z, 0, s.X, s.Y, s.Z, 0, o.X, o.Y, o.Z, 1)); }
private static Matrix RotateToFaceDirSpecial(Vector3 o, Vector3 p, Vector3 u) { var d = Vector3.Normalize(p - o); var s = Vector3.Normalize(Vector3.Cross(d, Vector3.Normalize(u))); var v = Vector3.Cross(s, d); return(SlimDxExtension.ToMatrix( d.X, d.Y, d.Z, 0, v.X, v.Y, v.Z, 0, s.X, s.Y, s.Z, 0, o.X, o.Y, o.Z, 1)); }
public override void UpdateBoundingBox() { // No, we can’t just “cache BB in default state and then transform min/max values”! No! // When rotated, some absolutely different vertices might become min/max! if (IsEmpty) { BoundingBox = null; } var parentMatrix = ParentMatrix; if (parentMatrix == _parentMatrix) { return; } _parentMatrix = parentMatrix; if (_positions == null) { PrepareSmart(); if (_positions == null) { return; } } if (_positions.Length == 0) { var p = TransformCoordinate(Vector3.Zero, parentMatrix); BoundingBox = new BoundingBox(p, p); return; } if (_temporary?.Length != _positions.Length) { _temporary = new Vector3[_positions.Length]; } Vector3.TransformCoordinate(_positions, ref parentMatrix, _temporary); var b = new BoundingBox(_temporary[0], _temporary[0]); for (var i = 1; i < _temporary.Length; i++) { SlimDxExtension.Extend(ref b, ref _temporary[i]); } BoundingBox = b; }
public static void Set(this EffectVariable variable, EffectDarkMaterial.NmUvMultMaterial o) { SlimDxExtension.Set(variable, o, EffectDarkMaterial.NmUvMultMaterial.Stride); }
public static void Set(this EffectVariable variable, EffectDeferredGObject.Material o) { SlimDxExtension.SetObject(variable, o, EffectDeferredGObject.Material.Stride); }