Tutorial:ScenePicking-Plugins

From Aristoteles

Jump to: navigation, search

Writing Picking PlugIn for Aristoteles3D

by Petar Tasev 10/2005

Prerequests

  1. SourceForge.net account
  2. Eclipse
  3. Java experience

You have to write a class that does something or calls other classes(for example JDialog). Then you have to invoke this class by editing the /config/plugin.xml file. This way your class(your PlugIn) can be loaded into Aristoteles3D.

Steps

1.

Start Eclipse

2.

Make a CVS Connection to SourceForge.net, so you can download the source code of the project.

  • a. Window -> Open Perspective -> Other -> CVS Exploring Repository.
  • b. Generate new ‘repository location’, enter username, host, connection typ=extssh, etc..

Finally, if everything's gone well you'll see something like this:
Image:Tutorial01.jpg
If you have any problems see www.sourceforge.net. You can find more information there.

3.

The Project is on your PC. You can make a new package, for example ‘myPlugIn’:
Image:Tutorial02.jpg

4.

Make a new class with the following code (manage imports with Eclipse) in ‘myPlugIn’:

Package myPlugIn;
public class Test extends AbstractPickingOperator{
public Object clone() {return this;} public String getDescription() {return "This is my first Picking PlugIn :)";} public String toString() {return "TestPickingPlugIn";} public void mouseClicked(MouseEvent e) { pickcanvas.setShapeLocation( e ); PickResult result = pickcanvas.pickClosest();
if (result != null) { ExtendedShape3D shape = (ExtendedShape3D) result.getObject(); //we have the ExtendedShape3D which represenst one shape in the //3DScene //we can print all the Nodes of this shape for example LinkedList nodes = shape.getExterior();
double[][] coord = new double[nodes.size() ][3]; for (int i = 0;i < nodes.size();i++ ) { Object obj = nodes.get( i ); Point3f point = (Point3f) nodes.get( i ); coord[i][0] = (double) point.x; coord[i][1] = (double) point.y; coord[i][2] = (double) point.z; System.out.println(coord[i][0]+" "+coord[i][1]+" "+coord[i][2]); } } } public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void keyTyped(KeyEvent e) {} public void keyPressed(KeyEvent e) {} public void keyReleased(KeyEvent e) {} }
5.

Update the configuration file which can load your plugIn into the program. This configuration file can be found in /config/plugin.xml.

All you have to do is adding the following line below the other <picking class=”…”/>:

<picking class="aquin.aristoteles.plugin.picking.InfoPickingOperator"/>
<picking class="myPlugIn.Test"/>
6.

Save and Run the program. Your PlugIn is now visible under plugin->picking->available. Apply it and select any shape in the current scene. You will get the coordinates of the nodes of the selected shape in the Eclipse Console.

7.

You have reacted to a user selection of a shape from 3D model.

powered by