Game Development Reference
In-Depth Information
Even though the term “ geometry ” technically applies to 2D and 3D assets, these are
contained in a javafx.scene.shape package, which I covered earlier (see the section
Scene Subpackages: The 13 Other Scene Packages ”). The javafx.geometry pack-
age could be considered more of a utility package, containing foundational classes for
building 2D and 3D constructs from scratch. As such, the package offers classes such
as a Bounds superclass and its BoundingBox subclass as well as Insets , Point2D ,
Point3D , Dimension2D , and Rectangle2D geometry content creation utility classes.
All the classes in the javafx.geometry package, except the BoundingBox class,
were extended directly from the java.lang.Object master class, meaning that they were
each developed (coded) from scratch for providing points (also called vertices), rect-
angles, dimensions, boundaries, and insets (inside boundaries) for use as geometric
utilities for JavaFX application development.
The Point2D and Point3D classes (objects, ultimately) hold x, y coordinates for a
2D point on a 2D plane or x, y, z coordinates for a 3D point in 3D space. These Point
objects will be used to build more complex 2D or 3D structures made up of a collection
of points, such as a 2D path or a 3D mesh. The Point2D and Point3D constructor meth-
od calls are not overloaded, and they use the following standard formats, respectively:
Point2D(double X, double Y )
Point3D(double X,doubleY, double Z )
The Rectangle2D class (object) can be used to define a rectangular 2D area, often
referred to as a plane, and has many uses in graphics programming, as you might well
imagine. A Rectangle2D object has a starting point in the upper left-hand corner of the
rectangle specified, using an x and a y coordinate location as well as a dimension
(width by height). A constructor method for a Rectangle2D object has the following
standard format and is not overloaded:
Rectangle2D(double minX , double minY , double width ,
double height )
In addition, a Dimension2D class (object) specifies only the width and height di-
mensions and does not place the dimensions (which would make it a rectangle) on the
screen using an x, y location. This class's constructor method is as follows:
Dimension2D(double width , double height )
The Insets class (object) is like a Dimension2D class, in that it does not provide a
location value for the inset but does offer offsets for a rectangular inset area, based on
Search WWH ::




Custom Search