dprakash
Enjoying the stay
Offline
Posts: 25
|
 |
« on: 06. February 2007, 11:56:25 am » |
|
Picking is working fine for all except Foreground Node. I have made an axis as foreground and if i try to pick it i dont get any results.I have my code here:
List<PickResult> results2 = canvas3D.pickAll(x, y,3,3); Foreground foreGround=(Foreground) ((TransformGroup)scene.getChild(1)).getChild(0); List<PickResult> pickResult = canvas3D.pickAll(foreGround.getGroup(), dataController.getMouseData().getMouseClickPos_X(), dataController.getMouseData().getMouseClickPos_Y());
i have found that "pickResult" returns null.
|
|
|
|
« Last Edit: 06. February 2007, 12:00:10 pm by dprakash »
|
Logged
|
|
|
|
|
Patheros
|
 |
« Reply #1 on: 06. February 2007, 04:07:29 pm » |
|
Have you tried using the PickingLibaray? Its a static tool that does more accurate picking than canvas.pickAll().
Another thing: Is the foreground node and all its sub nodes (that you want picked) set to pickable with setPickable(true)? I'm not sure if the parent nodes need to be set to pickable but it wouldn't hurt to try.
|
|
|
|
|
Logged
|
"I like my method, what was my method again?" - Jon
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #2 on: 06. February 2007, 07:03:26 pm » |
|
I'm not sure if the parent nodes need to be set to pickable but it wouldn't hurt to try.
This is necessary. @dprakash: Welcome to Xith3D. Please check, you cannot to the picking without Canvas3D.pick*() or PickingLibrary, since you're picking a foreground node. Have you also set the projection policy to parallel? Then you can do the picking more chaply than any of the thow above methods. Marvin
|
|
|
|
« Last Edit: 06. February 2007, 07:05:50 pm by Marvin Fröhlich »
|
Logged
|
|
|
|
|
'n ddrylliog
|
 |
« Reply #3 on: 06. February 2007, 07:31:28 pm » |
|
Hey dprakash! Welcome to Xith3D boards.
|
|
|
|
|
Logged
|
|
|
|
dprakash
Enjoying the stay
Offline
Posts: 25
|
 |
« Reply #4 on: 07. February 2007, 04:44:14 am » |
|
Patheros: I tried Picking Library but it does not pick shapes made of Line or LineStrip Array.
I am also setting foreGround and all its node to be pickable still i am not able to pick it.
I'll try to make a test case and post.
|
|
|
|
|
Logged
|
|
|
|
|
khangharoth
|
 |
« Reply #5 on: 07. February 2007, 04:51:38 am » |
|
@dprakash: Welcome to Xith3D. Please check, you cannot to the picking without Canvas3D.pick*() or PickingLibrary, since you're picking a foreground node. Have you also set the projection policy to parallel? Then you can do the picking more chaply than any of the thow above methods.
Hi Marvin ,can you elaborate your answer as its kind of unclear what you are trying to say.How is picking different if it is foreGround node if we do opengl style picking?
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #6 on: 07. February 2007, 08:51:47 am » |
|
Hi Marvin ,can you elaborate your answer as its kind of unclear what you are trying to say.How is picking different if it is foreGround node if we do opengl style picking?
Sorry, my mistake. It is no difference. I mixed that up with perspective/parallel projection, which definitely is a difference. Marvin
|
|
|
|
|
Logged
|
|
|
|
dprakash
Enjoying the stay
Offline
Posts: 25
|
 |
