Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 9 ■ JavaFX 9 User InterFaCe DesIgn: the Front enD For Java 9 game DesIgn

morphing, animation, camera data, lighting data, and the like. JavaFX has the capability to import quite a
few advanced 3D formats, such as Collada (DAE), FrameBox (FBX), 3D Studio 3DS and OBJ.


I will import this mesh data into the rendering engine, add a burled walnut texture map, render it, and
then export the 2D pixel data as a 2D image asset. I will make sure that it has an alpha channel, so it will still
look like it is a 3D object, even though in fact it is not. This is what is termed in the industry as 2.5D.
If we want to spin it around and so on later, we can always import it as a 3D asset later in the book when
we have learned more about the i3D content production pipeline in JavaFX. One of the advantages of the
hybrid 2D+3D environment (API) that JavaFX gives you is the ability to decide what 3D is an “illusion” (like
2.5D, or stereoscopic) and what 3D is “real” i3D. Stereoscopic 3D (film, primarily) is not really 3D, as you
cannot walk behind the scene and all its characters. In an i3D game, such as Halo or Madden Football, you
can, as it is a completely virtual reality.
Next let’s take some of the UI screen title digital Image objects I’ve created for use inside of your
ImageView object, and I will show you how to add these into the proper folder in your NetBeansProject
folder hierarchy. After NetBeans 9 can “see” these PNG32 digital image assets, you will then be able to code
the loadImageAssets() method, which will load PNG32 data into Image objects in system memory so the
ImageView can reference and display them.


Adding Image Assets to Your Project: Using the \src\ Folder


As you can see at the top of Figure 9-6, the path on my Windows 7 64-bit QuadCore AMD workstation starts
with the Users folder and looks like C:\Users\Walls\MyDocuments\NetBeansProjects\JavaFXGame\src\
credits.png. As you can see, I named the PNG32 files after what was inside of them, and even though they
look like they are on a white background, they’re actually transparent. Copy the files from the book assets
repository to your project folder, and then you will be able to reference them in your code.


Figure 9-5. I created an iTVBoardGame logo with 3D Studio Max, exported it to an OBJ file format, and
rendered it

Free download pdf