m3g note1

m3g note1

/////////////////
     note1
/////////////////
1.Grahpics3D
1.1 create
Graphics3D is the class that takes care of rendering. It is a singleton, and the unique instance can be obtained with the
getInstance() method.
1.2 render
To render a scene, it is necessary to bind the Graphics3D instance to a target object, do the rendering with one of the
render methods, and then release the target as follows:
// code start
Graphics3D g3d = Graphics3D.getInstance();
World world=…
Graphics g=…
boolean bound = false;
try {
g3d.bindTarget(g);
bound = true;
g3d.render(world);
}
finally
{
if (bound)
{
g3d.releaseTarget();
}
}
//code end
1.3 get the supported quality
The getProperties() method returns information about the supported quality hints, as well as other properties such as number
of texturing units, maximum number of lights, etc.
1.4 render mode
Graphics3D has four render methods that support the two rendering modes: immediate mode and retained mode. In retained mode,
the render method takes a World object, which is the parent of a scene graph. All the information needed for rendering is
contained in the scene graph, including lights, cameras, background, and geometry. When using this method, the color and
depth buffers are implicitly cleared.
In immediate mode, Graphics3D can render individual Node objects, Groups of nodes, or meshes. In this case it is necessary to
explicitly set the current camera and any required lights. Also, the color and depth buffers need to be explicitly cleared
using the clear method.
In both cases it is necessary to have at least one camera that defines the point of view of the scene. In retained mode it is
the World’s active camera and in immediate mode it is the Graphics3D camera. Failure to set an active camera will be
signaled with an exception during rendering.
2.Scene Graph
2.1 including what?
A complete scene graph must include the World, which is the top of the hierarchy, and a Camera. Normally it will also include
a Background, Lights if necessary, and Meshes of the scene. Animations can also be included in the scene graph associated
with different Nodes. They can be advanced individually or all at once by calling the animate method in the top World object
of the scene graph. It is also possible to build a partial scene graph using Group and SkinnedMesh nodes.
2.2 Object3D
The class Object3D is the parent of all the classes that can be part of the 3-D world. An important property of Object3D is
the userID, which can be used to find individual objects in a complex graph. Third-party modeling tools can set this userID
so that the designer and programmer can easily work in the same object. Object3D also includes support for animations, with
methods to add and remove AnimationTracks and to advance the animations.
2.3 Node
The scene graph itself is composed by Node objects, which include the classes Camera, Mesh (including SkinnedMesh and
MorphingMesh), Sprite3D, and Light. Node is the type of object commonly manipulated in an application. The rendering and
picking of nodes can be enabled or disabled individually. Nodes can also be manipulated with the usual translation, rotation,
and scaling transformations. Besides the userID, Nodes can have a scopeID, which can be used to group objects across
different parts of a scene graph for lighting and picking purposes.
2.4 Mesh
A Mesh is a 3-D geometrical object displayed in a scene. A mesh normally includes the positions of the vertices, colors, and
normals, as well as texture coordinates. It also includes information about the edges between vertices. The rendering of
Meshes is regulated by their Appearance. This comprises several properties such as material attributes, textures, compositing
mode, etc. A Mesh is lit only when its Appearance contains a Material definition. Developers can set this to null to enabled
and disable lighting for a particular object.
2.5 Group
Nodes are put together in Groups. Groups include the ability to perform a picking operation among the nodes in the group. The
World is also a Group, with the extra properties as indicated above.

Leave a Reply

Your email address will not be published. Required fields are marked *