Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (754) Games in Android Showcase (229) games submitted by our members Games in WIP (842) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Show Posts Pages: [1]
1  Game Development / Game Mechanics / Re: Gimble Lock I assume on: 2006-06-02 11:01:51
I have done a lot of reading into quaternion and matrix rotation but I cant work it out. I've tried 100 different things but they all come back to the fact that: I have a euler vector, created from the joystick and I dont know of a way that I can convert that into either quaternions or matrix rotatrion without creating gimble lock.

This is what I do to get a euler angle to a quaternion:

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33 `       private Quat4f createQuaternionFromEuler(float angleX, float angleY, float angleZ )      {      //simply call createQuaternionFromAxisAndAngle for each axis      //and multiply the results         Quat4f qx = createQuaternionFromAxisAndAngle(            1f,0f,0f, angleX );         Quat4f qy = createQuaternionFromAxisAndAngle(            0f,1f,0f, angleY );         Quat4f qz = createQuaternionFromAxisAndAngle(            0f,0f,1f, angleZ );            //qx = qx * qy         qx.mul( qy );            //qx = qx * qz         qx.mul( qz );               return qx;      }             public final Quat4f createQuaternionFromAxisAndAngle(       float x, float y, float z, float angle )      {         float sin_a = (float) Math.sin( angle * 0.5f );         float cos_a = (float) Math.cos( angle * 0.5f );               x = (float) (x * sin_a);         y = (float) (y * sin_a);         z = (float) (z * sin_a);         float w = (float) cos_a;                  return new Quat4f(x,y,z,w);      }`

I then multiply the 3 quaternion created from eluer angles  x, y and z and I just get gimble lock.
2  Game Development / Game Mechanics / Gimble Lock I assume on: 2006-06-01 03:59:29
I have a problem I'm tring to change the rotation of an odejava body by using a joystick. The problem is I think I'm getting Gimble Lock.

Here is my code:

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35 `private Matrix3f turn;private Matrix3f pitch;private Matrix3f roll;/* turn, pitch, roll are call in order rot = the rotation being passed from the jostick to body*/       void turn(float rot){         turn.setZero();         turn.rotY(rot);      }          void pitch(float rot){         pitch.setZero();         pitch.rotX(rot);            }          void roll(float rot){         roll.setZero();         roll.rotZ(rot);         rotate(); // turn, pitch, roll done now call rotate() to apply them      }             private void rotate(){               Matrix3f m = new Matrix3f();         m.setZero();         m.mul(turn, pitch);            m.mul(m, roll);         m.mul(m, shipBody.getRotation());         shipBody.setRotation(m);       }`

This code works if I only use 1 axis but as soon as I add in the 2 other axis it gets totaly confused and rotates all wrong. I've been doing a bit of reading into gimble lock but havnt found a solution yet. Does somone have a method that will fix this problem.
 3 Game Development / Game Mechanics / Re: Getting Velocity relative to a Body on: 2006-05-30 04:05:40 How do I get local velocity though thats what I'm after?
4  Game Development / Game Mechanics / Re: Getting Velocity relative to a Body on: 2006-05-28 23:24:27
arne I have one question about your code example. rotation.mul(velocity) does not seem to work mul does not accept a Vector3f, it looks like it only takes another Matrix3f, do you think you could help me fix this please?

Quote
but in a car I would expect the world coordinate speed vektor to be aligned with my car's orientation (momentarily), if not, then I'm sliding a lot and my forward speed would be the least of my worries.

Yeah that sliding is exactly what I am trying to counter act. I dont think setting a velocity will work to well as it will counter collisions so I will go straight through things I shouldn't. I am applying a force to my body not a velocity.

Currently I do this:

 1  2  3 `Vector3f relForce = getRelForce(speedForce); //get the force to apply to the body relative to the worldVector3f  FinalForce = FinalForce.sub(relForce, myBody.getLinearVel());  // removes the current velocity from the body which stops slidingmyBody.addForce(finalForce); //apply forces to body`

