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.
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
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!!