public VectorInputAction(Float3 direction, float length)
 {
     Direction = direction;
     Length    = length;
 }
Exemple #2
0
	internal static Float3 Max4(Float3 a, Float3 b, Float3 c, Float3 d) {
		var m0 = a.Max(b);
		var m1 = c.Max(d);
		return m0.Max(m1);
	}
Exemple #3
0
 public static void DrawArrow(Float3 origin, Float3 end) => DrawArrow(origin, end, (origin - end).Magnitude / 10f);
Exemple #4
0
 private static void SetData(out Rotator r, Float3 data)
 {
     r.X = data.X;
     r.Y = data.Y;
     r.Z = data.Z;
 }
        private Mesh CreateMesh()
        {
            MeshBuilder meshBuilder = new MeshBuilder();

            for (int i = 0; i < faces.Count; i++)
            {
                var face = faces.Data[i];
                if (face.Elements.Length < 3)
                {
                    throw par.CreateError("Need at least 3 vertices to form a triangle");
                }

                //Create a simple triangle fan for each face.
                //Note: this only supports ordered simple convex polygons
                FaceElement a = face.Elements[0]; //Pivot point for the fan
                for (int j = 2; j < face.Elements.Length; j++)
                {
                    FaceElement b = face.Elements[j - 1];
                    FaceElement c = face.Elements[j];

                    //Surface normal is used when a vertex doesn't specify explict normals
                    Float3 surfaceNormal = Triangle.GetNormal(
                        a: GetPosition(a),
                        b: GetPosition(b),
                        c: GetPosition(c));

                    //Add the triangle to the meshbuilder
                    //Note: Adding the triangle in reverse because obj has counter-clockwise
                    //triangle order by default and we want a clockwise order
                    meshBuilder.PushVertex(GetVertex(c, surfaceNormal));
                    meshBuilder.PushVertex(GetVertex(b, surfaceNormal));
                    meshBuilder.PushVertex(GetVertex(a, surfaceNormal));
                }
            }
            return(meshBuilder.ToMesh());

            //Helper functions
            Float3 GetPosition(FaceElement element) => positions.Data[element.PositionIndex];

            Vertex GetVertex(FaceElement element, Float3 surfaceNormal)
            {
                Float3 pos    = GetPosition(element);
                Float3 normal = surfaceNormal;
                Float2 uv     = Float2.Zero;

                //Obj makes no promises that normals are normalized so we need to normalize them
                if (element.NormalIndex != null)
                {
                    normal = Float3.FastNormalize(normals.Data[element.NormalIndex.Value]);
                }
                if (element.TexcoordIndex != null)
                {
                    uv = texcoords.Data[element.TexcoordIndex.Value];
                }
                return(new Vertex(
                           position: pos,
                           color: Float4.One, //Obj has no concept of vertex color
                           normal: normal,
                           //Convert uv to be origin = bottom left
                           uv1: (uv.X, 1f - uv.Y),
                           uv2: Float2.Zero)); //Obj has no concept of uv2
            }
        }
Exemple #6
0
 public static void Clip(Float3 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float3)})");
Exemple #7
0
        /// <summary>
        /// vector 在 onNormal的投影
        /// </summary>
        /// <param name="vector"></param>
        /// <param name="onNormal"></param>
        /// <returns></returns>
        public static Float3 Project(Float3 vector, Float3 onNormal)
        {
            Float3 normal = onNormal.normalized;

            return(Float3.Dot(vector, normal) * normal);
        }
        private static void MenuLoadFresh()
        {
            SaveDataManager.instance.Setup();
            QuestManager.instance.LoadQuests();
            ExperienceSystem.instance.Setup();
            ExperienceSystem.instance.FixOverflowedExperience();
            ExperienceSystem.instance.ApplyExperienceFinished += delegate { SaveDataManager.instance.ApplyToFile(); };

            //ExperienceSystem.instance.Invoke("TestLevel", 5f); //TODO: Remove later, FPFC testing
            var floatingScreen = FloatingScreen.CreateFloatingScreen(new Vector2(120, 52f), true,
                                                                     Float3.ToVector3(config.Value.FSPanelPosition),
                                                                     Quaternion.Euler(Float3.ToVector3(config.Value.FSPanelRotation)));

            floatingScreen.screenMover.OnRelease += (pos, rot) => {
                config.Value.FSPanelPosition = new Float3(pos.x, pos.y, pos.z);
                config.Value.FSPanelRotation = new Float3(rot.eulerAngles.x, rot.eulerAngles.y, rot.eulerAngles.z);
                configProvider.Store(config.Value);
            };
            floatingScreen.SetRootViewController(BeatSaberUI.CreateViewController <OverlayViewController>(), true);
            floatingScreen.GetComponent <Image>().enabled = false;
        }
