Example #1
0
 public static Plane FromPointNormal(Vec3 pt, Vec3 normal)
 {
     Plane plane = new Plane();
     plane.normal = normal;
     plane.dist = Vec3.Dot(normal, pt);
     return plane;
 }
Example #2
0
 public static Plane FromPoints(Vec3 p1, Vec3 p2, Vec3 p3)
 {
     Plane plane = new Plane();
     Vec3 vec = p2 - p1;
     Vec3 vec2 = p2 - p3;
     Vec3 vec3 = Vec3.Cross(vec, vec2);
     vec3.Normalize();
     plane.normal = vec3;
     plane.dist = Vec3.Dot(vec3, p1);
     return plane;
 }
Example #3
0
 public bool RayIntersect(Vec3 raySrc, Vec3 rayDir, out Vec3 pt)
 {
     float num = Vec3.Dot(this.normal, rayDir);
     if (Math.Abs(num) < 0.0001f)
     {
         pt = new Vec3();
         return false;
     }
     float num2 = Vec3.Dot(this.normal, ((Vec3)(this.dist * this.normal)) - raySrc) / num;
     pt = raySrc + ((Vec3)(num2 * rayDir));
     return true;
 }
        public Vec3 GetPivotPoint(Vec3 center, AABB bounds, Pivot pivot)
        {
            Vec3 vec = center;
            switch (pivot)
            {
                case Pivot.Left:
                    return (vec + ((Vec3)(this.axisX * bounds.min.X)));

                case Pivot.Right:
                    return (vec + ((Vec3)(this.axisX * bounds.max.X)));

                case Pivot.Down:
                    return (vec + ((Vec3)(this.axisY * bounds.min.Y)));

                case Pivot.Up:
                    return (vec + ((Vec3)(this.axisY * bounds.max.Y)));
            }
            return vec;
        }
 // Methods
 public void Unapply(EditorObject obj)
 {
     CoordinateSystem system = CoordinateSystem.FromAngles(obj.Angles);
     AABB localBounds = obj.LocalBounds;
     Vec3 vec = (Vec3)((localBounds.max + localBounds.min) * 0.5f);
     Vec3 vec2 = (Vec3)(localBounds.Length * 0.5f);
     this.position -= (Vec3)((obj.Position + (vec.X * system.axisX)) + (vec.Y * system.axisY));
     this.position = system.ConvertFromWorld(this.position);
     this.normal = system.ConvertFromWorld(this.normal);
     this.normalUp = system.ConvertFromWorld(this.normalUp);
     this.position.X /= vec2.X;
     this.position.Y /= vec2.Y;
     if (this.position.X > 1f)
     {
         this.position.X = 1f;
     }
     else if (this.position.X < -1f)
     {
         this.position.X = -1f;
     }
     if (this.position.Y > 1f)
     {
         this.position.Y = 1f;
     }
     else if (this.position.Y < -1f)
     {
         this.position.Y = -1f;
     }
     if (this.position.Z > 1f)
     {
         this.position.Z = 1f;
     }
     else if (this.position.Z < -1f)
     {
         this.position.Z = -1f;
     }
     this.normal.Z = 0f;
     this.normalUp = new Vec3(0f, 0f, 1f);
 }
Example #6
0
 public static void DrawSegmentedLineSegment(Vec3 p1, Vec3 p2, float penRadius, float penRadius2, Color color, bool back)
 {
     FCE_Draw_SegmentedLineSegment(p1.X, p1.Y, p1.Z, p2.X, p2.Y, p2.Z, penRadius, penRadius2, ((float)color.R) / 255f, ((float)color.G) / 255f, ((float)color.B) / 255f, back);
 }
Example #7
0
 public static void DrawArrow(Vec3 center, Vec3 direction, float length, float radius, float headLength, float headRadius, Color color)
 {
     FCE_Draw_Arrow(center.X, center.Y, center.Z, direction.X, direction.Y, direction.Z, length, radius, headLength, headRadius, ((float)color.R) / 255f, ((float)color.G) / 255f, ((float)color.B) / 255f, ((float)color.A) / 255f);
 }
Example #8
0
 public void Snap(Vec3 resolutionVector)
 {
     this.X -= (float)Math.IEEERemainder((double)this.X, (double)resolutionVector.X);
     this.Y -= (float)Math.IEEERemainder((double)this.Y, (double)resolutionVector.Y);
     this.Z -= (float)Math.IEEERemainder((double)this.Z, (double)resolutionVector.Z);
 }
Example #9
0
 public static Vec3 Cross(Vec3 v1, Vec3 v2)
 {
     return new Vec3((v1.Y * v2.Z) - (v1.Z * v2.Y), (v1.Z * v2.X) - (v1.X * v2.Z), (v1.X * v2.Y) - (v1.Y * v2.X));
 }
 public Vec3 ConvertToSystem(Vec3 pos, CoordinateSystem coords)
 {
     Vec3 vec = this.ConvertToWorld(pos);
     return coords.ConvertFromWorld(vec);
 }
 public void RotateCenter(float angle, Vec3 axis)
 {
     FCE_ObjectSelection_RotateCenter(this.m_selPtr, angle, axis.X, axis.Y, axis.Z);
 }
 public void Rotate(Vec3 angles, Vec3 axis, Vec3 pivot, bool affectCenter)
 {
     FCE_ObjectSelection_Rotate3(this.m_selPtr, angles.X, angles.Y, angles.Z, axis.X, axis.Y, axis.Z, pivot.X, pivot.Y, pivot.Z, affectCenter);
 }
 public void MoveTo(Vec3 pos, MoveMode mode)
 {
     FCE_ObjectSelection_MoveTo(this.m_selPtr, pos.X, pos.Y, pos.Z, mode);
 }
 public Vec3 GetComputeCenter()
 {
     Vec3 vec = new Vec3();
     FCE_ObjectSelection_GetComputeCenter(this.m_selPtr, out vec.X, out vec.Y, out vec.Z);
     return vec;
 }
