[ Prev | Index | Next ]
Japanese English

Screen Projection

This section explains how to perform screen projection of vectors. Screen projection allows you to obtain the X and Y coordinates (i.e., window coordinates) on the graphics display that correspond to arbitrary positions in 3D space.

Screen Projection

Screen Projection of a Vector

If you want to find out where a point in 3D space appears on the screen, you can use screen projection. By applying screen projection to a vector placed in 3D space, you can obtain the corresponding X and Y coordinates in the rendering area -- these are known as window coordinates.

Origin Is at the Bottom-Left

One important point to note is the position of the origin in the rendering area.

In many fields outside of 3DCG, the top-left corner of the screen is treated as the origin. However, in certain 3DCG contexts that use right-handed coordinate systems, the bottom-left corner is often used instead, due to various technical conventions (though the top-left origin is still used in some cases).

VCSSL Graphics3D adopts a right-handed coordinate system, so the origin of the rendering area is considered to be at the bottom-left.

As a result:

  • In VCSSL GUI and VCSSL Graphics2D, the origin is at the top-left.
  • In VCSSL Graphics3D, the origin is at the bottom-left.

Keep this difference in mind when combining these systems.

Projecting a Vector onto the Screen

To perform screen projection and obtain the X and Y screen coordinates of a vector, use the projectVectorX(...) and projectVectorY(...) functions, respectively.

- Function Format -

int projectVectorX ( int vectorID, int rendererID )
int projectVectorY ( int vectorID, int rendererID )

Arguments:

  • vectorID: The ID of the vector to project.
  • rendererID: The ID of the renderer.

Example Program

Let's get the screen coordinates corresponding to the origin of the world coordinate system. Try writing and running the following code:


import graphics3d.Graphics3DFramework ;
import Graphics3D ;

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

	// Create a vector at the origin
	int vector = newVector( 0.0, 0.0, 0.0 ) ;

	// Place the vector in the world coordinate system
	mountVector( vector, rendererID ) ;

	// Project the vector onto the screen
	int x = projectVectorX( vector, rendererID );
	int y = projectVectorY( vector, rendererID );


	// Output the result
	println( "X=" + x + ", " + "Y=" + y ) ;
}
Sample.vcssl

When you run this program, the VCSSL console will display something like:

X=391, Y=277

This indicates the coordinates near the center of the rendering area.
(The exact values may vary depending on your environment or software version.)

Note: In the Graphics3DFramework, the component ID of the GUI element representing the rendering area can be obtained using the getImageLabel() function.



Sponsored Link



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

The VCSSL Support AI is Here! — Requires a ChatGPT Plus Account for Practical Performance
2025-08-19 - A new AI assistant for the VCSSL programming language is here to answer your questions and help with coding. This article explains how to use it and showcases plenty of real Q&A and generated code examples.

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 Building Assistant AIs (Part 2: Implementation)
2024-10-12 - This article walks you through the actual steps of building an Assistant AI using ChatGPT's &quor;GPTs&quor; feature. It also covers how to embed your own knowledge and practical tips for improving accuracy.

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.