Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (788)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (860)
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 3774 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.

Julien Gouesse | Personal blog | Website | Jogamp
Offline theagentd
« 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  

hadezbladez (2078 views)
2018-11-16 13:46:03

hadezbladez (796 views)
2018-11-16 13:41:33

hadezbladez (2047 views)
2018-11-16 13:35:35

hadezbladez (412 views)
2018-11-16 13:32:03

EgonOlsen (3441 views)
2018-06-10 19:43:48

EgonOlsen (3663 views)
2018-06-10 19:43:44

EgonOlsen (2270 views)
2018-06-10 19:43:20

DesertCoockie (2991 views)
2018-05-13 18:23:11

nelsongames (3059 views)
2018-04-24 18:15:36

nelsongames (3724 views)
2018-04-24 18:14:32
Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20 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!