[idx3d::Docu2]
Working with idx3d_Scene

In order to work with 3d scenes, you need to have an instance of idx3d_Scene.
Its constructor is idx3d_Scene(int width, int height). You pass it a width and heigth as arguments to specify which dimension it should have when you render it. The size can be changed with resize(int width, int height).
The scene contains 3d objects, lights, cameras and materials.

1. Data structures

idx3d_Scene manages the data for you. It does so by using Hashtables, so you can access your instances more comfortablely.

Objects [idx3d_Object]

  • Add: void addObject(String name, idx3d_Object yourObject)
  • Remove: void removeObject(String name)
  • Retrieve: idx3d_Object object(String name)

    If you need very quick access to an object, you can access it over the temporary static data structures by its index. Rebuild the static data structures with rebuild() and access an instance with idx3d_Object object[index]. The total number of objects is stored in member int objects.

Lights [idx3d_Light]

  • Add: void addLight(String name, idx3d_Light yourLight)
  • Remove: void removeLight(String name)
  • Retrieve: idx3d_Light light(String name)

Materials [idx3d_Material]

  • Add: void addMaterial(String name, idx3d_Material yourMaterial)
  • Remove: void removeMaterial(String name)
  • Retrieve: idx3d_Material light(String name)

Cameras [idx3d_Camera]

  • Add: void addCamera(String name, idx3d_Camera yourCamera)
  • Remove: void removeCamera(String name)
  • Retrieve: idx3d_Camera light(String name)
2. Rendering

If you've properly defined objects, lights, cameras and materials, your scene is ready to be rendered. To render it, just call void render() to render from the default camera view.
If you want to render from a specific camera view, call render(idx3d_Camera yourCamera).

Once the scene is rendered, you can apply post render effects to it, for example a lens flare.
You can aquire a java.awt.Image from the rendered scene with Image getImage().

3. Manipulation

idx3d_Scene inherits 3d manipulation methods from idx3d_CoreObject.
For detailed information please refer to the object tutorial [Tutorial 3 : Working with 3d Objects]

4. Identifying objects and Triangles

idx3d_Scene contains a useful mechanism to identify objects at screen coordinates.

To activate/deactivate it, call useIdBuffer(boolean active).
You can reterieve instances of the identified objects using the following methods:

  • idx3d_Object identifyObjectAt(int xpos, int ypos) and
  • idx3d_Triangle identifyTriangleAt(int xpos, int ypos)

    If no object has been identified, both methods return null.

  • 5. Other useful methods

    Activate/deactivate antialiasing:
  • setAntialias(boolean antialias)

    Get current speed in frames per second (FPS):

  • float getFPS()

    Center objects and fit them to screen size:

  • normalize()
    This method is useful after importing object, as you don't know where in world space the are.

  • idx3d SubPages
    Demos
    Download
    Releases
    Feature list
    Documentation
    API [Interface]
    Source Code
    Class Diagrams
    Links

    Material Lab
    idx3d.debug.Inspector

    © 2000 by Peter Walser    |    proxima@active.ch     |    http://www2.active.ch/~proxima