This page has been translated automatically.
Getting Started
Migrating to UNIGINE 2.0
C++ API Migration
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unigine::Physics Class

Unigine physics. This interface provides access to Unigine physics functions.

To use this class, include the UniginePhysics.h file.

Unigine::Physics Class

Members


virtual ~Physics ()

Virtual destructor.

static Physics * get ()

Returns a pointer to the existing physics.

Return value

Pointer to the existing physics.

virtual void setEnabled (int enable) const =0

Enable or disables physics simulation.

Arguments

  • int enable - 1 to enable physics, 0 to disable it.

virtual int isEnabled () const =0

Returns a value indicating if physics simulation is enabled. The default is 1.

Return value

Return 1 if physics is enabled; otherwise, 0.

virtual void setStable (int stable) const =0

Sets a value indicating if objects are updated in a definite order or not.

Arguments

  • int stable - 1 to indicate that the objects are updated in a definite order; 0 to indicate that the update order may change.

virtual int isStable () const =0

Returns a value indicating if objects are updated in a definite order or not. The default is 0 (the update order may change).

Return value

Returns 1 if the objects are updated in a definite order; otherwise 0.

virtual void setFixed (int fixed) const =0

Sets a flag to synchronize rendering FPS to physics one. Such FPS limitation allows to calculate physics each rendered frame (rather then interpolate it when this flag is set to 0). In this mode, there are no twitching of physical objects if they have non-linear velocities. If the rendering FPS is lower than the physics one, this flag has no effect.

Arguments

  • int fixed - 1 to cap rendering FPS to physics one; 0 to interpolate physics if rendering FPS is higher.

virtual int isFixed () const =0

Returns a flag indicating if rendering FPS is synchronized to physics one. Such FPS limitation allows to calculate physics each rendered frame (rather then interpolate it when this flag is set to 0). In this mode, there are no twitching of physical objects if they have non-linear velocities. If the rendering FPS is lower than the physics one, this flag has no effect.

Return value

Returns 1 if the rendering FPS is synchronized to physics one; 0 if the physics is interpolated if rendering FPS is higher.

virtual void setData (const char * data) const =0

Sets user data associated with the world. In the *.world file, the data is set in the data tag.

Arguments

  • const char * data - New user data.

virtual const char * getData () const =0

Returns user string data associated with the world. This string is written directly into the data tag of the *.world file.

Return value

User string data.

virtual void setBudget (float budget) const =0

Sets the physics simulation budget. Physics isn't simulated when time is out of the budget.

Arguments

  • float budget - The budget value in seconds.

virtual float getBudget () const =0

Returns the physics simulation budget. Physics isn't simulated when time is out of the budget.

Return value

The budget value in seconds. The default value is 1/20.

virtual void setDistance (float distance) const =0

Updates a distance after which the physics will not be simulated.

Arguments

  • float distance - Distance in units.

virtual float getDistance () const =0

Returns a distance after which the physics will not be simulated.

Return value

Distance in units.

virtual int saveScene () const =0

Saves the current physics scene (physical properties of all objects) into the buffer.

Return value

Scene buffer ID.

virtual int restoreScene (int id) const =0

Restores the previously saved physics scene from the buffer.

Arguments

  • int id - Buffer ID.

Return value

Returns 1 if the scene is restored successfully; otherwise, 0.

virtual int removeScene (int id) const =0

Removes the previously saved physics scene.

Arguments

  • int id - Buffer ID.

Return value

Returns 1 if the scene is removed successfully; otherwise, 0.

virtual int loadSettings (const char * name) const =0

Loads the physics settings from a given file.

Arguments

  • const char * name - Path to an XML file with desired settings.

Return value

Returns 1 if the settings are loaded successfully; otherwise, 0.

virtual int saveSettings (const char * name, int force) const =0

Saves the current physics settings to a given file.

Arguments

  • const char * name - Path to an XML file to which the settings will be saved.
  • int force - Forced saving of physics settings.

Return value

Returns 1 if the settings are saved successfully; otherwise, 0.

virtual int loadWorld (const XmlPtr & xml) const =0

Loads physics settings from the Xml.

Arguments

  • const XmlPtr & xml - Xml smart pointer.

Return value

Returns 1 if settings are loaded successfully; otherwise, 0.

virtual int saveWorld (const XmlPtr & xml, int force) const =0

Saves physics settings into the Xml.

Arguments

  • const XmlPtr & xml - Xml smart pointer.
  • int force - Forced saving of physics settings.

Return value

Returns 1 if settings are saved successfully; otherwise, 0.

virtual int saveState (const StreamPtr & stream) const =0

Saves physics settings into the stream.

Arguments

  • const StreamPtr & stream - Stream smart pointer.

Return value

Returns 1 if settings are saved successfully; otherwise, 0.

virtual int restoreState (const StreamPtr & stream) const =0

Restores physics settings from the stream.

Arguments

  • const StreamPtr & stream - Stream smart pointer.

Return value

Returns 1 if settings are restored successfully; otherwise, 0.
Last update: 2017-07-03
Build: ()