- 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.
推薦閱讀
- WildFly:New Features
- 零基礎玩轉區塊鏈
- C語言程序設計實訓教程
- Java:Data Science Made Easy
- Android開發:從0到1 (清華開發者書庫)
- C語言程序設計
- 快速入門與進階:Creo 4·0全實例精講
- Clojure High Performance Programming(Second Edition)
- Java EE架構設計與開發實踐
- 深入理解Java虛擬機:JVM高級特性與最佳實踐
- ASP.NET本質論
- Unreal Engine Game Development Cookbook
- HTML5 Game Development by Example:Beginner's Guide(Second Edition)
- Azure for Architects
- Learning Rust