Exemple #9
0
	public Float3 Div(Float3 xx){
		x/=xx.x;
		y/=xx.y;
		z/=xx.z;
		return this;
	}
Exemple #10
0
	public Float3 Sub(Float3 xx){
		x-=xx.x;
		y-=xx.y;
		z-=xx.z;
		return this;
	}
Exemple #11
0
	public Float3 Add(Float3 xx){
		x+=xx.x;
		y+=xx.y;
		z+=xx.z;
		return this;
	}
Exemple #12
0
	public Float3 Mul(Float3 xx){
		x*=xx.x;
		y*=xx.y;
		z*=xx.z;
		return this;
	}
Exemple #13
0
Float DotNoise(Float X,Float Y,Float Val1,Float Val2,Float Val3)
{
	Float3 Rad = new Float3(Val1,Val2,Val3);
	Float2 P = new Float2(X,Y);
	Float radius_low = Rad.x;
	Float radius_high = Rad.y;
	Float2 Pi = floor(P,true);
	Float2 Pf = P-Pi;

	Float4 Hash = FastHash2D(Pi);
	
	Float Radius = max(0.0f,radius_low+Hash.z*(radius_high-radius_low),true);
	Float Value = Radius/max(radius_high,radius_low,true);
	
	Radius = 2.0f/Radius;
	Pf *= Radius;
	Pf -= (Radius - 1.0f);
	Pf += Hash.xy*(Radius - 2f);
	Pf = pow(Pf,Rad.z);
	return DotFalloff(min(dot(Pf,Pf),1.0f,true))*Value;
}
Exemple #14
0
	internal static Float3 Min4(Float3 a, Float3 b, Float3 c, Float3 d) {
		var m0 = a.Min(b);
		var m1 = c.Min(d);
		return m0.Min(m1);
	}
Exemple #15
0
 /// <summary>
 /// 求向量vector 在平面上的投影
 /// </summary>
 /// <param name="vector"></param>
 /// <param name="planeNormal">平面法向量</param>
 /// <returns></returns>
 public static Float3 ProjectOnPlane(Float3 vector, Float3 planeNormal)
 {
     return(vector - Float3.Project(vector, planeNormal));
 }
Exemple #16
0
 /// <summary>
 /// Creates RGB color from Hue[0-360], Saturation[0-1] and Value[0-1] packed to XYZ vector.
 /// </summary>
 /// <param name="hsv">The HSV color.</param>
 /// <param name="alpha">The alpha value. Default is 1.</param>
 /// <returns>The RGB color.</returns>
 public static Color FromHSV(Float3 hsv, float alpha = 1.0f)
 {
     return(FromHSV(hsv.X, hsv.Y, hsv.Z, alpha));
 }
Exemple #17
0
 /// <summary>
 /// 求发射光线
 /// </summary>
 /// <param name="inDirection">入射光线</param>
 /// <param name="inNormal">法线</param>
 /// <returns></returns>
 public static Float3 Reflect(Float3 inDirection, Float3 inNormal)
 {
     return(inDirection - Float3.Project(inDirection, inNormal) * 2);
 }
