Report as inappropriate.
This scenario can render 3D objects consisting of polygons (instead of only triangles) of different colours. It is fully 3D, meaning that its camera can be turned in any direction, and have the program render the world appropriately.
To illustrate its capabilities, a demo is included, showing 400 small cubes (of a random colour), along with a larger one that misses two sides, and which has a triangle inside of it. Note that the downloaded version runs much faster (consistent 61 FPS in this demo) than the online HTML5 version.
Controls for the demo are:
- wasd to move the camera forward/backward or sideways;
- arrow keys to turn the camera
- z and x to rotate the camera around its axis.
The source code is available and documented.
Some details on how it works: it renders by thinking of the screen as an object in 3D space itself. This is achieved by giving the camera a location (which can be thought of as the 'focal point'), a direction that the player is looking at, and two directions which tell what looks like the 'left-right' direction on screen, and the 'up-down' direction. These last two directions must always be orthogonal.
To illustrate, the z and x keys rotate the 'left-right' and 'up-down' around the direction of the player, whereas the arrow keys change the direction of the player.
The rendering is done from back to front: all objects are sorted from back to front, first drawing those furthest away.
The controls can be fully modified to create many different effects, such as an airplane-like behaviour, walking behaviour, etc.
The FPS counter is taken from mjrb4 (see https://www.greenfoot.org/scenarios/261).
3574 views / 11 in the last 7 days
9 votes | 0 in the last 7 days
This scenario is a member of: Reusable actors & support classes, 3D
Want to leave a comment? You must first log in.
2019/8/23
2019/8/29
2020/3/25
2021/8/4