GameEngine2D

Reply

Mixing GameEngine2D with 3D elements

Hi guys

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.

Please use plain text.

Re: Mixing GameEngine2D with 3D elements

HI varo_mix,

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.

Thanks,
James
PlayStation®Mobile Dev Team
Please use plain text.

Re: Mixing GameEngine2D with 3D elements

Thanks James

 

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.

 

thanks again

Please use plain text.

Re: Mixing GameEngine2D with 3D elements

Not a problem :smileywink:

 

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. 

Director.Instance.Update();

 

4. Get the Director to Render().You'll want to place this after the call to graphics.Clear() and before graphics.SwapBuffers()

Director.Instance.Render();

 

5.Post swap, should be called after the call to graphics.SwapBuffers()

Director.Instance.PostSwap();

 

Hope this helps,

James

PlayStation®Mobile Dev Team
Please use plain text.

Re: Mixing GameEngine2D with 3D elements

well, I can run it but I can't see any difference in the result :smileyhappy:

 

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

 

thanks

Please use plain text.

Re: Mixing GameEngine2D with 3D elements

ok I managed to get this working, GE2D and 3D model are on the scene yay!!
now the issue is, the model is BEHIND my GE2D elements,
how can I put the 3D in front and the GE2D behind?

draw order?

thanks for the help
Please use plain text.

Re: Mixing GameEngine2D with 3D elements

Great! You will need to make sure that your model draw calls happen after you have rendered the GameEngine2D elements, so for example in the BasicModelSample, you could move you call to Director.Instance.Reder() to directly after the graphics.Clear() call, and this should do the trick.

Hope this helps.
PlayStation®Mobile Dev Team
Please use plain text.

Re: Mixing GameEngine2D with 3D elements

Hey JAmes

 

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 :smileyhappy:

 

thanks for the help man you rock!!

Please use plain text.
This widget could not be displayed.
Announcements

Welcome to the PlayStation Mobile Developer Forums


This is a community for the discussion of technical topics with other developers and SCE engineers. Posting ideas/requests are also appreciated. Join the discussion!

PlayStation®Mobile開発者フォーラムでは世界中の開発者の皆様と一緒に、議論や情報交換が可能です。SCEも議論に参加し、皆様の開発をサポートします。アイデアやリクエストも大歓迎です。ぜひご参加ください。

PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.

フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと PSM DevPortalを一度ログアウトし、再度ログインしてください。






Recent News