Example #15
0
 public static bool RayCastTerrainFromScreenPoint(Vec2 screenPoint, out Vec3 hitPos)
 {
     Vec3 vec;
     Vec3 vec2;
     float num;
     GetWorldRayFromScreenPoint(screenPoint, out vec, out vec2);
     return RayCastTerrain(vec, vec2, out hitPos, out num);
 }
 public static CoordinateSystem FromAngles(Vec3 angles)
 {
     CoordinateSystem system = new CoordinateSystem();
     FCE_Core_GetAxisFromAngles(angles.X, angles.Y, angles.Z, out system.axisX.X, out system.axisX.Y, out system.axisX.Z, out system.axisY.X, out system.axisY.Y, out system.axisY.Z, out system.axisZ.X, out system.axisZ.Y, out system.axisZ.Z);
     return system;
 }
 public Vec3 ConvertFromWorld(Vec3 pos)
 {
     return new Vec3(Vec3.Dot(pos, this.axisX), Vec3.Dot(pos, this.axisY), Vec3.Dot(pos, this.axisZ));
 }
 public void RotateLocal(Vec3 angles)
 {
     FCE_ObjectSelection_RotateLocal3(this.m_selPtr, angles.X, angles.Y, angles.Z);
 }
 public Vec3 ConvertToWorld(Vec3 pos)
 {
     return (Vec3)(((pos.X * this.axisX) + (pos.Y * this.axisY)) + (pos.Z * this.axisZ));
 }
 public void SetAngles(Vec3 angles)
 {
     //foreach (EditorObject obj2 in this.GetObjects())
     //{
     //obj2.Angles = angles;
     //}
 }
 public Vec3 ToAngles()
 {
     Vec3 vec = new Vec3();
     FCE_Core_GetAnglesFromAxis(out vec.X, out vec.Y, out vec.Z, this.axisX.X, this.axisX.Y, this.axisX.Z, this.axisY.X, this.axisY.Y, this.axisY.Z, this.axisZ.X, this.axisZ.Y, this.axisZ.Z);
     return vec;
 }
 public void SetPos(Vec3 pos)
 {
     //foreach (EditorObject obj2 in this.GetObjects())
     //{
     //obj2.Position = pos;
     //}
 }
Example #23
0
 public static float Dot(Vec3 v1, Vec3 v2)
 {
     return (((v1.X * v2.X) + (v1.Y * v2.Y)) + (v1.Z * v2.Z));
 }
Example #24
0
 public void ComputeAutoOrientation(ref Vec3 pos, out Vec3 angles, Vec3 normal)
 {
     angles = new Vec3();
     FCE_Object_ComputeAutoOrientation(this.m_objPtr, ref pos.X, ref pos.Y, ref pos.Z, out angles.X, out angles.Y, out angles.Z, normal.X, normal.Y, normal.Z);
 }
Example #25
0
 public Vec3 ToAngles()
 {
     Vec3 vec = new Vec3();
     FCE_Core_GetAnglesFromDir(out vec.X, out vec.Y, out vec.Z, this.X, this.Y, this.Z);
     return vec;
 }
Example #26
0
 public bool GetClosestPivot(Vec3 pos, out EditorObjectPivot pivot)
 {
     return this.GetClosestPivot(pos, out pivot, float.MaxValue);
 }
Example #27
0
 public static void DrawDot(Vec3 center, float radius, Color color, bool back, bool startGroup)
 {
     FCE_Draw_Dot(center.X, center.Y, center.Z, radius, ((float)color.R) / 255f, ((float)color.G) / 255f, ((float)color.B) / 255f, back, startGroup);
 }
Example #28
0
 public bool GetClosestPivot(Vec3 pos, out EditorObjectPivot pivot, float minDist)
 {
     pivot = new EditorObjectPivot();
     return FCE_Object_GetClosestPivot(this.m_objPtr, pos.X, pos.Y, pos.Z, out pivot.position.X, out pivot.position.Y, out pivot.position.Z, out pivot.normal.X, out pivot.normal.Y, out pivot.normal.Z, out pivot.normalUp.X, out pivot.normalUp.Y, out pivot.normalUp.Z, minDist);
 }
Example #29
0
 public static void DrawWireBoxFromBottomZ(Vec3 pos, Vec3 size, float penWidth)
 {
     FCE_Draw_WireBoxFromBottomZ(pos.X, pos.Y, pos.Z, size.X, size.Y, size.Z, penWidth);
 }
 public CoordinateSystem(Vec3 x, Vec3 y, Vec3 z)
 {
     this.axisX = x;
     this.axisY = y;
     this.axisZ = z;
 }