Exemple #18
0
//Float2 Interpolation_C2( Float2 x ) { return (x*x).Square().Mul((x * ((x * 6.0f) - 15.0f)).Add(10.0f)); }
void FastHash2D(Float2 Pos,out Float4 hash_0, out Float4 hash_1, out Float4 hash_2){
	Float2 Offset = new Float2(26,161);
	Float Domain = 71f;
	Float3 SomeLargeFloats = new Float3(951.135664f,642.9478304f,803.202459f);
	Float4 P = new Float4(Pos,Pos+1);
	P = P.Sub(floor(P.Mul((1.0f/Domain)),true).Mul(Domain));
	P.Add(Offset.xyxy);
	P.Square();
	P = P.xzxz*P.yyww;
	hash_0 = frac(P*(1f/SomeLargeFloats.x),true);
	hash_1 = frac(P*(1f/SomeLargeFloats.y),true);
	hash_2 = frac(P*(1f/SomeLargeFloats.z),true);
}
Exemple #19
0
 /// <summary>
 /// 分量分别相乘,得到新的向量
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public static Float3 Scale(Float3 a, Float3 b)
 {
     return(new Float3(a.x * b.x, a.y * b.y, a.z * b.z));
 }
 /// <inheritdoc/>
 public ref readonly TPixel this[Float3 uvw] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture3D<T, TPixel>)}[{typeof(Float3)}]");
Exemple #21
0
 /// <summary>
 /// 求角度
 /// </summary>
 /// <param name="from"></param>
 /// <param name="to"></param>
 /// <param name="axis">from, to 的垂直轴</param>
 /// <returns></returns>
 public static float SignedAngle(Float3 from, Float3 to, Float3 axis)
 {
     return(0);
 }
        public override void ProcessPacket(ILSRequestgStationPoolSync packet, NebulaConnection conn)
        {
            if (IsClient)
            {
                return;
            }

            INebulaPlayer player = playerManager.GetPlayer(conn);

            if (player == null)
            {
                player = playerManager.GetSyncingPlayer(conn);
            }
            if (player != null)
            {
                int countILS = 0;
                int iter     = 0;

                foreach (StationComponent stationComponent in GameMain.data.galacticTransport.stationPool)
                {
                    if (stationComponent != null)
                    {
                        countILS++;
                    }
                }

                if (countILS == 0)
                {
                    return;
                }

                int[]    stationGId          = new int[countILS];
                int[]    stationMaxShipCount = new int[countILS];
                int[]    stationId           = new int[countILS];
                Float3[] DockPos             = new Float3[countILS];
                Float4[] DockRot             = new Float4[countILS];
                int[]    planetId            = new int[countILS];
                int[]    workShipCount       = new int[countILS];
                int[]    idleShipCount       = new int[countILS];
                ulong[]  workShipIndices     = new ulong[countILS];
                ulong[]  idleShipIndices     = new ulong[countILS];

                List <int>     shipStage      = new List <int>();
                List <int>     shipDirection  = new List <int>();
                List <float>   shipWarpState  = new List <float>();
                List <int>     shipWarperCnt  = new List <int>();
                List <int>     shipItemID     = new List <int>();
                List <int>     shipItemCount  = new List <int>();
                List <int>     shipPlanetA    = new List <int>();
                List <int>     shipPlanetB    = new List <int>();
                List <int>     shipOtherGId   = new List <int>();
                List <float>   shipT          = new List <float>();
                List <int>     shipIndex      = new List <int>();
                List <Double3> shipPos        = new List <Double3>();
                List <Float4>  shipRot        = new List <Float4>();
                List <Float3>  shipVel        = new List <Float3>();
                List <float>   shipSpeed      = new List <float>();
                List <Float3>  shipAngularVel = new List <Float3>();
                List <Double3> shipPPosTemp   = new List <Double3>();
                List <Float4>  shipPRotTemp   = new List <Float4>();

                foreach (StationComponent stationComponent in GameMain.data.galacticTransport.stationPool)
                {
                    if (stationComponent != null)
                    {
                        stationGId[iter]          = stationComponent.gid;
                        stationMaxShipCount[iter] = stationComponent.workShipDatas.Length;
                        stationId[iter]           = stationComponent.id;
                        DockPos[iter]             = new Float3(stationComponent.shipDockPos);
                        DockRot[iter]             = new Float4(stationComponent.shipDockRot);
                        planetId[iter]            = stationComponent.planetId;
                        workShipCount[iter]       = stationComponent.workShipCount;
                        idleShipCount[iter]       = stationComponent.idleShipCount;
                        workShipIndices[iter]     = stationComponent.workShipIndices;
                        idleShipIndices[iter]     = stationComponent.idleShipIndices;

                        // ShipData is never null
                        for (int j = 0; j < stationComponent.workShipDatas.Length; j++)
                        {
                            ShipData shipData = stationComponent.workShipDatas[j];

                            shipStage.Add(shipData.stage);
                            shipDirection.Add(shipData.direction);
                            shipWarpState.Add(shipData.warpState);
                            shipWarperCnt.Add(shipData.warperCnt);
                            shipItemID.Add(shipData.itemId);
                            shipItemCount.Add(shipData.itemCount);
                            shipPlanetA.Add(shipData.planetA);
                            shipPlanetB.Add(shipData.planetB);
                            shipOtherGId.Add(shipData.otherGId);
                            shipT.Add(shipData.t);
                            shipIndex.Add(shipData.shipIndex);
                            shipPos.Add(new Double3(shipData.uPos.x, shipData.uPos.y, shipData.uPos.z));
                            shipRot.Add(new Float4(shipData.uRot));
                            shipVel.Add(new Float3(shipData.uVel));
                            shipSpeed.Add(shipData.uSpeed);
                            shipAngularVel.Add(new Float3(shipData.uAngularVel));
                            shipPPosTemp.Add(new Double3(shipData.pPosTemp.x, shipData.pPosTemp.y, shipData.pPosTemp.z));
                            shipPRotTemp.Add(new Float4(shipData.pRotTemp));
                        }

                        iter++;
                    }
                }

                ILSgStationPoolSync packet2 = new ILSgStationPoolSync(
                    stationGId,
                    stationMaxShipCount,
                    stationId,
                    DockPos,
                    DockRot,
                    planetId,
                    workShipCount,
                    idleShipCount,
                    workShipIndices,
                    idleShipIndices,
                    shipStage.ToArray(),
                    shipDirection.ToArray(),
                    shipWarpState.ToArray(),
                    shipWarperCnt.ToArray(),
                    shipItemID.ToArray(),
                    shipItemCount.ToArray(),
                    shipPlanetA.ToArray(),
                    shipPlanetB.ToArray(),
                    shipOtherGId.ToArray(),
                    shipT.ToArray(),
                    shipIndex.ToArray(),
                    shipPos.ToArray(),
                    shipRot.ToArray(),
                    shipVel.ToArray(),
                    shipSpeed.ToArray(),
                    shipAngularVel.ToArray(),
                    shipPPosTemp.ToArray(),
                    shipPRotTemp.ToArray());
                player.SendPacket(packet2);
            }
        }
