Hey, Im playing around with the tutorials and Ive managed to get myself a terrain and the ninja model on top of it. Im still puzzled with 3D mechanics since, in 2D everything was so simple.
Anyways I have this, which moves the model forward along the Z-axis. If the player happens to turn sideways then this solution wouldnt work.
public void simpleUpdate(float tpf)
{
if(channel.getAnimationName().equals(“Walk”))
{
player.move(0.0f, 0.0f, 0.01f);
}
}
So how is the facing direction determined in 3D? Help needed and appreciated.
you could do spatial.getLocalRotation().getRotationColumn(2).mult(0.1). This should find the z rotation and move 0.1 in that direction (i think)
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies
Some API function calls would be nice(working solution or even better if they happen to be good practices in openGL), as I am somewhat familiar with math concerning Vectors/Trigonometry.
E: With some explanation if possible(unless its heavily documented).
Both tutorials use and show jme3 api, also stuff you dont learn in school as there were no methods on vector tuples or FastMath in your calculator Otherwise try the javadoc?
I guess nobody in this site helps, no matter how simple it is. When next time someone asks how much 1+1 is, don’t give a straight answer “2” instead create a blabla post saying “you cannot do that” as that is an undefined operation you have to define the symbols “1”, “+”, a mathematical model and a set of axioms. Afterall isn’t post count all that matters ? dont forget to downvote this post. thx.
Straight answer:
[java]
/*Creates a Vector that tells where is the forward vector of this object/
public final Vector3f getForward(Node node)
{
Vector3f forward = new Vector3f(0,0,1);
node.localToWorld(forward,forward);
return forward;
}
[/java]
node.localToWorld() converts local coordinates to world coordinates so :
(0,0,1) is forward.
(0,0,-1) is backward.
(1,0,0) is right.
(0,1,0) is upward.
You can give people some bread and see them ask for more bread a day later or you can show them how to bake bread… Also I am not 100% sure if your answer is applicable on all cases the question encompasses. I still think best is to have a solid idea about how the spatials and their transformation works, then the answer is “so easy” as you said.
Edit: And btw, did you check the author of the docs I linked?
Indeed I did. Though there might be a misconception here - i know how to place a spatial in the 3D space and how to apply basic operations(so the spatial moves, rotates, scales). The problem was applying so called rotation to calculate/define the facing of the spatial - so his “facing direction” would be where he goes when player presses UP key. Right now it doesnt matter which way he looks, he is still going to move 0.01z units.
English isnt my primary language so I might not be able express myself as much as I would like to.
E: Explanations on good practices are welcome and I thank anybody who contributes to make me a less ignorant person that I am right now.
E2: Imagine a car racing game in a third person view - the car keeps moving “nose” in front(and there are no fixed vectors as the car is able to rotate 360 degrees along its Y-axis), whenever the player applies acceleration.
Exactly thats the main point of the short math tutorial on rotations I did. It should allow you to seamlessly combine “direction” with “rotation” using quaternions. The “rotation” of a spatial (expressed in a quaternion) is the relative rotation from y-up z-forward “base” rotation. So instead of trying to store the characters rotation, store its direction and speed, you can easily get a rotation value from that to set it to the spatial, plus you avoid nasty stuff like gimbal lock etc.
I have to say that I am overwhelmed. Care to make a simple sample of those Quaternions?
E: For example a box, which roams around in the void(moved by numpad 8, 2, 4, 6 / rotated left 7, right 9 / rotated down 1, up 3). Would be nice if the “side” it considers front is colored differently.
http://hub.jmonkeyengine.org/groups/general-2/forum/topic/spatial-move-regarding-the-camera-direction/
But someone never searches the forum
@normen said: You can give people some bread and see them ask for more bread a day later or you can show them how to bake bread.. Also I am not 100% sure if your answer is applicable on all cases the question encompasses. I still think best is to have a solid idea about how the spatials and their transformation works, then the answer is "so easy" as you said.<br /> <br /> Edit: And btw, did you check the author of the docs I linked? :P
@normen, I don’t intend to crash your analogy, but sometimes a person might be having trouble figuring out how to make bread because they get stuck when trying to figure which (of a wide selection) of a particular ingredient to use, particularly when there are different consequences to using one type of ingredient over another. A person who has never tasted different types of vinegar, for example, might not know the difference between using balsamic vinegar instead of rice vinegar. Putting balsamic vinegar on sushi might not invoke a favorable outcome in dinner guests. The person’s resulting humiliation could have easily been prevented by an explanation about the different types of vinegar and their usages.
@devinbost said: @normen, I don't intend to crash your analogy, but sometimes a person might be having trouble figuring out how to make bread because they get stuck when trying to figure which (of a wide selection) of a particular ingredient to use, particularly when there are different consequences to using one type of ingredient over another. A person who has never tasted different types of vinegar, for example, might not know the difference between using balsamic vinegar instead of rice vinegar. Putting balsamic vinegar on sushi might not invoke a favorable outcome in dinner guests. The person's resulting humiliation could have easily been prevented by an explanation about the different types of vinegar and their usages.
Yes, and the vinegar questions would be appropriate in a “Bread Baking Beginner’s” forum but less appropriate in an “Advanced Baking” or “Baking with this Bread Mix” forum.
@devinbost said: @normen, I don't intend to crash your analogy, but sometimes a person might be having trouble figuring out how to make bread because they get stuck when trying to figure which (of a wide selection) of a particular ingredient to use, particularly when there are different consequences to using one type of ingredient over another. A person who has never tasted different types of vinegar, for example, might not know the difference between using balsamic vinegar instead of rice vinegar. Putting balsamic vinegar on sushi might not invoke a favorable outcome in dinner guests. The person's resulting humiliation could have easily been prevented by an explanation about the different types of vinegar and their usages.
Resurrecting a three year old thread for this? I say read the recipe that I wrote or die of vinegar poisoning, your decision. I wrote pages long descriptions with images that took days to complete, kiss my ass if you say I should still repeat all that each time somebody asks the same questions again.
@normen said: Resurrecting a three year old thread for this? I say read the recipe that I wrote or die of vinegar poisoning, your decision. I wrote pages long descriptions with images that took days to complete, kiss my ass if you say I should still repeat all that each time somebody asks the same questions again.
@normen, thank you for your suggestion. I’m not suggesting that you repeat yourself. I’m only suggesting that forum posts may indicate areas of the wiki that would benefit from additional clarification or detail. When somebody posts a simple question, it doesn’t always mean that the person is just too dumb to follow simple instructions or didn’t read the information on the wiki. Most people post a question after reading documentation, not prior to reading documentation. I’m sure you can relate to that.
I commented on this post because I was recently trying to figure out a similar issue (although I’m familiar with vector graphics and physics in languages more powerful than Java). There are conflicting recommendations on whether to use CharacterControl or BetterCharacterControl, and the documentation on the different ways to determine the direction that a character is facing is also in need of improvement. I spent quite a lot of time trying to figure out navigation for my character prior to implementing the physics only to realize that implementing physics (with BetterCharacterControl) basically required me to throw away all the code that I wrote. Issues like that are profoundly discouraging to developers who are new to a framework. If you criticize everyone who offers suggestions on how to improve your framework, then nothing will change except for the people who you attacked. (They will stop telling you about issues that you probably need to know about.) Perhaps that is a valid explanation for why documentation is unclear in many parts of the framework.
If it makes you feel better, I’ve already started adding content to the Wiki to correct the areas that are needing improvement.
@devinbost said: @normen, thank you for your suggestion. I'm not suggesting that you repeat yourself. I'm only suggesting that forum posts may indicate areas of the wiki that would benefit from additional clarification or detail. When somebody posts a simple question, it doesn't always mean that the person is just too dumb to follow simple instructions or didn't read the information on the wiki. Most people post a question after reading documentation, not prior to reading documentation. I'm sure you can relate to that.I commented on this post because I was recently trying to figure out a similar issue (although I’m familiar with vector graphics and physics in languages more powerful than Java). There are conflicting recommendations on whether to use CharacterControl or BetterCharacterControl, and the documentation on the different ways to determine the direction that a character is facing is also in need of improvement. I spent quite a lot of time trying to figure out navigation for my character prior to implementing the physics only to realize that implementing physics (with BetterCharacterControl) basically required me to throw away all the code that I wrote. Issues like that are profoundly discouraging to developers who are new to a framework. If you criticize everyone who offers suggestions on how to improve your framework, then nothing will change except for the people who you attacked. (They will stop telling you about issues that you probably need to know about.) Perhaps that is a valid explanation for why documentation is unclear in many parts of the framework.
If it makes you feel better, I’ve already started adding content to the Wiki to correct the areas that are needing improvement.
Nobody suggested anything to “make the engine better” in this thread. Nobody said he didn’t understand a part of the wiki in this thread. Nobody said the tutorial I linked was unclear, rather they indicated they still didn’t read it but get agitated that I posted it in the first place.
I think the documentation is mostly unclear if you read in the “F-form” that most younger people nowadays read in but you won’t be a good software engineer (or any kind of engineer) with this kind of “reading” anyway. Seriously, this guy asks the exact question I made the tutorial for and I get people jumping at me for posting it. I feel we should rather make the engine harder to use and remove all documentation from the web.
@normen said: Nobody suggested anything to "make the engine better" in this thread. Nobody said he didn't understand a part of the wiki in this thread. Nobody said the tutorial I linked was unclear, rather they indicated they still didn't read it but get agitated that I posted it in the first place.I think the documentation is mostly unclear if you read in the “F-form” that most younger people nowadays read in but you won’t be a good software engineer (or any kind of engineer) with this kind of “reading” anyway. Seriously, this guy asks the exact question I made the tutorial for and I get people jumping at me for posting it. I feel we should rather make the engine harder to use and remove all documentation from the web.
How about posting a heading at the top of: Hello animation tutorial that states, “Note: Everything you learn about character navigation in this tutorial will be useless when you later want to apply physics to ensure your character won’t walk through walls.”?
@normen, I apologize if I was unclear. I was partially responding to the comment by @tralala . My reason for finding the article was different from the reason of the author of this initial forum post.
@devinbost said: How about posting a heading at the top of: Hello animation tutorial that states, "Note: Everything you learn about character navigation in this tutorial will be useless when you later want to apply physics to ensure your character won't walk through walls."?
So this is your suggestion now? This is the point you don’t get. Nothing you learn in the tutorials is useless if you really want to write a game.
The tutorials are useless if:
- you look for a direct answer to the specific question you have in mind
- you skip every tutorial where you think “this isn’t what I am looking for”
- you try to copy-paste the example code into your game to make your character work
- you don’t do the tutorials
And its in no way necessary to use physics to keep your character from running through walls. If you feel compelled to say “but the tutorial says so!”, read the paragraphs above again.