-
Notifications
You must be signed in to change notification settings - Fork 44
Image World Configurations
DO NOT USE IMAGE WORLD FOR NEW DESIGNS
Image world is now replaced by Custom world and Missions world. If you have a world file that was designed using image world, it will continue to work. I have no plans to remove image world in the near future.
The new Custom world provides many more capabilities, and is supported by the graphic world builder. If you wish to convert your old world file to the new custom world format, you can do so by simply editing the JSON and changing "worldName" to "custom", provided that you are not using "obstacles" and "magnetics" in your file (..."objects" are fine).
- Click "World -> Generate from image" and set the options accordingly. DO NOT click "Ok". Instead, click "Save" when done.
- Open the saved file in your text editor or JSON editor.
You can safely ignore these fields. Do not change them.
- worldName, length, width
- image: This selects the built-in image.
- imageURL: This is for using your own external image. You'll need to first upload the image to a suitable website (Most image hosting sites will NOT work. See here for details. Imgur will work and is recommended.), and obtain the URL of the image. Be sure to use the URL of the image and NOT the URL of the Imgur page (...right click on the image, then "Copy image location/address").
- imageFile: If you see this line, you must remove it. This option is only used internally for manual loading of local files. It cannot work with a shared configurations file.
- imageScale: This scales the image (eg. If set to 2, every pixel will be equivalent to 2mm). The default is 1 (1px in the image is equal to 1mm in the world).
- These are the same as what you see in the configuration window: wall, wallHeight, wallThickness
- groundFriction and wallFriction controls the friction coefficient of the ground and walls.
- groundRestitution and wallRestitution controls how "bouncy" the object is when collided with. A value of 1 will make for a very "bouncy" interaction.
- If you have added any obstacles, they'll uses the physics parameters for the wall.
- missions will add the default mission models for the image if set to true.
- If you have added your own obstacles and magnetics, this option will be ignored (ie. you cannot combine both default and custom models).
You can add fixed (...immovable, blocks robot movement), moveable, and physicsless (...robot can drive through it) objects to your game world. Here's an example...
"objects": [
{
"type": "sphere",
"position": [0,20,10],
"size": [10],
"color": "#FF0000FF",
"physicsOptions": "moveable",
"magnetic": true
},
{
"type": "box",
"position": [20,20,10],
"size": [10,10,10],
"rotation": [0,0,45],
"color": "#00FF00FF",
"physicsOptions": "fixed"
}
],
This adds a moveable red sphere and a fixed green box to the game world. Any options that is unspecified (...the sphere didn't specify a rotation) will use the default value. All options are optional (...an empty object "{}" is valid).
Default values are...
type: "box",
position: [0,0,0],
size: [10,10,10],
rotationMode: "degrees",
rotation: [0,0,0],
color: "#E6808080",
physicsOptions: "fixed",
magnetic: false
- type: May be "box", "cylinder", or "sphere".
- position: Sets the position of the obstacle. First number is for left-right, second is forward-back, and the last is up-down. Note that the center of the world is [0, 0, 0]. Note that this is based on the center of the object (ie. if you set [0,0,0], the object will be embedded halfway through the floor), which is different from the old format.
- size: Sets the size of the object. For a box, it is [width, depth, height]. For a cylinder, it is [height, diameter]. For a sphere, it is [diameter].
- rotationMode: May be "degrees" or "radians".
- rotation: Sets the rotation. First number is for rotation about the left-right axis, second is for up-down axis, and the last is for the forward-back axis. Values may be in degrees or radians depending on rotationMode.
- color: Color in hexadecimal Red, Green, Blue, Alpha format. If Alpha is omitted, it'll be set to "FF" (fully opaque). You may also use the three or four digits shorthand notation.
- physicsOptions: May be "fixed", "moveable", false, or an object containing the BabylonJS physics options. Setting false will create a physicsless object (...robot can drive through it). To set custom physics options, use the following format...
// Default for "moveable"
// "fixed" uses the same settings, but with mass set to 0.
physicsOptions = {
mass: 10,
friction: 0.1,
restitution: 0.1
}
- magnetic: May be true or false. If set to true, the object can be attracted by the robot's magnet.
- laserDetection and ultrasonicDetection: May be set to "invisible" (The rays passes through the object as if it is not there. Object cannot be detected, but the sensor can detect object behind it.), "absorb" (The rays are absorbed by the object with no reflection. Sensor cannot detect objects behind it.), or "normal" (The rays are reflected back normally. Object can be detected.) If not set, they will default to "normal" for an object with physics and "invisible" for a physicsless object.
Please use the new "objects" format instead. The "obstacles" and "magnetics" format remains available for compatibility with older configuration files, but should not be used for new configurations.
You can add obstacles (...immovable, blocks robot movement) and magnetic items (...movable, can be attracted by the robot's magnet) to your game world. Here's an example...
"obstacles": [
[[-50, 10, 0], [10,20,40], [0, 0.1, 0], "#FF00AA80"],
[[-50, 10, 0], [10,20,40], [0, 0.1, 0]],
[[-70, 20, 0], [10,10,40]],
[[-50, -20, 0]]
],
"magnetics": [
[[-50, 10, 0], [10,20,40], [0, 0.1, 0], "#F00"],
[[-50, 10, 0], [10,20,40], [0, 0.1, 0]],
[[70, -30, 0], [10, 10, 1]],
[[50, 20, 0]]
],
Let's examine the first obstacle...
[[-50, 10, 0], [10,20,40], [0, 0.1, 0], "#FF00AA80"]
The first set of numbers... [-50, 10, 0] ...sets the position of the obstacle. First number is for left-right, second is forward-back, and the last is up-down. Note that the center of the world is [0, 0, 0].
The second set of numbers... [10,20,40] ...sets the size of the object. First number is for width, second for depth, third for height. This is optional and if omitted, it'll create a 10cm cube by default.
The third set of numbers... [0, 0.1, 0] ...sets the rotation. First number is for rotation about the left-right axis, second is for up-down axis, and the last is for the forward-back axis. This is optional. If omitted, the object will not be rotated.
The final string value... "#FF00AA80" ...represents the color. The red component is "FF" (255), green is "00" (0), blue is "AA" (170), and the alpha (transparency) is "80" (128). If omitted, alpha will be set to 255 (fully opaque). You may also use the three or four digits shorthand notation (...as shown in the second example). The default color for an an obstacle is "#E6808080".
All of the above applies to the "magnetics" section as well. The only difference is that the default size of a magnetic item is [5, 5, 0.5], and the default color is "#1AE61AFF".
- StartPos sets the starting position, but only if startPosXY is not set. Only the following are valid "center", "bottomLeft", "bottomCenter", "bottomRight".
- StartPosXY sets the starting position using the format "x, y" (in cm). The center of the world is "0, 0". If set, this will override startPos. You can also set the altitude using the format "x, y, z" (in cm).
- StartRot sets the starting rotation in degrees. Positive rotation is clockwise (...when view from top-down). Note that this setting is in degrees and NOT radian.
Python References