Some general (noob) questions about workflow

Hey there!

My 1st post, so first of all let me tell you something about the person you are dealing with (if you don’t care, skip the intro :wink: ).



I’m born in Jan. 1983 that makes me 29 years old by now (for this matter my math is good enough :slight_smile: ). I’m from germany (so please excuse me, if I make some mistakes in my english), a student of informatics and I’m a passionate (pc) gamer. Some years ago I got involved in a fight with openGL (in C++ / SUSE Linux / KDevelop)… and lost. It scared me away from 3d programming in any kind. Until now. I like Java pretty much and looked for a way to get a revenge with openGL but this time with the “weapons” I choose. So I ended up at jMonkey and that’s the reason why I’m here now…





So what I want to know (as the topic tells) is some basic things I’ve gotten stuck in.



What I did so far:

  • completed the HelloXYZ Tutorials as well as some others
  • completed the (german) blender “Gus” tutorial (http://de.wikibooks.org/wiki/Blender_Dokumentation:_Die_erste_Animation_in_30_plus_30_Minuten)
  • I’ve built my own model in blender similar to the tutorial above
  • I’ve built my terrain “per hand” as described in the HelloTerrain tutorial (created a height- / alphamap in GIMP and put it togetherlike “per hand” NOT in the Terrain Editor)
  • I’ve added physics for the terrain and my model
  • added controls to the Model (AnimControls and “moving” controls)
  • I’ve made the camera follow the model around (cameraNode attached to the playerNode)



    What my problems are:

    Terrain:

    As I mentioned I created the terrain in GIMP and coded it into my programm like:
...
/** 1.1) Add ALPHA map (for red-blue-green coded splat textures) */
mat_terrain.setTexture("Alpha", assetManager.loadTexture(
"Textures/Terrain/splat/alphamap.png"));

/** 1.2) Add GRASS texture into the red layer (Tex1). */
Texture grass = assetManager.loadTexture(
"Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
mat_terrain.setTexture("Tex1", grass);
mat_terrain.setFloat("Tex1Scale", 64f);...

and so on...
Well, it works, but as I haven't figured out a way to "preview this terrain" like in the editor, it's much work to edit the terrain if something is not as you wanted it to be (for example if a road is on a side of a cliff, you got to edit the heightmap at this point or the way in the alphamap, then build up the whole thing again...). Also I tried to use more than 3 texture layers, but it seems that there is no way like "mat_terrain.setTexture("Tex4", ice);".
So as I know there are 3 ways of creating a terrain. 1) as described above 2) with the terrain editor from the jme3SDK 3) model in Blender and export.
As I read somewhere Point 3) wouldn't be that good, since meshes are handeled different than terrains by the engine (culling for example) so I decided to not model terrains in Blender. (Is that true or legend?)
I tried the editor too but it seems I'm to dumb to use it properly. I created a terrain, but as I add light (some other than ambient) or a node or an effect or whatever, I cannot move it around (except by editing the xyz values in the Properties, but that's about "guessing the coordinates" what's not that convinient).
Is there a way to "drag things around" in the editor to position it or do I really have to guess / try coordinates?
Another problem with the editor, that I have is the following:
I created a model (blender -> Oger -> *.j3o) of a house. No anims, just a mesh with material / texture.
How do I add (and position as mentioned above) my model to the terrain (using the editor, not coding).
Same for other things like a startpos from a player / NSC and so on.
In some other words: How to create a complete scene with a terrain, some models and some "placeholder" for startpositions etc.?
And: What way / tool do you use to create this?

Camera:
As I mentioned in the things I've done so far, I used a CameraNode, that is child of the character-node to follow the char around. Here's something to help understand:

+rootNode
+ Blobbi (Node)
- BlobbiControl (CharacterControl)
- model (Spartial)
- CamNode (CameraNode)

