1
Support / Re: Camera rotation with the mouse...
« on: May 22, 2008, 04:00:10 pm »
Thanks Egon I'll check them...
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.
I am not an expert on this subject, but I believe the reason for movement not being parallel to the floor after lookAt(), is because the camera's Z-axis is changed by that method. Instead of using the camera's getZAxis() for the moveIn() and moveOut() methods, you will probably need to calculate a vector that is in the general direction of the object, but parallel to the ground (i.e. if the ground is flat and constant altitude, then destination Y should equal camera Y)). Use that vector in your call to checkCameraCollisionEllipsoid() instead of getZAxis().
Also, if you want the moveUp() and moveDown() methods to move perpendicular to the ground when you "lookAt()" an object with a different Y position than the camera, then instead of using the camera's getYAxis(), you will probably need to calculate a vector that is perpendicular to the ground (i.e. if the ground is flat and constant altitude, then use (0, 1, 0)).
In cases where the ground is not flat and constant altitude, you may be able to assume it is and just let the collision detection take care of the altitude adjustments. I don't have any experience with collision detection in jPCT yet, though, so you'll have to experiment, and I am sure some other people can help you, who have more experience than I do on the topic.
One more thing, if you are keeping track of a "playerDirection" matrix separate from the camera's direction matrix (as mentioned in the thread you brought up), then what EgonOlsen wrote is what you will need help with:... I assume that movement should stay parallel to the floor even when looking slightly up or down to the object in question. Then you have to maintain the player's rotation matrix yourself, i'm afraid ...
Unfortunately, I do not have any experience with that topic, either.
Anyway, I hope this helps you out a little
...
public void moveIn()
{
tempVector = cameraDirection.getZAxis();
scene.checkCameraCollisionEllipsoid(tempVector, CAMERA_ELLIPSOID_RADIUS, CAMERA_MOVE_SPEED, 5);
}
public void moveOut()
{
tempVector = cameraDirection.getZAxis();
tempVector.scalarMul(-1f);
scene.checkCameraCollisionEllipsoid(tempVector, CAMERA_ELLIPSOID_RADIUS, CAMERA_MOVE_SPEED, 5);
}
public void moveUp()
{
tempVector = cameraDirection.getYAxis();
tempVector.scalarMul(-1f);
scene.checkCameraCollisionEllipsoid(tempVector, CAMERA_ELLIPSOID_RADIUS, CAMERA_MOVE_SPEED, 5);
}
public void moveDown()
{
tempVector = cameraDirection.getYAxis();
scene.checkCameraCollisionEllipsoid(tempVector, CAMERA_ELLIPSOID_RADIUS, CAMERA_MOVE_SPEED, 5);
}
...
Just do something like:Code: [Select]camera.getBack().setIdentity();
Before doing the rotations. That should do the trick.
possibly that's the problem. you shouldn't do gui things in a thread other then awt event dispatching thread (if you want to use swing components)
try setting up a mechanism as described in this thread: it's almost the same as what i do in karga
http://www.jpct.net/forum2/index.php/topic,1032.msg6421.html#msg6421
mm strange. where do you call frameBuffer.display(canvas.getGraphics()) ? in which method and in which thread ?
if your canvas is awt.Canvas and combo is JComboBox, it's normal. you cant mix awt and swing components that way. google for "swing, mixing heavy and lightweight" etc
Quote from: robbyBut how could i add a JTextField in my scene.i used a JLayeredPane to show such components. at the bottom layer is my graphics component and on top of that there are may others: panels, text fields etc
as Egon said, that way you are stuck to software renderer since you cant mix awt and swing components in a JLayeredPane. if you do, independent of their layer, awt component show up at the top (heavy vs light-weight stuff)
it effects the performance somehow but it works even for a quite complicated gui which is impossible or very hard to implement with blittingCode: [Select]r a f t
I think you want the world drawn in wireframe? So, in your rendering loop instead of using world.draw(...) call world.drawWireFrame();
If you want to just draw a line, then get the graphics context from your canvas with getGraphics and then call graphics.drawLine(...);
Jman
Is it possible to use these classes with sw renderer? As I understood here multitexturing is used... and I don't know whether jpct allows to use multitexturing with sw renderer...there is no multitexturing here, so you can use these classes for sw renderer. albeit i would stick to java2d for sw renderer, which performs better and looks nicer