[ Prev | Index | Next ]
Japanese English

Flipping 3D Objects

This section covers how to flip models and polygons. In VCSSL, there are two types of flipping operations for 3D objects:

  • Reverse flipping, which inverts the front and back faces of surfaces
  • Mirror flipping, which creates a mirrored shape along a given axis

Reverse-Flipping a Model

The surfaces of a model have a front and a back side.

Surfaces are rendered only when viewed from the front; the back sides are invisible. For standard models, the outer surfaces are typically the front side, so nothing is visible from the inside.

However, in applications such as game development, there are many cases where you want the inner side of a model to be visible -- for example, when creating a sky dome or a tunnel-like corridor. In such cases, you can use reverse flipping to invert the front and back sides of the model.

Note: As an alternative, you can use the setModelCull(...) function to control whether front or back surfaces should be culled (not drawn).

To perform reverse flipping on a model, use the reverseModel function.

- Function Format -

void reverseModel ( int modelID )

Argument:

  • modelID: The ID of the model to reverse-flip.

Reverse-Flipping a Polygon

Like models, triangle and quadrilateral polygons also have a front and back side. To reverse-flip a polygon, use the reversePolygon(...) function.

- Function Format -

void reversePolygon ( int polygonID )

Argument:

  • polygonID: The ID of the polygon to reverse-flip.

Mirror-Flipping a Model

If you want to flip a model symmetrically, for example across the X-axis, you can perform a mirror flip using the mirrorModel(...) function.

- Function Format -

void mirrorModel (
  int modelID,
  bool xMirror, bool yMirror, bool zMirror
)

Arguments:

  • modelID: The ID of the model to mirror-flip
  • xMirror, yMirror, zMirror: Specify whether to flip in the X, Y, or Z direction ("true" to flip)

Mirror-Flipping a Polygon

To mirror-flip a polygon, use the mirrorPolygon(...) function.

- Function Format -

void mirrorPolygon (
  int polygonID,
  bool xMirror, bool yMirror, bool zMirror
)

Arguments:

  • polygonID: The ID of the polygon to mirror-flip
  • xMirror, yMirror, zMirror: Specify whether to flip in the X, Y, or Z direction ("true" to flip)

Mirror-Flipping Also Inverts Surface Orientation

There's an important point to keep in mind: Performing a mirror flip also inverts the front/back orientation of surfaces.

This occurs because a clockwise vertex order becomes counterclockwise after mirroring (and vice versa). In VCSSL, the front side of a surface is determined by whether the polygon's vertices are arranged in counterclockwise order.

When you apply a mirror flip, this order is reversed -- so what was the front side becomes the back side after the flip.

Therefore, every time you mirror-flip a model or polygon, you should also call "reverseModel" or "reversePolygon" to correct the surface orientation.

Surface Flip After Mirror
Surface Flip After Mirror
A mirror flip reverses the vertex order, turning clockwise into counterclockwise and inverting the surface. A reverse flip is needed to restore the correct orientation.

Example Program

Let's place a cylinder model and apply a mirror flip along the Z direction. Because mirror flipping also reverses the surface orientation, we correct it using reverse flipping. Write and run the following code:


import graphics3d.Graphics3DFramework;
import Graphics3D;

// Function called at the start of the program
void onStart ( int rendererID ) {

	// Optional: Set window size and background color
	setWindowSize( 800, 600 );
	setBackgroundColor( 0, 0, 0, 255 );


	// Create and place axis model
	int axis = newAxisModel( 3.0, 3.0, 3.0 );
	mountModel( axis, rendererID );

	// Create and place first cylinder
	int cylinder1 = newCylinderModel( 1.0, 1.0, 2.0, 20, 1 );
	setModelColor( cylinder1, 255, 0, 0, 255 ); // red
	mountModel( cylinder1, rendererID );

	// Create and place second cylinder
	int cylinder2 = newCylinderModel( 1.0, 1.0, 2.0, 20, 1 );
	setModelColor( cylinder2, 0, 0, 255, 255 ); // blue
	mountModel( cylinder2, rendererID );


	// Mirror-flip the second cylinder in the Z direction
	mirrorModel( cylinder2, false, false, true );
	reverseModel( cylinder2 ); // correct surface orientation
}
Sample.vcssl

When you run this program, two cylinders will appear on a black background: one red and one blue. The blue cylinder is a mirror-flipped version of the red one along the Z-axis.

Execution Result
Execution Result
The blue cylinder appears as a mirror-flipped version of the red one along the Z-axis.



Sponsored Link



Japanese English
Index
[ Prev | Index | Next ]
News From RINEARN
* VCSSL is developed by RINEARN.

English Documentation for Our Software and VCSSL Is Now Nearly Complete
2025-06-30 - We're happy to announce that the large-scale expansion of our English documentation with the support of AI — a project that began two years ago — has now reached its initial target milestone.

VCSSL 3.4.52 Released: Enhanced Integration with External Programs and More
2025-05-25 - This update introduces enhancements to the external program integration features (e.g., for running C-language executables). Several other improvements and fixes are also included. Details inside.

Released: Latest Version of VCSSL with Fixes for Behavioral Changes on Java 24
2025-04-22 - VCSSL 3.4.50 released with a fix for a subtle behavioral change in absolute path resolution on network drives, introduced in Java 24. Details inside.

Released the Latest Versions of RINEARN Graph and VCSSL - Now Supporting Customizable Tick Positions and Labels!
2024-11-24 - Starting with this update, a new "MANUAL" tick mode is now supported, allowing users to freely specify the positions and labels of ticks on the graph. We'll explain the details and how to use it.

Released Exevalator 2.2: Now Compatible with TypeScript and Usable in Web Browsers
2024-10-22 - The open-source expression evaluation library, Exevalator, has been updated to version 2.2. It now supports TypeScript and can be used for evaluating expressions directly in web browsers. Explains the details.

Behind the Scenes of Creating an Assistant AI (Part 1: Fundamental Knowledge)
2024-10-07 - The first part of a series on how to create an Assistant AI. In this article, we introduce the essential knowledge you need to grasp before building an Assistant AI. What exactly is an LLM-based AI? What is RAG? And more.

Launching an Assistant AI to Support Software Usage!
2024-09-20 - We've launched an Assistant AI that answers questions about how to use RINEARN software and helps with certain tasks. Anyone with a ChatGPT account can use it for free. We'll explain how to use it.

Software Updates: Command Expansion in RINEARN Graph, and English Support in VCSSL
2024-02-05 - We updated our apps. This updates include "Enhancing the Command-Line Features of RINEARN Graph" and "Adding English Support to VCSSL." Dives into each of them!