Exemple #23
0
 /// <summary>
 /// 绕目标轴旋转
 /// </summary>
 /// <param name="current"></param>
 /// <param name="target"></param>
 /// <param name="maxRadiansDelta"></param>
 /// <param name="maxMagnitudeDelta"></param>
 /// <returns></returns>
 public static Float3 RotateTowards(Float3 current, Float3 target, float maxRadiansDelta, float maxMagnitudeDelta)
 {
     return(Float3.zero);
 }
Exemple #24
0
 public Rotator(Float3 data)
 {
     SetData(out this, data);
 }
Exemple #25
0
 /// <summary>
 /// Spherically interpolates between two vectors 向量球面插值
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <param name="t"></param>
 /// <returns></returns>
 public static Float3 Slerp(Float3 a, Float3 b, float t)
 {
     return(Float3.zero);
 }
 public InputScalingAction(Float3 direction, float length) : base(direction, length)
 {
 }
Exemple #27
0
 /// <summary>
 /// Spherically interpolates between two vectors. 向量球面插值,非限制
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <param name="t"></param>
 /// <returns></returns>
 public static Float3 SlerpUnclamped(Float3 a, Float3 b, float t)
 {
     return(Float3.zero);
 }
 public InputMovementAction(Float3 direction, float length, bool relative = true, bool normalize = true) : base(direction, length)
 {
     Relative  = relative;
     Normalize = normalize;
 }
