Japanese | English | Korean

Samples

Preventing Z-sort rendering mistakes under certain circumstances

MascotCapsule V3 uses the Z-sort method for hidden surface removal to simultaneously render multiple models with very different sizes, for example, when a small object is placed on a large surface, etc. In such cases, models are sometimes not rendered correctly because of Z-sorting mistakes. If the positional relationship of polygons is known in advance, separately execute the rendering and flush processes for particular objects, in order to avoid such rendering mistakes.


In order to render the small object when it is placed on the large surface as stated above, execute the rendering and flush processes to the large surface first, and then execute the rendering and flush processes to the small object. Let's call this a "double-flush" method, for purposes of explanation. In the sample program, a small surface and a small sphere are placed on a large surface. When they are normally rendered, the small surface and the sphere will be partly hidden. However, they are rendered correctly by using the double-flush method.

Let's take a look at the portion of the sample code that executes the double-flush process. Normal rendering and the double-flush process are switched when the soft key is pressed-down.

public void paint( Graphics g ) {
g.setColor( bgc );           // Background color ( Entire scene )
g.fillRect( 0, 0, getWidth(), getHeight() );

g3d.bind( g );

if( isDouble ){
/* Double-flush */
g3d.renderFigure( planeBig, 0, 0, layout, effect );
g3d.flush();
g3d.renderFigure( planeSmall, 0, 0, layout, effect );
g3d.flush();
g3d.renderFigure( sphereSmall, 0, 0, layout, effect );
g3d.flush();
}else{
g3d.renderFigure( planeBig, 0, 0, layout, effect );
g3d.renderFigure( planeSmall, 0, 0, layout, effect );
g3d.renderFigure( sphereSmall, 0, 0, layout, effect );
g3d.flush();
}
g3d.release( g );
}
 
 Rendering using double-flush    Rendering without double-flush