< Zurück | Inhalt | Weiter >

J3dMessage


Java 3D communicates between its various worker threads using a message dispatch mechanism. Messages are instances of the J3dMessage class. Each message contains an identifier and a target VirtualUniverse as well as up to five parameters for the message (generic Objects). Certainly not the most OO of designs—in fact it reminds me of the WPARAM and LPARAM attributes on the MESSAGE structure used to propagate messages under Windows.


The message identifiers are defined in table 18.5.


Table 18.5 Message identifiers


Message

Identifier

INSERT_NODES

0

REMOVE_NODES

1

RUN

2

TRANSFORM_CHANGED

3

UPDATE_VIEW

4

STOP_THREAD

5

COLORINGATTRIBUTES_CHANGED

6

LINEATTRIBUTES_CHANGED

7

POINTATTRIBUTES_CHANGED

8

POLYGONATTRIBUTES_CHANGED

9

RENDERINGATTRIBUTES_CHANGED

10

TEXTUREATTRIBUTES_CHANGED

11

TRANSPARENCYATTRIBUTES_CHANGED

12

MATERIAL_CHANGED

13

TEXCOORDGENERATION_CHANGED

14

TEXTURE_CHANGED

15

MORPH_CHANGED

16

GEOMETRY_CHANGED

17

APPEARANCE_CHANGED

18

LIGHT_CHANGED

19

BACKGROUND_CHANGED

20

CLIP_CHANGED

21

FOG_CHANGED

22

BOUNDINGLEAF_CHANGED

23

SHAPE3D_CHANGED

24

TEXT3D_TRANSFORM_CHANGED

25

TEXT3D_DATA_CHANGED

26

SWITCH_CHANGED

27

COND_MET

28

BEHAVIOR_ENABLE

29

BEHAVIOR_DISABLE

30

INSERT_RENDERATOMS

31

ORDERED_GROUP_INSERTED

32

ORDERED_GROUP_REMOVED

33

COLLISION_BOUND_CHANGED

34

REGION_BOUND_CHANGED

35

MODELCLIP_CHANGED

36

BOUNDS_AUTO_COMPUTE_CHANGED

37

SOUND_ATTRIB_CHANGED

38

AURALATTRIBUTES_CHANGED

39

SOUNDSCAPE_CHANGED

40

ALTERNATEAPPEARANCE_CHANGED

41

RENDER_OFFSCREEN

42

RENDER_RETAINED

43

RENDER_IMMEDIATE

44

SOUND_STATE_CHANGED

45

ORIENTEDSHAPE3D_CHANGED

46

TEXTURE_UNIT_STATE_CHANGED

47

UPDATE_VIEWPLATFORM

48

BEHAVIOR_ACTIVATE

49

The type member refers to one of the predefined message types from the table.


Each J3dMessage maintains a reference count so that it can clear the references to its arguments when its reference count reaches zero. Messages with a reference count of zero are placed back into a list of free messages, for subsequent reuse. This message instance cache minimizes the number of message objects created by the Java 3D at runtime in an attempt to prevent excessive garbage collection. Interestingly this type of Object pooling is no longer favored as Sun’s HotSpot compiler performs object pooling and reuse automatically.


The MasterControl method getMessage will either return a message from the free list if one is available or allocate a new J3dMessage instance, which will get added to the free list once its reference count reaches zero. The J3dMessage also maintains a reference to a View object and contains a thread identifier (bit−field) that identifies the threads that should receive the message, as shown in table 18.6.


Identifier

Java 3D Thread

Java 3D Thread Name

0x1

BEHAVIOR_SCHEDULER

J3D−BehaviorScheduler−INSTANCE#

0x2

SOUND_SCHEDULER

J3D−SoundSchedulerUpdateThread−INSTANCE#

0x4

INPUT_DEVICE_SCHEDULER

J3D−InputDeviceScheduler−INSTANCE#

0x10

RENDER_THREAD

J3D−Renderer−INSTANCE#

0x40

UPDATE_GEOMETRY

J3D−GeometryStructureUpdateThread−INSTANCE#

0x80

UPDATE_RENDER

J3D−RenderStructureUpdateThread−INSTANCE#

0x100

UPDATE_BEHAVIOR

J3D−BehaviorStructureUpdateThread−INSTANCE#

0x200

UPDATE_SOUND

J3D−SoundStructureUpdateThread−INSTANCE#

0x400

UPDATE_RENDERING_ATTRIBUTES

J3D−RenderingAttributesStructureUpdateThread

0x1000

UPDATE_RENDERING_ENVIRONMENT

J3D−RenderingEnvironmentStructureUpdateThread−INSTA

0x2000

UPDATE_TRANSFORM

J3D−TransformStructureUpdateThread−INSTANCE#

Table 18.6 Java 3D Threads


The sendMessage method updates appropriate message queue data structures based on the value of the thread identifier (table 18.7).


Table 18.7 Target thread identifiers for messages


Thread Identifier

Effect


UPDATE_RENDERING_ATTRIBUTES

Appends the message to the global (across VirtualUniverses) RenderingAttributesStructure


UPDATE_GEOMETRY

Appends the message to the VirtualUniverses’ GeometryStructure

UPDATE_TRANSFORM

Appends the message to the VirtualUniverses’


TransformStructure


UPDATE_BEHAVIOR

Appends the message to the VirtualUniverses’ BehaviorStructure


UPDATE_SOUND

Appends the message to the VirtualUniverses’ SoundStructure


UPDATE_RENDERING_ENVIRONMENT

Appends the message to the VirtualUniverses’ RenderingEnvironmentStructure


SOUND_SCHEDULER

Appends the message to the View’s SoundScheduler (if a View is not specified, the message is added to the SoundScheduler for all registered Views)


UPDATE_RENDER

Appends the message to the View’s RenderBin (if a View is not specified, the message is added to the RenderBin for all registered Views that are attached to the specified VirtualUniverse)

18.3.1 System properties read by Java 3D

Java 3D reads a number of system properties, some documented and some internal. A list of these properties is also maintained on the J3D.ORG site at http://www.j3d.org/implementation/properties.php
.


Table 18.8 lists the system properties that are referenced in the Java code of the Java 3D distribution. Many more system properties are available which are specific to the OpenGL or DirectX versions of Java 3D. Please refer to the J3D.ORG website for the latest information on these properties.


Table 18.8 Thread Group: System


Name

Default

Purpose


java.version


None

Check to see whether Java 3D is running under SDK 1.3


j3d.sharedctx


False

Use shared display contexts when rendering

j3d.renderLock

True

Disable the render lock

j3d.g2ddrawpixel

True



j3d.threadLimit


Processors + 1

Number of concurrent threads that Java 3D can use.

j3d.deviceSampleTime

0

Input device sampling time.


j3d.debug


False

Switch on Java 3D debug output.

Currently only used by the

MasterController.


Javax.media.j3d.compileStats


None

Output scenegraph compilation statistics


Javax.media.j3d.compileVerbose


None

Output verbose message when compiling scenegraph