To learn about picking a target in the scene, let's add a second cube to the scene. Again we want to click to rotate a cube, but this time, we want to pick the cube that will be the target of the action.
Make a copy of the previous exercise,
UserInput.java
. Keep the mouse click and the key press actions for inspiration.Rename the copy of the class to
TargetPickCenter.java
. Remember to also refactor the first line of themain()
method to the following:TargetPickCenter app = new TargetPickCenter();.
Let's write a simple cube generator so that we can generate sample content more easily: move the code block that creates the blue cube from the
simpleInitApp()
method into a custom method calledmyCube()
. Turn theBox mesh
object into a static class field so that you can reuse it. Your method should use three arguments:String name
,Vector3f loc
, andColorRGBA
color. The method should return a new colored and named cubeGeometry
at the specified...