I'm building a game using the GameEngine2D and is working great
but now I want to add a 3D element on top of it,
how can I do that?
is just 3D elements on top, like in another layer totally separate.
thanks for the help.
Thank you for your question. Yes, you can mix GameEngine2D with your 3D modelling. The GameEngine2D library does it's rendering onto the GraphicsContext, so you will just need to ensure that you control the rendering order between your 3D elements and the GE2D. When specifying which Scene to run with, it would be best if you use a manual loop (set boolean to true in RunWithScene) and then add your Director.Instance.Update() and Director.Instance.Render() respectively.
If you would like any further help, please do not hesitate to ask and we can post a sample.
it would be very helpful to have an example of that
cause I'm having another issue with updates and that might help with that too.
Not a problem
I'll use BasicModelSample as a basis to overlay a GE2D SpriteUV on top of the 3D model (like a HUD).
1. You'll first want to delcare another static variable for the BasicModelSample class, as follows:
public static Scene scene;
2. We can then initialize the Director, instantiate the Scene and then setup the SpriteUV in the Init() method.
Director.Initialize(300, 300, graphics); scene= new Scene(); scene.Camera.SetViewFromViewport(); Texture2D text = new Texture2D("/Application/shoot.jpg", false); TextureInfo info = new TextureInfo(text); SpriteUV sprite = new SpriteUV(); sprite.TextureInfo = info; sprite.Scale = info.TextureSizef; sprite.Position = new Vector2(200, 200); scene.AddChild(sprite); Director.Instance.RunWithScene(scene, true);
By calling RunWithScene() and passing in true for the manual loop, this tells the GameEngine2D library that we'll be handling the calling of the update and render methods that it requires.
3. We now need to call the Update() method on the Director. At the start of the Draw() method in BasicModelSample, add the following line.
4. Get the Director to Render().You'll want to place this after the call to graphics.Clear() and before graphics.SwapBuffers()
5.Post swap, should be called after the call to graphics.SwapBuffers()
Hope this helps,
well, I can run it but I can't see any difference in the result
can you switch it?, cause I already have all this stuff build using GE2D and I want to add the 3D elements to that
I kinda get what's happening but I don't want to destroy what I already have hehe
now the issue is, the model is BEHIND my GE2D elements,
how can I put the 3D in front and the GE2D behind?
thanks for the help
Hope this helps.
yeah it works is on top now, but I can't se the game now, the 3D model comes with the gl clear color, so it's covering the whole thing, how can I just declare like and alpha channel or something.
so what I'm saying is the 3d layer of this mix, has a barkground right, that you declare with the
graphics.SetClearColor(0.0f, 0.0f, 0.0f, 0.5f);
and that is what is covering the whole screen and the GE2D layer of the mix is behind that
I'm thinking, set the model as it's alpha to blend it or something, set the clear color to nothing, but that's silly
thanks for the help man you rock!!