[ Prev | Index | Next ]
Japanese English

Using the Framework

This section introduces a simplified framework that automates the basic setup required for 3DCG programs.

Built-in Framework for 3DCG Programs

As we saw in the previous sections, 3DCG programs in VCSSL usually require a number of fundamental tasks: creating a window and a 3D renderer (drawing engine), setting up animation loops, handling mouse interaction, and so on.

To avoid writing these routines every time, VCSSL provides a built-in framework called Graphics3DFramework that automates all of these setup processes.

User-Defined Functions

The framework itself is a fully functional program, and you can run it as-is. However, by default, it doesn't place any models, so you'll just see a blank (white) screen.

Typically, you'll import the framework into your own program and define only the parts you want to customize -- like placing models or applying transformations.

To do this, simply define specific functions with predefined names and argument formats. The framework will automatically call those functions at the appropriate time.

Here are the five functions the framework can call automatically:

List of Functions Called by the Framework

void onStart ( int rendererID )
Called at the start of the program. → Use this for setting window size, background color, and placing models.
void onPaint ( int rendererID )
Called every screen refresh cycle. → Typically not used in 3DCG; more relevant for 2DCG.
void onUpdate ( int rendererID )
Called every screen refresh cycle. → Use this to move models or update animations.
void onResize ( int rendererID )
Called when the window is resized.
void onExit ( int rendererID )
Called when the program is exiting.

The "rendererID" parameter passed to each function is the ID of a pre-created 3DCG renderer, provided automatically by the framework.

You'll use this ID when placing or manipulating models.

Note: You don't need to define all five functions -- just the ones you need. A common pattern is to place models in onStart() and animate them in onUpdate().

The onUpdate() function is typically called around 30 times per second, depending on processing load. While onPaint() is commonly used in 2DCG applications, it is rarely needed for 3DCG.

Example Program

Let's use the framework to create a 3DCG animation where an axis model slowly rotates.


// Import the framework
import graphics3d.Graphics3DFramework;
import Graphics3D;


// Variable to store the axis model ID
int axis;


// 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 the axis model
	axis = newAxisModel( 3.0, 3.0, 3.0, );
	mountModel( axis, rendererID );
}


// Called multiple times per second (around 30 FPS)
void onUpdate( int rendererID ) {

	// Slightly rotate the axis model around the Z-axis
	rotModelZ( axis, 0.03 );
}
Sample.vcssl

When you run this program, a window will open displaying a coordinate axis model that continuously rotates slowly.

  • Left mouse drag: rotates the camera view.
  • Right mouse drag: pans the view.
  • Mouse wheel: zooms in and out.

Execution Result
Execution Result
The axis model appears on a black screen. Mouse interaction is enabled.



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!