Пример #1
0
        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;
        }
Пример #2
0
 public Vec3 ConvertToSystem(Vec3 pos, CoordinateSystem coords)
 {
     Vec3 pos2 = this.ConvertToWorld(pos);
     return coords.ConvertFromWorld(pos2);
 }