The View3D component inherit from the object java.awt.component, so
just use it this way.
Example:
| import java.awt.*:
import tom.graphic.ThreeD.*; public class MyApplet extends Applet{
|
the problem is that the object is created with the default object, which
is a dirigable. Maybe you want to add your own object.
So, if you're program is executed from an applet, just replace the
View3D canvas creation with the following lines:
| myView=new View3DCanvas(false);
// the false value is here to prevent
// the creation of the default obj try { String name="avion.m3d"; myView.setObj(new URL(getDocumentBase(), name ).openStream(),name); } catch(Exception e) { System.out.println(e); } |
Now you can move your object. Play with the setAngleX/setAngleY/setAngleY
values of the View3DCanvas, or the setPosX/setPosY/setPosZ to change the
user point of View.
Lesson2: How to create a more complex object.
The basic object used in our 3D worlds are Ojbect3D instances. Each
object is made of Points and several Elements ( see class Elem3D). An element
can be a line, face, sphere (or something else if you want to extends View3D).
So, using our previous applet, we will create a new object ( a pyramide)
and add this object in our world.
| Object3D myObj=new Object3D();
myObj.addVert(-1,-1,0); //
this is point number 0
Face f=new Face(0,1,4,4,Color.red); //if
you use 3 points for your face
// now, we add your new
object in the whole world
|
that's all....
Lesson3: Add new readers...
It's easy to add new reader. Just implement the ObjReaderInterface, and register your reader using the static method: Object3D.addReader(). Check the next tutorial: Create your own object Reader.