Before you ask, Blobbi is the name of the character (a snowman to be exact).
I move around with the following code (that I've "stolen" from a tutorial from jMonkey ;) )

Vector3f camDir = cam.getDirection().mult(0.75f);
Vector3f camLeft = cam.getLeft().mult(0.075f);

camDir.y = 0;
camLeft.y = 0;
viewDirection.set(camDir);
walkDirection.set(0, 0, 0);
if (left) {
viewDirection.addLocal(camLeft.mult(0.075f));
} else
if (right) {
viewDirection.addLocal(camLeft.mult(0.075f).negate());
}
if (up) {
walkDirection.addLocal(camDir);
} else
if (down) {
walkDirection.addLocal(camDir.negate());
}
BlobbiControl.setWalkDirection(walkDirection);
BlobbiControl.setViewDirection(viewDirection);


As I googled around a bit, I found the ChaseCam class. I altered my code (thrown out the CamNode thing) to use the ChaseCam instead, but then I'm not able to turn the char around any more. I think this is because the rotation is done according to the cam direction and because the ChaseCam smoothly turns around there is not enough change of view.
Question is: How do you "steer" your ChaseCam followed chars?
I found some tutorial or example class, but it's for jme2 and jme3 tells me, the .update() methods shouldn't be used any more. So the examples don't work in jme3 and an upToDate tutorial I haven't found by now.

Animations:
My Model has several Anims, that all do work. BUT I'm doing something wrong triggering one of them I think.
Blobbi can wave, nod, shakeHead, and walk. The first 3 work perfect. I trigger them with a keystroke, they play, they end.
The walking is the one, that's not doing what I want. I can trigger it, it plays and it stopps. But it should play continously from pressing the key until i release the key.
Question: How do I make the walk animation play from keypress until keyrelease?
Here's my Anim-code:

part of "create_Blobbi()" method in simpleInitApp()

// Control für Anims an Blobbi anbinden
control = model.getControl(AnimControl.class);
control.addListener(new BlobbiAnimListener());
channel = control.createChannel();
channel.setAnim("Stand");


setUpKeys() method in simpleInitApp();

private void setUpKeys(){
BlobbiActions = new BlobbiActionListener(this);
inputManager.addMapping("Location", new KeyTrigger(KeyInput.KEY_L));
inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_LEFT));
inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_RIGHT));
inputManager.addMapping("Up", new KeyTrigger(KeyInput.KEY_UP));
inputManager.addMapping("Down", new KeyTrigger(KeyInput.KEY_DOWN));
inputManager.addMapping("Jump", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("Wave", new KeyTrigger(KeyInput.KEY_1));
inputManager.addMapping("Nod", new KeyTrigger(KeyInput.KEY_2));
inputManager.addMapping("ShakeHead", new KeyTrigger(KeyInput.KEY_3));
inputManager.addMapping("Music", new KeyTrigger(KeyInput.KEY_M));
inputManager.addMapping("FreeCam", new MouseButtonTrigger(mouseInput.BUTTON_RIGHT));
inputManager.addListener(BlobbiActions, "Location");
inputManager.addListener(BlobbiActions, "Left");
inputManager.addListener(BlobbiActions, "Right");
inputManager.addListener(BlobbiActions, "Up");
inputManager.addListener(BlobbiActions, "Down");
inputManager.addListener(BlobbiActions, "Jump");
inputManager.addListener(BlobbiActions, "Wave");
inputManager.addListener(BlobbiActions, "Nod");
inputManager.addListener(BlobbiActions, "ShakeHead");
inputManager.addListener(BlobbiActions, "Music");
inputManager.addListener(BlobbiActions, "FreeCam");
}


part of "onAction" method in the ActionListener

if (name.equals("Up") && isPressed) {
if (!parent.get_AnimChannel().getAnimationName().equals("Walk")) {
parent.get_AnimChannel().setAnim("Walk", 0.50f);
parent.get_AnimChannel().setLoopMode(LoopMode.Loop);
}
}
if (name.equals("Wave") && !isPressed) { // this one works as I want it to!
if (!parent.get_AnimChannel().getAnimationName().equals("Wave")) {
parent.get_AnimChannel().setAnim("Wave", 0.50f);
parent.get_AnimChannel().setLoopMode(LoopMode.Loop);
}
}


Workflow:
Last but not least I want to mention my actual workflow and would like if you tell me any improvements.
1) creating Terrain (Landscape, light, sound, etc.)
2) creating Worldobjects (Houses, Plants, etc.)
3) creating Models (Player / NSC)
4) create behaviour (Physics, Collisions, Controls, etc.)
5) putting everything together in a "scene"
6) clean up, compile and run!

Some things depend on another, so for testing I implement some basics before others, but above is the "grand target" that I try to stick to.