Exemple #29
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="current"></param>
 /// <param name="target"></param>
 /// <param name="currentVelocity"></param>
 /// <param name="smoothTime"></param>
 /// <param name="maxSpeed"></param>
 /// <param name="deltaTime"></param>
 /// <returns></returns>
 public static Float3 SmoothDamp(Float3 current, Float3 target, ref Float3 currentVelocity, float smoothTime, float maxSpeed, float deltaTime)
 {
     return(Float3.zero);
 }
Exemple #30
0
	internal static Float3 Lerp(Float3 x, Float3 y, Float3 s) => (
Exemple #31
0
 public void API_SetColor(float r, float g, float b)
 {
     logger.Log("Called API_SetColor with arguments " + r + ", " + g + ", " + b);
     color = new Float3(r, g, b);
 }
Exemple #32
0
 /// <summary>
 /// Creates a foreach-loop compatible IEnumerable which yields all position in a 3D sphere.
 /// Centered at <paramref name="center"/> with radius <paramref name="radius"/>. Can use floats to get arbitrarily positioned spheres.
 /// </summary>
 public EnumerableSphere3D(Float3 center, float radius) => enumerator = new Enumerator(center, radius);
Exemple #33
0
 public BasicVertex(Float3 position, Float3 normal, Float2 textureCoordinates)
 {
     this.Position           = position;
     this.Normal             = normal;
     this.TextureCoordinates = textureCoordinates;
 }
        protected override bool HandleMessage(object message, SimpleServerChildTcpSocket socket)
        {
            ChildSocketState socketState = ChildSocketState.Disconnecting;

            Server.ChildSockets.TryGetValue(socket, out socketState);
            KeyValuePair <SimpleServerChildTcpSocket, ChildSocketState> childSocket = new KeyValuePair <SimpleServerChildTcpSocket, ChildSocketState>(socket, socketState);

            PositionRequest positionRequest = message as PositionRequest;

            if (positionRequest != null)
            {
                string consoleString;
                Float3 position = Float3.Zero;

                if (positionRequest.Type != PositionType.Bundled)
                {
                    consoleString = String.Format("{0} requests {1} position of controller {2} from camera {3}.",
                                                  socket.RemoteEndPoint,
                                                  Enum.GetName(typeof(PositionType), positionRequest.Type),
                                                  positionRequest.ControllerIndex,
                                                  positionRequest.CameraIndex);
                }
                else
                {
                    consoleString = String.Format("{0} requests {1} position of controller {2}.",
                                                  socket.RemoteEndPoint,
                                                  Enum.GetName(typeof(PositionType), positionRequest.Type),
                                                  positionRequest.ControllerIndex);
                }

                switch (positionRequest.Type)
                {
                case PositionType.Bundled:
                    position = GetBundledPosition(positionRequest.ControllerIndex);
                    break;

                case PositionType.Camera:
                    break;

                case PositionType.Fusion:
                    position = GetFusionPosition(positionRequest.CameraIndex, positionRequest.ControllerIndex);
                    break;

                case PositionType.Raw:
                    break;

                case PositionType.World:
                    position = GetWorldPosition(positionRequest.CameraIndex, positionRequest.ControllerIndex);
                    break;
                }

                ConsoleService.Write(consoleString);

                SendPositionMessage(childSocket, new PositionMessage()
                {
                    Position        = position,
                    Type            = positionRequest.Type,
                    StartTick       = positionRequest.StartTick,
                    CameraIndex     = positionRequest.CameraIndex,
                    ControllerIndex = positionRequest.CameraIndex
                });
                return(true);
            }

            return(base.HandleMessage(message, socket));
        }
Exemple #35
0
 public static Vector3 ToUnity(this Float3 vector) => new Vector3(vector.x, vector.y, vector.z);
Exemple #36
0
 public TangentVertex(Float3 position, Float2 textureCoordinates, Float3 uTangent, Float3 vTangent)
 {
     this.Position           = position;
     this.TextureCoordinates = textureCoordinates;
     this.UTangent           = uTangent;
     this.VTangent           = vTangent;
 }
Exemple #37
0
Float3 Interpolation_C2( Float3 x ) { return x * x * x * (x * (x * 6.0f - 15.0f) + 10.0f); }