Author Topic: 2d layer in 3d world, occlusion problem  (Read 2219 times)

Offline wehnsdaefflae

  • byte
  • *
  • Posts: 2
    • View Profile
2d layer in 3d world, occlusion problem
« on: February 03, 2013, 04:52:43 pm »
hello! i am trying to implement a game for android using jpct-ae. the view shows a space ship in quasi orthogonal projection (camera is far away, fov is very small) and from an isometric perspective (camera direction is 116.57 deg, 116.57 deg, 126.87 deg). the image below shows the result.

the image also shows a layer between camera and ship. i was trying to use a 2d layer to show the ships interior. i stumbled upon some possible ways to implement that, but everything has its drawbacks it seems. also, surely i am missing some alternatives.

the following are my ideas and the according problems. id be grateful if someone could push me in the right direction.

-blit the layer as texture in the framebuffer
 problems: alignment ship-layer when moving, zooming the view and 3d objects cannot be on top of layer (maybe relevant for sfx)
-put a 3dobject plane in the same world between camera and ship
 problems: offset due to the *quasi* orthogonal projection
-put a 3dobject plane in a new world at same position as the ship, first, render the ship, then the plane
 problems: the framebuffer doesnt seem to care in what order World.draw(FrameBuffer fb) was called. maybe it shouldnt, but i was expecting to be able to first draw the ship from one world, and then draw over *those* pixels in the framebuffer that are defined by the plane in the second world.
-put a 3dobject plane in the world at the ships position and make it nonoccludable *only* for the ship
 problems: how?

itd be cool if someone could help. thanks!

edit: oh. maybe i didnt make clear that by "ships interior" i dont mean the inside of the 3d model, but an isometric, 2.5d pixel art texture that i intend to map onto the layer.

[attachment deleted by admin]
« Last Edit: February 03, 2013, 06:01:12 pm by wehnsdaefflae »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: 2d layer in 3d world, occlusion problem
« Reply #1 on: February 03, 2013, 08:55:51 pm »
the framebuffer doesnt seem to care in what order World.draw(FrameBuffer fb) was called. maybe it shouldnt, but i was expecting to be able to first draw the ship from one world, and then draw over *those* pixels in the framebuffer that are defined by the plane in the second world.
I'm not 100% sure what you want to achieve and what the actual problem is. But if you draw two different worlds into the same buffer, they will be drawn in the order in which you are doing it. However, maybe what you need is to add a call to http://www.jpct.net/jpct-ae/doc/com/threed/jpct/FrameBuffer.html#clearZBufferOnly() between the two draw calls to clear the depth buffer.

Offline wehnsdaefflae

  • byte
  • *
  • Posts: 2
    • View Profile
Re: 2d layer in 3d world, occlusion problem
« Reply #2 on: February 07, 2013, 02:14:09 am »
That did it. Thanks!