Error in Tutorial 3

Hi,

I am busy working through the tutorials.
In Tut 3: Hello Assets (https://wiki.jmonkeyengine.org/jme3/beginner/hello_asset.html)

There is an appendix that reads:

Loading Assets From Custom Paths

What if your game relies on user supplied model files, that are not included in the distribution?
If a file is not located in the default location (e.g. assets directory), you can register a
custom Locator and load it from any path.

Here is a usage example of a ZipLocator that is registered to a file town.zip in the top level of
your project directory:

    assetManager.registerLocator("town.zip", ZipLocator.class);
    Spatial scene = assetManager.loadModel("main.scene");
    rootNode.attachChild(scene);

When I tried this it didnt seem correct.
I had to add

scene.setLocalTranslation(0.0f, -5.0f, 0.0f);

to get the ninja ‘standing’ on the ground (rather than it bisecting him through the waist)

In the tutorial it says to alter the ninja model with this code. I did it a few weeks ago and everything worked fine for me.

ninja.scale(0.05f, 0.05f, 0.05f);
ninja.rotate(0.0f, -3.0f, 0.0f);
ninja.setLocalTranslation(0.0f, -5.0f, -2.0f);

Here is a usage example of a ZipLocator that is registered to a file town.zip in the top level of your project directory:

Literally every example in the tutorial translate the scene or the model. This specific snippet shows how to use the ZipLocator. Translation info is not necessary info for this particular example.

notice that ninja is set to -5.0f ?? that means this:

if u also lower the scene by -5.0f, you get this:

now which one do you think is correct???

now, if its “only showing how to use Ziplocator” why does it include:

attachChild()?? If you’re going to post code in a TUTORIAL you post correct code!!
heck you should post correct code everywhere!

All the information is there… you just needed to keep reading…

Spatial gameLevel = assetManager.loadModel("main.scene");
    gameLevel.setLocalTranslation(0, -5.2f, 0);
    gameLevel.setLocalScale(2);
    rootNode.attachChild(gameLevel);
1 Like

i see, thank you

I still believe that code snippet either needs a translate added or the attachChild removed

Then the town won’t show up at all.

I think your confusion is that you don’t understand the tutorials.

You guys need to get ur story straight, the first person says it works just fine, which results in image_1 posted above, clearly incorrect.

The second person says you are not supposed to run the code at that point because 1/2 a page of reading later the additional REQUIRED code can be found, which adds the translation and sets the scale to 2 (the extra code is found later) if the code is not supposed to be run at that point then it shouldn’t be attached.

Person 3 says, ur supposed to transect the ninja through the waist and i just dont understand when ground is not below the feet the added objects

seriously??

I don’t see any inconsistency. The top of the tutorial shows a bunch of ways to load assets… that ARE UNRELATED TO EACH OTHER.

The exercises at the bottom show how to put it all together.

…but if positioning models is what’s tripping you up then this may all be too hard for you.

which is why in my first post i said:

to make the code work, because clearly translations are tooo difficult for me

you know, nvm,
no more posting bugs/problems from me to help with an open source project
after all, a code snippet in a TUTORIAL that draws ground through the middle of the model thats supposed to be standing on it is perfectly fine and its my problem that i cant grasp ground at waist level

so far i’m impressed with ur engine and i intend to use it, its still got rough edges but thats to be expected.
at least i now know not to post any code improvements i make because nobody is open to alteration/modification, will speed things up drastically

Which the tutorial tells you to add. Actually, it tells you to add:
gameLevel.setLocalTranslation(0, -5.2f, 0);

make up your mind: either

i’m too stupid to understand translations, and shouldn’t be doing this tutorial

-or-

the tutorial tells u what to do

you cant have it both ways !!!

its simple, by attaching to rootNode, you are ‘publishing’ the town model
either dont publish it at that point in the tutorial (remove the attachChild() ) because that is only an explanation of a concept and should not be run
-or-
add the translation to the code snippet because without it the code doesnt make sense

Its been a while since I looked at the tutorials but judging by the url this specific tutorial is about loading assets.

Now, am I allowed to ask what changing the position of an object has to do with loading assets?

Also, either the tutorial already explained how to change the position of an object. In which case it shouldn’t have to tell you how to do that again in order to put the ninja in the correct spot. OR the tutorial did not cover that in which case it should NOT add the code as its irrelevant and may confuse readers (as it deals with something they haven’t used before)

In the first case an side note also shouldn’t be nesesary as when you read the code you should see what is missing. In the second case a side note would indeed be preferred though not containing the code that “fixes” it but rather a warning that this will happen and that the way to fix this will be touched on later.

this works too

a better solution maybe.