![]() |
|
|
Resources Assignments
|
FPS370
- Changes from Alpha6 to Alpha7 In this change I only added a bit of code to the doFire() method and also attached that method to the mouse clicked. Previously it was only attached to the space bar press. The changes should look all too familiar. We use a PickCanvas to find if the use is looking directly at the ball. If he is, then we take unit vector oriented in the look direction and add it to the ball's velocity.
The PickCanvas uses a unit vector along the negative z axis and transformed with the YPR (yaw pitch roll) matrix as a ray. This ray may intersect a number of different objects (if we had more in our scene). In this case we find the closest one to the canvas and check to see if it is a sphere. If it is, we add the vector we created in the look direction and add it to the ball's velocity. This was not a big change. I also need to change permission on the sphere so we could use the PickTool. sphere = new Sphere(1.0f);
tgSphere.addChild(sphere);
// allow picking on the sphere
PickTool.setCapabilities(sphere.getShape(),PickTool.INTERSECT_COORD);
If we do not do this we will get a: javax.media.j3d.CapabilityNotSetException: Shape3D: no capability to
get geometry
For now you click away and hits to the ball will send it off in that direction.
|
|
CPSC370 - Games Development Chapman University Instructor: W. Wood Harter (c) copyright 2006 - W. Wood Harter - All Rights Reserved Screen shots on banner (c) copyright their resprective owners |
|