For now that's that (what is pretty much, I know :) ) and if you read until here, I want to thank you for your patience!
Answers can also be given in german (since I'm german), but maybe others (not german) ran into simmilar problems and answers could help them too so english is ok.

Thanks for reading and I hope you can help the noob of mine with my questions,

regards

Markus

thats one big ass first post ^^, a lot better than i’ve seen before. Cant read it atm tho sorry, will check it out later.



Welcome to jME!!

Welcome,

I read everything but did not work with the editor and I can’t tell why the animation doesn’t work so I can just give some advice:



If I would answer in our mother tongue other user wouldn’t answer anymore because how should they know what we already talked about. (And I personally don’t want to encounter numbers of french, chinese, japanese or whatever posts here, too ;)).



The workflow seems to be good but you will not strictly stick to it I guess. Probably you will encounter missing things in terrain when doing plants and so on :wink:



I do not know what you mean with “How do you “steer” your ChaseCam followed chars?”? How to control a character is answered in some tutorials.

You can move things when you open a j3o scene with the “SceneComposer”. You can switch between TerrainEditor and SceneComposer. You can add models by having them in your assets folder (or as an asset pack) and then right-clicking in a scene in the SceneComposer to place the cursor, then right-click the model in the assets folder and select “add to scenecomposer”. Check the videos on the SDK wiki page.

Well… thanks :slight_smile:



I tried to solve most problems i ran into by myself. I read lots of tutorials etc. but as I solved 1 problem, 3 new appeared.



So before making my life harder by running in the complete wrong direction (and endless new problems), I asked for help to get me on the right path at least.



For example the whole “blender thing”. Almost every tutorial is for blender 2.49b not 2.6. So I installed 2.49b. To export to Ogre you got to install python too. Problem: blender doesn’t find Python. Searched for the solution (add PYTHONPATH to Systemvars). But Ogre still not working… after spending lots and lots of time getting this to run, I discovered that jME3SDK can generate a pythonscript to export from blender 2.6 to Ogre. 2.6 had no trouble finding python (even without the PHYTONPATH) etc. and worked perfect right out of the box. About 10 mins to get it running vs. some Days of getting 2.49b to run.

(Word of fairness: 2.6 does solve the “setup” problem, but as mentioned new problems appeared. Almost no tuts, many functions are called different, many functions are “hidden” in other places,…)



But a simple “use 2.6 with the script from the SDK” would have saved me lots of time (and nerves) but hey… I never asked! :slight_smile: So it’s my own fault.

To prevent this kind of wasting time by going in the complete wrong direction in the future, I decided to ask for help. :wink:



But by now, “some” problems added up and that makes the

big ass first post


I hope furter posts of mine get smaller. :wink:



Btw. thanks for the fast reply.

@normen

Thanks!!!

right-clicking in a scene in the SceneComposer to place the cursor, then right-click the model in the assets folder and select “add to scenecomposer“

That was EXACTLY what I wanted!

@enum
I do not know what you mean with “How do you “steer” your ChaseCam followed chars?”? How to control a character is answered in some tutorials.

How to describe? I have my playermodel, that should go forward / backward, turn left / right. followed by a ChaseCam.
The tuts I found (covering ChaseCams or 3rd Person view) are for jme2 and methods used in these examples souldn't be used in jme3. (as the SDK tells me).
Example (full code: http://www.cs.miami.edu/60_Courses/75_UG_Project_Archives/_20082_CSC329_Group5/LuxGame/jme/src/jmetest/flagrushtut/lesson8/Lesson8.java):
//We don't want the chase camera to go below the world, so always keep
//it 2 units above the level.
if(cam.getLocation().y < (tb.getHeight(cam.getLocation())+2)) {
cam.getLocation().y = tb.getHeight(cam.getLocation()) + 2;
cam.update();
}


The cam.update() should no longer be used.

The movement I use (code in 1st post) with the camNode doesn't work for turning with the ChaseCam so there has to be a different way of "steering".

I hope this makes it more clear what I mean.

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:making_the_camera_follow_a_character



This is the tutorial from this site and it keeps the camera above the ground. (But it can still intersect higher obstacles… There are some implementations that you can find in this forum through Google that solve that problem. I guess it was named PhysicalChaseCam.)