private void ComponentsAttachmentTest() { Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "..."); Actor actor = new Actor(); StaticMeshComponent staticMeshComponent = new StaticMeshComponent(actor, setAsRoot: true); InstancedStaticMeshComponent instancedStaticMeshComponent = new InstancedStaticMeshComponent(actor); SceneComponent sceneComponent = new SceneComponent(actor); sceneComponent.AttachToComponent(instancedStaticMeshComponent, AttachmentTransformRule.KeepRelativeTransform); if (!sceneComponent.IsAttachedToComponent(instancedStaticMeshComponent)) { Debug.Log(LogLevel.Error, "Component attachment check failed!"); return; } if (!sceneComponent.IsAttachedToActor(actor)) { Debug.Log(LogLevel.Error, "Component attachment to actor check failed!"); return; } Debug.Log(LogLevel.Display, "Test passed successfully"); }
public static void OnBeginPlay() { Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, MethodBase.GetCurrentMethod().DeclaringType + " system started!"); World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera")); const int maxActors = 100; Actor[] actors = new Actor[maxActors]; StaticMeshComponent[] staticMeshComponents = new StaticMeshComponent[maxActors]; for (int i = 0; i < maxActors; i++) { actors[i] = new Actor(); staticMeshComponents[i] = new StaticMeshComponent(actors[i], setAsRoot: true); staticMeshComponents[i].SetStaticMesh(StaticMesh.Cube); staticMeshComponents[i].SetMaterial(0, Material.Load("/Game/Tests/BasicMaterial")); staticMeshComponents[i].CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", LinearColor.Red); staticMeshComponents[i].SetRelativeLocation(new Vector3(10000.0f, 0.0f, 0.0f)); staticMeshComponents[i].UpdateToWorld(TeleportType.ResetPhysics); staticMeshComponents[i].SetSimulatePhysics(true); staticMeshComponents[i].SetCollisionChannel(CollisionChannel.PhysicsBody); } RadialForceComponent radialForceComponent = new RadialForceComponent(new Actor(), setAsRoot: true); radialForceComponent.IgnoreOwningActor = true; radialForceComponent.ImpulseVelocityChange = true; radialForceComponent.LinearFalloff = true; radialForceComponent.ForceStrength = 10000000.0f; radialForceComponent.Radius = 1000; radialForceComponent.SetRelativeLocation(new Vector3(10000.0f, 0.0f, -100.0f)); Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, "Actors are spawned! Number of actors in the world: " + World.ActorCount); }
public static void OnBeginPlay() { Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, MethodBase.GetCurrentMethod().DeclaringType + " system started!"); World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera")); const int halfActors = maxActors / 2; for (int i = 0; i < maxActors; i++) { actors[i] = new Actor(); staticMeshComponents[i] = new StaticMeshComponent(actors[i], setAsRoot: true); staticMeshComponents[i].SetStaticMesh(StaticMesh.Cube); staticMeshComponents[i].SetMaterial(0, material); staticMeshComponents[i].CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", LinearColor.Yellow); if (i < halfActors) { staticMeshComponents[i].SetRelativeLocation(new Vector3(0.0f, -400.0f, 250.0f * i)); } else { staticMeshComponents[i].SetRelativeLocation(new Vector3(0.0f, 400.0f, 250.0f * (i - halfActors))); } staticMeshComponents[i].UpdateToWorld(TeleportType.ResetPhysics); staticMeshComponents[i].SetSimulatePhysics(true); } Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, "Actors are spawned! Number of actors in the world: " + World.ActorCount); }
protected override void SetupScene() { // it's not required, but we should have a least one light. SceneContext.AddActor(new Actor(new PointLightComponent() { Name = "StaticLight", RelativeTranslation = new Vector3(2f, -2.5f, 3.25f), })); #region construct var sphere = Mesh.CreateSphere(); var cylinder1 = Mesh.CreateCylinder(slices: 16); cylinder1.Scale(0.3f, 0.3f); cylinder1.Translate(new Vector3(0, 0, 0.05f)); sphere.AddMesh(cylinder1, filterMaterialId: 0, newMaterialId: 1); var cylinder2 = Mesh.CreateCylinder(); cylinder2.Scale(0.05f, 0.05f); cylinder2.Translate(new Vector3(0, 0, 0.3f)); sphere.AddMesh(cylinder2, filterMaterialId: 0, newMaterialId: 2); #endregion var comp = new StaticMeshComponent(sphere) { Name = "Bomb", RelativeTranslation = new Vector3(0, 0, 0.55f), RelativeScale = new Vector3(2), RelativeRotation = new Vector3(0.15f, 0.15f, 0f).ToQuaternion(), }; #region materials comp.AddMaterial(new Material { Color = new Vector4(0.2f, 0.2f, 0.2f, 1), Ambient = 0.5f, Shininess = 64.0f, SpecularStrength = 1f, }); comp.AddMaterial(new Material { Color = new Vector4(0.1f, 0.1f, 0.1f, 1), Ambient = 0.5f, Shininess = 32.0f, SpecularStrength = 0.5f, }); comp.AddMaterial(new Material { Color = new Vector4(0.5f, 1 / 255f * 165 * 0.5f, 0, 1), Ambient = 0.5f, Shininess = 32.0f, SpecularStrength = 0.5f, }); #endregion SceneContext.AddActor(new Actor(comp)); }
public DynamicEvents() { leftActor = new Actor("LeftActor"); rightActor = new Actor("RightActor"); leftStaticMeshComponent = new StaticMeshComponent(leftActor, "LeftActorComponent", true); rightStaticMeshComponent = new StaticMeshComponent(rightActor, "RightActorComponent", true); material = Material.Load("/Game/Tests/BasicMaterial"); stopTranslation = false; }
internal static unsafe void Invoke(StaticMeshComponent StaticMeshComponent) { long *p = stackalloc long[] { 0L, 0L }; byte *b = (byte *)p; *((IntPtr *)(b + 0)) = StaticMeshComponent; Main.GetProcessEvent(MeshVertexPainterKismetLibrary.DefaultObject, RemovePaintedVertices_ptr, new IntPtr(p));; } }
internal static unsafe void Invoke(StaticMeshComponent StaticMeshComponent, LinearColor FillColor, bool bConvertToSRGB) { long *p = stackalloc long[] { 0L, 0L, 0L, 0L, 0L }; byte *b = (byte *)p; *((IntPtr *)(b + 0)) = StaticMeshComponent; *((LinearColor *)(b + 8)) = FillColor; *((bool *)(b + 24)) = bConvertToSRGB; Main.GetProcessEvent(MeshVertexPainterKismetLibrary.DefaultObject, PaintVerticesSingleColor_ptr, new IntPtr(p));; } }
internal static unsafe void Invoke(StaticMeshComponent StaticMeshComponent, int LODIndex, ProceduralMeshComponent ProcMeshComponent, bool bCreateCollision) { long *p = stackalloc long[] { 0L, 0L, 0L, 0L, 0L }; byte *b = (byte *)p; *((IntPtr *)(b + 0)) = StaticMeshComponent; *((int *)(b + 8)) = LODIndex; *((IntPtr *)(b + 16)) = ProcMeshComponent; *((bool *)(b + 24)) = bCreateCollision; Main.GetProcessEvent(KismetProceduralMeshLibrary.DefaultObject, CopyProceduralMeshFromStaticMeshComponent_ptr, new IntPtr(p));; } }
public DynamicEvents() { playerController = World.GetFirstPlayerController(); triggerBox = new(); triggerCollisionComponent = triggerBox.GetComponent <BoxComponent>(); leftActor = new("LeftActor"); rightActor = new("RightActor"); leftStaticMeshComponent = new(leftActor, "LeftActorComponent", true); rightStaticMeshComponent = new(rightActor, "RightActorComponent", true); material = Material.Load("/Game/Tests/BasicMaterial"); stopTranslation = false; }
internal static unsafe void Invoke(StaticMeshComponent StaticMeshComponent, LinearColor StartColor, LinearColor EndColor, EVertexPaintAxis Axis, bool bConvertToSRGB) { long *p = stackalloc long[] { 0L, 0L, 0L, 0L, 0L, 0L, 0L }; byte *b = (byte *)p; *((IntPtr *)(b + 0)) = StaticMeshComponent; *((LinearColor *)(b + 8)) = StartColor; *((LinearColor *)(b + 24)) = EndColor; *(b + 40) = (byte)Axis; *((bool *)(b + 41)) = bConvertToSRGB; Main.GetProcessEvent(MeshVertexPainterKismetLibrary.DefaultObject, PaintVerticesLerpAlongAxis_ptr, new IntPtr(p));; } }
private static void Translate(StaticMeshComponent staticMeshComponent, float direction) { if (!stopTranslation) { Vector3 currentLocation = default; staticMeshComponent.GetLocation(ref currentLocation); currentLocation.Y += direction * World.DeltaTime; staticMeshComponent.SetWorldLocation(currentLocation); } }
private StaticMeshComponent CreateBompComponent() { var tmp = Mesh.CreateSphere(); var m2 = Mesh.CreateCylinder(); m2.Scale(0.3f, 0.3f); m2.Translate(new Vector3(0, 0, 0.05f)); tmp.AddMesh(m2, 1); var m3 = Mesh.CreateCylinder(); m2.Scale(0.15f, 0.15f); m2.Translate(new Vector3(0, 0, 0.3f)); tmp.AddMesh(m2, 2); var comp = new StaticMeshComponent(tmp); comp.AddMaterial(new Material() { Color = new Vector4(0.2f, 0.2f, 0.2f, 1), Ambient = 0.5f, Shininess = 64.0f, SpecularStrength = 1f, CastShadow = true, }); comp.AddMaterial(new Material() { Color = new Vector4(0.1f, 0.1f, 0.1f, 1), Ambient = 0.5f, Shininess = 32.0f, SpecularStrength = 0.5f, CastShadow = true, }); comp.AddMaterial(new Material() { Color = new Vector4(0.5f, 1 / 255f * 165 * 0.5f, 0, 1), Ambient = 0.5f, Shininess = 32.0f, SpecularStrength = 0.5f, CastShadow = true, }); return(comp); }
public void OnBeginPlay() { World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera")); Actor actor = new Actor(); StaticMeshComponent staticMeshComponent = new StaticMeshComponent(actor, setAsRoot: true); Texture2D texture = Texture2D.Load("/Game/Tests/BasicTexture"); staticMeshComponent.SetStaticMesh(StaticMesh.Plane); staticMeshComponent.SetMaterial(0, Material.Load("/Game/Tests/TextureMaterial")); staticMeshComponent.CreateAndSetMaterialInstanceDynamic(0).SetTextureParameterValue("Texture", texture); staticMeshComponent.SetWorldLocation(new Vector3(-800.0f, 0.0f, 0.0f)); staticMeshComponent.SetWorldRotation(Maths.Euler(90.0f, 0.0f, 90.0f)); Debug.AddOnScreenMessage(-1, 5.0f, Color.PowderBlue, "Texture size: " + texture.GetSize()); Debug.AddOnScreenMessage(-1, 5.0f, Color.PowderBlue, "Pixel format: " + texture.GetPixelFormat()); }
public void OnBeginPlay() { World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera")); for (int i = 0; i < maxActors; i++) { actors[i] = new Actor(); staticMeshComponents[i] = new StaticMeshComponent(actors[i], setAsRoot: true); staticMeshComponents[i].AddLocalOffset(new Vector3(15.0f * i, 20.0f * i, 25.0f * i)); staticMeshComponents[i].SetStaticMesh(StaticMesh.Cube); staticMeshComponents[i].SetMaterial(0, material); staticMeshComponents[i].CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", new LinearColor((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble())); staticMeshComponents[i].SetRelativeLocation(new Vector3(150.0f * i, 50.0f * i, 100.0f * i)); staticMeshComponents[i].SetRelativeRotation(Maths.CreateFromYawPitchRoll(5.0f * i, 0.0f, 0.0f)); } Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, "Actors are spawned! Number of actors in the world: " + World.ActorCount); }
protected override void BeginPlay() { base.BeginPlay(); m_Root = Actor.GetComponentByTag <StaticMeshComponent>("root"); m_Child = Actor.GetComponentByTag <StaticMeshComponent>("child"); if (m_Root == null) { Log.Print("root is null"); return; } if (m_Child == null) { Log.Print("child is null"); return; } m_Child.AttachTo(m_Root); //m_Child.AttachToSocket(m_Root, "Socket"); }
public PlanetObject(Planet parentPlanet, StaticMesh mesh, string objectName = null, bool isActiveAtStart = true) : base(parentPlanet, objectName, isActiveAtStart) { if (parentPlanet == null) { throw new ArgumentNullException(nameof(parentPlanet)); } planetMesh = new StaticMeshComponent(this) { Mesh = mesh, DefaultShader = new PhongShader("Models/Earth/Textures/Diffuse_2K_transparent.png") { AmbientReflection = .23125f, DiffuseReflection = 0.2775f, SpecularReflection = .773911f, Shininess = 89.6f, }, }; }
public static void OnBeginPlay() { Debug.Log(LogLevel.Display, "Hello, Unreal Engine!"); Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, MethodBase.GetCurrentMethod().DeclaringType + " system started!"); World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera")); for (int i = 0; i < maxActors; i++) { actors[i] = new Actor(); staticMeshComponents[i] = new StaticMeshComponent(actors[i], setAsRoot: true); staticMeshComponents[i].AddLocalOffset(new Vector3(15.0f * i, 20.0f * i, 25.0f * i)); staticMeshComponents[i].SetStaticMesh(StaticMesh.Cube); staticMeshComponents[i].SetMaterial(0, material); staticMeshComponents[i].CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", new LinearColor((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble())); staticMeshComponents[i].SetRelativeLocation(new Vector3(50.0f * i, 100.0f * i, 150.0f * i)); staticMeshComponents[i].SetRelativeRotation(Quaternion.CreateFromYawPitchRoll(5.0f * i, 0.0f, 0.0f)); } Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, "Actors are spawned! Number of actors in the world: " + World.ActorCount); }
private void ComponentsMatchingTest() { Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "..."); Actor actor = new Actor(); StaticMeshComponent staticMeshComponent = new StaticMeshComponent(actor, setAsRoot: true); SceneComponent sceneComponent = actor.GetRootComponent <SceneComponent>(); InstancedStaticMeshComponent instancedStaticMeshComponent = actor.GetRootComponent <InstancedStaticMeshComponent>(); if (sceneComponent == null) { Debug.Log(LogLevel.Error, "Component obtainment with inherited type matching to the root component failed!"); return; } if (instancedStaticMeshComponent != null) { Debug.Log(LogLevel.Error, "Component obtainment with type matching to the root component failed!"); return; } if (actor.GetComponent <StaticMeshComponent>() == null) { Debug.Log(LogLevel.Error, "Component type matching failed!"); return; } if (actor.GetRootComponent <StaticMeshComponent>() == null) { Debug.Log(LogLevel.Error, "Component type matching to the root component failed!"); return; } Debug.Log(LogLevel.Display, "Test passed successfully"); }
public static void OnBeginPlay() { Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, MethodBase.GetCurrentMethod().DeclaringType + " system started!"); World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera")); Actor actor = new Actor(); StaticMeshComponent staticMeshComponent = new StaticMeshComponent(actor, setAsRoot: true); Texture2D texture = Texture2D.Load("/Game/Tests/BasicTexture"); staticMeshComponent.SetStaticMesh(StaticMesh.Plane); staticMeshComponent.SetMaterial(0, Material.Load("/Game/Tests/TextureMaterial")); staticMeshComponent.CreateAndSetMaterialInstanceDynamic(0).SetTextureParameterValue("Texture", texture); staticMeshComponent.SetWorldLocation(new Vector3(-800.0f, 0.0f, 0.0f)); staticMeshComponent.SetWorldRotation(Maths.Euler(90.0f, 0.0f, 90.0f)); Vector2 textureSize = default(Vector2); texture.GetSize(ref textureSize); Debug.AddOnScreenMessage(-1, 5.0f, Color.PowderBlue, "Texture size: " + textureSize); }
private StaticMeshComponent CreateMesh() { var mesh = Mesh.CreateCube().ToPrimitive(MeshFaceType.Triangle); mesh.CreateFacesAndIndicies(); mesh.Scale(10); var ind = mesh.GetIndiciesArray(); var vert = mesh.GetComponent <MeshPosition3Component>().ToArray().Select(s => new Vector3d(s.X, s.Y, s.Z)).ToArray(); var box = new Net3dBool.Solid(vert, ind); mesh = Mesh.CreateCube().ToPrimitive(MeshFaceType.Triangle); mesh.CreateFacesAndIndicies(); mesh.Scale(3); ind = mesh.GetIndiciesArray(); vert = mesh.GetComponent <MeshPosition3Component>().ToArray().Select(s => new Vector3d(s.X, s.Y, s.Z)).ToArray(); var box2 = new Net3dBool.Solid(vert, ind); mesh = Mesh.CreateCube().ToPrimitive(MeshFaceType.Triangle); mesh.CreateFacesAndIndicies(); mesh.Scale(2); mesh.Translate(1, 0, 0); ind = mesh.GetIndiciesArray(); vert = mesh.GetComponent <MeshPosition3Component>().ToArray().Select(s => new Vector3d(s.X, s.Y, s.Z)).ToArray(); var box3 = new Net3dBool.Solid(vert, ind); var modeller = new Net3dBool.BooleanModeller(box, box2); var tmp = modeller.GetDifference(); modeller = new Net3dBool.BooleanModeller(tmp, box3); tmp = modeller.GetDifference(); VertexDataPosNormalColor[] data = tmp.GetVertices().Select(v => new VertexDataPosNormalColor(new Vector3((float)v.X, (float)v.Y, (float)v.Z), new Vector3(1, 0, 0), new Vector4(1, 1, 0, 1))).ToArray(); for (var i = 0; i < data.Length; i++) { var face = i / 3; var vertex = i % 3; // switch (vertex) // { // case 0: // data[i].Color = new Vector4(1, 0, 0, 1); // break; // case 1: // data[i].Color = new Vector4(0, 1, 0, 1); // break; // case 2: // data[i].Color = new Vector4(0, 0, 1, 1); // break; // } data[i].Normal = Vector3.UnitX; } var meshData = Mesh.CreateFromVertices(data, tmp.GetIndices().ToArray()); meshData.Expand(); meshData.RecalculateNormals(25f); var material = new Material { Ambient = 0.5f, Color = new Vector4(1, 1, 1, 1), UseVertexColor = true, PipelineType = PipelineType.Forward, }; var comp = new StaticMeshComponent() { Name = "BoolMesh", RelativeRotation = new Vector3(0, 0, 0.5f).ToQuaternion(), RelativeScale = new Vector3(1), RelativeTranslation = new Vector3(2, 0, 0.5f), Material = material, }; comp.SetMesh(meshData); return(comp); }
private void TestSpline() { cube = Actor.GetComponent <StaticMeshComponent>(); spline = Actor.GetComponent <SplineComponent>(); }
public void Bomb() { SceneContext.AddActor(new Actor(new DirectionalLightComponent() { Name = "StaticLight", RelativeTranslation = new Vector3(-0.2f, -2.1f, 1.85f), Direction = GetTestFrontLightDirection(), })); var tmp = Mesh.CreateSphere(); var m2 = Mesh.CreateCylinder(); m2.Scale(0.3f, 0.3f); m2.Translate(new Vector3(0, 0, 0.05f)); tmp.AddMesh(m2, 1); var m3 = Mesh.CreateCylinder(); m2.Scale(0.15f, 0.15f); m2.Translate(new Vector3(0, 0, 0.3f)); tmp.AddMesh(m2, 2); var comp = new StaticMeshComponent(tmp) { Name = "Bomb1", RelativeTranslation = new Vector3(0, 0, 0.55f), RelativeScale = new Vector3(2), }; comp.AddMaterial(new Material() { Color = new Vector4(0.2f, 0.2f, 0.2f, 1), Ambient = 0.5f, Shininess = 64.0f, SpecularStrength = 1f, CastShadow = true, }); comp.AddMaterial(new Material() { Color = new Vector4(0.1f, 0.1f, 0.1f, 1), Ambient = 0.5f, Shininess = 32.0f, SpecularStrength = 0.5f, CastShadow = true, }); comp.AddMaterial(new Material() { Color = new Vector4(0.5f, 1 / 255f * 165 * 0.5f, 0, 1), Ambient = 0.5f, Shininess = 32.0f, SpecularStrength = 0.5f, CastShadow = true, }); SceneContext.AddActor(new Actor(comp)); RenderAndCompare(nameof(Bomb)); }
public void Dispose() { RenderObject.Dispose(); RenderObject = null; }
public static string GenerateUDKFileForLevel(string udkPath, IMEPackage pcc) { #region AssetPackage string meshPackageName = $"{Path.GetFileNameWithoutExtension(pcc.FilePath)}Meshes"; string meshFile = Path.Combine(udkPath, @"UDKGame\Content\Shared\", $"{meshPackageName}.upk"); MEPackageHandler.CreateAndSavePackage(meshFile, MEGame.UDK); using IMEPackage meshPackage = MEPackageHandler.OpenUDKPackage(meshFile); meshPackage.getEntryOrAddImport("Core.Package"); IEntry defMat = meshPackage.getEntryOrAddImport("EngineMaterials.DefaultMaterial", "Material", "Engine"); var allMats = new HashSet <int>(); var relinkMap = new Dictionary <IEntry, IEntry>(); #region StaticMeshes List <ExportEntry> staticMeshes = pcc.Exports.Where(exp => exp.ClassName == "StaticMesh").ToList(); foreach (ExportEntry mesh in staticMeshes) { var mats = new Queue <int>(); StaticMesh stm = ObjectBinary.From <StaticMesh>(mesh); foreach (StaticMeshRenderData lodModel in stm.LODModels) { foreach (StaticMeshElement meshElement in lodModel.Elements) { mats.Enqueue(meshElement.Material); allMats.Add(meshElement.Material); meshElement.Material = 0; } } if (pcc.GetEntry(stm.BodySetup) is ExportEntry rbBodySetup) { rbBodySetup.RemoveProperty("PhysMaterial"); } mesh.WriteBinary(stm); IEntry newParent = EntryImporter.GetOrAddCrossImportOrPackage(mesh.ParentFullPath, pcc, meshPackage); EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.CloneTreeAsChild, mesh, meshPackage, newParent, false, out IEntry ent, relinkMap); ExportEntry portedMesh = (ExportEntry)ent; stm = ObjectBinary.From <StaticMesh>(portedMesh); foreach (StaticMeshRenderData lodModel in stm.LODModels) { foreach (StaticMeshElement meshElement in lodModel.Elements) { meshElement.Material = mats.Dequeue(); } } portedMesh.WriteBinary(stm); } #endregion #region Materials using (IMEPackage udkResources = MEPackageHandler.OpenMEPackageFromStream(Utilities.GetCustomAppResourceStream(MEGame.UDK))) { ExportEntry normDiffMat = udkResources.Exports.First(exp => exp.ObjectName == "NormDiffMat"); foreach (int matUIndex in allMats) { if (pcc.GetEntry(matUIndex) is ExportEntry matExp) { List <IEntry> textures = new MaterialInstanceConstant(matExp).Textures; ExportEntry diff = null; ExportEntry norm = null; foreach (IEntry texEntry in textures) { if (texEntry is ExportEntry texport) { if (texport.ObjectName.Name.ToLower().Contains("diff")) { diff = texport; } else if (texport.ObjectName.Name.ToLower().Contains("norm")) { norm = texport; } } } if (diff == null) { relinkMap[matExp] = defMat; continue; } else { EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.AddSingularAsChild, diff, meshPackage, null, false, out IEntry ent); diff = (ExportEntry)ent; diff.RemoveProperty("TextureFileCacheName"); diff.RemoveProperty("TFCFileGuid"); diff.RemoveProperty("LODGroup"); } if (norm != null) { EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.AddSingularAsChild, norm, meshPackage, null, false, out IEntry ent); norm = (ExportEntry)ent; norm.RemoveProperty("TextureFileCacheName"); norm.RemoveProperty("TFCFileGuid"); norm.RemoveProperty("LODGroup"); } EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.CloneTreeAsChild, normDiffMat, meshPackage, null, true, out IEntry matEnt); ExportEntry newMat = (ExportEntry)matEnt; newMat.ObjectName = matExp.ObjectName; Material matBin = ObjectBinary.From <Material>(newMat); matBin.SM3MaterialResource.UniformExpressionTextures = new UIndex[] { norm?.UIndex ?? 0, diff.UIndex }; newMat.WriteBinary(matBin); relinkMap[matExp] = newMat; if (newMat.GetProperty <ArrayProperty <ObjectProperty> >("Expressions") is {} expressionsProp&& expressionsProp.Count >= 2) { ExportEntry diffExpression = meshPackage.GetUExport(expressionsProp[0].Value); ExportEntry normExpression = meshPackage.GetUExport(expressionsProp[1].Value); diffExpression.WriteProperty(new ObjectProperty(diff.UIndex, "Texture")); normExpression.WriteProperty(new ObjectProperty(norm?.UIndex ?? 0, "Texture")); } } else if (pcc.GetEntry(matUIndex) is ImportEntry matImp) { relinkMap[matImp] = defMat; } } var relinkMapping = new OrderedMultiValueDictionary <IEntry, IEntry>(relinkMap); foreach (ExportEntry stmExport in staticMeshes) { if (relinkMap.TryGetValue(stmExport, out IEntry destEnt) && destEnt is ExportEntry destExp) { Relinker.Relink(stmExport, destExp, relinkMapping); } } } #endregion meshPackage.Save(); #endregion var staticMeshActors = new List <ExportEntry>(); var lightActors = new List <ExportEntry>(); string tempPackagePath = Path.Combine(App.ExecFolder, $"{Path.GetFileNameWithoutExtension(pcc.FilePath)}.udk"); File.Copy(Path.Combine(App.ExecFolder, "empty.udk"), tempPackagePath, true); using IMEPackage udkPackage = MEPackageHandler.OpenUDKPackage(tempPackagePath); { var topLevelMeshPackages = new List <IEntry>(); foreach (ExportEntry exportEntry in staticMeshes) { IEntry imp = udkPackage.getEntryOrAddImport($"{exportEntry.FullPath}", "StaticMesh", "Engine", exportEntry.ObjectName.Number); while (imp.Parent != null) { imp = imp.Parent; } if (!topLevelMeshPackages.Contains(imp)) { topLevelMeshPackages.Add(imp); } } ExportEntry levelExport = udkPackage.Exports.First(exp => exp.ClassName == "Level"); List <int> actorsInLevel = ObjectBinary.From <Level>(pcc.Exports.First(exp => exp.ClassName == "Level")).Actors.Select(u => u.value).ToList(); var componentToMatrixMap = new Dictionary <int, Matrix>(); foreach (int uIndex in actorsInLevel) { if (pcc.GetEntry(uIndex) is ExportEntry stcExp) { if (stcExp.ClassName == "StaticMeshCollectionActor") { StaticMeshCollectionActor stmc = ObjectBinary.From <StaticMeshCollectionActor>(stcExp); var components = stcExp.GetProperty <ArrayProperty <ObjectProperty> >("StaticMeshComponents"); for (int i = 0; i < components.Count; i++) { componentToMatrixMap[components[i].Value] = stmc.LocalToWorldTransforms[i]; } } else if (stcExp.ClassName == "StaticLightCollectionActor") { StaticLightCollectionActor stlc = ObjectBinary.From <StaticLightCollectionActor>(stcExp); var components = stcExp.GetProperty <ArrayProperty <ObjectProperty> >("LightComponents"); for (int i = 0; i < components.Count; i++) { componentToMatrixMap[components[i].Value] = stlc.LocalToWorldTransforms[i]; } } } } #region StaticMeshActors { var emptySMCBin = new StaticMeshComponent(); IEntry staticMeshActorClass = udkPackage.getEntryOrAddImport("Engine.StaticMeshActor"); udkPackage.getEntryOrAddImport("Engine.Default__StaticMeshActor", "StaticMeshActor", "Engine"); IEntry staticMeshComponentArchetype = udkPackage.getEntryOrAddImport("Engine.Default__StaticMeshActor.StaticMeshComponent0", "StaticMeshComponent", "Engine"); int smaIndex = 2; int smcIndex = 2; foreach (ExportEntry smc in pcc.Exports.Where(exp => exp.ClassName == "StaticMeshComponent")) { if (smc.Parent is ExportEntry parent && actorsInLevel.Contains(parent.UIndex) && parent.IsA("StaticMeshActorBase")) { StructProperty locationProp; StructProperty rotationProp; StructProperty scaleProp = null; smc.CondenseArchetypes(); if (!(smc.GetProperty <ObjectProperty>("StaticMesh") is { } meshProp) || !pcc.IsUExport(meshProp.Value)) { continue; } smc.WriteBinary(emptySMCBin); smc.RemoveProperty("bBioIsReceivingDecals"); smc.RemoveProperty("bBioForcePrecomputedShadows"); //smc.RemoveProperty("bUsePreComputedShadows"); smc.RemoveProperty("bAcceptsLights"); smc.RemoveProperty("IrrelevantLights"); smc.RemoveProperty("Materials"); //should make use of this? smc.ObjectName = new NameReference("StaticMeshComponent", smcIndex++); if (parent.ClassName == "StaticMeshCollectionActor") { if (!componentToMatrixMap.TryGetValue(smc.UIndex, out Matrix m)) { continue; } (Vector3 posVec, Vector3 scaleVec, Rotator rotator) = m.UnrealDecompose(); locationProp = CommonStructs.Vector3Prop(posVec, "Location"); rotationProp = CommonStructs.RotatorProp(rotator, "Rotation"); scaleProp = CommonStructs.Vector3Prop(scaleVec, "DrawScale3D"); //smc.WriteProperty(CommonStructs.Matrix(m, "CachedParentToWorld")); } else { locationProp = parent.GetProperty <StructProperty>("Location"); rotationProp = parent.GetProperty <StructProperty>("Rotation"); scaleProp = parent.GetProperty <StructProperty>("DrawScale3D"); if (parent.GetProperty <FloatProperty>("DrawScale")?.Value is float scale) { Vector3 scaleVec = Vector3.One; if (scaleProp != null) { scaleVec = CommonStructs.GetVector3(scaleProp); } scaleProp = CommonStructs.Vector3Prop(scaleVec * scale, "DrawScale3D"); } } ExportEntry sma = new ExportEntry(udkPackage, EntryImporter.CreateStack(MEGame.UDK, staticMeshActorClass.UIndex)) { ObjectName = new NameReference("StaticMeshActor", smaIndex++), Class = staticMeshActorClass, Parent = levelExport }; sma.ObjectFlags |= UnrealFlags.EObjectFlags.HasStack; udkPackage.AddExport(sma); EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.AddSingularAsChild, smc, udkPackage, sma, true, out IEntry result); var props = new PropertyCollection { new ObjectProperty(result.UIndex, "StaticMeshComponent"), new NameProperty(new NameReference(Path.GetFileNameWithoutExtension(smc.FileRef.FilePath), smc.UIndex), "Tag"), new ObjectProperty(result.UIndex, "CollisionComponent") }; if (locationProp != null) { props.Add(locationProp); } if (rotationProp != null) { props.Add(rotationProp); } if (scaleProp != null) { props.Add(scaleProp); } sma.WriteProperties(props); staticMeshActors.Add(sma); } } IEntry topMeshPackageImport = udkPackage.getEntryOrAddImport(meshPackageName, "Package"); foreach (IEntry mp in topLevelMeshPackages) { mp.Parent = topMeshPackageImport; } } #endregion #region LightActors { IEntry pointLightClass = udkPackage.getEntryOrAddImport("Engine.PointLight"); IEntry spotLightClass = udkPackage.getEntryOrAddImport("Engine.SpotLight"); IEntry directionalLightClass = udkPackage.getEntryOrAddImport("Engine.DirectionalLight"); int plaIndex = 1; int plcIndex = 1; int slaIndex = 1; int slcIndex = 1; int dlaIndex = 1; int dlcIndex = 1; foreach (ExportEntry lightComponent in pcc.Exports) { if (!(lightComponent.Parent is ExportEntry parent && actorsInLevel.Contains(parent.UIndex))) { continue; } StructProperty locationProp; StructProperty rotationProp; StructProperty scaleProp; switch (lightComponent.ClassName) { case "PointLightComponent": lightComponent.CondenseArchetypes(); lightComponent.ObjectName = new NameReference("PointLightComponent", plcIndex++); if (parent.ClassName == "StaticLightCollectionActor") { if (!componentToMatrixMap.TryGetValue(lightComponent.UIndex, out Matrix m)) { continue; } (Vector3 posVec, Vector3 scaleVec, Rotator rotator) = m.UnrealDecompose(); locationProp = CommonStructs.Vector3Prop(posVec, "Location"); rotationProp = CommonStructs.RotatorProp(rotator, "Rotation"); scaleProp = CommonStructs.Vector3Prop(scaleVec, "DrawScale3D"); } else { locationProp = parent.GetProperty <StructProperty>("Location"); rotationProp = parent.GetProperty <StructProperty>("Rotation"); scaleProp = parent.GetProperty <StructProperty>("DrawScale3D"); if (parent.GetProperty <FloatProperty>("DrawScale")?.Value is float scale) { Vector3 scaleVec = Vector3.One; if (scaleProp != null) { scaleVec = CommonStructs.GetVector3(scaleProp); } scaleProp = CommonStructs.Vector3Prop(scaleVec * scale, "DrawScale3D"); } } ExportEntry pla = new ExportEntry(udkPackage, EntryImporter.CreateStack(MEGame.UDK, pointLightClass.UIndex)) { ObjectName = new NameReference("PointLight", plaIndex++), Class = pointLightClass, Parent = levelExport }; pla.ObjectFlags |= UnrealFlags.EObjectFlags.HasStack; udkPackage.AddExport(pla); EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.AddSingularAsChild, lightComponent, udkPackage, pla, true, out IEntry portedPLC); var plsProps = new PropertyCollection { new ObjectProperty(portedPLC.UIndex, "LightComponent"), new NameProperty("PointLight", "Tag"), }; if (locationProp != null) { plsProps.Add(locationProp); } if (rotationProp != null) { plsProps.Add(rotationProp); } if (scaleProp != null) { plsProps.Add(scaleProp); } pla.WriteProperties(plsProps); lightActors.Add(pla); break; case "SpotLightComponent": lightComponent.CondenseArchetypes(); lightComponent.ObjectName = new NameReference("SpotLightComponent", slcIndex++); if (parent.ClassName == "StaticLightCollectionActor") { if (!componentToMatrixMap.TryGetValue(lightComponent.UIndex, out Matrix m)) { continue; } (Vector3 posVec, Vector3 scaleVec, Rotator rotator) = m.UnrealDecompose(); locationProp = CommonStructs.Vector3Prop(posVec, "Location"); rotationProp = CommonStructs.RotatorProp(rotator, "Rotation"); scaleProp = CommonStructs.Vector3Prop(scaleVec, "DrawScale3D"); } else { locationProp = parent.GetProperty <StructProperty>("Location"); rotationProp = parent.GetProperty <StructProperty>("Rotation"); scaleProp = parent.GetProperty <StructProperty>("DrawScale3D"); if (parent.GetProperty <FloatProperty>("DrawScale")?.Value is float scale) { Vector3 scaleVec = Vector3.One; if (scaleProp != null) { scaleVec = CommonStructs.GetVector3(scaleProp); } scaleProp = CommonStructs.Vector3Prop(scaleVec * scale, "DrawScale3D"); } } ExportEntry sla = new ExportEntry(udkPackage, EntryImporter.CreateStack(MEGame.UDK, spotLightClass.UIndex)) { ObjectName = new NameReference("SpotLight", slaIndex++), Class = spotLightClass, Parent = levelExport }; sla.ObjectFlags |= UnrealFlags.EObjectFlags.HasStack; udkPackage.AddExport(sla); EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.AddSingularAsChild, lightComponent, udkPackage, sla, true, out IEntry portedSLC); var slaProps = new PropertyCollection { new ObjectProperty(portedSLC.UIndex, "LightComponent"), new NameProperty("SpotLight", "Tag"), }; if (locationProp != null) { slaProps.Add(locationProp); } if (rotationProp != null) { slaProps.Add(rotationProp); } if (scaleProp != null) { slaProps.Add(scaleProp); } sla.WriteProperties(slaProps); lightActors.Add(sla); break; case "DirectionalLightComponent": lightComponent.CondenseArchetypes(); lightComponent.ObjectName = new NameReference("DirectionalLightComponent", dlcIndex++); if (parent.ClassName == "StaticLightCollectionActor") { if (!componentToMatrixMap.TryGetValue(lightComponent.UIndex, out Matrix m)) { continue; } (Vector3 posVec, Vector3 scaleVec, Rotator rotator) = m.UnrealDecompose(); locationProp = CommonStructs.Vector3Prop(posVec, "Location"); rotationProp = CommonStructs.RotatorProp(rotator, "Rotation"); scaleProp = CommonStructs.Vector3Prop(scaleVec, "DrawScale3D"); } else { locationProp = parent.GetProperty <StructProperty>("Location"); rotationProp = parent.GetProperty <StructProperty>("Rotation"); scaleProp = parent.GetProperty <StructProperty>("DrawScale3D"); if (parent.GetProperty <FloatProperty>("DrawScale")?.Value is float scale) { Vector3 scaleVec = Vector3.One; if (scaleProp != null) { scaleVec = CommonStructs.GetVector3(scaleProp); } scaleProp = CommonStructs.Vector3Prop(scaleVec * scale, "DrawScale3D"); } } ExportEntry dla = new ExportEntry(udkPackage, EntryImporter.CreateStack(MEGame.UDK, directionalLightClass.UIndex)) { ObjectName = new NameReference("DirectionalLight", dlaIndex++), Class = directionalLightClass, Parent = levelExport }; dla.ObjectFlags |= UnrealFlags.EObjectFlags.HasStack; udkPackage.AddExport(dla); EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.AddSingularAsChild, lightComponent, udkPackage, dla, true, out IEntry portedDLC); var dlaProps = new PropertyCollection { new ObjectProperty(portedDLC.UIndex, "LightComponent"), new NameProperty("DirectionalLight", "Tag"), }; if (locationProp != null) { dlaProps.Add(locationProp); } if (rotationProp != null) { dlaProps.Add(rotationProp); } if (scaleProp != null) { dlaProps.Add(scaleProp); } dla.WriteProperties(dlaProps); lightActors.Add(dla); break; } } } UDKifyLights(udkPackage); #endregion Level level = ObjectBinary.From <Level>(levelExport); level.Actors = levelExport.GetChildren().Where(ent => ent.IsA("Actor")).Select(ent => new UIndex(ent.UIndex)).ToList(); levelExport.WriteBinary(level); udkPackage.Save(); } string resultFilePath = Path.Combine(udkPath, @"UDKGame\Content\Maps\", $"{Path.GetFileNameWithoutExtension(pcc.FilePath)}.udk"); using (IMEPackage udkPackage2 = MEPackageHandler.OpenUDKPackage(Path.Combine(App.ExecFolder, "empty.udk"))) { ExportEntry levelExport = udkPackage2.Exports.First(exp => exp.ClassName == "Level"); Level levelBin = ObjectBinary.From <Level>(levelExport); foreach (ExportEntry actor in staticMeshActors) { EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.CloneTreeAsChild, actor, udkPackage2, levelExport, true, out IEntry result); levelBin.Actors.Add(result.UIndex); } foreach (ExportEntry actor in lightActors) { EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.CloneTreeAsChild, actor, udkPackage2, levelExport, true, out IEntry result); levelBin.Actors.Add(result.UIndex); } levelExport.WriteBinary(levelBin); udkPackage2.Save(resultFilePath); } File.Delete(tempPackagePath); return(resultFilePath); }
public StaticMeshActor() { StaticMeshComponent = new StaticMeshComponent(Vector3.Zero); AttachComponent(StaticMeshComponent); }
public StaticMeshSceneProxy(StaticMeshComponent component) : base(component) { }
///<summary>Copy materials from StaticMeshComponent to ProceduralMeshComponent.</summary> public static void CopyProceduralMeshFromStaticMeshComponent(StaticMeshComponent StaticMeshComponent, int LODIndex, ProceduralMeshComponent ProcMeshComponent, bool bCreateCollision) => KismetProceduralMeshLibrary_methods.CopyProceduralMeshFromStaticMeshComponent_method.Invoke(StaticMeshComponent, LODIndex, ProcMeshComponent, bCreateCollision);
public static void OnBeginPlay() { Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, MethodBase.GetCurrentMethod().DeclaringType + " system started!"); World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera")); const float linesThickness = 3.0f; const string collisionProfile = "TestCollisionProfile"; Actor box = new Actor("Box"); StaticMeshComponent staticMeshComponent = new StaticMeshComponent(box, setAsRoot: true); Vector3 boxLocation = new Vector3(0.0f, 500.0f, 0.0f); Vector3 boxScale = new Vector3(1.0f, 1.0f, 1.0f); staticMeshComponent.SetWorldLocation(boxLocation); staticMeshComponent.SetWorldScale(boxScale); staticMeshComponent.SetStaticMesh(StaticMesh.Cube); staticMeshComponent.SetMaterial(0, Material.Load("/Game/Tests/BasicMaterial")); staticMeshComponent.CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", new LinearColor(0.18f, 0.0f, 0.9f)); staticMeshComponent.SetCollisionChannel(CollisionChannel.WorldStatic); staticMeshComponent.SetCollisionProfileName(collisionProfile); Debug.DrawBox(boxLocation, boxScale * 50.0f, Quaternion.Identity, Color.SlateBlue, true, thickness: linesThickness); Hit hit = default(Hit); Vector3 lineTraceStart = new Vector3(0.0f, 0.0f, 0.0f); bool hitTraceByChannel = World.LineTraceSingleByChannel(lineTraceStart, boxLocation, CollisionChannel.WorldStatic, ref hit); Assert.IsTrue(hitTraceByChannel); Assert.IsTrue(hit.BlockingHit); Assert.IsTrue(box.Equals(hit.GetActor())); if (hitTraceByChannel) { Debug.AddOnScreenMessage(-1, 15.0f, Color.DeepPink, "Box trace hit by channel!"); Debug.DrawPoint(hit.TraceStart, 8.0f, Color.DeepPink, true, depthPriority: 3); Debug.DrawPoint(hit.TraceEnd, 8.0f, Color.DeepPink, true, depthPriority: 3); Debug.DrawLine(hit.TraceStart, hit.TraceEnd, Color.DeepPink, true, depthPriority: 3, thickness: linesThickness); } bool hitTraceByProfile = World.LineTraceSingleByProfile(lineTraceStart, boxLocation, collisionProfile, ref hit); Assert.IsTrue(hitTraceByProfile); Assert.IsTrue(hit.BlockingHit); if (hitTraceByProfile) { Debug.AddOnScreenMessage(-1, 15.0f, Color.DeepPink, "Box trace hit by profile!"); } const float sphereRadius = 50.0f; CollisionShape sphereShape = CollisionShape.CreateSphere(sphereRadius); bool hitSweepByChannel = World.SweepSingleByChannel(lineTraceStart, boxLocation, Quaternion.Identity, CollisionChannel.WorldStatic, sphereShape, ref hit); Assert.IsTrue(hitSweepByChannel); Assert.IsTrue(hit.BlockingHit); if (hitSweepByChannel) { Debug.AddOnScreenMessage(-1, 15.0f, Color.Yellow, "Sphere sweep hit by channel!"); Debug.DrawSphere(hit.Location, sphereRadius, 16, Color.Yellow, true, depthPriority: 2, thickness: linesThickness); } bool hitSweepByProfile = World.SweepSingleByProfile(lineTraceStart, boxLocation, Quaternion.Identity, collisionProfile, sphereShape, ref hit); Assert.IsTrue(hitSweepByProfile); Assert.IsTrue(hit.BlockingHit); if (hitSweepByProfile) { Debug.AddOnScreenMessage(-1, 15.0f, Color.Yellow, "Sphere sweep hit by profile!"); } Vector3 overlapLocation = boxLocation - new Vector3(0.0f, 100.0f, 0.0f); Vector3 boxExtent = boxScale * 60.0f; CollisionShape boxShape = CollisionShape.CreateBox(boxExtent); bool overlapByChannel = World.OverlapAnyTestByChannel(overlapLocation, Quaternion.Identity, CollisionChannel.WorldStatic, boxShape); Assert.IsTrue(hitSweepByProfile); if (overlapByChannel) { Debug.AddOnScreenMessage(-1, 15.0f, Color.MediumTurquoise, "Box overlap by channel!"); Debug.DrawBox(overlapLocation, boxExtent, Quaternion.Identity, Color.MediumTurquoise, true, thickness: linesThickness); } bool overlapByProfile = World.OverlapAnyTestByProfile(overlapLocation, Quaternion.Identity, collisionProfile, boxShape); Assert.IsTrue(hitSweepByProfile); if (overlapByProfile) { Debug.AddOnScreenMessage(-1, 15.0f, Color.MediumTurquoise, "Box overlap by profile!"); } }
static void Main(string[] args) { var gameWidth = 800; var gameHeight = 600; var solarSystemGame = Game.CreateGame("Space", gameWidth, gameHeight, true); var testModel = MeshImporter.ImportModelFromFile("Models/Earth/Earth.obj"); var planet = testModel[0]; var tableMesh = MeshImporter.ImportModelFromFile("Models/Table/table.obj")[0]; solarSystemGame.CurrentWorld = new World("Solar System"); SetupInput(solarSystemGame.InputManager); var center = new WorldObject(objectName: "System center") { WorldLocation = Vector3.Up * 400 }; var CameraLocation = new Vector3(0, 1000, 2000); var camera = new SimpleControllableCamera(objectName: "Camera") { ForwardAxis = "Forward", RightAxis = "Right", UpAxis = "Up", TurnRightAxis = "Turn Right", TurnUpAxis = "Turn Up", WorldLocation = CameraLocation, WorldRotation = Quaternion.Invert(Quaternion.LookAtRH(CameraLocation, center.WorldLocation, Vector3.Up)), }; var table = new WorldObject(objectName: "Table mesh"); var tableComponent = new StaticMeshComponent(table) { Mesh = tableMesh, DefaultShader = new PhongVertexColorShader() { AmbientReflection = .23125f, DiffuseReflection = 0.2775f, SpecularReflection = .1f, Shininess = 6.0f, }, }; var sun = new Planet(0, planet, center, "Sun") { PlanetSize = 100, RotationAngularSpeed = 0.0f, TurningAngularSpeed = 1.0f, }; var mercury = new Planet(400, planet, center, "Mercury") { PlanetSize = 9, RotationAngularSpeed = 5.0f, TurningAngularSpeed = 2.0f, }; var venus = new Planet(700, planet, center, "Venus") { PlanetSize = 27, RotationAngularSpeed = 3.0f, TurningAngularSpeed = -1.0f, }; var earth = new Planet(1000, planet, center, "Earth") { PlanetSize = 30, RotationAngularSpeed = 1.0f, TurningAngularSpeed = 1.0f, }; var moon = new Planet(6, planet, earth.PlanetCenter, "Moon") { PlanetSize = 6, RotationAngularSpeed = 2.0f, TurningAngularSpeed = 1.0f, }; var mars = new Planet(1500, planet, center, "Mars") { PlanetSize = 15, RotationAngularSpeed = 1.0f, TurningAngularSpeed = 0.8f, }; var directionalLight = new DirectionalLightComponent(center) { Direction = Vector3.Normalize(Vector3.Down + Vector3.Right), Intensity = 3, }; var moonPointLight = new PointLightComponent(moon.PlanetCenter) { Intensity = 2 }; var sunPointLight = new PointLightComponent(sun) { Intensity = 10, }; solarSystemGame.GameRenderer.LightingModel.AddDirectionalLight(directionalLight); solarSystemGame.GameRenderer.LightingModel.AddPointLight(sunPointLight); solarSystemGame.GameRenderer.LightingModel.AddPointLight(moonPointLight); solarSystemGame.StartGame(); solarSystemGame.Dispose(); Console.WriteLine(); Console.WriteLine("Game finished. Press Enter."); Console.ReadLine(); }