public override void Init() { _world = new World(RC); // load mesh as geometry var geo1 = MeshReader.LoadGeometry("Assets/Cube.obj.model"); // create and set shader var sp = RC.CreateShader(VsSimpleTexture, PsSimpleTexture); RC.SetShader(sp); var material = new ShaderMaterial(sp); // load a texture and write a text on it var imgData = RC.LoadImage("Assets/cube_tex.jpg"); imgData = RC.TextOnImage(imgData, "Verdana", 80f, "FUSEE rocks!", "Black", 0, 30); var iTex = RC.CreateTexture(imgData); Texture1Param = sp.GetShaderParam("texture1"); RC.SetShaderParamTexture(Texture1Param, iTex); // add object with material _world.AddObject(geo1, material, 0, 0, 500); RC.ClearColor = new float4(0.1f, 0.1f, 0.1f, 1); }
public override void Init() { _sceneManager = new SceneManager(); _sceneManager.AttachToContext(RC); var spot = new SpotLight(new float3(0, 0, 0), new float3(0, 0, 0), new float4(0.7f, 0.7f, 0.7f, 1), new float4(0.3f, 0.3f, 0.3f, 1), new float4(0.1f, 0.1f, 0.1f, 1), (float)Math.PI / 8, 0); var sphereGeom = MeshReader.LoadGeometry("Assets/Sphere.obj.model"); var spaceboxGeom = MeshReader.LoadGeometry("Assets/Spacebox.obj.model"); var lampGeom = MeshReader.LoadGeometry("Assets/Lamp.obj.model"); // main objects var worldOrigin = new SceneEntity("WorldOrigin", new MouseAction()); var cameraholder = new SceneEntity("CameraOwner", new CamScript()) { Transform = { GlobalPosition = new float3(0, 0, 10) } }; worldOrigin.AddChild(cameraholder); _sceneCamera = new Camera(cameraholder); _sceneCamera.Resize(Width, Height); var root = new SceneEntity("Root1", new MouseAction()) { Transform = { GlobalPosition = new float3(0, 0, 0), GlobalScale = new float3(1, 1, 1) } }; var sphere = new SceneEntity("Sphere", new ActionCode(), new SpecularMaterial(RC, MoreShaders.GetSpecularShader(RC), "Assets/metall.jpg"), new Renderer(sphereGeom)) { Transform = { GlobalPosition = new float3(2, 0, 0), GlobalScale = new float3(0.5f, 0.5f, 0.5f) } }; var cube = new SceneEntity("Sphere2", new ActionCode(), new BumpMaterial(RC, MoreShaders.GetBumpDiffuseShader(RC), "Assets/metall.jpg", "Assets/normal.jpg"), new Renderer(sphereGeom)) { Transform = { GlobalPosition = new float3(5, 0, 0) } }; var light = new SceneEntity("Light", new ActionCode()); var spaceBox = new SceneEntity("Spacebox", new DiffuseMaterial(RC, MoreShaders.GetDiffuseTextureShader(RC), "Assets/sky.jpg"), new Renderer(spaceboxGeom)); spaceBox.Transform.GlobalScale = new float3(0.5f, 0.5f, 0.5f); spaceBox.Transform.LocalEulerAngles = new float3(-90, 90, 0); _sceneManager.AddSceneEntity(worldOrigin); _sceneManager.AddSceneEntity(root); _sceneManager.AddSceneEntity(sphere); _sceneManager.AddSceneEntity(cube); _sceneManager.AddSceneEntity(light); _sceneManager.AddSceneEntity(spaceBox); // LightObject var lamp = new SceneEntity("DirLight", new RotateAction(new float3(0, 20, 0)), new DiffuseMaterial(RC, MoreShaders.GetDiffuseTextureShader(RC), "Assets/metall.jpg"), new Renderer(lampGeom)) { Transform = { GlobalPosition = new float3(0, 0, 0), GlobalScale = new float3(0.7f, 0.7f, 0.7f) } }; light.AddChild(lamp); lamp.AddComponent(spot); _sceneManager.StartActionCode(); RC.ClearColor = new float4(1, 0, 0, 1); }
public override void Init() { _sceneManager = new SceneManager(); _sceneManager.AttachToContext(RC); var dir = new DirectionalLight(new float3(0, 10, -1), new float4(1, 1, 1, 1), new float4(1, 1, 1, 1), new float4(1, 1, 1, 1), new float3(0, 0, 0), 0); var stativ = new SceneEntity("stativ", new ActionCode()) { Transform = { GlobalPosition = new float3(0, 0, 100) } }; stativ.AddComponent(dir); _sceneManager.AddSceneEntity(stativ); _camera = new Camera(stativ); _camera.Resize(Width, Height); Geometry sohGeo = MeshReader.LoadGeometry("Assets/Sphere.obj.model"); _sphere = new SceneEntity("sphere", new SphereMaterial(MoreShaders.GetDiffuseColorShader(RC)), new Renderer(sohGeo)); _sceneManager.AddSceneEntity(_sphere); _channel2 = new Channel <float3>(Lerp.Float3Lerp); _channel1 = new Channel <float4>(Lerp.Float4Lerp, new float4(0.5f, 0.5f, 0.5f, 0.5f)); var key0 = new Keyframe <float4>(0, new float4(1, 0, 1, 1)); var key1 = new Keyframe <float4>(2, new float4(0.125f, 1, 0.125f, 1)); var key2 = new Keyframe <float4>(4, new float4(0.250f, 0.75f, 0.250f, 1)); var key3 = new Keyframe <float4>(6, new float4(0.5f, 0.5f, 0.5f, 1)); var key4 = new Keyframe <float4>(8, new float4(0.75f, 0.25f, 0.75f, 1)); var key5 = new Keyframe <float4>(10, new float4(1, 25, 0.125f, 1)); var key6 = new Keyframe <float4>(0, new float4(0, 1, 0, 1)); _channel1.AddKeyframe(key0); _channel1.AddKeyframe(key1); _channel1.AddKeyframe(key2); _channel1.AddKeyframe(key3); _channel1.AddKeyframe(key4); _channel1.AddKeyframe(key5); _channel1.AddKeyframe(key6); var key40 = new Keyframe <float3>(8, new float3(8, 0, 80)); var key00 = new Keyframe <float3>(0, new float3(0, 0, 0)); var key10 = new Keyframe <float3>(2, new float3(1, 2, 20)); var key20 = new Keyframe <float3>(4, new float3(2, 4, 40)); var key30 = new Keyframe <float3>(6, new float3(4, 4, 60)); var key50 = new Keyframe <float3>(12, new float3(0, 4, 60)); var key60 = new Keyframe <float3>(0, new float3(8, 8, 8)); _channel2.AddKeyframe(key00); _channel2.AddKeyframe(key10); _channel2.AddKeyframe(key20); _channel2.AddKeyframe(key30); _channel2.AddKeyframe(key40); _channel2.AddKeyframe(key50); _channel2.AddKeyframe(key60); _myAnim.AddAnimation(_channel1, RC, "ClearColor"); _myAnim.AddAnimation(_channel2, _sphere, "Transform.GlobalPosition"); }