« Reply #7 on: 08. February 2007, 05:53:12 am » |
|
Here is my Test Case.If i try to pick sphere, attached to Foreground node,pick results show null.While the quad attached directly to group gets picked.
package Test; /** * @author dprakash * Picking Test with Foreground node not working. */
import java.util.List;
import javax.vecmath.Color3f; import javax.vecmath.Point3f; import net.jtank.input.KeyCode; import org.xith3d.geometry.Quad; import org.xith3d.geometry.Sphere; import org.xith3d.picking.PickResult; import org.xith3d.render.base.Xith3DEnvironment; import org.xith3d.render.canvas.Canvas3DWrapper; import org.xith3d.render.canvas.Canvas3DWrapper.Resolution; import org.xith3d.render.loop.RenderLoop; import org.xith3d.scenegraph.Foreground; import org.xith3d.scenegraph.Group; import org.xith3d.scenegraph.View.CameraMode;
public class ForeGroundPickTest extends RenderLoop {
Canvas3DWrapper canvas; private Group group; /** * Synchronization object to ensure that only one thread has access to pick params */ private Object pickParamsMutex = new Object(); private boolean picked = false; private int pickX; private int pickY;
private Group createScene() { group= new Group(); group.setPickable(true); Sphere sph = new Sphere(10, 10, 1, 20); sph.setPickable(true); // group.addChild(sph); /** * Attaching the sphere to foreground node then it is not picked. */ Group foregroundG = new Group(); foregroundG.addChild(sph); foregroundG.setPickable(true); Foreground fg = new Foreground(foregroundG,CameraMode.VIEW_FIXED); fg.setPickable(true); group.addChild(fg); Point3f[] vertexArray={new Point3f(30, 10, 0), new Point3f(50, 10, 0), new Point(50, 40, 0), new Point3f(30, 40, 0)}; Quad quad = new Quad(new Color3f(1, 1, 1),0,vertexArray); quad.setPickable(true); group.addChild(quad); return group; }
public ForeGroundPickTest() {
Xith3DEnvironment env = new Xith3DEnvironment(this); env.getView().setScreenScale(100); env.getView().setProjectionPolicy(env.getView().PARALLEL_PROJECTION); canvas = Canvas3DWrapper.createStandalone(Resolution.RES_800X600,"Picking test"); this.registerKeyboardAndMouse(canvas); env.addCanvas(canvas); env.addChild(createScene()); this.begin(); }
public static void main(String[] args) { new ForeGroundPickTest(); } protected void loopIteration(long gameTime, long frameTime) { super.loopIteration(gameTime, frameTime); synchronized (pickParamsMutex) { if (picked) { // Pick object at mouse point and within 3 pixels around it System.out.println("Picking at " + pickX + ", " + pickY); List<PickResult> results = canvas.pickAll(pickX, pickY, 3, 3); if (results == null) { System.out.println("Pick results are null"); } else { System.out.println("Detected " + results.size() + " hits"); int i = 0; for (PickResult pr: results) { System.out.println(" Hit (" + i++ + "): Shape3D: \"" + pr.getShape().toString() ); } } picked = false; } } } public void onMouseButtonPressed(int button, int x, int y) {
// Transfer mouse event parameters to rendering thread synchronized (pickParamsMutex) { this.pickX = x; this.pickY = y; picked = true; } } public void onKeyReleased(int key) { switch (key) { case KeyCode.VK_ESCAPE: System.exit(0); break; } } }
|
|
|
|
« Last Edit: 08. February 2007, 06:13:37 am by dprakash »
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #8 on: 08. February 2007, 11:37:44 am » |
|
Picking on a Foreground Node is simply not supported by Xith3D and is not easily implemented. Sorry. When I have time, I will see, if I can do that. What do you need it for?
Marvin
|
|
|
|
|
Logged
|
|
|
|
dprakash
Enjoying the stay
Offline
Posts: 25
|
 |
« Reply #9 on: 08. February 2007, 12:33:19 pm » |
|
Hi Marvin
Actually picking of Foreground Node was working fine with Xith 8.0(older version) but after migrating to Xith 9.0 i am facing this problem.
I have an (x,y,z) axis which i have to keep on foreground, to pick it for rotation.
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #10 on: 09. February 2007, 07:18:08 pm » |
|
Hi Marvin
Actually picking of Foreground Node was working fine with Xith 8.0(older version) but after migrating to Xith 9.0 i am facing this problem.
I have an (x,y,z) axis which i have to keep on foreground, to pick it for rotation.
OK, I will see, what I can do to get it (back to) working. Marvin
|
|
|
|
|
Logged
|
|
|
|
|