官术网_书友最值得收藏!

  • jMonkeyEngine 3.0 Cookbook
  • Rickard Edén
  • 574字
  • 2021-09-03 10:00:44

Common development concepts in jMonkeyEngine

Some common development concepts in jMonkeyEngine are as follows:

  • Spatial: Central to all things in the scene graph is the Spatial. In jMonkeyEngine, it's an abstract class, defining translation (location), rotation, and scale of an object. Imagine it as a purely logical object without a physical body. A Spatial is extended into either a Geometry or Node.
  • Geometry: This extends Spatial. This class is what gives a Spatial its physical presence in the world. It has a Mesh defining its form and shape, and a Material, telling us what the surface of the Mesh looks like.
  • Node: This extends Spatial. It can have several children attached, and can in turn be attached to a parent. Since it's a Spatial, it has a translation, rotation, and scale, which it will propagate to its children. Unlike a Geometry, it can't have a Mesh. It doesn't have a visible presence in itself.
  • Transforms: Translation, rotation, and scale are commonly referred to as a Spatial's transforms. A Spatial has both local and world transforms. The local transform is always in relation to its parent (if any). The world transform is the absolute transform with all possible parent transforms propagated together. As an example, imagine your own local translation being the position you have on Earth. Your world translation could be your local translation added to the Earth's local translation in its orbit around the Sun. Normally, you will only work with local transforms. World transforms are handled by the engine.
  • Mesh: This is made up of triangles. In a Mesh, you will find long lists called buffers detailing the points of these triangles (vertices), how the surfaces of these triangles are made (indices), their colors, normal, and other data. Normally, you will load a model from disk, not having to care about what it looks like on this level, but some recipes will create meshes from scratch, and I recommend having a basic understanding of meshes when you do 3D game development.
  • Material: This defines the surface of the Mesh. It's backed by a Material Definition (MatDef), usually containing a vertex shader and a fragment shader. The complexity stretches from simply setting a color or texture for a mesh, to ones that alter the shape of the Mesh. You will get far by using jMonkeyEngine's predefined MatDef.

These are some of the basic must-know concepts of the engine. The following concepts can be considered nice-to-know. I know from experience that these are the ones you wish you had known when your applications were in the process of being developed. They will also be used quite frequently throughout the chapters of this book:

  • AppState: This is an object that affects the behavior of the whole application, and you can, for example, use them to specify logic for different parts of the application. An example could be if you have a game that is played out both on a campaign map and on the ground, both player input and game logic would probably differ quite a lot. By using the AppState class, you can manage the code more easily and avoid monstrous classes.
  • Control: Like AppState, this is a good way to manage your code. The Control affects the Spatial it's attached to, and is commonly used to give Spatials special functionalities. You will see several examples of Control behavior in many of the chapters, so if you prefer learning-by-doing, you're in for a treat.
主站蜘蛛池模板: 大竹县| 洛浦县| 沁源县| 边坝县| 漳州市| 浠水县| 定州市| 蒲城县| 中宁县| 沧源| 惠来县| 太康县| 平泉县| 南涧| 来宾市| 钟山县| 九龙县| 罗山县| 札达县| 巩义市| 平南县| 西乡县| 卢龙县| 全南县| 张家界市| 锡林浩特市| 那曲县| 邯郸市| 徐州市| 濮阳县| 中江县| 黑水县| 土默特左旗| 昌江| 阆中市| 连云港市| 菏泽市| 长兴县| 延庆县| 宁明县| 沈丘县|