Motorola E680 Technical Manual - Page 33

Initializing the world

Page 33 highlights

9 JSR 184 Initializing the world The Loader class is used to initialize the world. It has two static methods: one takes in a byte array, while the other takes a named resource, such as a URI or an individual file in the JAR package. The load methods return an array of Object3Ds that are the root level objects in the file. The following example calls Loader.load() and passes it an M3G file from the JAR file using a property in the JAD file. Alternatively, you could specify a URI, for example: Object3D[] roots = Loader.load(http://www.example.com/m3g/simple.m3g)[0]; The example assumes that there is only one root node in the scene, which will be the world object. If the M3G file has multiple root nodes the code must be changed to reflect this, but generally most M3G files have a single root node. public void startApp() throws MIDletStateChangeException { myDisplay.setCurrent(myCanvas); try { // Load a file. Objects3D[] roots = Loader.load(getAppProperty("Content- 33

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107

9
JSR 184
33
Initializing the world
The Loader class is used to initialize the world. It has two static methods: one takes in a
byte array, while the other takes a named resource, such as a URI or an individual file in
the JAR package.
The
load
methods return an array of Object3Ds that are the root level objects in the file.
The following example calls Loader.load() and passes it an M3G file from the JAR file
using a property in the JAD file. Alternatively, you could specify a URI, for example:
Object3D[] roots =
Loader.load(
];
The example assumes that there is only one root node in the scene, which will be the
world object. If the M3G file has multiple root nodes the code must be changed to reflect
this, but generally most M3G files have a single root node.
public void startApp() throws MIDletStateChangeException
{
myDisplay.setCurrent(myCanvas);
try
{
// Load a file.
Objects3D[] roots = Loader.load(getAppProperty("Content-