public static void Main(string[] _) { //new Input().Initialize(Input.ReadConsole).OnKey += (c) => { System.Console.WriteLine(c); }; //camera.AddComponent(new Camera(60)); camera = new Camera(60, new ConsoleRenderer(), new Dimensions2(30, 20)).DefaultObject(); Scene scene = new Scene(camera.GetComponent <Camera>()); camera.GetComponent <Camera>().renderer.renderMode = RenderMode.Shaded; EngineLoop e = new EngineLoop(scene, 10); e.RenderEvent += OnUpdate; // Add the OnUpdate event for every time the camera renders cube1.AddComponent(new Mesh(BaseGeometry.CubeGeometry())); // Add a cube geometry to cube1 cube1.GetComponent <Mesh>().color = new Color(1, 0, 1); // Set the color of cube1's mesh cube1.worldPosition += new Point3(0, 0, 3); // Change the worldPosition of cube1 scene.objects.Add(cube1); // Add cube1 to the scene camera.worldPosition = new Point3(0, -2, 0); camera.worldRotation = Quaternion.Euler(-30, 0, 0, Quaternion.AngleUnit.Degrees); //scene.light.color = Color.FromArgb(0, 255, 0); //cubeChild.parent = cube1; // Set the parent of cubeChild to be cube1 cubeChild.localScale = new Direction3(0.5, 0.5, 1); cubeChild.AddComponent(new Mesh(BaseGeometry.CubeGeometry())); cubeChild.localPosition = new Point3(0, 0, 3); cubeChild.localRotation = Quaternion.Euler(145, 0, 0, Quaternion.AngleUnit.Degrees); cubeChild.GetComponent <Mesh>().color = new Color(0, 1, 1); SceneObject occ = new SceneObject(); //occ.parent = cubeChild; occ.AddComponent(new Mesh(BaseGeometry.CubeGeometry())); occ.localPosition = new Point3(0, 0, 3); occ.GetComponent <Mesh>().color = new Color(0, 1, 0); occ.worldScale = new Direction3(1, 1, 1); //Tweener.TweenTo(ref cube1._localworldPosition,new Point3(0,0,0),5000); //scene.objects.Add(occ); //c.parent = o;*/ //c.localworldPosition = new Point3(0, 0, 5); while (true) { } }
/// <summary> /// Register all native functions with managed code /// </summary> /// <param name="registerFunctionsAddr">The address of the RegisterFunctions method defined in native code</param> public static void RegisterFunctions(IntPtr registerFunctionsAddr) { if (!EntryPoint.Preloaded) { string namespaceName = typeof(NativeFunctions).Namespace; foreach (Type type in Assembly.GetExecutingAssembly().GetTypes()) { if (type.IsClass && type.IsAbstract && type.IsSealed && type.Name.StartsWith("Native_") && type.Namespace == namespaceName) { // Native_FName -> Export_FName_XXXXX string nativeFunctionPrefix = "Export" + type.Name.Replace("Native", string.Empty) + "_"; foreach (FieldInfo field in type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)) { if (field.IsStatic && field.FieldType.IsSubclassOf(typeof(Delegate))) { functions.Add(nativeFunctionPrefix + field.Name, field); } } } } // Call the native RegisterFunctions method with our managed RegisterFunction as the callback Del_RegisterFunctions registerFunctions = (Del_RegisterFunctions)Marshal.GetDelegateForFunctionPointer( registerFunctionsAddr, typeof(Del_RegisterFunctions)); registerFunctions(Marshal.GetFunctionPointerForDelegate(registerFunction)); // Highest (these may be called from a thread other than the game thread, don't access UObject methods) FBuild.OnNativeFunctionsRegistered(); FGlobals.OnNativeFunctionsRegistered(); Classes.OnNativeFunctionsRegistered(); BoolMarshaler.OnNativeFunctionsRegistered(); FStringMarshaler.OnNativeFunctionsRegistered(); InputCore.FKey.OnNativeFunctionsRegistered(); FFrame.OnNativeFunctionsRegistered(); // Validate native struct sizes match the managed struct sizes before running any handlers // NOTE: This MUST come after FStringMarshaler.OnNativeFunctionsRegistered as this requires TCHAR size StructValidator.ValidateStructs(); } if (!EntryPoint.Preloading) { Debug.Assert(FThreading.IsInGameThread(), "Load/hotreload should be on the game thread"); // Highest = Used for initializing very important data required by other functions. // VeryHigh = Used for initializing data before UObject classes are loaded. // High = This is when UObject classes are loaded. Don't access UObjects at this or any higher priority. // Medium = UObject classes are loaded and available to use at this priority. // If GEngine is null we need to bind OnPostEngineInit to load anything which requires GEngine if (FGlobals.GEngine == IntPtr.Zero) { FCoreDelegates.OnPostEngineInit.Bind(OnPostEngineInit); } // Highest GCHelper.OnNativeFunctionsRegistered(); FMessage.OnNativeFunctionsRegistered(); Engine.FTimerManagerCache.OnNativeFunctionsRegistered(); WorldTimeHelper.OnNativeFunctionsRegistered(); if (FGlobals.GEngine != IntPtr.Zero) { // Needs GEngine for binding delegates StaticVarManager.OnNativeFunctionsRegistered(); Coroutine.OnNativeFunctionsRegistered(); } // VeryHigh NativeReflection.OnNativeFunctionsRegistered();// Requires Classes to be initialized // High OnNativeFunctionsRegistered(); // Low EngineLoop.OnNativeFunctionsRegistered(); // Lowest CodeGenerator.OnNativeFunctionsRegistered(); #if WITH_USHARP_TESTS Tests.Tests.OnNativeFunctionsRegistered(); #endif } }
private void PerformMovementInput() { float desiredXVelocity = MovementInput.X * MaxSpeed; float desiredYVelocity = MovementInput.Y * MaxSpeed; var xSign = Math.Sign(desiredXVelocity - XVelocity); XVelocity += xSign * MaxSpeed * TimeManager.SecondDifference / AccelerationTime; if (xSign != Math.Sign(desiredXVelocity - XVelocity)) { XVelocity = desiredXVelocity; } var ySign = Math.Sign(desiredYVelocity - YVelocity); YVelocity += ySign * MaxSpeed * TimeManager.SecondDifference / AccelerationTime; if (ySign != Math.Sign(desiredYVelocity - YVelocity)) { YVelocity = desiredYVelocity; } float currentVelocityLength = Velocity.Length(); if (currentVelocityLength > MaxSpeed) { Velocity.Normalize(); Velocity = Velocity * MaxSpeed; currentVelocityLength = MaxSpeed; } if (desiredYVelocity != 0 || desiredXVelocity != 0) { BubblesInstance.ThrustVector = new Microsoft.Xna.Framework.Vector3(desiredXVelocity, desiredYVelocity, 0); } else if (BubblesInstance.ThrustVector.Length() != 0) { BubblesInstance.ThrustVector = Microsoft.Xna.Framework.Vector3.Zero; } if (desiredXVelocity != 0 || desiredYVelocity != 0) { if (EngineLoop.State != SoundState.Playing) { EngineLoop.Play(); } if (EngineVolume == 0) { this.Tween(nameof(EngineVolume), MaxEngineSfxVolume, EngineFadeTime, InterpolationType.Linear, Easing.In); } } else { if (engineVolume > 0 && TweenerManager.Self.IsObjectReferencedByTweeners(this) == false) { this.Tween(nameof(EngineVolume), 0, EngineFadeTime, InterpolationType.Linear, Easing.In); } } if ((desiredXVelocity == 0 && desiredYVelocity == 0) && Velocity.LengthSquared() > 0) { if (SubLoop.State != SoundState.Playing) { SubLoop.Play(); } SubLoop.Volume = MaxEngineSfxVolume * currentVelocityLength / MaxSpeed; } else { // Calling stop or pause here seems to make the sound "pop" //SubLoop.Stop(); } }