Main Menu
Menu

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.

Show posts Menu

Messages - entis

#1
Support / Re: Camera rotation with the mouse...
May 22, 2008, 04:00:10 PM
Thanks Egon I'll check them...
#2
Support / Camera rotation with the mouse...
May 22, 2008, 03:35:45 PM
Hi,

I would like to know how camera rotation (relative to the camera center) with a mouse could be implemented in jpct (in sw renderer mode), i.e. I would like to choose direction with the mouse and only then move there with the keys (like in 3D shooter games, e.g. CS), also zooming with the mouse wheel would be great... May be someone has an example?

Thanks in advance.
#3
Support / Re: Camera rotation question
April 29, 2008, 07:59:43 AM
Quote from: paulscode on April 28, 2008, 11:34:49 PM
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:

Quote from: EgonOlsen on November 01, 2005, 08:15:48 AM
... 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  ;D

Thanks Paulscode... the following action after lookAt() method solves all the problems with parallel movement: cameraDirection.set(2,1,0.0f);
#4
Support / Re: Camera rotation question
April 28, 2008, 05:28:32 PM
I found some solution here http://www.jpct.net/forum2/index.php/topic,317.0.html but anyway my movement is not parallel to the floor after lookAt()...
#5
Support / Re: Camera rotation question
April 28, 2008, 04:32:55 PM
Hi,

I have another one question about camera rotation/movement...

In my app I move the camera just like in the JPCT FPS example is shown:


   ...
   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);
   }
   ...


and it works ok... but know I need to call once camera.lookAt() method to point my camera to some object... but after this my camera begin to move not good with the code listed above...
I understand that it's due to the fact that my cameraDirection matrix is not changed with lookAt() method, but I just can't get how to apply modifications made by lookAt() method to the cameraDirection matrix... Please help...
#6
Support / Re: Camera rotation question
April 16, 2008, 12:22:27 PM
Quote from: EgonOlsen on April 16, 2008, 12:14:34 PM
Just do something like:

camera.getBack().setIdentity();

Before doing the rotations. That should do the trick.

Thanks a lot! it really works...
#7
Support / Camera rotation question
April 16, 2008, 10:58:25 AM
Hi,

I have a question about camera rotation... I would like to rotate a camera each time absolutely (i.e. rotation angle should be layed off from the world axis each time I call the rotation method) .. currently I have a problem with it. For example if I call camera.rotateY(Math.toRadians(10)) two times it will do camera rotation each time and the camera angle relative to the world Y axis will be 20 deg. not 10.

Here is what I want:
...
camera.rotateY(Math.toRadians(10)) // camera has been rotated on 10 deg. (relative to the world Y axis)
camera.rotateY(Math.toRadians(10)) // actually camera has been rotated on 10 deg. (relative to the world Y axis) but nothing changed on the screen since angle is 10 again
camera.rotateY(Math.toRadians(12)) // actually camera has been rotated on 12 deg. (relative to the world Y axis) but on the screen it looks like rotation on 2 deg. (relative to the old position)

So your sugestions are welcome about how can I realize this in jpct... may be it's already done in jpct?
Thanks in advance.
#8
Support / Re: how to blit jcomponents?
April 11, 2008, 01:20:25 PM
Quote from: raft on April 11, 2008, 01:17:42 PM
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


Thanks a lot, I'll try..
#9
Support / Re: how to blit jcomponents?
April 11, 2008, 01:09:40 PM
Quote from: raft on April 11, 2008, 01:00:57 PM
mm strange. where do you call frameBuffer.display(canvas.getGraphics()) ? in which method and in which thread ?

I call it in a separate thread wich performs all the rendering work in my app... In a word I have main thread (where all the gui is created and its behaviour is described) and a child thread where I perform rendering which in its turn has a link to canvas (JPanel) that is created in the main thread... By the way may be it is important that it's not a standalone app but an applet.
#10
Support / Re: how to blit jcomponents?
April 11, 2008, 12:52:11 PM
Quote from: raft on April 11, 2008, 12:50:48 PM
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

My canvas is JPanel...
#11
Support / Re: how to blit jcomponents?
April 11, 2008, 12:43:01 PM
Quote from: raft on July 26, 2005, 12:53:39 PM
Quote from: robby
But 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 blitting

r a f t

Hi,

I have a question about using the JLayeredPane component with jpct (in sw rendering mode)... I can't get how can I use it to prevent my swing components to be overpainted with jpct (i.e. frameBuffer.display(canvas.getGraphics()))... I add my JPanel on which I draw a scene with jpct on the bottom of JLayeredPane (i.e. layeredPane.add(canvas, new Integer(0))) then I add some other components to JLayeredPane's top (i.e. layeredPane.add(comboBox, new Integer(1)))... But still my combobox is behind the canvas... Of course everything works fine when I remove "frameBuffer.display(canvas.getGraphics())" - my components are painted in correct order...

Thanks in advance.
#12
Support / Re: How to draw a line...
April 03, 2008, 03:34:32 PM
Quote from: JavaMan on April 03, 2008, 03:20:21 PM
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

No, I don't want to draw a world in a wireframe and also I don't want to draw a line on the top of the rendered image... I want to draw a line inside the world... for example behind some object in 3d world... I understand that this could be done with the "Primitives" class (draw a line as a cylinder for example)... but I'm wondering whether this is the only way or there are some other ways... 
#13
Support / How to draw a line...
April 03, 2008, 09:54:37 AM
Hi,

I would like to know how can I draw a line in jpct (like in a wireframe mode.. triangles are drawn with lines i suppose?) while I'm in a normal rendering mode.

Thanks in advance.
#14
Support / Re: blitting text and images
April 01, 2008, 04:32:56 PM
Quote from: raft on April 01, 2008, 02:13:50 PM
Quote from: entis on April 01, 2008, 01:25:45 PM
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

thanks, then I 'll try :)
#15
Support / Re: blitting text and images
April 01, 2008, 01:25:45 PM
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...