public GUI(RenderContext rc) { //Basic Init _fontSmall = rc.LoadFont("Assets/Cabin.ttf", 12); _fontMedium = rc.LoadFont("Assets/Cabin.ttf", 18); _fontBig = rc.LoadFont("Assets/Cabin.ttf", 40); _guiHandler = new GUIHandler(); _guiHandler.AttachToContext(rc); //Start Pannel Init _guiPanel = new GUIPanel("PhysicsTest", _fontMedium, 10, 10, 330, 250); _info1 = new GUIText("Über die Tasten des Nummernblocks " , _fontMedium, 30, 170, _color2); _info2 = new GUIText("(1-4) kann zwischen 4 verschiedenen ", _fontMedium, 30, 190, _color2); _info3 = new GUIText("Szenen gewechselt werden", _fontMedium, 30, 210, _color2); _fps = new GUIText("FPS", _fontMedium, 30, 55, _color2); _numberRb = new GUIText("Rigidbodies: ", _fontMedium, 30, 85, _color2); _shapeType = new GUIText("Collision Shapes: ", _fontMedium, 30, 115, _color2); _shapes = new GUIText("", _fontMedium, 50, 135, _color2); _guiPanel.ChildElements.Add(_info1); _guiPanel.ChildElements.Add(_info2); _guiPanel.ChildElements.Add(_info3); _guiPanel.ChildElements.Add(_fps); _guiPanel.ChildElements.Add(_numberRb); _guiPanel.ChildElements.Add(_shapeType); _guiPanel.ChildElements.Add(_shapes); ShowGUI(); }
public void InitShaders(RenderContext rc) { if (rc != _rc) { _rc = rc; _meshMap = new Dictionary<MeshContainer, Mesh>(); _matMap = new Dictionary<MaterialContainer, ShaderEffect>(); _curMat = null; } if (_curMat == null) { _curMat = MakeMaterial(new MaterialContainer { Diffuse = new MatChannelContainer() { Color = new float3(0.5f, 0.5f, 0.5f) }, Specular = new SpecularChannelContainer() { Color = new float3(1, 1, 1), Intensity = 0.5f, Shininess = 22 } }); CurMat.AttachToContext(rc); } }
public override void Update(RenderContext renderContext) { renderContext.SetShader(sp); renderContext.SetShaderParamTexture(Textureparam, Tex); renderContext.SetShaderParam(Shininess, 16.0f); renderContext.SetShaderParam(SpecularLevel, 256.0f); }
public Sheep(RenderContext rc, float3 position, float3 rotation, float3 scaleFactor, SceneRenderer sc, Game game) : base(rc, position, rotation, scaleFactor, sc) { _distance = position.Length; if (_distance > 60) { _score = 120; } if (_distance > 40) { _score = 80; } else { _score = 50; } Speed = (5 / _distance) * game.Level; Radius = 4f; _game = game; Pos = position; _alpha = (float)Math.Tan(Pos.z/Pos.x); Tag = "Sheep"; _level = 1; //zufällige Wellenbewegung if (position.x % 2 == 0) { TheWave = SinWave; } else { TheWave = CosWave; } }
public Skybox(RenderContext rc) { // load texture imgData = rc.LoadImage("Assets/skyboxOberflächenfarbe.jpg"); _iTex = rc.CreateTexture(imgData); _rc = rc; _syboxMesh = MeshReader.LoadMesh(@"Assets/skybox.obj.model"); }
public GameHandler(RenderContext rc, RenderCanvas rCanvas) { RCanvas = rCanvas; this.Rc = rc; this.gui = new Gui(Rc, RCanvas, this); this.GameState = new GameState(ref gui, this); // DbConnection =new DbConnection(this); }
/// <summary> /// Sets the ViewMatrix in the RenderContext. /// </summary> /// <param name="renderContext">The RenderContext that handles the rendering.</param> public override void SubmitWork(RenderContext renderContext) { if(_dirty) { renderContext.Projection = _projection; } renderContext.View=_matrix; }
public Tomato(RenderContext rc, float3 position, float3 rotation, float3 scaleFactor,SceneRenderer sc, RigidBody tomatoRigidBody, Game game, DynamicWorld world) : base(rc, position, rotation, scaleFactor, sc) { TomatoRb = tomatoRigidBody; Radius = 2f; Tag = "Tomato"; timer = 2.0f; _game = game; _world = world; }
public Weapon(DynamicWorld world, Game game) { _click = true; _world = world; _sphereCollider = _world.AddSphereShape(1); _game = game; _srTomato = _game.SceneLoader.LoadTomato(); Magazin = 10; imgData = game.RC.LoadImage("Assets/TomateOberflächenfarbe.jpg"); RC = game.RC; }
public GameWorld(RenderContext rc) { _rc = rc; _currentGameState = (int)GameState.StartScreen; _camMatrix = float4x4.CreateTranslation(0, -400, 0); _gui = new GUI(rc, this); _player = new Player("Assets/rocket3.protobuf.model", rc); _player.SetShader("Assets/rocket3.png", "Assets/toon_generic_4_tex.png", new float4(0, 0, 0, 1), new float2(5, 5)); _player.SetCorrectionMatrix(float4x4.CreateRotationX((float)-Math.PI / 2) * float4x4.CreateTranslation(-30, 0, 0) * float4x4.Scale(0.5f)); _room = new GameEntity("Assets/spacebox.obj.model", rc, 150, 1600, -1700); _room.SetShader(new float4(1, 1, 1, 1), "Assets/toon_room_7_tex.png", new float4(0, 0, 0, 1), new float2(15, 15)); _room.SetCorrectionMatrix(float4x4.Scale(13, 8, 19)); _furniture.Add(new GameEntity("Assets/rocket3.protobuf.model", rc, -1900, 0, -5000)); _furniture[0].SetShader("Assets/rocket3.png", "Assets/toon_generic_4_tex.png", new float4(0, 0, 0, 1), new float2(15, 15)); _furniture[0].SetCorrectionMatrix(float4x4.Scale(5)); _furniture.Add(new GameEntity("Assets/chair.protobuf.model", rc, 1600, 0, -4100, 0, 2.6f)); _furniture[1].SetShader("Assets/chair.png", "Assets/toon_generic_4_tex.png", new float4(0, 0, 0, 1), new float2(15, 15)); _furniture[1].SetCorrectionMatrix(float4x4.Scale(29)); _furniture.Add(new GameEntity("Assets/desk.protobuf.model", rc, 1500, 0, -4950)); _furniture[2].SetShader("Assets/desk.png", "Assets/toon_generic_4_tex.png", new float4(0, 0, 0, 1), new float2(15, 15)); _furniture[2].SetCorrectionMatrix(float4x4.Scale(5)); _furniture.Add(new GameEntity("Assets/bed.protobuf.model", rc, 1800, 0, 800)); _furniture[3].SetShader("Assets/bed.png", "Assets/toon_generic_4_tex.png", new float4(0, 0, 0, 1), new float2(15, 15)); _furniture[3].SetCorrectionMatrix(float4x4.Scale(13)); _furniture.Add(new GameEntity("Assets/drawer.protobuf.model", rc, -700, 0, 1850, 0, (float)Math.PI)); _furniture[4].SetShader("Assets/drawer.png", "Assets/toon_generic_4_tex.png", new float4(0, 0, 0, 1), new float2(15, 15)); _furniture[4].SetCorrectionMatrix(float4x4.Scale(14)); _furniture.Add(new GameEntity("Assets/football.obj.model", rc, -1200, 0, 1000)); _furniture[5].SetShader("Assets/football.png", "Assets/toon_generic_4_tex.png", new float4(0, 0, 0, 1), new float2(15, 15)); _furniture[5].SetCorrectionMatrix(float4x4.Scale(4)); _furniture.Add(new GameEntity("Assets/book.protobuf.model", rc, 500, 1030, -4950, 0, 1)); _furniture[6].SetShader("Assets/book.png", "Assets/toon_generic_4_tex.png", new float4(0, 0, 0, 1), new float2(15, 15)); _furniture[6].SetCorrectionMatrix(float4x4.Scale(35)); _targets.Add(new Target("Assets/cube.obj.model", rc, 1500, 1500, -4950, (float)Math.PI / 4, (float)Math.PI / 4, (float)Math.PI / 4)); _targets[0].SetCorrectionMatrix(float4x4.Scale(0.5f)); _targets.Add(new Target("Assets/cube.obj.model", rc, -1200, 800, 1000, (float)Math.PI / 4, (float)Math.PI / 4, (float)Math.PI / 4)); _targets[1].SetCorrectionMatrix(float4x4.Scale(0.5f)); _maxScore = _targets.Count; }
public GameObject(RenderContext rc, float3 position, float3 rotation, float3 scaleFactor, SceneRenderer sc) { SceneRenderer = sc; _rc = rc; _scale = scaleFactor; ObjectMtx = float4x4.CreateRotationX(rotation.x) *float4x4.CreateRotationY(rotation.y) *float4x4.CreateRotationZ(rotation.z) *float4x4.CreateTranslation(position); Rotation = rotation; Tag = "GameObject"; }
public Level(RenderContext rc, ShaderProgram sp, int id, Stereo3D stereo3D) { ObjRandom = new Random(); VColorObj = sp.GetShaderParam("vColor"); VTextureObj = sp.GetShaderParam("vTexture"); RContext = rc; _stereo3D = stereo3D; UseStereo3D = false; ConstructLevel(id); }
public World(RenderContext renderCon) { _rc = renderCon; _objects = new List<Object>(); _globalPosX = 0; _globalPosY = 0; _globalPosZ = 0; _globalAngleX = 0; _speed = 7; _rotationSpeedM = 15; _rotationSpeed = 0.015f; }
// Konstruktor public GUIRender(RenderContext rc, BeeTheGame thisGame) { RC = rc; _game = thisGame; //GUIHandler an den Kontext anhaengen _guiHandler = new GUIHandler(); _guiHandler.AttachToContext(rc); //Bilder einbinden _guiImageDummy = new GUIImage("Assets/dummy.png", 0, 0, 0, 5, 5); _guiImageBarText = new GUIImage("Assets/nectarCollected.png", 10, 10, -1, 153, 23); _guiImageStartBack = new GUIImage("Assets/background.png", 0, 0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height/9)*2); _guiImageGameHelp = new GUIImage("Assets/gameHelp.png", 0, 0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height/9)*2); _guiImageStartBee = new GUIImage("Assets/beePlaceholder.png", 200, 30, 1, 130, 118); _guiImageStartPlay = new GUIImage("Assets/play.png", (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width/2 - 300/2), 0, 2, 300, (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height/9)*2); _guiImageHelpButton = new GUIImage("Assets/helpButton.png", 10, 10, 2, 41, 50); _guiImageHelpOne = new GUIImage("Assets/helpOne.png", 100, 10, 1, 300, 129); _guiImageHelpTwo = new GUIImage("Assets/helpTwo.png", 950, 20, 1, 300, 130); //Text _guiFontArial24 = RC.LoadFont("Assets/arial.ttf", 16); _guiArial24 = new GUIText("Score: ", _guiFontArial24, 1200, 25); _guiArial24.TextColor = new float4(1, 1, 1, 1); //Button _guiButtonPlay = new GUIButton((System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width/2 - 300/2), 0, 3, 300, (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height/9)*2); _guiButtonPlay.ButtonColor = new float4(0, 0, 0, 0); _guiButtonPlay.BorderColor = new float4(0, 0, 0, 1); _guiButtonPlay.BorderWidth = 0; _guiButtonHelp = new GUIButton(10, 10, 1, 50, 50); //Buttonfarbe setzen _guiButtonHelp.ButtonColor = new float4(0, 0, 0, 0); _guiButtonHelp.BorderColor = new float4(0, 0, 0, 1); _guiButtonHelp.BorderWidth = 0; //an den Handler anhaengen _guiHandler.Add(_guiImageDummy); _guiHandler.Add(_guiImageBarText); _guiImagePause = new GUIImage("Assets/gamePaused.png", 350, 40, 0, 500, 100); }
public Game(GameHandler gh,RenderContext rc) { _gameHandler = gh; RC = rc; //alle 3D Assets laden SceneLoader = new SceneLoader(); srTomato = SceneLoader.LoadTomato(); srSheep = SceneLoader.LoadSheep(); srTrees = SceneLoader.LoadTrees(); srCows = SceneLoader.LoadCows(); srLandschaft = SceneLoader.LoadEnvironment(); srBuildings = SceneLoader.LoadBuildings(); CreateEnvironment(); //Hürde die zum Austieg zum nächsten level erreicht werden muss _nextLevel = 500; Points = 0; LoadLevel(); _skybox = new Skybox(RC); }
public GUI(RenderContext rc, GameWorld gw) { //Basic Init _gw = gw; _fontSmall = rc.LoadFont("Assets/Cabin.ttf", 12); _fontMedium = rc.LoadFont("Assets/Cabin.ttf", 18); _fontBig = rc.LoadFont("Assets/Cabin.ttf", 40); _guiHandler = new GUIHandler(); _guiHandler.AttachToContext(rc); //Start Pannel Init _startPanel1 = new GUIPanel("RocketGame", _fontMedium, 10, 10, 150, 110); _startPanelButtonStart = new GUIButton("Start", _fontSmall, 10, 30, 130, 30); _startPanelButtonStart.OnGUIButtonDown += OnGUIButtonDown; _startPanelButtonStart.OnGUIButtonUp += OnGUIButtonUp; _startPanelButtonStart.OnGUIButtonEnter += OnGUIButtonEnter; _startPanelButtonStart.OnGUIButtonLeave += OnGUIButtonLeave; _startPanelButtonStuff = new GUIButton("Stuff", _fontSmall, 10, 70, 130, 30); _startPanelButtonStuff.OnGUIButtonDown += OnGUIButtonDown; _startPanelButtonStuff.OnGUIButtonUp += OnGUIButtonUp; _startPanelButtonStuff.OnGUIButtonEnter += OnGUIButtonEnter; _startPanelButtonStuff.OnGUIButtonLeave += OnGUIButtonLeave; _startPanel1.ChildElements.Add(_startPanelButtonStart); _startPanel1.ChildElements.Add(_startPanelButtonStuff); _startPanel2 = new GUIPanel("Find and activate all the red cubes!", _fontMedium, 170, 20, 300, 30); _playPanel = new GUIPanel("Goals found:", _fontMedium, 10, 10, 150, 60); _playScore = new GUIText("", _fontMedium, 48, 45, new float4(1, 0, 0, 1)); _playPanel.ChildElements.Add(_playScore); _overText = new GUIText("Game Over, you Win!", _fontBig, 200, 100, new float4(0, 1, 0, 1)); ShowStartGUI(); }
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 FuseeSerializer(); 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 static ShaderEffect GetShaderEffect(RenderContext rc, ITexture iTexture) { EffectPassDeclaration[] epd = { new EffectPassDeclaration { VS = VsSimpleTexture, PS = PsSimpleTexture, StateSet = new RenderStateSet { AlphaBlendEnable = false, ZEnable = true } } }; var shaderEffect = new ShaderEffect(epd, new[] { new EffectParameterDeclaration {Name = "texture1", Value = iTexture} }); shaderEffect.AttachToContext(rc); return shaderEffect; }
public static ShaderEffect GetShaderEffect(RenderContext rc, ITexture baseTexture, ITexture colorMapTexture, float4 lineColor, float2 lineWidth) { EffectPassDeclaration[] epd = { new EffectPassDeclaration { VS = VsSimpleToonPass1, PS = PsSimpleToonPass1, StateSet = new RenderStateSet { AlphaBlendEnable = false, ZEnable = true } }, new EffectPassDeclaration { VS = VsSimpleToonPass2, PS = PsTextureToonPass2, //The only difference to the previous shader definition StateSet = new RenderStateSet { AlphaBlendEnable = false, ZEnable = true } } }; var shaderEffect = new ShaderEffect(epd, new[] { new EffectParameterDeclaration {Name = "uLineColor", Value = lineColor}, new EffectParameterDeclaration {Name = "texture1", Value = colorMapTexture}, new EffectParameterDeclaration {Name = "uLineWidth", Value = lineWidth}, new EffectParameterDeclaration {Name = "texture2", Value = baseTexture} }); shaderEffect.AttachToContext(rc); return shaderEffect; }
/// <summary> /// The SubmitWork method will be overwritten by a visited Component that "want's" to be rendered. /// Therefore a RenderContext is needed. /// </summary> /// <param name="renderContext">The render context.</param> public virtual void SubmitWork(RenderContext renderContext) { }
public static ShaderEffect GetShaderEffect(RenderContext rc, float4 color) { EffectPassDeclaration[] epd = { new EffectPassDeclaration { VS = VsSimpleColor, PS = PsSimpleColor, StateSet = new RenderStateSet { AlphaBlendEnable = false, ZEnable = true } } }; var shaderEffect = new ShaderEffect(epd, new[] { new EffectParameterDeclaration {Name = "color", Value = color} }); shaderEffect.AttachToContext(rc); return shaderEffect; }
public override void Update(RenderContext renderContext) { renderContext.SetShader(sp); renderContext.SetShaderParamTexture(Textureparam, Tex); }
/// <summary> /// Overwrites the SubmitWork method of RenderJob class. Render Component will get shaders and materials and passed to the RenderContextImplementation. /// </summary> /// <param name="renderContext">The render context.</param> public override void SubmitWork(RenderContext renderContext) { _renderer.material.Update(renderContext); SceneManager.Manager.UpdateLights(); }
/// <summary> /// Attaches the object to a specific <see cref="RenderContext"/> object. /// </summary> /// <param name="rc">The <see cref="RenderContext"/> object to be used.</param> public void AttachToContext(RenderContext rc) { _rc = rc; _clearColor = rc.ClearColor; var imgData = _rc.CreateImage(_screenWidth, _screenHeight, "black"); _contentLTex = _rc.CreateTexture(imgData); _contentRTex = _rc.CreateTexture(imgData); // initialize shader and image switch (_activeMode) { case Stereo3DMode.Oculus: _guiLImage = new GUIImage(null, 0, 0, _screenWidth/2, _screenHeight); _guiLImage.AttachToContext(rc); _guiLImage.Refresh(); _guiRImage = new GUIImage(null, _screenWidth/2, 0, _screenWidth/2, _screenHeight); _guiRImage.AttachToContext(rc); _guiRImage.Refresh(); _shaderProgram = _rc.CreateShader(OculusVs, OculusPs); _shaderTexture = _shaderProgram.GetShaderParam("vTexture"); _lensCenterParam = _shaderProgram.GetShaderParam("LensCenter"); _screenCenterParam = _shaderProgram.GetShaderParam("ScreenCenter"); _scaleParam = _shaderProgram.GetShaderParam("Scale"); _scaleInParam = _shaderProgram.GetShaderParam("ScaleIn"); _hdmWarpParam = _shaderProgram.GetShaderParam("HmdWarpParam"); break; case Stereo3DMode.Anaglyph: _shaderProgram = _rc.CreateShader(AnaglyphVs, AnaglyphPs); _shaderTexture = _shaderProgram.GetShaderParam("vTexture"); _guiLImage = new GUIImage(null, 0, 0, _screenWidth, _screenHeight); _guiLImage.AttachToContext(rc); _guiLImage.Refresh(); break; } }
/// <summary> /// Sets the materials shaderprogram onto the rendercontext upon render time. /// </summary> /// <param name="renderContext">The render context that handles the drawing of the application.</param> public virtual void Update(RenderContext renderContext) { renderContext.SetShader(sp); }
/// <summary> /// Inits the canvas for the rendering loop. /// </summary> protected void InitCanvas() { InitImplementors(); _canvasImp.Caption = GetAppName(); _rc = new RenderContext(_renderContextImp); _rc.Viewport(0, 0, Width, Height); Input.Instance.InputImp = _inputImp; Audio.Instance.AudioImp = _audioImp; Input.Instance.InputDriverImp = _inputDriverImp; Network.Instance.NetworkImp = _networkImp; _canvasImp.Init += delegate { Init(); }; _canvasImp.UnLoad += delegate { UnLoad(); }; _canvasImp.Render += delegate { // pre-rendering Network.Instance.OnUpdateFrame(); Input.Instance.OnUpdateFrame(); Time.Instance.DeltaTimeIncrement = _canvasImp.DeltaTime; // rendering RenderAFrame(); // post-rendering Input.Instance.OnLateUpdate(); }; _canvasImp.Resize += delegate { Resize(); }; }
protected override void PreRender(RenderContext rc) { base.PreRender(rc); foreach (var childElement in ChildElements) { childElement.OffsetX = PosX; childElement.OffsetY = PosY; childElement.OffsetZ = PosZ; childElement.Render(rc); } }
/// <summary> /// Passes pointlight's parameters to RenderContext. /// </summary> /// <param name="renderContext">The render context.</param> public override void SubmitWork(RenderContext renderContext) { renderContext.SetLight(_position, _diffuseColor, _ambientColor, _specularColor, (int)_type, _channel); }
public Player(String meshPath, RenderContext rc, float posX = 0, float posY = 0, float posZ = 0, float angX = 0, float angY = 0, float angZ = 0) : base(meshPath, rc, posX, posY, posZ, angX, angY, angZ) { }
/// <summary> /// The SubmitWork method will be overwritten by a visited Component that "want's" to be rendered. /// Therefore a RenderContext is needed. /// </summary> /// <param name="renderContext">The render context.</param> public override void SubmitWork(RenderContext renderContext) { renderContext.Model = _matrix; }