This works fairly well as long as the body is moving forwards however if my body hits and object and bounces backwards my linera velocity is negative and FinalForce.sub(relForce, myBody.getLinearVel()); add the 2 forces together which creates a situation where I now have more force than I'm supposed to. I think I can fix this using the example arne provided.

But otelo I have seen other examples around of what you describe and it sounds interesting. My question is from your code what is carForward and what does carTransfrom do and do your think it would apply the same way to force not velocity?
 5 Game Development / Game Mechanics / Re: I have a game written in java and I need some physics on: 2006-05-28 23:08:30 yeah In that case I'm going to use a constant step size and I'm got to try to control the velocity of each body manualy.
 6 Game Development / Game Mechanics / Re: Getting Velocity relative to a Body on: 2006-05-28 12:32:12 Thanks arne thats exactly what I was looking for . The problem I have is I'm not used to the way javax.vecmath does rotation. I'm my program I mainly deal with 4x4 matrix and euler values. I'm sure I get used to it as I use it more.Quote Relative speed to itself... are you going all 'theory of relativity' on us?lol no I just want to know my speed, I think if the speedo in a car read your speed relative to the origin rather than relative to your car you would have problems.
 7 Game Development / Game Mechanics / Re: Getting Velocity relative to a Body on: 2006-05-28 04:01:53 No thats not reall what I am talking about. I'll explane. My body has a velocity of (x, y ,z) where x, y, z are the change in position relative to the origin(0,0,0), what I want is my body's velocity relative to itself not the origin. So to give you an example say my body is facing down the X axis and is traveling at 1 unit per second my velocity will be (0,0,1) now lets say I turn my ship 180 degress so its going straight down the X axis in the other direction my velocity is now (0,0,-1)  that is relative to the origin. The velocity in both cases relative to my body is (0,0,1) because I am moving forwards in both cases. So does anyone know a calculation that can convert a velocity so its relative to my body no the origin?
 8 Game Development / Game Mechanics / Getting Velocity relative to a Body on: 2006-05-28 01:02:44 Hi,Can somone tell my how to get velocity relative to my ship? That is the velocity as if my ship were at (0,0,0).Thanks
 9 Game Development / Game Mechanics / Re: I have a game written in java and I need some physics on: 2006-05-26 09:04:06 ok, tried that and it works well thanks.
 10 Game Development / Game Mechanics / Re: I have a game written in java and I need some physics on: 2006-05-26 07:29:00 yeah thats a solution but not a very dynamic one. Currenly I'm thinking that if I do body.setForce(forceWithDirection-Velocity) it fixes the problem as long as I'm going forwards, if my body goes backwards I'm adding the thrust with the velocity and getting more thrust that I should. There must be some sort of calculation I can do to get it so that it work no matter which direction my body is traveling.
 11 Game Development / Game Mechanics / Re: I have a game written in java and I need some physics on: 2006-05-26 04:05:48 odejava and my scene graph are woking together fine. The problem I have is that 1 unit on my scene graph is different in size to 1 unit in ode.I have another problem now as well. I have a body in space and I want it to have a thrust from an engine, the problem I have is that each loop of my program I do Body.setForce(forceWithDirection), The body keeps getting faster and faster it never reaches top speed(or doesnt seem to). There must be somthing I need to do the counter the thrust force so that the body reaches a top speed. This is also creating the problem that when I turn the body it has momentum in its original direction that never goes away unless it is directly opposed(ie the ship turns 180 and thrust in the reverse direction). I think these two problems are one in the same. I some how need to create a force that reverses old forces so that the new ones can move the body in a more friendly manner.
 12 Game Development / Game Mechanics / Re: I have a game written in java and I need some physics on: 2006-05-23 23:37:58 back again  . I've had a bit of a play with odejava and it seems to be ok for what I want. What I need help with now is a bit of program design. My scene graph is not thread safe and in order to get it to run I need to have a while loop and call renderScene(). Each loop I change the position/rotation of the objects in the scene based on user input. Currently I move nodes based on the time it took to render each loop. What I want to do is call odejava and say its taken X amount of time to reneder this frame move everything relative to  X, then I want to be able to get the new postitions of all my nodes set them in the scene and start the next loop. Can somone just give me a few ideas of  whats required to do this.Edit: I've have intergrated odejava with my scene graph, I'm still not sure about how to get it to run based on time.Edit 2: is there an easy way to work out scale between my scene graph and ode? The objects I draw are not the same as ode objects.
 13 Game Development / Game Mechanics / Re: I have a game written in java and I need some physics on: 2006-05-23 02:00:30 Ok thanks, the reason I dont use novodex/physX or newton or somthing with a C++ API is that I dont want to have to program in C++ the reason for using the java binding was because I can code at least 10 times faster in java than C++. I'm going to give odejava a shot it sounds like it may do the trick.
 14 Game Development / Game Mechanics / Re: I have a game written in java and I need some physics on: 2006-05-22 22:49:06 I'm using a OGL scene graph written in C++ with a java binding. So I need somthing that works independent of the scene graph.Thanks for the advice I'm going to give odejava a shot. jme physics 2 sound very interesting pitty its not independent of jme.
 15 Game Development / Game Mechanics / I have a game written in java and I need some physics on: 2006-05-22 04:38:14 Hi guys  I've been working on a game for a while now and its getting to the stage where netoworking is good game-play is good and things are really comming together well, but I have hit a wall with the physics side of things(no pun intended  ).  My game is in space and does not require the physics to be very involved. But I would like to have fairly realistic collisions between meshes in space. I've been looking at odejava but that project seems to have been abandoned and Ive had a read through a few post here on JOODE but I dont know if its upto the job yet. Can anyone offer me some advice on how I could proceed?
 16 Java Game APIs & Engines / Java 3D / Re: Swing menus and the old heavy and light problem on: 2006-05-18 23:13:11 Thanks for your help! I have a problem though,  when I use the panel the panel gets drawn the but  not the button . I'm going to have a play with it and see if I can fix it. If you have any ideas let me know.Also I was thinking is it possible to draw the button maually? I was thinking of calling draw each loop of my 3d app.
 17 Java Game APIs & Engines / Java 3D / Re: Swing menus and the old heavy and light problem on: 2006-05-16 22:49:31 Thanks swpalmer if you could whip somthing up and let me know how its goes, I'm curretly a little stumped by the whole thing.
 18 Java Game APIs & Engines / Java 3D / Swing menus and the old heavy and light problem on: 2006-05-15 02:18:31 Hi,I've made a 3d game in java that uses what seems to be heayweight, it runs inside a full screen swing window. My current idea is to use swing to create a menu system for the game. I really wanted to use swing because of Synth and making really good looking menus seems fairly straight forward. I had the idea that I would be able to to put swing buttons and so forth over my game as it ran, but after doing a lot of reading this does not seem possible because of the lightwieght nature of swing and the heavyweight nature of my game. I dont really have much experience in this area and was wondering if anyone had some ideas of way around my problem?Thanks
 Pages: [1]
 DesertCoockie (20 views) 2018-05-13 18:23:11 nelsongames (68 views) 2018-04-24 18:15:36 nelsongames (65 views) 2018-04-24 18:14:32 ivj94 (748 views) 2018-03-24 14:47:39 ivj94 (79 views) 2018-03-24 14:46:31 ivj94 (555 views) 2018-03-24 14:43:53 Solater (94 views) 2018-03-17 05:04:08 nelsongames (168 views) 2018-03-05 17:56:34 Gornova (338 views) 2018-03-02 22:15:33 buddyBro (998 views) 2018-02-28 16:59:18
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org