public bool GetVirtualPos(out Vec3 pos) { Vec3 raySrc; Vec3 rayDir; pos = Vec3.Zero; //TODO: Editor GetWorldRayFromScreenPoint Useful? :D //Editor.GetWorldRayFromScreenPoint(Editor.Viewport.NormalizedMousePos, out raySrc, out rayDir); // if (!this.m_virtualPlane.RayIntersect(raySrc, rayDir, out pos)) // { // return false; // } switch (this.m_axisConstraint) { case Axis.X: pos = Vec3.Dot(pos, this.m_virtualPlaneBase.axisX) * this.m_virtualPlaneBase.axisX; break; case Axis.Y: pos = Vec3.Dot(pos, this.m_virtualPlaneBase.axisY) * this.m_virtualPlaneBase.axisY; break; case Axis.Z: pos = Vec3.Dot(pos, this.m_virtualPlaneBase.axisZ) * this.m_virtualPlaneBase.axisZ; break; } return true; }
public static Plane FromPointNormal(Vec3 pt, Vec3 normal) { return new Plane { normal = normal, dist = Vec3.Dot(normal, pt) }; }
public static bool RayCastPhysicsFromScreenPoint(Vec2 screenPoint, out Vec3 hitPos) { Vec3 raySrc; Vec3 rayDir; GetWorldRayFromScreenPoint(screenPoint, out raySrc, out rayDir); float num; return RayCastPhysics(raySrc, rayDir, EditorObject.Null, out hitPos, out num); }
public static EditorObject GetObjectFromScreenPoint(Vec2 pt, out Vec3 hitPos, bool includeFrozen, EditorObjectSelection ignore) { EditorObject result; using (PhysEntityVector vector = PhysEntityVector.Create()) { ignore.GetPhysEntities(vector); result = new EditorObject(Binding.FCE_ObjectManager_GetObjectFromScreenPoint(pt.X, pt.Y, out hitPos.X, out hitPos.Y, out hitPos.Z, includeFrozen, vector.Pointer)); } return result; }
public static bool GetScreenPointFromWorldPos(Vec3 worldPos, out Vec2 screenPoint, bool clipped) { bool flag = Binding.FCE_Editor_GetScreenPointFromWorldPos(worldPos.X, worldPos.Y, worldPos.Z, out screenPoint.X, out screenPoint.Y); if (flag && clipped) { screenPoint.X = Math.Min(Math.Max(0f, screenPoint.X), 1f); screenPoint.Y = Math.Min(Math.Max(0f, screenPoint.Y), 1f); } return flag; }
public static Plane FromPoints(Vec3 p1, Vec3 p2, Vec3 p3) { Plane result = default(Plane); Vec3 v = p2 - p1; Vec3 v2 = p2 - p3; Vec3 v3 = Vec3.Cross(v, v2); v3.Normalize(); result.normal = v3; result.dist = Vec3.Dot(v3, p1); return result; }
public void InitVirtualPlane(Vec3 planePos, CoordinateSystem planeBase, Axis axisConstraint) { this.m_virtualPlanePos = planePos; this.m_virtualPlaneBase = planeBase; this.m_axisConstraint = axisConstraint; CoordinateSystem virtualPlaneCoords = default(CoordinateSystem); switch (this.m_axisConstraint) { case Axis.X: virtualPlaneCoords.axisX = planeBase.axisX; virtualPlaneCoords.axisY = Vec3.Cross(Camera.FrontVector, planeBase.axisX); virtualPlaneCoords.axisY.Normalize(); virtualPlaneCoords.axisZ = Vec3.Cross(planeBase.axisX, virtualPlaneCoords.axisY); virtualPlaneCoords.axisZ.Normalize(); break; case Axis.Y: virtualPlaneCoords.axisX = planeBase.axisY; virtualPlaneCoords.axisY = Vec3.Cross(Camera.FrontVector, planeBase.axisY); virtualPlaneCoords.axisY.Normalize(); virtualPlaneCoords.axisZ = Vec3.Cross(planeBase.axisY, virtualPlaneCoords.axisY); virtualPlaneCoords.axisZ.Normalize(); break; case Axis.XY: virtualPlaneCoords.axisX = planeBase.axisX; virtualPlaneCoords.axisY = planeBase.axisY; virtualPlaneCoords.axisZ = planeBase.axisZ; break; case Axis.Z: virtualPlaneCoords.axisX = planeBase.axisZ; virtualPlaneCoords.axisY = Vec3.Cross(Camera.FrontVector, planeBase.axisZ); virtualPlaneCoords.axisY.Normalize(); virtualPlaneCoords.axisZ = Vec3.Cross(planeBase.axisZ, virtualPlaneCoords.axisY); virtualPlaneCoords.axisZ.Normalize(); break; case Axis.XZ: virtualPlaneCoords.axisX = planeBase.axisX; virtualPlaneCoords.axisY = planeBase.axisZ; virtualPlaneCoords.axisZ = planeBase.axisY; break; case Axis.YZ: virtualPlaneCoords.axisX = planeBase.axisY; virtualPlaneCoords.axisY = planeBase.axisZ; virtualPlaneCoords.axisZ = planeBase.axisX; break; } this.m_virtualPlane = Plane.FromPointNormal(this.m_virtualPlanePos, virtualPlaneCoords.axisZ); this.m_virtualPlaneCoords = virtualPlaneCoords; }
public bool RayIntersect(Vec3 raySrc, Vec3 rayDir, out Vec3 pt) { float num = Vec3.Dot(this.normal, rayDir); if (Math.Abs(num) < 0.0001f) { pt = default(Vec3); return false; } float s = Vec3.Dot(this.normal, this.dist * this.normal - raySrc) / num; pt = raySrc + s * rayDir; return true; }
public static void ApplyScreenDeltaToWorldPos(Vec2 screenDelta, ref Vec3 worldPos) { Vec3 vec = Camera.FrontVector; if ((double)Math.Abs(vec.X) < 0.001 && (double)Math.Abs(vec.Y) < 0.001) { vec = Camera.UpVector; } Vec2 vec2 = -vec.XY; vec2.Normalize(); Vec2 vec3 = new Vec2(-vec2.Y, vec2.X); float num = (float)((double)Vec3.Dot(worldPos - Camera.Position, Camera.FrontVector) * Math.Tan((double)Camera.HalfFOV) * 2.0); worldPos.X += num * screenDelta.X * vec3.X + num * screenDelta.Y * vec2.X; worldPos.Y += num * screenDelta.X * vec3.Y + num * screenDelta.Y * vec2.Y; }
public static EditorObject GetObjectFromScreenPoint(Vec2 pt, out Vec3 hitPos, bool includeFrozen, EditorObject ignore) { PhysEntityVector vector = PhysEntityVector.Null; if (ignore.IsValid) { vector = PhysEntityVector.Create(); ignore.GetPhysEntities(vector); } EditorObject result = new EditorObject(Binding.FCE_ObjectManager_GetObjectFromScreenPoint(pt.X, pt.Y, out hitPos.X, out hitPos.Y, out hitPos.Z, includeFrozen, vector.Pointer)); if (vector.IsValid) { vector.Dispose(); } return result; }
public void Unapply(EditorObject obj) { CoordinateSystem coordinateSystem = CoordinateSystem.FromAngles(obj.Angles); AABB localBounds = obj.LocalBounds; Vec3 vec = (localBounds.max + localBounds.min) * 0.5f; Vec3 vec2 = localBounds.Length * 0.5f; this.position -= obj.Position + vec.X * coordinateSystem.axisX + vec.Y * coordinateSystem.axisY; this.position = coordinateSystem.ConvertFromWorld(this.position); this.normal = coordinateSystem.ConvertFromWorld(this.normal); this.normalUp = coordinateSystem.ConvertFromWorld(this.normalUp); this.position.X = this.position.X / vec2.X; this.position.Y = 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); }
public Vec3 GetPivotPoint(Vec3 center, AABB bounds, Pivot pivot) { Vec3 vec = center; switch (pivot) { case Pivot.Left: vec += this.axisX * bounds.min.X; break; case Pivot.Right: vec += this.axisX * bounds.max.X; break; case Pivot.Down: vec += this.axisY * bounds.min.Y; break; case Pivot.Up: vec += this.axisY * bounds.max.Y; break; } return vec; }
public bool GetClosestPivot(Vec3 pos, out EditorObjectPivot pivot, float minDist) { pivot = new EditorObjectPivot(); return Binding.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); }
public bool GetClosestPivot(Vec3 pos, out EditorObjectPivot pivot) { return this.GetClosestPivot(pos, out pivot, 3.40282347E+38f); }
public void ComputeAutoOrientation(ref Vec3 pos, out Vec3 angles, Vec3 normal) { angles = default(Vec3); Binding.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); }
public static void DrawSquare(Vec3 center, float radius, float penWidth, Color color, float zOrder, Color borderColor) { Binding.FCE_Draw_Square(center.X, center.Y, center.Z, radius, penWidth, (float)color.R / 255f, (float)color.G / 255f, (float)color.B / 255f, (float)color.A / 255f, zOrder, (float)borderColor.R / 255f, (float)borderColor.G / 255f, (float)borderColor.B / 255f, (float)borderColor.A / 255f); }
public static void DrawQuad(Vec3 center, float width, float height, Color color) { Binding.FCE_Draw_Quad(center.X, center.Y, center.Z, width, height, (float)color.R / 255f, (float)color.G / 255f, (float)color.B / 255f, (float)color.A / 255f); }
public AABB(Vec3 min, Vec3 max) { this.min = min; this.max = max; }
public static void DrawArrow(Vec3 center, Vec3 direction, float length, float radius, float headLength, float headRadius, Color color) { Binding.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); }
public static void DrawDot(Vec3 center, float radius, Color color, bool back, bool startGroup) { Binding.FCE_Draw_Dot(center.X, center.Y, center.Z, radius, (float)color.R / 255f, (float)color.G / 255f, (float)color.B / 255f, back, startGroup); }
public void MoveTo(Vec3 pos, EditorObjectSelection.MoveMode mode) { Binding.FCE_ObjectSelection_MoveTo(this.m_selPtr, pos.X, pos.Y, pos.Z, (int)mode); }
public static void DrawSegmentedLineSegment(Vec3 p1, Vec3 p2, float penRadius, float penRadius2, Color color, bool back) { Binding.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); }
public void RotateCenter(float angle, Vec3 axis) { Binding.FCE_ObjectSelection_RotateCenter(this.m_selPtr, angle, axis.X, axis.Y, axis.Z); }
public static void DrawWireBoxFromBottomZ(Vec3 pos, Vec3 size, float penWidth) { Binding.FCE_Draw_WireBoxFromBottomZ(pos.X, pos.Y, pos.Z, size.X, size.Y, size.Z, penWidth); }
public void SetAngles(Vec3 angles) { foreach (EditorObject current in this.GetObjects()) { current.Angles = angles; } }
public void Rotate(Vec3 angles, Vec3 axis, Vec3 pivot, bool affectCenter) { Binding.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 static bool RayCastTerrain(Vec3 raySrc, Vec3 rayDir, out Vec3 hitPos, out float hitDist) { return Binding.FCE_Editor_RayCastTerrain(raySrc.X, raySrc.Y, raySrc.Z, rayDir.X, rayDir.Y, rayDir.Z, out hitPos.X, out hitPos.Y, out hitPos.Z, out hitDist); }
public void RotateLocal(Vec3 angles) { Binding.FCE_ObjectSelection_RotateLocal3(this.m_selPtr, angles.X, angles.Y, angles.Z); }
public static bool RayCastTerrainFromMouse(out Vec3 hitPos, ViewportControl viewport) { return RayCastTerrainFromScreenPoint(viewport.NormalizedMousePos, out hitPos); }
public void SetPos(Vec3 pos) { foreach (EditorObject current in this.GetObjects()) { current.Position = pos; } }
public static bool RayCastTerrainFromScreenPoint(Vec2 screenPoint, out Vec3 hitPos) { Vec3 raySrc; Vec3 rayDir; GetWorldRayFromScreenPoint(screenPoint, out raySrc, out rayDir); float num; return RayCastTerrain(raySrc, rayDir, out hitPos, out num); }