Advertisement

Umm I think I'm not out of the pit yet

Started by June 29, 2003 03:25 PM
9 comments, last by JavaCoolDude 21 years, 7 months ago
Here'' what I have and what I want to get to; I have 2 spheres colliding and then parting from each other with newly computed velocities. Everything till now is fine, but when I wanna set up a shokwave that propagates perpendicularly to the vector that links the two spheres'' centers, I fail (not miserably since I got a partial success). I have the vector that links the colliding objects centers, and I also have the exact location where the collision occurs. Now how do I set up an axis (figured out this might be the way to do it) and an angle to accomplish the correct rotation? Thanks in advance
I''m affraid that you will have to be a little bit more precise. What kind of shockwave? Is it only a graphical effect? And if the shockwave "propagates perpendicularly to the vector that links the two spheres'' centers", isn''t its axis the "vector that links the two spheres'' centers"?

Cédric
Advertisement
Aight basically I hold the shockwave within a transformGroup (java3d).
The shockwave, when at rest, lies on the x/z plan as a TriangleFanArray (a disc) meaning its vertices have 0s for y coordinates.
Now I want to orient that transformGroup such as the disc(shockwave) gets the vector linking the two spheres for normal.
Think of it this way; you got a dish sitting on the table, you hold it and rotate it along the z axis by half Pi. Now that's the shockwave correct rotation for two spheres that collided along the x axis --> O | O.

Hope my babbling made some sence.
Btw the wave propagates by increasing the scale of the transformGroup that's holding it .



[edited by - JavaCoolDude on June 29, 2003 5:09:49 PM]
Ah, I think that I understand. Well, the easy way is to consider the normal''s rotation. You want your normal to rotate from N = (0,1,0) to its new orientation, N'', which is the vector between the two spheres.

The rotation axis is thus the cross product of N and N'', and you can find the angle of rotation by taking the dot product of N and N''.

You can apply this rotation to the fan, and it should work fine.

If you have a problem with the specifics, ask again, or search the archives. Rotation and angles are frequent topics.

Cédric
That''s how I did it before jumping in here looking for a potentially better alternative :D
Thx anyways
Blf, what were you hoping for? What would a "better alternative" do?
Advertisement
You have my first born child Sir
Merci encore
http://www.realityflux.com/abba/demo.JPG
Eh, that''s a pretty good start!

Perhaps you could smooth the border more like a real wave, with a function like 1 / (1 + (x - vt)²) where vt is the distance travelled...

Just a suggestion.

Cédric
Where was the other ball? Did you make the ring yourself?
You know what I never noticed before?
I pretty much did everything myself including how to figure out the sphere/cylinder collisions (ubber easy when you have A''s in linear algebra/calc 3 backing you up )
Here''s a snap shot of the final demo
http://www.realityflux.com/abba/demo.JPG
Unfortunately the spheres'' move too fast for me to get a snap of the shockwave generated by their collision (even if I use a frame cap :D)
Here''s how I create the cylinders;
From class Cylinder_spawn    cylinders[0] =  new cylinder_info(new Vector3f( -25, 100, 100),//End point                                      new Vector3f( -25,-100,-100),//Start point                                      new Vector3f(  10, 270,   0));//radius, height, nothing 

From class Cylinder_info()  cylinder_info(Vector3f end,                Vector3f start,                Vector3f properties){    this.properties = properties;    this.start      = start;    this.end        = end;    mid_point = new Vector3f();    mid_point.add(start,end);    mid_point.scale(.5f);    direction = new Vector3f();    direction.sub(end,start);    direction.normalize();    length = direction.x*direction.x +             direction.y*direction.y +             direction.z*direction.z;    create_cylinder();  }  /**********************************************************************************************/  /*                                                                                            */  /*                               Create an oriented cylinder                                  */  /*                                                                                            */  /**********************************************************************************************/  public void create_cylinder(){    Vector3f appearance_prop = new Vector3f(0,0,0);    Vector3f axis            = new Vector3f();    axis.cross(new Vector3f(0,1,0),direction);    float angle = (float)Math.acos(new Vector3f(0,1,0).dot(direction));    Appearance look            = new appearance(appearance_prop,new Color3f());    Cylinder cylinder = new Cylinder(properties.x, properties.y,3,look);    cylinder.setAppearance(new texturing(new Frame()).map_texture(look,                                         "textures/brick.jpg",                                          true));    locate_cylinder   = new Transform3D();    locate_cylinder.setRotation(new AxisAngle4f(axis.x,axis.y,axis.z,angle));    locate_cylinder.setTranslation(mid_point);    hold_cylinder   = new TransformGroup(locate_cylinder);    hold_cylinder.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);    hold_cylinder.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);    hold_cylinder.addChild(cylinder);  } 


If anybody wanna know how my collisions work, lemmie know

This topic is closed to new replies.

Advertisement