- jMonkeyEngine 3.0 Beginner’s Guide
- Ruth Kusterer
- 235字
- 2021-08-13 17:02:08
Time for action – navigating the scene
Let's look at things from a different perspective:
- Run the
BasicGame
template once more. - Press the W, A, S, and D keys to move forward, left, backwards, and right. Move the mouse to turn around. This navigates your camera away from the default location.
- Press the C key while the application is running to print the current camera location and rotation to the console.
In your Java code, you can access the current camera location, which is also the location of the player in a first-person game, using getters on the cam object:
Vector3f loc = cam.getLocation(); Quaternion rot = cam.getRotation();
If you want the camera to start out at a different location in the scene, position it using the following:
cam.setLocation(x,y,z); cam.setRotation(q);
The default navigational keys in the included samples are optimized for QWERTY keyboards. Every game has its unique navigation that you will have to define yourself, including a way to let your users with a non-QWERTY keyboard customize the keys.
Note that cam.setRotation(q)
is one of the rotation methods that accepts the Quaternion
data type, which we just learned about, as an argument.
Pop quiz ? spinning around
Q2. How far does geom.rotate(0.0f, 2.1f, 0.0f);
rotate the geometry around the y axis?
- 2
.
1 times = 2.1 * 360° = 756° = 36° - 2
.
1 degrees - 2
.
1 radians = 120° - 2
.
1 world units
- C++程序設計(第3版)
- Beginning C++ Game Programming
- ReSharper Essentials
- Practical Data Science Cookbook(Second Edition)
- Podman實戰
- 鋒利的SQL(第2版)
- Learning Data Mining with R
- Mastering Ext JS
- 從0到1:Python數據分析
- ElasticSearch Cookbook(Second Edition)
- Quantum Computing and Blockchain in Business
- 打開Go語言之門:入門、實戰與進階
- Hadoop 2.X HDFS源碼剖析
- Kohana 3.0 Beginner's Guide
- 嵌入式Linux與物聯網軟件開發:C語言內核深度解析