Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (565)
Games in Android Showcase (151)
games submitted by our members
Games in WIP (606)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Problem on overlapped region  (Read 1987 times)
0 Members and 1 Guest are viewing this topic.
Offline clement

Junior Newbie

« Posted 2012-09-20 23:03:33 »

there are two size rectangles.  The small one is red and placed inside the big one (green).  My problem is that two rectangles are overlapped and the colors sometimes show red and green if I rotated the camera.  I would like to know how to do to prevent this problem.  I want to show red color on smaller rectangle only.  Thanks.
Offline sproingie

JGO Kernel

Medals: 202

« Reply #1 - Posted 2012-09-20 23:06:58 »

Can you post a screenshot of the behavior you're getting?  And what are you using for your graphics?  Java2D, Slick, LWJGL, something else?

Offline clement

Junior Newbie

« Reply #2 - Posted 2012-09-20 23:49:18 »

bigger rectangle is green and smaller is blue.  When zooming or rotating the camera, the blue color will disappear sometimes.  I would like the blue is solid on the surface of green rectangle.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline erikd

JGO Ninja

Medals: 16
Projects: 4
Exp: 14 years


« Reply #3 - Posted 2012-09-21 13:36:04 »

It seems what you're seeing is something sometimes called "z-buffer fighting": There are different polygons that have the same z-values in the z-buffer, so it will become a matter of rounding differences deciding which block will become visible.

You could try to prevent this situation of the 2 blocks occupying the same space (i.e. just make the green block smaller so they don't overlap anymore).
If the blue block is really a bit wider/deeper than the green one (which is just taller), you could try to improve the situation by moving the camera's near-plane a bit forward (although this is not the best solution).

Offline theBasicMelon

Junior Devvie

Projects: 2

« Reply #4 - Posted 2012-09-21 15:58:39 »

What are you trying to achieve by having two cubes in the same place? If it's just for the colour difference then maybe you could just use a texture.  Tongue
Offline gouessej
« Reply #5 - Posted 2012-09-21 18:23:46 »

erikd is right, use glPolygonOffset or use 2 quads with no overlap.

Offline theagentd

« JGO Bitwise Duke »

Medals: 410
Projects: 2
Exp: 8 years

« Reply #6 - Posted 2012-09-22 01:07:03 »

What are your z-values for the near plane and the far plane?

Offline clement

Junior Newbie

« Reply #7 - Posted 2012-09-24 05:53:31 »

Thanks for all your replied.  Two cubes are possible to move anywhere, so I cannot make different z positions.  Is glPolygonOffset able to fix the problem?  Any good example for using glPolygonOffset?  Thanks.
Offline clement

Junior Newbie

« Reply #8 - Posted 2012-09-24 07:13:55 »

All cubes are printed by order.  Is possible the last order cube overlap the previous cube?  For example, both cubs are overlapped in some surfaces. Green cube is printed first and blue cube is printed second.  Can jogl allow to display blue cube color on overlapped surfaces only?
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

ags1 (21 views)
2015-03-31 10:55:12

theagentd (13 views)
2015-03-27 23:08:20

wxwsk8er (54 views)
2015-03-20 15:39:46

Fairy Tailz (48 views)
2015-03-15 21:52:20

Olo (29 views)
2015-03-13 17:51:59

Olo (33 views)
2015-03-13 17:50:51

Olo (40 views)
2015-03-13 17:50:16

Olo (44 views)
2015-03-13 17:47:07

ClaasJG (61 views)
2015-03-10 11:36:42

ClaasJG (44 views)
2015-03-10 11:33:01
How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!