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


Author of This Article

Fumihiro Matsui
[ Founder of RINEARN, Doctor of Science (Physics), Applied Info Tech Engineer ]
Develops VCSSL, RINEARN Graph 3D and more. Also writes guides and articles.

Translation Cooperator

ChatGPT AIs
[ GPT-3.5, 4, 5, 5.1 ]
We greatly appreciate the cooperation of ChatGPT AIs in translating this article.


Sponsored Link



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

Exevalatorv2.4Released—MCPSupportAdded,NowUsableasanAICalculationTool
2025-11-15 - We'vereleasedExevalatorv2.4,ourexpression-evaluationlibrary.Startingwiththisversion,itsupportsMCP,makingitusableasacalculationtoolforAIassistants.

Exevalatorv2.3Released—NowUsablefromPython
2025-11-04 - We'vereleasedExevalatorv2.3.Startingwiththisversion,youcannowuseitfromPython!WithgrowingdemandaroundAItooldevelopmentinmind,wesharethedetailshere.

ExevalatorUpdated—EasyJapaneseLocalizationforErrorMessages
2025-10-31 - Exevalator2.2.2isout.YoucannowlocalizeerrormessagestoJapanesewithasimplecopy-and-paste,andwe'veincludedseveralbugfixesandminorparseradjustments.

InsideRINPnOnline:ArchitectureOverview
2025-10-22 - AninsidelookatthearchitectureoftherecentlylaunchedonlineversionoftheRINPnscientificcalculator.It'sopensource,soyoucanfreelymodifyandreuseittobuildyourownwebcalculator(maybe!).

MeetRINPnOnline:UsetheScientificCalculatorAnywhere,Instantly
2025-10-21 - RINPn,thefreescientificcalculator,nowhasanonlineversionyoucanuseinstantlyinyourbrowser—onbothPCandsmartphones.Readtheannouncementfordetails.

TheVCSSLSupportAIisHere!—RequiresaChatGPTPlusAccountforPracticalPerformance
2025-08-19 - AnewAIassistantfortheVCSSLprogramminglanguageisheretoansweryourquestionsandhelpwithcoding.ThisarticleexplainshowtouseitandshowcasesplentyofrealQ&Aandgeneratedcodeexamples.

EnglishDocumentationforOurSoftwareandVCSSLIsNowNearlyComplete
2025-06-30 - We'rehappytoannouncethatthelarge-scaleexpansionofourEnglishdocumentationwiththesupportofAI—aprojectthatbegantwoyearsago—hasnowreacheditsinitialtargetmilestone.

VCSSL3.4.52Released:EnhancedIntegrationwithExternalProgramsandMore
2025-05-25 - Thisupdateintroducesenhancementstotheexternalprogramintegrationfeatures(e.g.,forrunningC-languageexecutables).Severalotherimprovementsandfixesarealsoincluded.Detailsinside.