Skip to main content

Geometry BY_REFERENCE

2 replies [Last post]
millerni456
Offline
Joined: 2010-12-09
Points: 0

Hey all! I was hoping I could find some help here at java.net.

Here is the problem: I'm trying to create an application where I can select a point on the canvas3D,convert the coordinates to the 3D virtual world, then use PointArray to add a point at the spot I clicked. However... I'm running into some issues.
So far I can obtain the virtual world coordinates by clicking the canvas3D, but I'm not sure how to add the point. I've been looking into using Geometry By-Reference to see if this could solve the problem-- and I think it will-- but I'm not sure how I can modify the geometry after runtime.
Currently, I believe I need to create a PointArray object using the "BY_REFERENCE" flag and enabling the proper capabilities: ALLOW_REF_DATA_READ and ALLOW_REF_DATA_WRITE. I also have a capability set to a Shape3D: ALLOW_GEOMETRY_WRITE. I'm not sure if I need the ALLOW_COUNT_WRITE capability for the PointArray object.
So I used these ideas and tried to increment the amount of indices the PointArray is using based on how many clicks I make to the cavas3D.

public void mouseReleased(MouseEvent e)
{
//get the 3D coordinate
numPoints++;
createPoint(objRoot, numPoints); //objRoot is the BranchGroup object
}

createPoint() changes the data for the PointArray accordingly, but I get an error when I add the my Shape3D object to the BranchGroup. Also, I'm not sure if i need to do anything with the GeometryUpdater class. All help is appreciated, and thanks for taking your time to read this.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
millerni456
Offline
Joined: 2010-12-09
Points: 0

I got it working :)

atulsaroha
Offline
Joined: 2010-08-06
Points: 0

Will you please tell me how you are fetching cordinate at some point of universe using mouse operation?