private void ConstructLevel(int id) { if (_rCube != null) { return; } _lvlTmp = LevelTemplates.LvlTmp; // load meshes GlobalFieldMesh = MeshReader.LoadMesh("Assets/Tile.obj.model"); GlobalCubeMesh = MeshReader.LoadMesh("Assets/Cube.obj.model"); // load textures var imgData = RContext.LoadImage("Assets/tex_stone.jpg"); TextureField = RContext.CreateTexture(imgData); imgData = RContext.LoadImage("Assets/tex_cube.jpg"); TextureCube = RContext.CreateTexture(imgData); // camera _camPosition = -3000; // colh _objOrientation = float4x4.CreateRotationX(MathHelper.Pi / 2); // create cube and set vars _rCube = new RollingCube(this); _startXy = new int[2]; _curLvlId = id; // load level LoadLevel(id); }
// is called on startup public override void Init() { RC.ClearColor = new float4(1f, 1f, 1f, 1); // initialize the variables _meshTea = MeshReader.LoadMesh(@"Assets/Teapot.obj.model"); _shaderEffect.AttachToContext(RC); /* * RC.SetRenderState(RenderState.ZEnable, (uint) 1); * RC.SetRenderState(RenderState.AlphaBlendEnable, (uint) 1); * RC.SetRenderState(RenderState.BlendFactor, (uint)new ColorUint(0.25f, 0.25f, 0.25f, 0.25f)); * RC.SetRenderState(RenderState.BlendOperation, (uint)(BlendOperation.Add)); * RC.SetRenderState(RenderState.SourceBlend, (uint)(Blend.BlendFactor)); * RC.SetRenderState(RenderState.DestinationBlend, (uint)(Blend.InverseBlendFactor)); */ RC.SetRenderState(new RenderStateSet { AlphaBlendEnable = true, BlendFactor = new float4(0.5f, 0.5f, 0.5f, 0.5f), BlendOperation = BlendOperation.Add, SourceBlend = Blend.BlendFactor, DestinationBlend = Blend.InverseBlendFactor }); RC.SetRenderState(RenderState.AlphaBlendEnable, (uint)0); }
public override void Init() { _angleHorz = 0.2f; _angleVert = 0.2f; // is called on startup RC.ClearColor = new float4(1, 1, 1, 1); // initialize the variables _meshTea = MeshReader.LoadMesh(@"Assets/Teapot.obj.model"); _meshCube = MeshReader.LoadMesh(@"Assets/Cube.obj.model"); _meshSphere = MeshReader.LoadMesh(@"Assets/Sphere.obj.model"); _meshCylinder = MeshReader.LoadMesh(@"Assets/Cylinder.obj.model"); _meshPlatonic = MeshReader.LoadMesh(@"Assets/Platonic.obj.model"); //RC.CreateShader(Vs, Ps); _spColor = RC.CreateShader(Vs, Ps); //MoreShaders.GetShader("simple", RC); _spTexture = RC.CreateShader(Vt, Pt); //MoreShaders.GetShader("texture", RC); _spCustom = RC.CreateShader(VLin, PLin); _colorParam = _spColor.GetShaderParam("vColor"); _colorCustom = _spCustom.GetShaderParam("vColor"); _textureParam = _spTexture.GetShaderParam("vTexture"); // load texture var imgData = RC.LoadImage("Assets/world_map.jpg"); _iTex = RC.CreateTexture(imgData); _physic = new Physics(); _gui = new GUI(RC); _gui.SetUp(_physic.GetNumRB(), _physic.GetShapes()); }
// is called on startup public override void Init() { RC.ClearColor = new float4(1, 1, 1, 1); _cubeMesh = MeshReader.LoadMesh(@"Assets/cube.obj.model"); _spColor = MoreShaders.GetDiffuseColorShader(RC); _colorParam = _spColor.GetShaderParam("color"); }
public override void Init() { Input.Instance.InitializeDevices(); _meshTea = MeshReader.LoadMesh(@"Assets/Teapot.obj.model"); _spColor = Shaders.GetDiffuseColorShader(RC); _colorParam = _spColor.GetShaderParam("color"); }
public void InitGearConstraint() { var mesh = MeshReader.LoadMesh(@"Assets/Cube.obj.model"); var rbA = _world.AddRigidBody(0, new float3(0, 150, 0), float3.Zero, MyBoxCollider); _numRB++; var rbB = _world.AddRigidBody(1, new float3(0, 300, 0), float3.Zero, MyBoxCollider); _numRB++; }
public GameEntity(String meshPath, RenderContext rc, float posX = 0, float posY = 0, float posZ = 0, float angX = 0, float angY = 0, float angZ = 0) { _mesh = MeshReader.LoadMesh(meshPath); _rc = rc; Position = float4x4.CreateRotationX(angX) * float4x4.CreateRotationY(angY) * float4x4.CreateRotationZ(angZ) * float4x4.CreateTranslation(posX, posY, posZ); SetShader(_color); }
public override void Init() { RC.ClearColor = new float4(1, 1, 1, 1); _pc = new PickingContext(RC); _meshTea = MeshReader.LoadMesh(@"Assets/Teapot.obj.model"); _meshCube = MeshReader.LoadMesh(@"Assets/Cube.obj.model"); _spColor = Shaders.GetDiffuseColorShader(RC); _colorParam = _spColor.GetShaderParam("color"); }
// is called on startup public override void Init() { RC.ClearColor = new float4(0.1f, 0.1f, 0.5f, 1); _meshCube = MeshReader.LoadMesh(@"Assets/Cube.obj.model"); _spTexture = Shaders.GetTextureShader(RC); _textureParam = _spTexture.GetShaderParam("texture1"); _videoStream = VideoManager.Instance.LoadVideoFromFile(@"Assets/pot.webm", true); //_videoStream = VideoManager.Instance.LoadVideoFromCamera(0, false); }
public GameEntity(String meshPath, RenderContext rc, float posX = 0, float posY = 0, float posZ = 0, float angX = 0, float angY = 0, float angZ = 0) { _mesh = MeshReader.LoadMesh(meshPath); _rc = rc; Position = float4x4.CreateRotationX(angX) * float4x4.CreateRotationY(angY) * float4x4.CreateRotationZ(angZ) * float4x4.CreateTranslation(posX, posY, posZ); _shaderProgram = MoreShaders.GetDiffuseColorShader(rc); _shaderParam = _shaderProgram.GetShaderParam("color"); }
public override void Init() { RC.ClearColor = new float4(0.5f, 0.5f, 0.5f, 1); // load meshes Body = MeshReader.LoadMesh(@"Assets/mageBodyOBJ.obj.model"); GloveL = MeshReader.LoadMesh(@"Assets/mageGloveLOBJ.obj.model"); GloveR = MeshReader.LoadMesh(@"Assets/mageGloveROBJ.obj.model"); // set up shader, lights and textures var spBody = RC.CreateShader(VsBump, PsBump); RC.SetShader(spBody); RC.SetLightActive(0, 1); RC.SetLightPosition(0, new float3(5.0f, 0.0f, 2.0f)); RC.SetLightAmbient(0, new float4(0.2f, 0.2f, 0.2f, 1.0f)); RC.SetLightSpecular(0, new float4(0.1f, 0.1f, 0.1f, 1.0f)); RC.SetLightDiffuse(0, new float4(0.8f, 0.8f, 0.8f, 1.0f)); RC.SetLightDirection(0, new float3(-1.0f, 0.0f, 0.0f)); RC.SetLightActive(1, 1); RC.SetLightPosition(1, new float3(-5.0f, 0.0f, 2.0f)); RC.SetLightAmbient(1, new float4(0.5f, 0.5f, 0.5f, 1.0f)); RC.SetLightSpecular(1, new float4(0.1f, 0.1f, 0.1f, 1.0f)); RC.SetLightDiffuse(1, new float4(1.0f, 1.0f, 1.0f, 1.0f)); RC.SetLightDirection(1, new float3(1.0f, 0.0f, 0.0f)); _texture1ParamBody = spBody.GetShaderParam("texture1"); _texture2ParamBody = spBody.GetShaderParam("normalTex"); _specularLevelBody = spBody.GetShaderParam("specularLevel"); var imgDataGlove = RC.LoadImage("Assets/HandAOMap.jpg"); var imgData2Glove = RC.LoadImage("Assets/HandschuhNormalMap.jpg"); _iTexGlove = RC.CreateTexture(imgDataGlove); _iTex2Glove = RC.CreateTexture(imgData2Glove); var imgData = RC.LoadImage("Assets/TextureAtlas.jpg"); var imgData2 = RC.LoadImage("Assets/TextureAtlasNormal.jpg"); _iTex = RC.CreateTexture(imgData); _iTex2 = RC.CreateTexture(imgData2); // misc settings _angleHorz = 0; _angleVert = 0; _rotationSpeed = 1.5f; }
private void LoadMeshWithObjParser() { RC.Clear(ClearFlags.Color | ClearFlags.Depth); _isCurrentlyLoading = true; _currentMesh = null; Debug.WriteLine("Started loading Mesh using MeshReader."); RC.Clear(ClearFlags.Color | ClearFlags.Depth); _watch.Start(); _currentMesh = MeshReader.LoadMesh(@"Assets/Teapot.obj.model"); _watch.Stop(); Debug.WriteLine("Mesh loaded using MeshReader in " + _watch.ElapsedMilliseconds + "ms"); _watch.Reset(); _isCurrentlyLoading = false; }
public void InitColliders() { MyBoxCollider = _world.AddBoxShape(2); MySphereCollider = _world.AddSphereShape(2); MyCylinderCollider = _world.AddCylinderShape(new float3(2, 4, 2)); BoxMesh = MeshReader.LoadMesh(@"Assets/Cube.obj.model"); TeaPotMesh = MeshReader.LoadMesh(@"Assets/Teapot.obj.model"); PlatonicMesh = MeshReader.LoadMesh(@"Assets/Platonic.obj.model"); float3[] verts = PlatonicMesh.Vertices; MyConvHull = _world.AddConvexHullShape(verts, true); float3[] vertsTeaPot = TeaPotMesh.Vertices; TeaPotHull = _world.AddConvexHullShape(vertsTeaPot, true); TeaPotHull.LocalScaling = new float3(0.05f, 0.05f, 0.05f); }
public void InitSliderConstraint() { var mesh = MeshReader.LoadMesh(@"Assets/Cube.obj.model"); var rbA = _world.AddRigidBody(1, new float3(400, 500, 0), float3.Zero, MyBoxCollider); _numRB++; rbA.LinearFactor = new float3(0, 0, 0); rbA.AngularFactor = new float3(0, 0, 0); var rbB = _world.AddRigidBody(1, new float3(200, 500, 0), float3.Zero, MyBoxCollider); _numRB++; var frameInA = float4x4.Identity; frameInA.Row3 = new float4(0, 1, 0, 1); var frameInB = float4x4.Identity; frameInA.Row3 = new float4(0, 0, 0, 1); var sc = _world.AddSliderConstraint(rbA, rbB, frameInA, frameInB, true); }
// is called on startup public override void Init() { _theColor = new float4(0.5f, 0.8f, 0, 1); RC.ClearColor = new float4(1, 1, 1, 1); // initialize the variables _meshTea = MeshReader.LoadMesh(@"Assets/Teapot.obj.model"); _meshFace = MeshReader.LoadMesh(@"Assets/Face.obj.model"); _spColor = MoreShaders.GetShader("simple", RC); _spTexture = MoreShaders.GetShader("texture", RC); _colorParam = _spColor.GetShaderParam("vColor"); _textureParam = _spTexture.GetShaderParam("texture1"); // load texture var imgData = RC.LoadImage("Assets/world_map.jpg"); _iTex = RC.CreateTexture(imgData); }
public GameEntity(String meshPath, RenderContext rc, float posX = 0, float posY = 0, float posZ = 0, float angX = 0, float angY = 0, float angZ = 0) { if (meshPath.Contains("protobuf")) { _ser = new MySerializer(); using (var file = File.OpenRead(meshPath)) { _mesh = _ser.Deserialize(file, null, typeof(Mesh)) as Mesh; } } else { _mesh = MeshReader.LoadMesh(meshPath); } _rc = rc; Position = float4x4.CreateRotationX(angX) * float4x4.CreateRotationY(angY) * float4x4.CreateRotationZ(angZ) * float4x4.CreateTranslation(posX, posY, posZ); SetShader(_color); }
public override void Init() { // Set ToonShaderEffect _shaderEffect.AttachToContext(RC); // Setup GUI // GUIHandler _guiHandler = new GUIHandler(); _guiHandler.AttachToContext(RC); // font + text _guiFontCabin18 = RC.LoadFont("Assets/Cabin.ttf", 18); _guiFontCabin24 = RC.LoadFont("Assets/Cabin.ttf", 24); _guiText = new GUIText("FUSEE Shader Demo", _guiFontCabin24, 30, Height - 30) { TextColor = new float4(1, 1, 1, 1) }; _guiHandler.Add(_guiText); // image _guiImage = new GUIImage("Assets/repbg.jpg", 0, 0, -5, Width, Height); _guiHandler.Add(_guiImage); _borderImage = new GUIImage("Assets/redbg.png", 0, 0, -4, 230, 32); //_guiHandler.Add(_borderImage); //* Menu1: Select Shader _panelSelectShader = new GUIPanel("Select Shader", _guiFontCabin24, 10, 10, 230, 230); _panelSelectShader.ChildElements.Add(_borderImage); _guiHandler.Add(_panelSelectShader); //** Possible Shader Buttons _btnDiffuseColorShader = new GUIButton("Diffuse Color", _guiFontCabin18, 25, 40, 180, 25); _btnTextureShader = new GUIButton("Texture Only", _guiFontCabin18, 25, 70, 180, 25); _btnDiffuseTextureShader = new GUIButton("Diffuse Texture", _guiFontCabin18, 25, 100, 180, 25); _btnDiffuseBumpTextureShader = new GUIButton("Diffuse Bump Texture", _guiFontCabin18, 25, 130, 180, 25); _btnSpecularTexture = new GUIButton("Specular Texture", _guiFontCabin18, 25, 160, 180, 25); _btnToon = new GUIButton("Toon", _guiFontCabin18, 25, 190, 180, 25); //*** Add Handlers _btnDiffuseColorShader.OnGUIButtonDown += OnMenuButtonDown; _btnDiffuseColorShader.OnGUIButtonUp += OnMenuButtonUp; _btnDiffuseColorShader.OnGUIButtonEnter += OnMenuButtonEnter; _btnDiffuseColorShader.OnGUIButtonLeave += OnMenuButtonLeave; _btnTextureShader.OnGUIButtonDown += OnMenuButtonDown; _btnTextureShader.OnGUIButtonUp += OnMenuButtonUp; _btnTextureShader.OnGUIButtonEnter += OnMenuButtonEnter; _btnTextureShader.OnGUIButtonLeave += OnMenuButtonLeave; _btnDiffuseTextureShader.OnGUIButtonDown += OnMenuButtonDown; _btnDiffuseTextureShader.OnGUIButtonUp += OnMenuButtonUp; _btnDiffuseTextureShader.OnGUIButtonEnter += OnMenuButtonEnter; _btnDiffuseTextureShader.OnGUIButtonLeave += OnMenuButtonLeave; _btnDiffuseBumpTextureShader.OnGUIButtonDown += OnMenuButtonDown; _btnDiffuseBumpTextureShader.OnGUIButtonUp += OnMenuButtonUp; _btnDiffuseBumpTextureShader.OnGUIButtonEnter += OnMenuButtonEnter; _btnDiffuseBumpTextureShader.OnGUIButtonLeave += OnMenuButtonLeave; _btnSpecularTexture.OnGUIButtonDown += OnMenuButtonDown; _btnSpecularTexture.OnGUIButtonUp += OnMenuButtonUp; _btnSpecularTexture.OnGUIButtonEnter += OnMenuButtonEnter; _btnSpecularTexture.OnGUIButtonLeave += OnMenuButtonLeave; _btnToon.OnGUIButtonDown += OnMenuButtonDown; _btnToon.OnGUIButtonUp += OnMenuButtonUp; _btnToon.OnGUIButtonEnter += OnMenuButtonEnter; _btnToon.OnGUIButtonLeave += OnMenuButtonLeave; //**** Add Buttons to Panel _panelSelectShader.ChildElements.Add(_btnDiffuseColorShader); _panelSelectShader.ChildElements.Add(_btnTextureShader); _panelSelectShader.ChildElements.Add(_btnDiffuseTextureShader); _panelSelectShader.ChildElements.Add(_btnDiffuseBumpTextureShader); _panelSelectShader.ChildElements.Add(_btnSpecularTexture); _panelSelectShader.ChildElements.Add(_btnToon); //* Menu3: Select Mesh _panelSelectMesh = new GUIPanel("Select Mesh", _guiFontCabin24, 270, 10, 230, 130); _panelSelectMesh.ChildElements.Add(_borderImage); _guiHandler.Add(_panelSelectMesh); //** Possible Meshes _btnCube = new GUIButton("Cube", _guiFontCabin18, 25, 40, 180, 25); _btnSphere = new GUIButton("Sphere", _guiFontCabin18, 25, 70, 180, 25); _btnTeapot = new GUIButton("Teapot", _guiFontCabin18, 25, 100, 180, 25); _panelSelectMesh.ChildElements.Add(_btnCube); _panelSelectMesh.ChildElements.Add(_btnSphere); _panelSelectMesh.ChildElements.Add(_btnTeapot); //** Add handlers _btnCube.OnGUIButtonDown += OnMenuButtonDown; _btnCube.OnGUIButtonUp += OnMenuButtonUp; _btnCube.OnGUIButtonEnter += OnMenuButtonEnter; _btnCube.OnGUIButtonLeave += OnMenuButtonLeave; _btnSphere.OnGUIButtonDown += OnMenuButtonDown; _btnSphere.OnGUIButtonUp += OnMenuButtonUp; _btnSphere.OnGUIButtonEnter += OnMenuButtonEnter; _btnSphere.OnGUIButtonLeave += OnMenuButtonLeave; _btnTeapot.OnGUIButtonDown += OnMenuButtonDown; _btnTeapot.OnGUIButtonUp += OnMenuButtonUp; _btnTeapot.OnGUIButtonEnter += OnMenuButtonEnter; _btnTeapot.OnGUIButtonLeave += OnMenuButtonLeave; //* Menu2: Light Settings _panelLightSettings = new GUIPanel("Light Settings", _guiFontCabin24, 530, 10, 230, 130); _panelLightSettings.ChildElements.Add(_borderImage); _guiHandler.Add(_panelLightSettings); //** Possible Light Settings _btnDirectionalLight = new GUIButton("Directional Light", _guiFontCabin18, 25, 40, 180, 25); _btnPointLight = new GUIButton("Point Light", _guiFontCabin18, 25, 70, 180, 25); _btnSpotLight = new GUIButton("Spot Light", _guiFontCabin18, 25, 100, 180, 25); _panelLightSettings.ChildElements.Add(_btnDirectionalLight); _panelLightSettings.ChildElements.Add(_btnPointLight); _panelLightSettings.ChildElements.Add(_btnSpotLight); //*** Add Handlers _btnDirectionalLight.OnGUIButtonDown += OnMenuButtonDown; _btnDirectionalLight.OnGUIButtonUp += OnMenuButtonUp; _btnDirectionalLight.OnGUIButtonEnter += OnMenuButtonEnter; _btnDirectionalLight.OnGUIButtonLeave += OnMenuButtonLeave; _btnPointLight.OnGUIButtonDown += OnMenuButtonDown; _btnPointLight.OnGUIButtonUp += OnMenuButtonUp; _btnPointLight.OnGUIButtonEnter += OnMenuButtonEnter; _btnPointLight.OnGUIButtonLeave += OnMenuButtonLeave; _btnSpotLight.OnGUIButtonDown += OnMenuButtonDown; _btnSpotLight.OnGUIButtonUp += OnMenuButtonUp; _btnSpotLight.OnGUIButtonEnter += OnMenuButtonEnter; _btnSpotLight.OnGUIButtonLeave += OnMenuButtonLeave; // Setup 3D Scene // Load Images and Assign iTextures var imgTexture = RC.LoadImage("Assets/crateTexture.jpg"); var imgBumpTexture = RC.LoadImage("Assets/crateNormal.jpg"); _texCube = RC.CreateTexture(imgTexture); _texBumpCube = RC.CreateTexture(imgBumpTexture); imgTexture = RC.LoadImage("Assets/earthTexture.jpg"); imgBumpTexture = RC.LoadImage("Assets/earthNormal.jpg"); _texSphere = RC.CreateTexture(imgTexture); _texBumpSphere = RC.CreateTexture(imgBumpTexture); imgTexture = RC.LoadImage("Assets/porcelainTexture.png"); imgBumpTexture = RC.LoadImage("Assets/normalRust.jpg"); _texTeapot = RC.CreateTexture(imgTexture); _texBumpTeapot = RC.CreateTexture(imgBumpTexture); _currentTexture = _texCube; _currentBumpTexture = _texBumpCube; // Load Meshes _meshCube = MeshReader.LoadMesh(@"Assets/Cube.obj.model"); _meshSphere = MeshReader.LoadMesh(@"Assets/Sphere.obj.model"); _meshTeapot = MeshReader.LoadMesh(@"Assets/Teapot.obj.model"); // Set current Mesh and Update GUI _currentMesh = _meshCube; _btnCube.ButtonColor = ColorHighlightedButton; // Setup Shaderprograms and Update GUI _shaderDiffuseColor = Shaders.GetDiffuseColorShader(RC); _shaderDiffuseTexture = Shaders.GetDiffuseTextureShader(RC); _shaderTexture = Shaders.GetTextureShader(RC); _shaderDiffuseBumpTexture = Shaders.GetBumpDiffuseShader(RC); _shaderSpecularTexture = Shaders.GetSpecularShader(RC); _btnDiffuseColorShader.ButtonColor = ColorHighlightedButton; _currentShader = _shaderDiffuseColor; RC.SetShader(_shaderDiffuseColor); // Setup ShaderParams _paramColor = _shaderDiffuseColor.GetShaderParam("color"); // Setup Light and Update GUI RC.SetLightActive(0, 1); RC.SetLightPosition(0, new float3(5.0f, 0.0f, -2.0f)); RC.SetLightAmbient(0, new float4(0.2f, 0.2f, 0.2f, 1.0f)); RC.SetLightSpecular(0, new float4(0.1f, 0.1f, 0.1f, 1.0f)); RC.SetLightDiffuse(0, new float4(0.8f, 0.8f, 0.8f, 1.0f)); RC.SetLightDirection(0, new float3(-1.0f, 0.0f, 0.0f)); RC.SetLightSpotAngle(0, 10); _btnDirectionalLight.ButtonColor = ColorHighlightedButton; }
public override void Init() { _sceneManager = new SceneManager(); _sceneManager.AttachToContext(RC); // Light var direct = new DirectionalLight(new float3(1, 1, 1), new float4(0.7f, 0.7f, 0.7f, 1), new float4(1f, 1f, 1f, 1), new float4(0.9f, 0.9f, 0.9f, 1), new float3(0, 0, 0), 0); // Load Meshes var planetMesh = MeshReader.LoadMesh(@"Assets/Sphere.obj.model"); var spaceBoxMesh = MeshReader.LoadMesh(@"Assets/spacebox.obj.model"); // Setup Empty Objects _earthSpeed = new float3(0, 0.69635f, 0); var emptyMoon = new SceneEntity("emptyPlanetHolder", new MoonAction(_earthSpeed * 5.0f)); var emptyMercury = new SceneEntity("emptyPlanetHolder", new PlanetAction(RC, _earthSpeed * 4.1477f)); var emptyVenus = new SceneEntity("emptyPlanetHolder", new PlanetAction(RC, _earthSpeed * 1.6150f)); var emptyEarth = new SceneEntity("emptyPlanetHolder", new PlanetAction(RC, _earthSpeed)); var emptyMars = new SceneEntity("emptyPlanetHolder", new PlanetAction(RC, _earthSpeed * 0.5320f)); var emptyJupiter = new SceneEntity("emptyPlanetHolder", new PlanetAction(RC, _earthSpeed * 0.0833f)); var emptySaturn = new SceneEntity("emptyPlanetHolder", new PlanetAction(RC, _earthSpeed * 0.03476f)); var emptyUranus = new SceneEntity("emptyPlanetHolder", new PlanetAction(RC, _earthSpeed * 0.0119f)); var emptyNeptun = new SceneEntity("emptyPlanetHolder", new PlanetAction(RC, _earthSpeed * 0.0062f)); _sceneManager.AddSceneEntity(emptyMoon); _sceneManager.AddSceneEntity(emptyMercury); _sceneManager.AddSceneEntity(emptyVenus); _sceneManager.AddSceneEntity(emptyEarth); _sceneManager.AddSceneEntity(emptyMars); _sceneManager.AddSceneEntity(emptyJupiter); _sceneManager.AddSceneEntity(emptySaturn); _sceneManager.AddSceneEntity(emptyUranus); _sceneManager.AddSceneEntity(emptyNeptun); // Scene Camera var worldOrigin = new SceneEntity("WorldOrigin", new RotationScript()); _sceneManager.AddSceneEntity(worldOrigin); var cameraholder = new SceneEntity("CameraOwner", new CameraScript(RC)) { Transform = { GlobalPosition = new float3(0, 0, -10) } }; worldOrigin.AddChild(cameraholder); _sceneCamera = new Camera(cameraholder); _sceneCamera.Resize(Width, Height); // Setup Space Box var spaceBox = new SceneEntity("Spacebox", new PlanetMaterial(RC, MoreShaders.GetTextureShader(RC), "Assets/spaceboxTexture.png"), new Renderer(spaceBoxMesh)); _sceneManager.AddSceneEntity(spaceBox); // Setup Sun var planet = new SceneEntity("Sun", new PlanetMaterial(RC, MoreShaders.GetDiffuseTextureShader(RC), "Assets/sun.jpg"), new Renderer(planetMesh)) { Transform = { LocalScale = new float3(2, 2, 2) } }; _sceneManager.AddSceneEntity(planet); // Setup Earth planet = new SceneEntity("Earth", new PlanetAction(RC, new float3(0, 0.69635f * 365, 0)), new PlanetMaterial(RC, MoreShaders.GetDiffuseTextureShader(RC), "Assets/earth.jpg"), new Renderer(planetMesh)) { Transform = { GlobalPosition = new float3(2.9f, 0, 0), GlobalScale = new float3(0.1f, 0.1f, 0.1f) } }; planet.AddComponent(direct); emptyEarth.AddChild(planet); // Setup Moon planet = new SceneEntity("Moon", new PlanetAction(RC, new float3(0, 2.7f, 0)), new PlanetMaterial(RC, MoreShaders.GetDiffuseTextureShader(RC), "Assets/moon.jpg"), new Renderer(planetMesh)) { Transform = { GlobalPosition = new float3(0.5f, 0, 0), GlobalScale = new float3(0.05f, 0.05f, 0.05f) } }; emptyMoon.AddChild(planet); // Setup Mercury planet = new SceneEntity("Mercury", new PlanetAction(RC, _earthSpeed * 6.2234f), new PlanetMaterial(RC, MoreShaders.GetDiffuseTextureShader(RC), "Assets/merkur.jpg"), new Renderer(planetMesh)) { Transform = { GlobalPosition = new float3(2.35f, 0, 0), GlobalScale = new float3(0.05f, 0.05f, 0.05f) } }; emptyMercury.AddChild(planet); // Setup Venus planet = new SceneEntity("Venus", new PlanetAction(RC, _earthSpeed * 1.5021f), new PlanetMaterial(RC, MoreShaders.GetDiffuseTextureShader(RC), "Assets/venus.jpg"), new Renderer(planetMesh)) { Transform = { GlobalPosition = new float3(2.6f, 0, 0), GlobalScale = new float3(0.08f, 0.08f, 0.08f) } }; emptyVenus.AddChild(planet); // Setup Mars planet = new SceneEntity("Mars", new PlanetAction(RC, _earthSpeed * 374.125f), new PlanetMaterial(RC, MoreShaders.GetDiffuseTextureShader(RC), "Assets/mars.jpg"), new Renderer(planetMesh)) { Transform = { GlobalPosition = new float3(3.25f, 0, 0), GlobalScale = new float3(0.07f, 0.07f, 0.07f) } }; emptyMars.AddChild(planet); // Setup Jupiter planet = new SceneEntity("Jupiter", new PlanetAction(RC, _earthSpeed * 882.62f), new PlanetMaterial(RC, MoreShaders.GetDiffuseTextureShader(RC), "Assets/jupiter.jpg"), new Renderer(planetMesh)) { Transform = { GlobalPosition = new float3(4, 0, 0), GlobalScale = new float3(0.4f, 0.4f, 0.4f) } }; emptyJupiter.AddChild(planet); // Setup Saturn planet = new SceneEntity("Saturn", new PlanetAction(RC, _earthSpeed * 820.61f), new PlanetMaterial(RC, MoreShaders.GetDiffuseTextureShader(RC), "Assets/saturn.jpg"), new Renderer(planetMesh)) { Transform = { GlobalPosition = new float3(5, 0, 0), GlobalScale = new float3(0.3f, 0.3f, 0.3f) } }; emptySaturn.AddChild(planet); // Setup Uranus planet = new SceneEntity("Uranus", new PlanetAction(RC, _earthSpeed * 509.30f), new PlanetMaterial(RC, MoreShaders.GetDiffuseTextureShader(RC), "Assets/uranus.jpg"), new Renderer(planetMesh)) { Transform = { GlobalPosition = new float3(6, 0, 0), GlobalScale = new float3(0.12f, 0.12f, 0.12f) } }; emptyUranus.AddChild(planet); // Setup Neptun planet = new SceneEntity("Neptun", new PlanetAction(RC, _earthSpeed * 544.10f), new PlanetMaterial(RC, MoreShaders.GetDiffuseTextureShader(RC), "Assets/neptune.jpg"), new Renderer(planetMesh)) { Transform = { GlobalPosition = new float3(7, 0, 0), GlobalScale = new float3(0.14f, 0.14f, 0.14f) } }; emptyNeptun.AddChild(planet); _sceneManager.StartActionCode(); // Random Rotations emptyEarth.Transform.LocalEulerAngles = new float3(0, 45, 0); emptyMercury.Transform.LocalEulerAngles = new float3(0, 55, 0); emptyVenus.Transform.LocalEulerAngles = new float3(0, 335, 0); emptyMars.Transform.LocalEulerAngles = new float3(0, 125, 0); emptyJupiter.Transform.LocalEulerAngles = new float3(0, 65, 0); emptySaturn.Transform.LocalEulerAngles = new float3(0, 95, 0); emptyUranus.Transform.LocalEulerAngles = new float3(0, 145, 0); emptyNeptun.Transform.LocalEulerAngles = new float3(0, 245, 0); RC.ClearColor = new float4(1, 0, 0, 1); }