SSWorld:
Filter:
3Dj/Classes (extension) | Libraries > 3Dj

SSWorld
ExtensionExtension

Sound Scene World Simulation

Description

The world where the sound scene exists. It can contain an arbitrary number of SSObject.

A SSWorld presents some settable physical parameters (gravity, friction...), that objects are subject to.

There is a sweet spot in the bottom center of the room, where the objects cannot be located. For a room with dimmension dim =[x,y,z], the room center will be [0,0,0], and the possible locations: [ -x/2 to x/2, -y/2 to y/2, 0 to z ]. If an object location exceeds world limits, it will be relocated in the equivalent folded position.

The SSWorld is continuously monitoring what happens inside, and sending to a desired addres the scene description in OSC-SpatDIF format.

It is a subclass of RedWorld1. Notice that, in contraposition with its superclass, the SSWorld is the higher level element. There is, for the moment, not a such thing like SSUniverse.

Class Methods

.new

Arguments:

dim

Array or Cartesian with the world dimensions (in m) in each of the three axis, in the format [dimX,dimY,dimZ].

Default to [10, 10, 5].

gravity

Array or Cartesian with the default gravity acceleration (in m/s^2) in each of the three axis, in the format [gravX,gravY,gravZ].

Default to [0, 0, 0.98]

maxVel

Light velocity : maximum velocity allowed in the world, in m/s. Default to 100.

damping

Coefficient of energy loss when an object rebounces in the wall. 0 for nothing and 1 for all.

Default to 0.25

friction

Coefficient of velocity loss in contact with the medium. 0 for nothing and 1 for all.

Default to 0.01

timeStep

Frequency of monitoring changes inside the world, and generating the scene description.

Default to 60 Hz.

netAddr

Instance of NetAddr where to send the scene description.

Default to NetAddr.localAddr

Instance Methods

World Properties

.dim

Get/set the world dimensions.

Arguments:

value

Array or Cartesian in the form [dimX,dimY,dimX]

.sweetSpotSize

.setSweetSpotSize

Arguments:

newSize

Radius in meters. Default to 2 m

.stepFreq

Get/set the world's update frequency.

.rDiff

Get/set the distance JND: minimum distance change (in spherical coordenates) to be considered as a different position.

Default to 0.05 m.

.aziDiff

Get/set the azimuth JND: minimum angle change to be considered as a different position.

Default to 1 degree.

.eleDiff

Get/set the elevation JND: minimum angle change to be considered as a different position.

Default to 5 degrees.

.center

Get the world's coordinate system center.

Returns:

Cartesian()

.maxDistance

Get the maximum possible distance from any point to the world's coordinate system center.

.friction

Get/set the medium friction parameter. A number between 0 (no friction) and 1 (every time step, velocity will be decreased a 100%)

.pause

Stop the time passing.

.resume

Resume the time passing, as if nothing happened.

.update

Forces a world update. This can be useful when the world is paused.

This method is called automatically every SSWorld: -stepFreq

Object managing

.add

Add an object to the world. This method is called automatically from SSObject: *new

Arguments:

obj

an instance of SSObject

.remove

Remove completely the given object from the world

Arguments:

obj

An instance of SSObject

.removeByName

Remove completely the given object from the world

Arguments:

name

A \Symbol with the object's name.

.contains

Ask if the world contains the given object.

Arguments:

ssObj

An instance of SSObject

Returns:

Boolean

.getObject

Get the reference to an object, given its name

Arguments:

objName

A Symbol with the object name

Returns:

The SSObject instance, or nil if not found

.getAllObjects

Returns:

an Array with references to all existing SSObjects

.getAllObjectNames

Returns:

an Array with the names of all existing SSObjects

.numObjects

Get the number of exisisting objects in the world

Visualization

.showView

Show the world's view

.hideView

Hide the world's view

.alwaysOnTop

Set the alwaysOnTop property of the world's view

.viewDiff

If true, update world's view only after checking that the scene changed. If false, update it in a continuous way (every stepFreq.reciprocal seconds)

Default to false

.showNames

Show or hide the object names in the view

.closeWindow

Closes the window

Network Communication

.renderAddresses

Get the list of all Classes/SpatialRender addresses where to send the scene information.

Multiple addresses are allowed, in order to support remote control.

By default, there will be only the NetAddress provided in instanciation.

.addRenderAddress

Add a NetAddress to the SSWorld: -renderAddresses

.removeRenderAddress

Remove a NetAddress to the SSWorld: -renderAddresses

Returns:

The removed NetAddress if succesful, or nil if not.

.receivingFromServer

If this receives any external messages (from SpatDifPlayer playback or remote control), SSWorld: -receivingFromServer will be automatically set to true. In that case, the world won't update itself (avoiding message redundancy to the server).

The user can set its value at any time through the set method.

Examples