Przeglądaj źródła

Wiki refresh (Hello Assets) (#153)

I am going through the beginner wiki pages and updating them so they are the same as the source code files in jme3test/helloworld. 

The main difference in this change is setting the DisplayStatView to false, adding normalizeLocal to the sun and then a few lines of assetManager materials. Very minor changes with the code being almost the same to start with.
woodx319 3 lat temu
rodzic
commit
ced12de382
1 zmienionych plików z 21 dodań i 25 usunięć
  1. 21 25
      docs/modules/tutorials/pages/beginner/hello_asset.adoc

+ 21 - 25
docs/modules/tutorials/pages/beginner/hello_asset.adoc

@@ -40,42 +40,40 @@ public class HelloAssets extends SimpleApplication {
 
     @Override
     public void simpleInitApp() {
-
+    
+        /* Load a teapot model (OBJ file from jme3-testdata) */ 
         Spatial teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
-        Material mat_default = new Material(
-            assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
+        Material mat_default = new Material( assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
         teapot.setMaterial(mat_default);
         rootNode.attachChild(teapot);
 
-        // Create a wall with a simple texture from test_data
+        /* Create a wall (Box with material and texture from jme3-testdata) */
         Box box = new Box(2.5f,2.5f,1.0f);
         Spatial wall = new Geometry("Box", box );
-        Material mat_brick = new Material(
-            assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
-        mat_brick.setTexture("ColorMap",
-            assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
+        Material mat_brick = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
+        mat_brick.setTexture("ColorMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
         wall.setMaterial(mat_brick);
         wall.setLocalTranslation(2.0f,-2.5f,0.0f);
         rootNode.attachChild(wall);
 
-        // Display a line of text with a default font
-        guiNode.detachAllChildren();
+        /* Display a line of text (default font from jme3-testdata) */
+        setDisplayStatView(false); 
         guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
-        BitmapText helloText = new BitmapText(guiFont, false);
+        BitmapText helloText = new BitmapText(guiFont);
         helloText.setSize(guiFont.getCharSet().getRenderedSize());
         helloText.setText("Hello World");
         helloText.setLocalTranslation(300, helloText.getLineHeight(), 0);
         guiNode.attachChild(helloText);
 
-        // Load a model from test_data (OgreXML + material + texture)
+        /* Load a Ninja model (OgreXML + material + texture from test_data) */
         Spatial ninja = assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
         ninja.scale(0.05f, 0.05f, 0.05f);
         ninja.rotate(0.0f, -3.0f, 0.0f);
         ninja.setLocalTranslation(0.0f, -5.0f, -2.0f);
         rootNode.attachChild(ninja);
-        // You must add a light to make the model visible
+        /* You must add a light to make the model visible. */
         DirectionalLight sun = new DirectionalLight();
-        sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
+        sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal());
         rootNode.addLight(sun);
 
     }
@@ -126,13 +124,11 @@ Place your textures in a subdirectory of `assets/Textures/`. Load the texture in
 [source,java]
 ----
 
-// Create a wall with a simple texture from test_data
+/* Create a wall (Box with material and texture from jme3-testdata) */
 Box box = new Box(2.5f,2.5f,1.0f);
 Spatial wall = new Geometry("Box", box );
-Material mat_brick = new Material(
-    assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
-mat_brick.setTexture("ColorMap",
-    assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
+Material mat_brick = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
+mat_brick.setTexture("ColorMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
 wall.setMaterial(mat_brick);
 wall.setLocalTranslation(2.0f,-2.5f,0.0f);
 rootNode.attachChild(wall);
@@ -149,10 +145,10 @@ The following code sample goes into the `simpleInitApp()` method.
 
 [source,java]
 ----
-// Display a line of text with a default font
-guiNode.detachAllChildren();
+/* Display a line of text (default font from jme3-testdata) */
+setDisplayStatView(false); 
 guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
-BitmapText helloText = new BitmapText(guiFont, false);
+BitmapText helloText = new BitmapText(guiFont);
 helloText.setSize(guiFont.getCharSet().getRenderedSize());
 helloText.setText("Hello World");
 helloText.setLocalTranslation(300, helloText.getLineHeight(), 0);
@@ -162,7 +158,7 @@ guiNode.attachChild(helloText);
 
 [TIP]
 ====
-Clear existing text in the guiNode by detaching all its children.
+You can use `setDisplayStatView(false);` to deactivate the HUD display statistics.
 ====
 
 
@@ -173,13 +169,13 @@ Export your 3D model in a <<ROOT:getting-started/features.adoc#supported-externa
 [source,java]
 ----
 
-// Load a model from test_data (OgreXML + material + texture)
+/* Load a Ninja model (OgreXML + material + texture from test_data) */
 Spatial ninja = assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
 ninja.scale(0.05f, 0.05f, 0.05f);
 ninja.rotate(0.0f, -3.0f, 0.0f);
 ninja.setLocalTranslation(0.0f, -5.0f, -2.0f);
 rootNode.attachChild(ninja);
-// You must add a directional light to make the model visible!
+/* You must add a light to make the model visible. */
 DirectionalLight sun = new DirectionalLight();
 sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal());
 rootNode.addLight(sun);