I am using MouseRotate class of Java3d to rotate two cylinders. But when i rotate one cylinder the other cylinder rotates with it. Is there a way around this problem.

Thanks.

Member Avatar for hfx642

Make sure that you have TWO mouse listeners,
with TWO handlers, EACH of which will control ONE of the cylinders.

The thing is that i have got the two cylinders on the canvas. So wherever i click, the two cylinders rotate simultaneously. I understand that by having mouselisteners for each cylinder separately will solve the problem, however since i am adding the cylinders on the canvas, therefore i can only invoke the mouselistener on the canvas instance not the cylinder instance.

Can u please post a code of how a mouselistener can be invoked from a cylinder instance.

Thanks.

Member Avatar for hfx642

How do you know which cylinder that you are trying to rotate?
You will need some sort of bounding box to identify which cylinder you want to rotate.
If you mouse click is inside of bounding box 1, rotate cylinder 1.

I have used MouseRotate and passed the cylinder transform group as its transform group. But the problem still is that the rotating via mouse anywhere on the canvas rotates the mouse, which i don't want. THerefore i had used the MouseRotate and set the transform group of the cylinder, so that only that particular transform group gets rotated.

I can set the scheduling bounds of this behavior (MouseRotate) but still the canvas rotates the mouse.

Can you please tell me how to restrict the scheduling bounds only to the diameter of the cylinder and not the entire canvas.

Member Avatar for hfx642

I have never used MouseRotate.
If it was me, I would try using MouseWheelListener instead.
But, that's just me.

Yes i tried to use mousewheellistener as well, but same issue, if i use the mouse wheel on the canvas the cylinder rotates, i only want the mouse wheel to be enabled when i hover over the mouse.

Member Avatar for hfx642

I understand.
However... go back to my second post.
Create bounding boxes around the cylinders (one box around each) and
listen for where the mouse is (X and Y coordinates) when you use the wheel.

Is there any way that i can get the bounds of my cylinder and and then set the scheduling bounds to the center till the radius, so that only that region gets invoked on the mouserotate.

I used Cylinder.getbounds(), to get the center and the radius and then used the points and the radius as my scheduling bounds. But still no effect.

CAn you please help me in this one, i am really stuck.

Member Avatar for hfx642

I've never used MouseRotate.
Sorry, but I can't answer any questions about it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.