Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (494)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 1733 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


Maximumisness


« 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 Member


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
« Reply #6 - Posted 2012-09-22 01:07:03 »

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

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

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (19 views)
2014-09-12 09:08:26

Norakomi (54 views)
2014-09-10 13:57:51

TehJavaDev (63 views)
2014-09-10 06:39:09

Tekkerue (31 views)
2014-09-09 02:24:56

mitcheeb (53 views)
2014-09-08 06:06:29

BurntPizza (37 views)
2014-09-07 01:13:42

Longarmx (23 views)
2014-09-07 01:12:14

Longarmx (26 views)
2014-09-07 01:11:22

Longarmx (26 views)
2014-09-07 01:10:19

mitcheeb (34 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!