Moving and Rotating at the same time

Guys, I am very new to jME, can anyone point me to a tutorial or reference code for moving a spatial and rotating at the same time? And by that I mean like a car making a turn and moving in an arc fashion (and not a simple spatial rotating and moving straight).



Thanks and sorry if the question is too broad, I just started…

:? How did you find the button to post?

You’re so mean @normen :stuck_out_tongue:

-.- he just answered your question… what you need more? tell you what lines on totorials to read?





post before was deleted

I lol’d.

http://bilder.hifi-forum.de/max/5455/not-sure-if-troll_87222.png







@Normen below:

Well. At least he learned to pose a decent question.





Edit:

I won’t take out that picture. I knew what was there originally. Its as polite as the op deserves.

Need to look into : https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:vehicles



u will find it there

1 Like

Be aware, quote his posts, he deletes and changes the content to make you look stupid :wink:

@KuroSei please be respectful, if you don’t like the question you don’t have to answer it, and with all due respect, I’m not stupid and I don’t like being called stupid. I am new to forums and still trying to learn.



I am working on something complicated where the graphical portion is just one aspect of it. I read all the tutorials and I even looked at tthe Fancy car example. Maybe I didn’t pose the question the right way and I do apologize for that. My question was how to move a vehicle and rotate it as if it’s doing a turn. I looked into steer() in VehicleCotnrol and didn’t get much out of it.



I use for example:



[java]// get spatial acceleration direction

float vitesse_x = (mySpeed * Math.cos(theta));

float vitesse_y = (mySpeed * Math.sin(theta));[/java]



to move my vehicle horizontal or vertical and was wondering how would I write a “make a turn” method which is not in the tutorials and that’s why I was looking into a link or some reference/guidance to write such a thing.





Graphics is not my background and I did the math for dummies and scene for dummies tutorials.

If you did the tutorials, as well as read the math for dummies… You know how to rotate, you know how to move, you know how to rotate vectors, you know how to use vectors to move… What is the exact question thats left?

@homsi said:
@KuroSei please be respectful, if you don't like the question you don't have to answer it, and with all due respect, I'm not stupid and I don't like being called stupid. I am new to forums and still trying to learn.

I am working on something complicated where the graphical portion is just one aspect of it. I read all the tutorials and I even looked at tthe Fancy car example. Maybe I didn't pose the question the right way and I do apologize for that. My question was how to move a vehicle and rotate it as if it's doing a turn. I looked into steer() in VehicleCotnrol and didn't get much out of it.

I use for example:

[java]// get spatial acceleration direction
float vitesse_x = (mySpeed * Math.cos(theta));
float vitesse_y = (mySpeed * Math.sin(theta));[/java]

to move my vehicle horizontal or vertical and was wondering how would I write a "make a turn" method which is not in the tutorials and that's why I was looking into a link or some reference/guidance to write such a thing.


Graphics is not my background and I did the math for dummies and scene for dummies tutorials.


you can just set your normal vector(direction vector) for an object and modify it(by rotating), then move object in this direction vector.

this is how flyCamera propably work. use Quaternion for it.

what problem do you have? if you want help then show part of code.

yeah I think I was too broad, I need to brush up on my trigonometry I guess in order to do this. This is more of a maths question

are you coming from a flash background by any chance? And as @pspeed will tell you, you rarely need to use trig, vectors have all the info you need

Its an update loop. Just use a direction vector and rotate it gradually while moving the spatial in the direction vector a bit each frame…

but thats the question, how much to rotate and how much to move every frame

@homsi said:
but thats the question, how much to rotate and how much to move every frame

tpf * x, depending on how fast you want to turn, its explained in the tutorials.

I think part of the problem is the phrasing of the question which made it sound like you were asking something much simpler than you actually are. Have a read of the “Please Read This” link to the right and it will help you with phrasing questions.



As for the movement thing - there are several approaches depending on whether its scripted or player controlled, etc. For example on a scripted movement you could define the curve however you like and then just move the car along it. Alternatively for player controlled you just apply a turn based on how the player is pressing and tpf and then move the car in the new forwards at the current speed. The curve you want is then emergent behaviour for that.



To get the behaviour in an automated car just apply the same logic yourself. If pointing too far right steer left, if too far left steer right.



The question is too generic to get a good answer though. It’s like going up to a builder and saying “I want a house” without saying when, where, what materials, how big, etc.

2 Likes

You are right @zarch, I will take a look at it to learn how to ask questions more clearly. Thanks



Think of the problem like that (in scripted movement). I have a car located at point A and need to reach point B. I have both locations. The car starting at (-1,0,0) and with Theta 0 degrees need to reach B(1,1,0) with Theta 45 degrees. The challenge for me is really more related to the movement along that curve (marked in red). The rotation is simple from 0 to 45 but again it needs to be synched with the car movement.



My math background is not the best and that’s why I am not sure how to approach the problem.







1PxMB.png





I don’t care about acceleration/braking for now. Just constant speed to get it working first

As I said there are two approaches to this, emergent and scripted behaviour. Depending on the situation one is more useful than others.



For example in a cinematic scripted behaviour is easier. If the player can interact though (for example drop something in front of the car to obstruct it) you need something more flexible.



Make sure you’ve done all the basic tutorials and then take a look at:



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

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

and

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math

Dude, did you even try what we say all the time? There is no need to do math, the curve happens automatically :roll:

http://www.javabeginner.com/