Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 14 ■ 3D MoDel hierarChy Creation: Using priMitives to Create a gaMe BoarD

Before we finish up with this chapter, let’s see if we can improve our game board rendering result by
using a different Camera (algorithm) class since we seem to be having some Box face rendering order and
positioning problems. If it is not the camera object causing these slight ridges between squares, we will have
to look further for solutions to this problem, as we need to get a photorealistic game board that looks like the
cardboard game boards we all use to play games in real life. As you now know, pro Java 9 game development
is an iterative process, so you know we will figure it out eventually!


Changing Cameras: Using the ParallelCamera Class


Next, I am going to change camera objects from a PerspectiveCamera to a ParallelCamera, both to
give you some experience using them and to see if this face-order rendering problem (the seeming
overlap in squares) is any different between the two Camera class algorithms (between the two Camera
subclasses). This is as simple as changing the declaration at the top of your class from PerspectiveCamera
to ParallelCamera and making sure the same changes are made to the instantiation statement in
createBoardGameNodes(), as shown here as well as in Figure 14-27:


ParallelCamera camera;
...
camera = new ParallelCamera();
camera.setTranslateZ(0);
camera.setNearClip(0.1);
camera.setFarClip(5000.0);


Figure 14-26. Rotate the gameBoard Group Node object 30 to 45 degrees to see where it defines its center for
rotation

Free download pdf