SceneContainer CreateScene() { // Initialize transform components that need to be changed inside "RenderAFrame" _baseTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0) }; // Setup the scene graph return(new SceneContainer { Children = new List <SceneNode> { new SceneNode { Components = new List <SceneComponent> { // TRANSFORM COMPONENT _baseTransform, // SHADER EFFECT COMPONENT MakeEffect.FromDiffuseSpecular((float4)ColorUint.LightGrey, float4.Zero), // MESH COMPONENT SimpleMeshes.CreateCuboid(new float3(10, 2, 10)) } } } }); }
private void AddGeometryToSceneNode(Geometry geometry, float3 position) { Geometry newGeo = geometry.CloneGeometry(); newGeo.Triangulate(); JometriMesh geometryMesh = new JometriMesh(newGeo); SceneNode sceneNodeContainer = new SceneNode { Components = new List <SceneComponent>() }; Mesh meshComponent = new Mesh { Vertices = geometryMesh.Vertices, Triangles = geometryMesh.Triangles, Normals = geometryMesh.Normals, }; Transform translationComponent = new Transform { Rotation = float3.Zero, Scale = new float3(1, 1, 1), Translation = position }; sceneNodeContainer.Components.Add(translationComponent); sceneNodeContainer.Components.Add(MakeEffect.FromDiffuseSpecular(_defaultColor, float4.Zero)); sceneNodeContainer.Components.Add(meshComponent); _parentNode.Children.Add(sceneNodeContainer); _activeGeometrys.Add(_parentNode.Children.IndexOf(sceneNodeContainer), geometry); }
// Init is called on startup. public override void Init() { // Set the clear color for the backbuffer to "greenery" ;-) (https://store.pantone.com/de/de/color-of-the-year-2017/). RC.ClearColor = new float4(136f / 255f, 176f / 255f, 75f / 255f, 1); // Create a scene with a cube // The three components: one Transform, one ShaderEffect (blue material) and the Mesh _cubeTransform = new Transform { Translation = new float3(0, 0, 0) }; _cubeEffect = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero); var cubeMesh = SimpleMeshes.CreateCuboid(new float3(10, 10, 10)); // Assemble the cube node containing the three components var cubeNode = new SceneNode(); cubeNode.Components.Add(_cubeTransform); cubeNode.Components.Add(_cubeEffect); cubeNode.Components.Add(cubeMesh); // Create the scene containing the cube as the only object _scene = new SceneContainer(); _scene.Children.Add(cubeNode); // Create a scene renderer holding the scene above _sceneRenderer = new SceneRendererForward(_scene); _camAngle = 0; }
// Init is called on startup. public override void Init() { // Set the clear color for the backbuffer to white (100% intensity in all color channels R, G, B, A). RC.ClearColor = new float4(1, 1, 1, 1); // Create a scene with a cube // The three components: one Transform, one ShaderEffect (blue material) and the Mesh _cubeTransform = new Transform { Translation = new float3(0, 0, 0) }; var cubeShader = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero); var cubeMesh = SimpleMeshes.CreateCuboid(new float3(10, 10, 10)); // Assemble the cube node containing the three components var cubeNode = new SceneNode(); cubeNode.Components.Add(_cubeTransform); cubeNode.Components.Add(cubeShader); cubeNode.Components.Add(cubeMesh); // Create the scene containing the cube as the only object _scene = new SceneContainer(); _scene.Children.Add(cubeNode); // Create a scene renderer holding the scene above _sceneRenderer = new SceneRendererForward(_scene); }
public static SurfaceEffect MakeMaterial(float4 color) { return(MakeEffect.FromDiffuseSpecular( albedoColor: color, emissionColor: float4.Zero, shininess: 25.0f, specularStrength: 1f)); }
private static SceneNode CreateCircle(float2 circleDim, MatColor color) { float4 col; string nameSuffix; switch (color) { default: case MatColor.White: col = White; nameSuffix = "white"; break; case MatColor.Green: col = Green; nameSuffix = "green"; break; case MatColor.Yellow: col = Yellow; nameSuffix = "yellow"; break; case MatColor.Gray: col = Gray; nameSuffix = "gray"; break; } return(new SceneNode { Name = "Circle_" + nameSuffix, Components = new List <SceneComponent> { new RectTransform { Name = "circle" + "_RectTransform", Anchors = new MinMaxRect { Min = new float2(0.5f, 0.5f), Max = new float2(0.5f, 0.5f) }, Offsets = UIElementPosition.CalcOffsets(AnchorPos.Middle, new float2(0, 0), CanvasHeightInit, CanvasWidthInit, circleDim), }, new XForm { Name = "circle" + "_XForm", }, MakeEffect.FromDiffuseSpecular(col, float4.Zero), new Circle(false, 30, 100, _circleThickness) } }); }
private SceneContainer BuildScene() { Sphere sphere = new Sphere(32, 24); List <float3> lineControlPoints = new List <float3> { new float3(-3f, 0, 0), new float3(-1.5f, -1.5f, 0), new float3(1f, 1.5f, 0) }; Line line = new Line(lineControlPoints, 0.2f); var paperTex = new Texture(AssetStorage.Get <ImageData>("crumpled-paper-free.jpg")); return(new SceneContainer() { Children = new List <SceneNode>() { new SceneNode() { Components = new List <SceneComponent>() { new Transform() { Name = "SphereTransform", Rotation = new float3(0, 0, 0), Translation = new float3(0, 0, 0), Scale = new float3(1, 1, 1) }, MakeEffect.FromDiffuseSpecularNormalTexture(new float4(0.90980f, 0.35686f, 0.35686f, 1).LinearColorFromSRgb(), float4.Zero, paperTex, 1.0f, float2.One, 20, 0.5f) //sphere } }, new SceneNode() { Components = new List <SceneComponent>() { new Transform() { Name = "LineTransform", Rotation = new float3(0, 0, 0), Translation = new float3(0, 0, 0), Scale = new float3(1, 1, 1) }, MakeEffect.FromDiffuseSpecular(new float4(0, 0, 1, 1).LinearColorFromSRgb(), float4.Zero, 20, 1.0f), line } } } }); }
private static SceneNode CreateLine(MatColor color) { float4 col; switch (color) { default: case MatColor.White: col = White; break; case MatColor.Green: col = Green; break; case MatColor.Yellow: col = Yellow; break; case MatColor.Gray: col = Gray; break; } return(new SceneNode() { Name = "line", Components = new List <SceneComponent> { new RectTransform { Name = "line" + "_RectTransform", Anchors = new MinMaxRect { Min = new float2(0.5f, 0.5f), Max = new float2(0.5f, 0.5f) }, Offsets = UIElementPosition.CalcOffsets(AnchorPos.Middle, new float2(0, 0), CanvasHeightInit, CanvasWidthInit, new float2(CanvasWidthInit, CanvasHeightInit)), }, new XForm { Name = "line" + "_XForm", }, MakeEffect.FromDiffuseSpecular(col, float4.Zero), } }); }
public override void Init() { // Set the clear color for the backbuffer to "greenery" RC.ClearColor = (float4)(ColorUint.Black); // Create a scene with a cube // The three components: one Transform, one ShaderEffect (blue material) and the Mesh /* _cubeTransform1 = new Transform { * Translation = new float3(-10, 0, 40), * Rotation = new float3(0,0.3f,0), * }; * _cubeshader = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Cyan, float4.Zero); * var cubeMesh = SimpleMeshes.CreateCuboid(new float3(10, 10, 10)); * * * _cubeTransform2 = new Transform{ * Translation = new float3(10,0,40), * Rotation = new float3(0,0.3f,0), * }; * * * // Assemble the cube node containing the three components * * var Cubenode2 = new SceneNode(); * Cubenode2.Components.Add(_cubeTransform2); * Cubenode2.Components.Add(_cubeshader); * Cubenode2.Components.Add(cubeMesh); * * var cubeNode = new SceneNode(); //Hauptnode * cubeNode.Components.Add(_cubeTransform1);// kinderKomponenten werden gesetzt * cubeNode.Components.Add(_cubeshader); * cubeNode.Components.Add(cubeMesh); * * // Create the scene containing the cube as the only object * _scene = new SceneContainer(); * _scene.Children.Add(cubeNode); * _scene.Children.Add(Cubenode2); // in childrenliste der szene einreihen */ // Create a scene renderer holding the scene above _cubeTransform1 = new Transform { Translation = new float3(-10, 0, 70), Rotation = new float3(0, 0.3f, 0), }; _cubeshader = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Cyan, float4.Zero); _cubeshader2 = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Cyan, float4.Zero); _cubeTransform2 = new Transform { Translation = new float3(10, 0, 70), Rotation = new float3(0, 0.3f, 0), }; _cubeTransform3 = new Transform { Translation = new float3(0, 0, 70), Rotation = new float3(0, 0.3f, 0), }; _cubeTransform4 = new Transform { Translation = new float3(0, 0, 70), Rotation = new float3(0, 0.3f, 0), }; _cubeMesh = SimpleMeshes.CreateCuboid(new float3(6, 6, 6)); node = new SceneNode { Components = { _cubeTransform4, _cubeshader2, _cubeMesh, } }; _scene = new SceneContainer { Children = { new SceneNode { Components = { _cubeTransform1, _cubeshader, SimpleMeshes.CreateCuboid(new float3(3, 3, 3)) } }, new SceneNode { Components = { _cubeTransform2, _cubeshader, SimpleMeshes.CreateCuboid(new float3(3, 3, 3)) } }, new SceneNode { Components = { _cubeTransform3, _cubeshader, SimpleMeshes.CreateCuboid(new float3(3, 3, 3)) } }, node } }; _sceneRenderer = new SceneRendererForward(_scene);//renderer der einzelne pixel einfärben kann }
// Init is called on startup. public override void Init() { Font fontLato = AssetStorage.Get <Font>("Lato-Black.ttf"); FontMap fontLatoMap = new FontMap(fontLato, 32); string vsTex = AssetStorage.Get <string>("texture.vert"); string psTex = AssetStorage.Get <string>("texture.frag"); Icosphere icosphereWithTangents = new Icosphere(5); icosphereWithTangents.Tangents = icosphereWithTangents.CalculateTangents(); icosphereWithTangents.BiTangents = icosphereWithTangents.CalculateBiTangents(); icosphereWithTangents.BoundingBox = new AABBf(icosphereWithTangents.Vertices); float canvasWidth = Width / 100f; float canvasHeight = Height / 100f; var albedoTex = new Texture(AssetStorage.Get <ImageData>("albedoTex.jpg")); var normalTex = new Texture(AssetStorage.Get <ImageData>("normalTex.jpg")); SceneContainer guiDescriptionScene = new SceneContainer { Children = new List <SceneNode> { new CanvasNode("Canvas", CanvasRenderMode.World, new MinMaxRect { Min = new float2(-canvasWidth / 2, -canvasHeight / 2f), Max = new float2(canvasWidth / 2, canvasHeight / 2f) }) { Children = new ChildList { new TextNode( "How-To:\n############################\n- Move with WASD\n- Left mouse button rotates spheres\n- Mouse wheel zooms", "howTo", vsTex, psTex, UIElementPosition.GetAnchors(AnchorPos.DownDownLeft), UIElementPosition.CalcOffsets(AnchorPos.DownDownLeft, new float2(-11, -5), canvasHeight, canvasWidth, new float2(12, 1)), fontLatoMap, new float4(1, 1, 0, 1).LinearColorFromSRgb(), HorizontalTextAlignment.Left, VerticalTextAlignment.Center) } }, new CanvasNode("Complete", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One)) { Components = new List <SceneComponent> { new Transform { Name = "TextTransform", Translation = new float3(-15, 2.5f, 0) } }, Children = new ChildList { new TextNode( "Complete", "desc", vsTex, psTex, MinMaxRect.FromCenterSize(float2.Zero, float2.One), new MinMaxRect(), fontLatoMap, (float4)ColorUint.Black, HorizontalTextAlignment.Left, VerticalTextAlignment.Center), new TextNode( "NOT YET IMPLEMENTED", "desc", vsTex, psTex, MinMaxRect.FromCenterSize(float2.Zero, float2.One), new MinMaxRect { Max = new float2(0, 0), Min = new float2(0, -1.25f) }, fontLatoMap, new float4(1, 0, 0, 0.5f), HorizontalTextAlignment.Left, VerticalTextAlignment.Center) } }, new CanvasNode("Albedo and specular", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One)) { Components = new List <SceneComponent> { new Transform { Name = "TextTransform", Translation = new float3(-10, 2.5f, 0) } }, Children = new ChildList { new TextNode( "Albedo and Specular", "desc", vsTex, psTex, MinMaxRect.FromCenterSize(float2.Zero, float2.One), new MinMaxRect(), fontLatoMap, (float4)ColorUint.Black, HorizontalTextAlignment.Left, VerticalTextAlignment.Center) } }, new CanvasNode("Albedo, specular and albedo texture", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One)) { Components = new List <SceneComponent> { new Transform { Name = "TextTransform", Translation = new float3(-5, 2.5f, 0) } }, Children = new ChildList { new TextNode( "Albedo, specular and\nalbedo texture", "desc", vsTex, psTex, MinMaxRect.FromCenterSize(float2.Zero, float2.One), new MinMaxRect(), fontLatoMap, (float4)ColorUint.Black, HorizontalTextAlignment.Left, VerticalTextAlignment.Center) } }, new CanvasNode("Specular texture", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One)) { Components = new List <SceneComponent> { new Transform { Name = "TextTransform", Translation = new float3(0, 2.5f, 0) } }, Children = new ChildList { new TextNode( "Specular texture", "desc", vsTex, psTex, MinMaxRect.FromCenterSize(float2.Zero, float2.One), new MinMaxRect(), fontLatoMap, (float4)ColorUint.Black, HorizontalTextAlignment.Left, VerticalTextAlignment.Center), new TextNode( "NOT YET IMPLEMENTED", "desc", vsTex, psTex, MinMaxRect.FromCenterSize(float2.Zero, float2.One), new MinMaxRect { Max = new float2(0, 0), Min = new float2(0, -1.25f) }, fontLatoMap, new float4(1, 0, 0, 0.75f).LinearColorFromSRgb(), HorizontalTextAlignment.Left, VerticalTextAlignment.Center) } }, new CanvasNode("Normal map", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One)) { Components = new List <SceneComponent> { new Transform { Name = "TextTransform", Translation = new float3(5, 2.5f, 0) } }, Children = new ChildList { new TextNode( "Normal map", "desc", vsTex, psTex, MinMaxRect.FromCenterSize(float2.Zero, float2.One), new MinMaxRect(), fontLatoMap, (float4)ColorUint.Black, HorizontalTextAlignment.Left, VerticalTextAlignment.Center) } }, new CanvasNode("Albedo and emissive", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One)) { Components = new List <SceneComponent> { new Transform { Name = "TextTransform", Translation = new float3(10, 2.5f, 0) } }, Children = new ChildList { new TextNode( "Albedo and emissive", "desc", vsTex, psTex, MinMaxRect.FromCenterSize(float2.Zero, float2.One), new MinMaxRect(), fontLatoMap, (float4)ColorUint.Black, HorizontalTextAlignment.Left, VerticalTextAlignment.Center), new TextNode( "NOT YET IMPLEMENTED", "desc", vsTex, psTex, MinMaxRect.FromCenterSize(float2.Zero, float2.One), new MinMaxRect { Max = new float2(0, 0), Min = new float2(0, -1.25f) }, fontLatoMap, new float4(1, 0, 0, 0.75f).LinearColorFromSRgb(), HorizontalTextAlignment.Left, VerticalTextAlignment.Center) } }, new CanvasNode("Albedo and emissive with texture", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One)) { Components = new List <SceneComponent> { new Transform { Name = "TextTransform", Translation = new float3(15, 3, 0) } }, Children = new ChildList { new TextNode( "Albedo, emissive and\nemissive texture", "desc", vsTex, psTex, MinMaxRect.FromCenterSize(float2.Zero, float2.One), new MinMaxRect(), fontLatoMap, (float4)ColorUint.Black, HorizontalTextAlignment.Left, VerticalTextAlignment.Center), new TextNode( "NOT YET IMPLEMENTED", "desc", vsTex, psTex, MinMaxRect.FromCenterSize(float2.Zero, float2.One), new MinMaxRect { Max = new float2(0, 0), Min = new float2(0, -1.75f) }, fontLatoMap, new float4(1, 0, 0, 0.75f).LinearColorFromSRgb(), HorizontalTextAlignment.Left, VerticalTextAlignment.Center) } } } }; _scene = new SceneContainer { Header = new SceneHeader { CreatedBy = "MR", CreationDate = DateTime.Now.ToString(), Generator = "by hand" }, Children = new List <SceneNode> { new SceneNode { Children = new ChildList { new SceneNode { Components = new List <SceneComponent> { new Transform { Name = "complete", Translation = new float3(-15, 0, 0) }, MakeEffect.FromDiffuseSpecularTexture( albedoColor: (float4.One * 0.25f).LinearColorFromSRgb(), emissionColor: float4.Zero, shininess: 25f, albedoTex: albedoTex, normalTex: normalTex, albedoMix: 1f, texTiles: float2.One, specularStrength: 1f, normalMapStrength: 1f //SpecularMix = 1f, //SpecularTexture = "specularTex.jpg", //EmissiveColor = new float4(0, 1, 1, 1), //EmissiveMix = 0.5f, //EmissiveTexture = "emissiveTex.jpg" ), icosphereWithTangents, } }, new SceneNode { Components = new List <SceneComponent> { new Transform { Name = "albedo and specular", Translation = new float3(-10, 0, 0) }, MakeEffect.FromDiffuseSpecular( albedoColor: new float4(0.39f, 0.19f, 0, 1).LinearColorFromSRgb(), emissionColor: float4.Zero, shininess: 25.0f, specularStrength: 1f), icosphereWithTangents } }, new SceneNode { Components = new List <SceneComponent> { new Transform { Name = "albedo, specular, albedo texture", Translation = new float3(-5, 0, 0) }, MakeEffect.FromDiffuseSpecularAlbedoTexture ( albedoColor: new float4(0.39f, 0.19f, 0, 1).LinearColorFromSRgb(), emissionColor: float4.Zero, albedoTex: albedoTex, albedoMix: 1f, texTiles: float2.One, shininess: 256.0f, specularStrength: 1.0f ), icosphereWithTangents } }, // ---- Specular Textures are not implemented yet. There is no fitting shader! ---- // //new SceneNode //{ // Components = new List<SceneComponent> // { // new Transform // { // Name = "specular texture", // Translation = new float3(0, 0, 0) // }, // ShaderCodeBuilder.MakeShaderEffectFromShaderEffectPropsProto(new ShaderEffectProps // { // MatProbs = // { // HasAlbedo = true, // HasAlbedoTexture = true, // HasSpecular = true, // HasSpecularTexture = true // }, // MatType = MaterialType.Standard, // MatValues = // { // AlbedoColor = new float4(0.39f, 0.19f, 0, 1), // SpecularColor = float4.One, // SpecularIntensity = 2f, // SpecularShininess = 25f, // SpecularMix = 1f, // TODO: Implement in ShaderShards // SpecularTexture = "specularTex.jpg" // TODO: Implement in ShaderShards // } // }), // icosphereWithTangents // } //}, new SceneNode { Components = new List <SceneComponent> { new Transform { Name = "specular texture - not impl.", Translation = new float3(0, 0, 0) }, MakeEffect.FromDiffuseSpecular(float4.One, float4.Zero, 85, 0.5f), icosphereWithTangents } }, new SceneNode { Components = new List <SceneComponent> { new Transform { Name = "normal map", Translation = new float3(5, 0, 0) }, MakeEffect.FromDiffuseSpecularTexture( albedoColor: (float4.One * 0.25f).LinearColorFromSRgb(), emissionColor: float4.Zero, shininess: 200f, albedoTex: albedoTex, normalTex: normalTex, albedoMix: 1f, texTiles: float2.One, specularStrength: 1f, normalMapStrength: 1f ), icosphereWithTangents } }, new SceneNode { Components = new List <SceneComponent> { new Transform { Name = "albedo, emissive - not impl.", Translation = new float3(10, 0, 0) }, MakeEffect.FromDiffuseSpecularAlbedoTexture( albedoColor: new float4(0.39f, 0.19f, 0, 1).LinearColorFromSRgb(), emissionColor: float4.Zero, albedoTex: albedoTex, albedoMix: 1f, texTiles: float2.One, shininess: 256.0f, specularStrength: 1f), icosphereWithTangents } }, new SceneNode { Components = new List <SceneComponent> { new Transform { Name = "albedo, emissive, emissive texture - not impl.", Translation = new float3(15, 0, 0) }, MakeEffect.FromDiffuseSpecularAlbedoTexture( albedoColor: new float4(0.39f, 0.19f, 0, 1).LinearColorFromSRgb(), emissionColor: float4.Zero, albedoTex: albedoTex, albedoMix: 1f, texTiles: float2.One, shininess: 256.0f, specularStrength: 1.0f), icosphereWithTangents } } } } } }; _guiDescRenderer = new SceneRendererForward(guiDescriptionScene); _renderer = new SceneRendererDeferred(_scene); }
public override void Init()//Farbe wird definiert { // Set the clear color for the backbuffer to "greenery" RC.ClearColor = (float4)ColorUint.Greenery; // Create a scene with a cube // The three components: one Transform, one ShaderEffect (blue material) and the Mesh //Umständliche Schreibweise /*_cubeTransform = new Transform * { * Translation = new float3(0, 0, 20), //Position wird festgelegt (3D), x,y,z * Rotation = new float3(0, 0.3f, 0), * }; * _cubeShader = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero); //hier wird die Farbe festgelegt; Grundfarbe * var cubeMesh = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));// Größe des Würfels * * // Assemble the cube node containing the three components * var cubeNode = new SceneNode(); * cubeNode.Components.Add(_cubeTransform); //fügt die Transform-Kompenente an * cubeNode.Components.Add(_cubeShader); // fügt den Shader * cubeNode.Components.Add(cubeMesh);// fügt den Mesh * * // Create the scene containing the cube as the only object * _scene = new SceneContainer(); // Container, der alles enthält * _scene.Children.Add(cubeNode);// Node zu den Kinder-Komponenten hinzufügen */ //Alternative (einfache) Schreibweise _cubeTransform = new Transform { Translation = new float3(0, 0, 20), Rotation = new float3(0, 0.3f, 0), }; _cubeShader = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero); _scene = new SceneContainer { Children = { new SceneNode { Components = { _cubeTransform, _cubeShader, SimpleMeshes.CreateCuboid(new float3(10, 10, 10)) } }, new SceneNode { Components = { new Transform { Translation = new float3(0, 0, 10), Rotation = new float3(0, 0.3f, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero), SimpleMeshes.CreateCuboid(new float3(5, 10, 5)) } } } }; // Create a scene renderer holding the scene above _sceneRenderer = new SceneRendererForward(_scene); // }
private SceneContainer CreateScene() { return(new SceneContainer { Header = new SceneHeader { CreationDate = "April 2017", CreatedBy = "*****@*****.**", Generator = "Handcoded with pride", }, Children = new List <SceneNode> { new SceneNode { Name = "Base", Components = new List <SceneComponent> { new Transform { Scale = float3.One }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Red, float4.Zero, 4.0f, 1f), CreateCuboid(new float3(100, 20, 100)) }, Children = new ChildList { new SceneNode { Name = "Arm01", Components = new List <SceneComponent> { new Transform { Translation = new float3(0, 60, 0), Scale = float3.One }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Green, float4.Zero, 4.0f, 1f), CreateCuboid(new float3(20, 100, 20)) }, Children = new ChildList { new SceneNode { Name = "Arm02Rot", Components = new List <SceneComponent> { new Transform { Translation = new float3(-20, 40, 0), Rotation = new float3(0.35f, 0, 0), Scale = float3.One }, }, Children = new ChildList { new SceneNode { Name = "Arm02", Components = new List <SceneComponent> { new Transform { Translation = new float3(0, 40, 0), Scale = float3.One }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Yellow, float4.Zero, 4.0f, 1f), CreateCuboid(new float3(20, 100, 20)) }, Children = new ChildList { new SceneNode { Name = "Arm03Rot", Components = new List <SceneComponent> { new Transform { Translation = new float3(20, 40, 0), Rotation = new float3(0.25f, 0, 0), Scale = float3.One }, }, Children = new ChildList { new SceneNode { Name = "Arm03", Components = new List <SceneComponent> { new Transform { Translation = new float3(0, 40, 0), Scale = float3.One }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero, 4.0f, 1f), CreateCuboid(new float3(20, 100, 20)) } }, } } } }, } } } }, } }, } }); }
// Init is called on startup. public override void Init() { VSync = false; _mainCam.Viewport = new float4(0, 0, 100, 100); _mainCam.BackgroundColor = new float4(0f, 0f, 0f, 1); _mainCam.Layer = -1; _sndCam.Viewport = new float4(60, 60, 40, 40); _sndCam.BackgroundColor = new float4(0.5f, 0.5f, 0.5f, 1); _sndCam.Layer = 10; _guiCam.ClearColor = false; _guiCam.ClearDepth = false; _guiCam.FrustumCullingOn = false; _mainCamTransform = _guiCamTransform = new Transform() { Rotation = float3.Zero, Translation = new float3(0, 1, -30), Scale = new float3(1, 1, 1) }; _gui = CreateGui(); // Create the interaction handler _sih = new SceneInteractionHandler(_gui); _frustum = new WireframeCube(); SceneNode frustumNode = new SceneNode() { Name = "Frustum", Components = new List <SceneComponent>() { MakeEffect.FromDiffuseSpecular(new float4(1, 1, 0, 1), float4.Zero), _frustum } }; SceneNode cam = new SceneNode() { Name = "MainCam", Components = new List <SceneComponent>() { _mainCamTransform, _mainCam, MakeEffect.FromDiffuseSpecular(new float4(1, 0, 0, 1), float4.Zero), new Cube(), }, Children = new ChildList() { new SceneNode() { Components = new List <SceneComponent>() { new Transform() { Scale = new float3(0.5f, 0.5f, 1f), Translation = new float3(0, 0, 1f) }, new Cube() } } } }; _sndCamTransform = new Transform() { Rotation = new float3(M.PiOver6, 0, 0),//float3.Zero, Translation = new float3(10, 40, -60), Scale = float3.One }; SceneNode cam1 = new SceneNode() { Name = "SecondCam", Components = new List <SceneComponent>() { _sndCamTransform, _sndCam, } }; _anlgeHorznd = _sndCamTransform.Rotation.y; _angleVertSnd = _sndCamTransform.Rotation.x; _anlgeHorzMain = _mainCamTransform.Rotation.y; _angleVertMain = _mainCamTransform.Rotation.x; // Load the rocket model _rocketScene = AssetStorage.Get <SceneContainer>("rnd.fus"); _cubeOneTransform = _rocketScene.Children[0].GetComponent <Transform>(); _rocketScene.Children.Add(cam); _rocketScene.Children.Add(cam1); _rocketScene.Children.Add(frustumNode); // Wrap a SceneRenderer around the model. _sceneRenderer = new SceneRendererForward(_rocketScene); _guiRenderer = new SceneRendererForward(_gui); }
public override void Init() { // Set the clear color for the backbuffer to "greenery" RC.ClearColor = (float4)ColorUint.Greenery; _cubeTransform = new Transform { Translation = new float3(0, 0, 50), Rotation = new float3(0, 0, 2.3f), }; _cubeShader = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero); _scene = new SceneContainer { Children = { new SceneNode { Components = { _cubeTransform, _cubeShader, SimpleMeshes.CreateCuboid(new float3(4, 4, 4)) } }, new SceneNode { Components = { _cubeTransform, new Transform{ Translation = new float3(12, 5, 15), Rotation = new float3(20.8f, 55.3f, 6.9f), }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.BlueViolet, float4.Zero), SimpleMeshes.CreateCuboid(new float3(4, 4, 4)) } }, new SceneNode { Components = { _cubeTransform, new Transform{ Translation = new float3(12, -15, 17), Rotation = new float3(34f, 0.03f * Time.DeltaTime, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Wheat, float4.Zero), SimpleMeshes.CreateCuboid(new float3(6, 6, 6)) } }, new SceneNode { Components = { _cubeTransform, new Transform{ Translation = new float3(0, 15, -15), Rotation = new float3(6.9f, 0.3f * Time.DeltaTime, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero), SimpleMeshes.CreateCuboid(new float3(3, 3, 3)) } }, new SceneNode { Components = { _cubeTransform, new Transform{ Translation = new float3(-25, -10, 8), Rotation = new float3(0, 6.9f, 67.2f) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Yellow, float4.Zero), SimpleMeshes.CreateCuboid(new float3(2, 2, 2)) } } } }; // Create a scene renderer holding the scene above _sceneRenderer = new SceneRendererForward(_scene); }
SceneContainer CreateScene() { // Initialize transform components that need to be changed inside "RenderAFrame" _baseTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0) }; _bodyTransform = new Transform { Rotation = new float3(0, 1.2f, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 6, 0) }; _upperArmTransform = new Transform { Rotation = new float3(0.8f, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(2, 4, 0) }; _foreArmTransform = new Transform { Rotation = new float3(0.8f, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(-2, 8, 0) }; _baseHandTransform = new Transform { Rotation = new float3((float)Math.PI, 0, (float)Math.PI / 2), Scale = new float3(1, 1, 1), Translation = new float3(4, 10, 0) }; _leftHandTransform = new Transform { Rotation = new float3((float)Math.PI / 2, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(-2, 8, 2) }; _rightHandTransform = new Transform { Rotation = new float3((float)Math.PI / 2, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(-2, 0, 2) }; // Setup the scene graph return(new SceneContainer { Children = new List <SceneNode> { // GREY BASE new SceneNode { Components = new List <SceneComponent> { // TRANSFROM COMPONENT _baseTransform, // SHADER EFFECT COMPONENT MakeEffect.FromDiffuseSpecular((float4)ColorUint.LightGrey, float4.Zero), // MESH COMPONENT SimpleMeshes.CreateCuboid(new float3(10, 2, 10)) } }, // RED BODY new SceneNode { Components = new List <SceneComponent> { _bodyTransform, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Red, float4.Zero), SimpleMeshes.CreateCuboid(new float3(2, 10, 2)) }, Children = new ChildList { // GREEN UPPER ARM new SceneNode { Components = new List <SceneComponent> { _upperArmTransform, }, Children = new ChildList { new SceneNode { Components = new List <SceneComponent> { new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 4, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Green, float4.Zero), SimpleMeshes.CreateCuboid(new float3(2, 10, 2)) } }, // BLUE FOREARM new SceneNode { Components = new List <SceneComponent> { _foreArmTransform, }, Children = new ChildList { new SceneNode { Components = new List <SceneComponent> { new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 4, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero), SimpleMeshes.CreateCuboid(new float3(2, 10, 2)) } }, // HandBase new SceneNode { Components = new List <SceneComponent> { _baseHandTransform, }, Children = new ChildList { new SceneNode { Components = new List <SceneComponent> { new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 4, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.LightGrey, float4.Zero), SimpleMeshes.CreateCuboid(new float3(2, 10, 2)) } }, // HandLeft new SceneNode { Components = new List <SceneComponent> { _leftHandTransform, }, Children = new ChildList { new SceneNode { Components = new List <SceneComponent> { new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero), SimpleMeshes.CreateCuboid(new float3(2, 6, 2)) } } } }, // HandRight new SceneNode { Components = new List <SceneComponent> { _rightHandTransform, }, Children = new ChildList { new SceneNode { Components = new List <SceneComponent> { new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero), SimpleMeshes.CreateCuboid(new float3(2, 6, 2)) } }, } } } } } } } }, } } } }); }
SceneContainer CreateScene() { // Initialize transform components that need to be changed inside "RenderAFrame" _baseTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0) }; _bodyTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 6, 0) }; _upperarmTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(2, 4, 0) }; _forearmTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 8, 0) }; _fingerLeftTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(2, 1, 0) }; _fingerRightTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(-2, 1, 0) }; _fingerUpTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 1, 2) }; _fingerBottomTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 1, -2) }; // Setup the scene graph return(new SceneContainer { Children = new List <SceneNode> { // grey Base new SceneNode { Components = new List <SceneComponent> { // TRANSFORM COMPONENT _baseTransform, // SHADER EFFECT COMPONENT MakeEffect.FromDiffuseSpecular((float4)ColorUint.Black, float4.Zero), // MESH COMPONENT SimpleMeshes.CreateCuboid(new float3(10, 2, 10)) }, Children = { // red body new SceneNode { Components = { _bodyTransform, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Red,float4.Zero), SimpleMeshes.CreateCuboid(new float3(2, 10, 2)) }, Children = { new SceneNode { Components = { _upperarmTransform, }, Children = { new SceneNode { Components = { new Transform { Translation = new float3(0, 4, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Green, float4.Zero), SimpleMeshes.CreateCuboid(new float3(2, 10, 2)) } },// forearm new SceneNode { Components = { _forearmTransform, }, Children = { new SceneNode { Components = { new Transform { Translation = new float3(-2, 4, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero), SimpleMeshes.CreateCuboid(new float3(2, 10, 2)) }, Children = { // base of the hand new SceneNode { Components = { new Transform { Translation = new float3(0, 5, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero), SimpleMeshes.CreateCuboid(new float3(5, 1, 5)) }, Children = { new SceneNode { Components = { _fingerUpTransform, }, Children = { new SceneNode { Components = { new Transform { Translation = new float3(0, 1.5f, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.White, float4.Zero), SimpleMeshes.CreateCuboid(new float3(1, 4, 1)) } } } }, new SceneNode { Components = { _fingerLeftTransform }, Children = { new SceneNode { Components = { new Transform { Translation = new float3(0, 1.5f, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.White, float4.Zero), SimpleMeshes.CreateCuboid(new float3(1, 4, 1)) } } } }, new SceneNode { Components = { _fingerRightTransform, }, Children = { new SceneNode { Components = { new Transform { Translation = new float3(0, 1.5f, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.White, float4.Zero), SimpleMeshes.CreateCuboid(new float3(1, 4, 1)) } } } }, new SceneNode { Components = { _fingerBottomTransform, }, Children = { new SceneNode { Components = { new Transform { Translation = new float3(0, 1.5f, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.White, float4.Zero), SimpleMeshes.CreateCuboid(new float3(1, 4, 1)) } } } } } } }, } } } } } } } } } } }); }
SceneContainer CreateScene() { // Initialize transform components that need to be changed inside "RenderAFrame" _baseTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0) }; _bodyTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 6, 0) }; _upperArmTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(2, 4, 0) }; _foreArmTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(-2, 4, 0) }; _bindingHandTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 6, 0) }; _firstHandTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0) }; _secondHandTransform = new Transform { Rotation = new float3(0, 0, 0), Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0) }; // Setup the scene graph return(new SceneContainer { Children = new List <SceneNode> { //Grey Base new SceneNode { Components = new List <SceneComponent> { // TRANSFORM COMPONENT _baseTransform, // SHADER EFFECT COMPONENT MakeEffect.FromDiffuseSpecular((float4)ColorUint.LightGrey, float4.Zero), // MESH COMPONENT SimpleMeshes.CreateCuboid(new float3(10, 2, 10)) }, Children = { //red Body new SceneNode { Components = { _bodyTransform, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Red,float4.Zero), SimpleMeshes.CreateCuboid(new float3(2, 10, 2)) }, Children = { //green UpperArm new SceneNode { Components = { _upperArmTransform, }, Children = { new SceneNode { Components = { new Transform { Translation = new float3(0, 4, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Green, float4.Zero), SimpleMeshes.CreateCuboid(new float3(2, 10, 2)) }, Children = { //blue ForeArm new SceneNode { Components = { _foreArmTransform, }, Children = { new SceneNode { Components = { new Transform { Translation = new float3(0, 4, 0) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero), SimpleMeshes.CreateCuboid(new float3(2, 10, 2)) }, Children = { //bindingPiece new SceneNode { Components = { _bindingHandTransform, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Aquamarine,float4.Zero), SimpleMeshes.CreateCuboid(new float3(3, 2, 3)) }, Children = { //Greifhand firsthand new SceneNode { Components = { _firstHandTransform, }, Children = { new SceneNode { Components = { new Transform { Translation = new float3(0, 2, -1) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Turquoise, float4.Zero), SimpleMeshes.CreateCuboid(new float3(1, 4, 1)) } }, // Greifhand secondHand new SceneNode { Components = { _secondHandTransform, }, Children = { new SceneNode { Components = { new Transform { Translation = new float3(0, 2, 1) }, MakeEffect.FromDiffuseSpecular((float4)ColorUint.Turquoise, float4.Zero), SimpleMeshes.CreateCuboid(new float3(1, 4, 1)) } } } } } } } } } } } } } } } } } } } } } }); }