Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - stormp

Pages: [1] 2 3
Support / Trackball Rotation
« on: January 23, 2008, 05:24:08 pm »
Here is a great example of what I would like to do:

News / Re: New version of...myself!
« on: December 17, 2007, 09:54:44 am »
I don't know where you found the time  ;-)

Congratulations and best wishes for you and your family.


Support / Re: Scene Rotation
« on: December 12, 2007, 11:40:40 am »
Will do Egon.  Thanks! :)

Support / Re: Scene Rotation
« on: December 12, 2007, 01:26:06 am »
Thanks Egon,

I also found this site that should solve part of the problem but it implements Quaternion math.


Support / Re: Scene Rotation
« on: December 10, 2007, 03:44:17 pm »
Hi Egon,

Thanks for the code!  I tried messaging you before but I think my browser was acting up.. the replies never end up in the outbox. :-S

Your example seems to be similar to my Euler Angle Rotation example here:

It's not really what I'm trying to accomplish. I'm trying to get the same effect that google earth has.  The use clicks on the screen, the code calculates the closet point on an imaginary sphere as the drag point. As the user drags the cursor around the screen, the camera moves such that the original point grabbed is rotated to where the current mouse position is.  If the user drags outside the sphere area and around it would rotate around the Z axis (i believe).

Does that make sense?   I think the term is called Trackball Rotation? or Virtual Trackball Rotation.

Very grateful for your time.


Support / Re: How to Rotate Object relative to camera?
« on: November 05, 2007, 07:57:48 pm »
Thanks Egon!  I really misunderstood what the rotateAxis() function was for.  Now suddenly everything is coming to light ;-)  Thanks again!!!!

I made a demo base that i am using to build on for my quest to solve the my bigger problem of natural rotations (hopefully soon).  I know these are elementary examples, but they might help someone else starting out.   

Applet demo with source:

Simple free camera movement and rotation around a simple scene using keyboard and mouse.

Simple free camera movement and rotation with keyboard and object rotation and movement with mouse relative to camera view.

I'll try to clean up the code and optimize with comments later :-)

Thanks so much again!


Support / How to Rotate Object relative to camera?
« on: November 04, 2007, 10:25:43 pm »
Hi again,

I'm trying to figure out how to rotate an object relative to the X Y axis of the screen space.

This *seemed* at first to almost work, but when I move the camera behind or under the object, I get inverse and / or reverse rotations - so I guess I'm way off here. :-(

Any suggestions?

Thank you,


Code: [Select]
public SimpleVector rotateRespect2Cam(float rotX, float rotY)
   SimpleVector dir = theCamera.getDirection();


   return dir.calcSub(theCamera.getDirection());

Code: [Select]
SimpleVector rotate = rotateRespect2Cam(delta.x * -camRotSpeed, delta.y * -camRotSpeed);

object.rotateX(rotate.x);  // rx rz ry to avoid gimbal lock.

Support / Re: Scene Rotation
« on: October 30, 2007, 11:05:02 am »
I think my main problem is that I haven't fully sorted out in my head the transition from mouse (screen space) to camera space to world space and back.  Are there any examples that show mouse interaction with objects?  That might enlighten me more :-)

In the example I posted, it appears everything is done in world space and the object is moving, not a free moving camera that does arbitrary rotations on mouse drags.

Support / Re: Jpct tutorial
« on: October 29, 2007, 04:35:49 am »
A tutorial would be good! Can't we wiki it somehow? Then we could all help out...

A wiki would be great.

Support / Re: Jpct tutorial
« on: October 28, 2007, 05:27:02 pm »
I have a demo I made when I was learning how to manipulate the camera.  Basically its a simple scene with a camera that rotates around the scene.  You can watch the camera move from a fixed position or watch from behind the camera in a chase mode.  I'm not 100% sure that my implementation was the best way, but I would be willing to post it somewhere if you think it would be helpful as a tutorial for some newbies.  :-)

Support / Re: Scene Rotation
« on: October 28, 2007, 05:13:26 pm »
EDIT: This, of course, does not depend on the user actually grabbing the sphere. If that's an issue then you could use Interact2D to check if the user is actually clicking on the sphere or not, and then calculating the distance from that point to the center of the sphere (instead of calculating the distance from the click and to the center of the screen).

The sphere is imaginary. :)    Basically I have a 3D graph chart as a scene and I wanted to implement "natural rotations" around the chart (scene).  The effect is that if the user grabs a point and drags it in any zig zag direction, they can return to the scene to the original view by simply dragging the mouse back to its original mouse down position -  "zero-hysteresis rotation".  With normal rotations you cant really do this. :-S  Also, the original mouse-down point can not be rotated behind the sphere.

I believe this sort of explains it better:
The main idea is to think in terms of arc intervals. If we have two arbitrary points A and B on the surface of a unit sphere, the most natural way to get from A to B is to rotate the sphere so that A follows the shortest path (or geodesic) from A to B. Thus the rotation occurs in the plane of the geodesic. If a = (xa, ya, za) and b = (xb,yb,zb) are the position vectors of the points, the axis of rotation is given by a 5 b. The angle of the rotation can be obtained from cos-1 (a b).

How do we get from 2D mouse coordinates to 3D rotations? We construct a pseudo-3D coordinate space as follows. (This is essentially the method of Shoemake in Graphic Gems IV, p. 176.) Superimpose an imaginary sphere on our 3D object such that the center of the sphere is at the position vector c = (screen_x, screen_y, 0), where screen_x and screen_y are the local screen coordinates of the center of the object. We assume that any mouse-downs will happen on the surface of our imaginary sphere, which has a radius of r pixels.

I'd prefer to rotate the camera rather than the scene ^_^  To be honest my math is rusty to achieve this :-(

Support / Re: Scene Rotation
« on: October 28, 2007, 04:05:07 pm »
You'd just calculate the X/Y deltas of the mouse-drags and feed those distances into the rotation methods. The other thing you could do is keep the object still and rotate the camera around the object instead (in that case look at the Camera class documentation for rotation).

Hi, thanks for the reply.  I have a regular camera rotation based on the x/y deltas of the mouse-drags.  Unless I've understood you wrong, what you described wouldn't give me the drag point (where the mouse button was first downed) that Google Earth has.  If you grabbed a sphere close to the top and dragged it a little, the rotation would be much more than if you grabbed a sphere from the middle and dragged it the equal distance across the screen.

Support / Re: wireframe mode per object/mesh
« on: October 28, 2007, 07:12:56 am »
I'd love this feature too :-D

Support / Scene Rotation
« on: October 28, 2007, 07:02:12 am »
Hi :-)

I'm looking for some pointers on how to mimic scene rotation similar to how GoogleEarth does.  IE: grabbing a point on a (imaginary) sphere and dragging that point around.

I found this article:

Is there any similar examples in jPCT?

Appreciate any help!




Still working on my grid lines.  ;D 

project3D2D wont render if "the center is behind the viewplane".   How can I adjust my vectors to clip at the approriate end?

Much thanks.


Code: [Select]
    private void drawLine(FrameBuffer fb, Graphics2D g, SimpleVector v1, SimpleVector v2)
        SimpleVector point1 = Interact2D.project3D2D(theWorld.getCamera(), fb, v1);
        SimpleVector point2 = Interact2D.project3D2D(theWorld.getCamera(), fb, v2);

        if(point1 != null && point2 != null)
            g.drawLine((int)point1.x, (int)point1.y, (int)point2.x, (int)point2.y);
        }  // if

Pages: [1] 2 3