# Creating Your Own 3D Object

This tutorial will teach you how to write your own implementation of a 3D object.

Before you begin this tutorial, we assume you've done the following:

- Installed the Java SDK (7.0 or later)
- Installed NetBeans IDE (7.3.1 or later)
- Installed INTViewer


### Create your module template in Netbeans

- Click **File -> New Project**
- In the New Project Wizard, select **NetBeans Modules** from the **Categories** list and **Module** from the **Projects** list and click **Next >**
- For **Project Name** specify *MyPolyline*
- Select option **Standalone Module** and make sure to specify the INTViewer platform in the **NetBeans Platform** field.
- Click **Next >** and specify *com.mycompany.myviewer.mypolylineobject* for the **Code Base Name** and *MyPolyline* for the **Module Display Name**.
- Click on **Finish.**
- In the **Projects** tree view, you should see your project.


### Configuring your Module

- In the **Projects** tree, right click on the module **MyPolyline** and select **Properties** from the list.
- Under **Categories**, select **Libraries**
- Click on the **Add** button next to **Module Dependencies**
- In the list, select *AllDeps, INTViewerCore, JCarnacProWrapper, Lookup API, Utilities API, UI Utilities API, Viewer3D* and click **OK**.
- Click on **OK** in the Project Properties Dialog


### Create your Polyline3DObject class

- In the **Projects** tree, right click on the module **MyPolyline** and select **New -> Java Class...** from the list.
- Enter *Polyline3DObject* as the class name and select *com.mycompany.myviewer.mypolylineobject* as **Package**.
- Click **Finish**.
- In the class editor, indicate that this Polyline3DObject class extends AbstractObject3D
- Right-click in the class editor and select "Fix Imports". This will automatically import the abstract class AbstractObject3D
- On the line with the class definition, click on the little light bulb with the red exclamation mark.
- Click on "Implement all abstract methods" to make skeletons for all the methods.
- Comment out all the "throw new UnsupportedOperationException...", and have the methods return null for right now.
- Add a constructor to override the AbstractObject3D constructor.
- Be sure to *fix imports* to import IWindow3D.
- Before we can fill out the object class more, we need to define two helper classes in our module; **PolylineData** and **PolylineJOGLNode**.
- **PolylineData** is quite simple. Just copy the code below.
- Don't forget to *fix your imports*.
- **PolylineJOGLNode** is a little more complicated; this class does all the actual OpenGL rendering in this class. Just copy the code in the two images below:
- With these two classes defined, we can finish our Polyline3DObject class:


### Create a new Polyline 3D Object Action

- Now we will create a user action that triggers the creation of a new polyline
- In the **Projects** tree, right click on the module **MyPolyline** and select **New -> Action...** from the list.
- Make sure the radio button "*Always Enabled*" is clicked, and click **Next >**
- In the GUI registration make sure it is the **File** category.
- Then change the **Menu** selection to "*File*" and **Position** to `<separator> - HERE`. Click **Next >**
- In practice, this screen is how you specify where and what will trigger your action.
- For the class name write "*NewPolylineObjectAction*," and the display name put "*New Polyline Object*." Click **Finish**.
- If you run the program now ,you will see that the action is successfully wired up but does actually not do anything when clicked on.
- Now we will code up an action to create a horizon layer. Since Polyline Objects only make sense in relation to a 3D window, we need to know which 3D window has been selected, if at all. To do this, we will need to use a class called *GlobalSelection*.
- Edit *NewPolylineObjectAction.java* to contain the following code. You may have to *Fix Imports* like before.
- Now click on the green arrow to run the program. Click on File -> New 3D Window.
- After the window is open, Click on File ->New Polyline Object.
- If you did everything correctly, the final image should look something like the image below: