This page has been translated automatically.
编程
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
应用程序接口
Containers
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::Property Class

Header:#include <UnigineProperties.h>

This class provides an interface for property manipulation: it is used to modify properties that allow you to control values and states of the logic-related parameters. When a property parameter value is modified for a single node, an instanced property is saved into the .world file, however, it contains only the modified parameter rather than the whole list of parameters.

By using functions of this class, you can, for example, implement a properties editor.

All properties are organized in property libraries. To be modified, properties should be obtained from a loaded library via API functions. For example, if you have the following library:

Source code (XML)
<!unigine_project.prop library>
<?xml version="1.0" encoding="utf-8"?>
<properties version="2.0">
	<property name="surface_base_0" parent="surface_base">
		<parameter name="friction">1.833</parameter>
		<parameter name="restitution">0.194</parameter>
		<parameter name="occlusion">0.791</parameter>
		<parameter name="my_parameter">190</parameter>
	</property>
	<property name="surface_base_1" parent="surface_base">
		<parameter name="my_parameter">191</parameter>
	</property>
	<property name="surface_base_2" parent="surface_base">
		<parameter name="my_parameter">192</parameter>
	</property>
</properties>

You can implement a function that changes a parameter of a given property stored in this library:

Source code (C++)
// 1. Declare the required number of instances of the Property class
Vector<PropertyPtr> my_properties;

// 2. Implement the function that sets the given value for the given property
void set_my_parameter(int num, int value){
	PropertyPtr property = my_properties[num];
	property->setParameterInt(property->findParameter("my_parameter"),value);
} 

// 3. On the application initialization, form the array of the library properties.
// It will allow for fast access to the required properties later
int AppWorldLogic::init() {
	// get a pointer to the property manager
	Properties *properties = Properties::get();
	// load the library and associate it with the current world
	properties->addWorldLibrary("../data/unigine_project/unigine_project.prop");
	// get the library number
	int library = properties->findLibrary("../data/unigine_project/unigine_project.prop");
	for (int num = 0; num < properties->getNumProperties(library); num++) {
		// get a property from the library and append it to the list of properties
		my_properties.append(properties->getProperty(library, num));
	}
	
	return 1;
}

// 4. Call the implemented function when it is necessary
int AppWorldLogic::update() {

	...
	set_my_parameter(num,num+100);
	...
	
	return 1;

}

Notice
You can modify only existing parameters and states of the property. To add or remove new parameters and states, you should manually edit the .prop file or use API to edit the XML file via the code.

Adding and Removing Properties

Notice
The Property class doesn't allow adding a new property to the property library.
A new property can be added to the library in one of the following ways:
  • By manual editing of the corresponding .prop file. For example, the following .prop file contains 2 properties added manually:
    Source code (XML)
    <?xml version="1.0" encoding="utf-8"?>
    <properties version="1.00">
    	<property editable="0" name="GameObjectsUnit">
    		<state name="weapon_type" type="switch" items="air,land,all_types">0</state>
    		<state name="attack" type="toggle">1</state>
    		<parameter name="damage" type="int" max="1000">1</parameter>
    		<parameter name="velocity" type="float" max="100">30</parameter>
    		<parameter name="material" type="string"/>
    	</property>
    	<property editable="1" name="GameObjectsNavy" parent="GameObjectsUnit">
    		<state name="weapon_type">2</state>
    		<parameter name="damage">120</parameter>
    		<parameter name="material">military_navy</parameter>
    		<parameter name="material_color" type="color">1.0 1.0 1.0 1.0</parameter>
    	</property>
    </properties>
  • By inheriting from the existing property via inheritProperty() function of the Properties class.
    Notice
    The inherit() function of the Property class cannot be used in this case, as it allows inheriting a new material during runtime without storing it in any property libraries.
    For example:
    Source code (C++)
    // get a pointer to the property manager
    Properties *properties = Properties::get();
    // load the library and associate it with the current world
    properties->addWorldLibrary("../data/unigine_project/unigine_project.prop");
    // inherit a GameObjectsUnit_0 property from the GameObjectsUnit property
    // stored in the unigine_project.prop library
    properties->inheritProperty("GameObjectsUnit","unigine_project/unigine_project.prop","GameObjectsUnit_0");
    To save changes in the library, save the world.
    Notice
    By default, all parameters and states of the inherited property are the same as specified in the parent property. A child property can override some parameters of its parent or add new ones.
  • By editing the corresponding .prop file via C++ API: you can open an XML file, write data into it and save it.

To delete a property, you can simply call the removeProperty() function:

Source code (C++)
// remove the property with the given name
properties->removeProperty("GameObjectsUnit_0");
// save changes in the library if necessary
properties->save("unigine_project/unigine_project.prop");

Property Class

Members


Ptr<Property> getChild(int num)

Returns the child property of the current property.

Arguments

  • int num - The number of the target child property.

Return value

Child property.

void setCollision(int enable)

Updates the collision option: a value indicating if the collision test is enabled for objects with the assigned property. The object will collide only if it has the collider node flag, the surface collision flag and the property collision option set at the same time.

Arguments

  • int enable - The collision option: 1 to enable the collision test, 0 to disable it.

int getCollision()

Returns the collision option: a value indicating if the collision test is enabled for objects with the assigned property. The object will collide only if it has the collider node flag, the surface collision flag and the property collision option set at the same time.

Return value

The collision option: 1 if the collision test is enabled; otherwise, 0.

Ptr<Property> getCompare()

Returns the parent property, parameters of which have been changed.

Return value

Parent property.

int isEditable()

Returns a value indicating if the property can be edited.

Return value

1 if the property is editable; otherwise, 0.

int isHidden()

Returns a value indicating if the property is hidden.

Return value

1 if the property is hidden; otherwise, 0.

void setIntersection(int enable)

Updates the intersection option: a value indicating if the intersection test is enabled for objects with the assigned property. The intersection with the object will be detected only if it has the surface intersection flag and the property intersection option set at the same time.

Arguments

  • int enable - The intersection option: 1 to enable the intersection test, 0 to disable it.

int getIntersection()

Returns the intersection option: a value indicating if the intersection test is enabled for objects with the assigned property. The intersection with the object will be detected only if it has the surface intersection flag and the property intersection option set at the same time.

Return value

The intersection option: 1 if the intersection test is enabled; otherwise, 0.

const char * getName()

Returns the property name.

Return value

Name of the property.

int getNumChildren()

Returns the number of children of the current property.

Return value

Number of child properties.

int getNumParameters()

Returns the number of property's parameters.

Return value

Number of property parameters.

int getNumStates()

Returns the number of property's states including states of the parent property. If the state of the current property overrides the parent property's state, the parent property's isn't taken into account.

Return value

Number of property's states including states of the parent property.

int isOwner()

Returns the owner flag. If the pointer is the owner, on its deletion the property also will be deleted. Use grab() and release() functions to change ownership.

Return value

The owner flag.

bool setParameter(int num, const Variable & value)

Updates the value of the given parameter.

Arguments

  • int num - The number of the target parameter .
  • const Variable & value - New value of the parameter.

Variable getParameter(int num)

Returns the value of the given parameter.

Arguments

  • int num - The number of the target parameter.

Return value

Value of the parameter.

void setParameterColor(int num, const Math::vec4 & value)

Updates a value of the given color parameter. If the PARAMETER_COLOR variable isn't set for the parameter, the color value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of the property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • const Math::vec4 & value - New value for the color parameter.

Math::vec4 getParameterColor(int num)

Returns the current color set for the given color parameter. If the PARAMETER_COLOR variable isn't set for the parameter, the function will return (0,0,0,0).

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Color value of the color parameter. If an error occurs, (0,0,0,0) will be returned.

void setParameterDouble(int num, double value)

Updates the value of the given double parameter. If the PARAMETER_DOUBLE variable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • double value - New value for the double parameter.

double getParameterDouble(int num)

Returns the current value of the given double parameter. If the PARAMETER_DOUBLE variable isn't set for the parameter, the function will return 0.0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the douuble parameter.

double getParameterDoubleMaxValue(int num)

Returns the maximum allowed value of the given double parameter. If the PARAMETER_DOUBLE variable isn't set for the parameter, the function will return 1.0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Maximum allowed value of the double parameter.

double getParameterDoubleMinValue(int num)

Returns the minimum allowed value of the given double parameter. If the PARAMETER_DOUBLE variable isn't set for the parameter, the function will return 0.0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Minimum allowed value for the double parameter.

void setParameterFloat(int num, float value)

Updates the value of the given float parameter. If the PARAMETER_FLOAT variable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • float value - New value of the float parameter.

float getParameterFloat(int num)

Returns the current value of the given float parameter. If the PARAMETER_FLOAT variable isn't set for the parameter, the function will return 0.0f.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the float parameter.

float getParameterFloatMaxValue(int num)

Returns the maximum allowed value of the given float parameter. If the PARAMETER_FLOAT variable isn't set for the parameter, the function will return 1.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Maximum allowed value of the float parameter.

float getParameterFloatMinValue(int num)

Returns the minimum allowed value of the given float parameter. If the PARAMETER_FLOAT variable isn't set for the parameter, the function will return 0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Minimum allowed value of the float parameter.

int isParameterHidden(int num)

Returns a value indicating if the given parameter is hidden.

Arguments

  • int num - The number of the target parameter in range from 0 to the total number of the property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

1 is the parameter is hidden; otherwise, 0.

void setParameterInt(int num, int value)

Updates the value of the given integer parameter. If the PARAMETER_INT variable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • int value - New value for the integer parameter.

int getParameterInt(int num)

Returns the current value of the given integer parameter. If the PARAMETER_INT variable isn't set for the parameter, the function will return 0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the integer parameter.

int getParameterIntMaxValue(int num)

Returns the maximum allowed value of the given integer parameter. If the PARAMETER_INT variable isn't set for the parameter, the function will return 1.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Maximum allowed value of the integer parameter.

int getParameterIntMinValue(int num)

Returns the minimum allowed value of the given integer parameter. If the PARAMETER_INT variable isn't set for the parameter, the function will return 0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Minimum allowed value of the integer parameter.

void setParameterMask(int num, int value)

Updates a value of the given mask parameter. If the PARAMETER_MASK variable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • int value - New value for the mask parameter.

int getParameterMask(int num)

Returns the current value set for the given mask parameter. If the PARAMETER_MASK variable isn't set for the parameter, the function will return 0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the mask parameter. If an error occurs, 0 will be returned.

const char * getParameterName(int num)

Returns the name of the given property's parameter name.

Arguments

  • int num - The number of the target parameter in range from 0 to the total number of the property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Name of the parameter.

int getParameterSliderLog10(int num)

Returns a value indicating if the given slider parameter of the current property uses a logarithmic scale (with the base ten). The slider parameter is a parameter of one of the following types: PARAMETER_INT, PARAMETER_FLOAT, PARAMETER_DOUBLE.

Arguments

  • int num - The number of the slider parameter in range from 0 to the total number of the property's parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

1 if the parameter uses a logarithmic scale; otherwise, 0.

int getParameterSliderMaxExpand(int num)

Returns a value indicating if the maximum value of the given slider parameter can be increased. The slider parameter is a parameter of one of the following types: PARAMETER_INT, PARAMETER_FLOAT, PARAMETER_DOUBLE.

Arguments

  • int num - The number of the slider parameter in range from 0 to the total number of the property's parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

1 if the maximum value can be changed; otherwise, 0.

int getParameterSliderMinExpand(int num)

Returns a value indicating if the minimum value of the given slider parameter can be decreased. The slider parameter is a parameter of one of the following types: PARAMETER_INT, PARAMETER_FLOAT, PARAMETER_DOUBLE.

Arguments

  • int num - The number of the slider parameter in range from 0 to the total number of the property's parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

1 if the minimum value can be changed; otherwise, 0.

void setParameterString(int num, const char * value)

Updates the value of the given string parameter. If the PARAMETER_STRING variable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • const char * value - New value for the string parameter.

const char * getParameterString(int num)

Returns the current value of the given string parameter. If the PARAMETER_STRING variable isn't set for the parameter, the function will return NULL.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the string parameter.

int getParameterStringFile(int num)

Returns a value indicating if the given string parameter has a file flag. If the PARAMETER_STRING variable isn't set for the parameter, the function will return 0. The file flag allows opening a file dialog window by double-clicking the string parameter value. Such flag is specified as a value of the file attribute of the property, for example:
Source code (XML)
<properties>
	<property name="surface_base_0" type="string" flags="file"/>	
</properties>

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

1 if the target parameter has a file flag; otherwise 0.

void setParameterSwitch(int num, int value)

Updates the value of the given switch parameter. If the PARAMETER_SWITCH variable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • int value - New value for the switch parameter.

int getParameterSwitch(int num)

Returns the current value of the given switch parameter. If the PARAMETER_SWITCH variable isn't set for the parameter, the function will return 0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the switch parameter.

const char * getParameterSwitchItem(int num, int item)

Returns the value of the item of the given switch parameter. If the PARAMETER_SWITCH variable isn't set for the parameter, the function will return NULL.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • int item - The number of the item of the switch parameter.

Return value

Value of the item. If an error occurs, NULL will be returned.

int getParameterSwitchNumItems(int num)

Returns the number of items of the given switch parameter. If the PARAMETER_SWITCH variable isn't set for the parameter, the function will return 0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Number of the items of the switch parameter.

void setParameterToggle(int num, int value)

Updates the value of the given toggle parameter. If the PARAMETER_TOGGLE variable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • int value - New value of the toggle parameter.

int getParameterToggle(int num)

Returns the current value of the given toggle parameter. If the PARAMETER_TOGGLE variable isn't set for the parameter, the function will return 0.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the toggle parameter.

int getParameterType(int num)

Returns the type of the given parameter.

Arguments

  • int num - The number of the target parameter in range from 0 to the total number of the property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

One of the PARAMETER_* pre-defined variables; if an error occurs, -1 will be returned.

void setParameterVec3(int num, const Math::vec3 & value)

Updates the value of the given vector (vec3) parameter. If the PARAMETER_VEC3 variable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • const Math::vec3 & value - New value for the vector (vec3) parameter.

Math::vec3 getParameterVec3(int num)

Returns the current value of the given vector (vec3) parameter. If the PARAMETER_VEC3 variable isn't set for the parameter, the function will return (0,0,0).

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the vector (vec3) parameter.

void setParameterVec4(int num, const Math::vec4 & value)

Updates the value of the given vector (vec4) parameter. If the PARAMETER_VEC4 variable isn't set for the parameter, the value won't be updated.

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).
  • const Math::vec4 & value - New value for the vector (vec4) parameter.

Math::vec4 getParameterVec4(int num)

Returns the current value of the given vector (vec4) parameter. If the PARAMETER_VEC4 variable isn't set for the parameter, the function will return (0,0,0,0).

Arguments

  • int num - The number of the parameter in range from 0 to the total number of property parameters (including parameters of its parent; if a parameter of the current property overrides the parent property's parameter, the parent property's parameter isn't taken into account).

Return value

Value of the vector (vec4) parameter.

Ptr<Property> getParent()

Returns the parent property.

Return value

Parent property smart pointer.

int isParent(const char * name)

Returns a value indicating if the property with the given name is a parent of the current property.
Source code (XML)
<properties version="2.0">
	<property name="surface_base_0" parent="surface_base">
		<state name="my_state">1</state>
		<parameter name="my_parameter">100</parameter>
	</property>
	<property name="surface_base_1" parent="surface_base_0">
		<parameter name="my_parameter">101</parameter>
	</property>
</properties>
The following code will return 1 as the surface_base_0 property is the parent of the surface_base_1 property:
Source code (UnigineScript)
// load the library and associate it with the current world
engine.properties.addWorldLibrary("../data/unigine_project/unigine_project.prop");
Property property = engine.properties.findProperty("surface_base_1");
log.message("%d\n",property.isParent("surface_base_0"));
Returns a value indicating if the property with the given name is a parent of the current property.
Source code (XML)
<properties version="2.0">
	<property name="surface_base_0" parent="surface_base">
		<state name="my_state">1</state>
		<parameter name="my_parameter">100</parameter>
	</property>
	<property name="surface_base_1" parent="surface_base_0">
		<parameter name="my_parameter">101</parameter>
	</property>
</properties>
The following code will return 1 as the surface_base_0 property is the parent of the surface_base_1 property:
Source code (C++)
// get a property to be cloned
Properties *properties = Properties::get();
// load the library and associate it with the current world
properties->addWorldLibrary("../data/unigine_project/unigine_project.prop");
PropertyPtr property = properties->findProperty("surface_base_1");
Log::message("%d\n",property->isParent("surface_base_0"));

Arguments

  • const char * name - Name of the property.

Return value

1 if the property is a parent of the current property; otherwise, 0.

void setState(int num, int value)

Updates the value or the given state. Note that the state must be editable. If the current property has no states, the state of the parent property will be changed.

Arguments

  • int num - The number of the target state in range from 0 to the total number of the property's states (including states of its parent; if the state of the current property overrides the parent property's state, the parent property's state isn't taken into account).
  • int value - New value of the state.

int getState(int num)

Returns the value of the given state. If the current property has no states, the state value of the parent property will be returned.

Arguments

  • int num - The number of the target state in range from 0 to the total number of the property's states (including states of its parent; if a state of the current property overrides the parent property's state, the parent property's isn't taken into account).

Return value

Value of the state.

int isStateHidden(int num)

Returns a value indicating if the given state is hidden.

Arguments

  • int num - The number of the target state in range from 0 to the total number of the property states (including states of its parent; if the state of the current property overrides the parent property's state, the parent property's state isn't taken into account).

Return value

1 if the state is hidden; otherwise, 0.

const char * getStateName(int num)

Returns the name of the given state.

Arguments

  • int num - The number of the target state in range from 0 to the total number of the property states (including states of its parent; if the state of the current property overrides thethe parent property's state, the parent property's isn't taken into account).

Return value

Name of the state.

const char * getStateSwitchItem(int num, int item)

Returns the name of the item of the switch state. The switch state is a state for which the STATE_SWITCH variable is set.

Arguments

  • int num - The number of the target switch state in range from 0 to the total number of the property states (including states of its parent; if the state of the current property overrides the parent property's state, the parent property's state isn't taken into account).
  • int item - The number of the item of the switch state.

Return value

Name of the switch item.

int getStateSwitchNumItems(int num)

Returns the number of items of the given switch state. The switch state is a state for which the STATE_SWITCH variable is set.

Arguments

  • int num - The number of the target switch state in range from 0 to the total number of the property states (including states of its parent; if the state of the current property overrides the parent property's state, the parent property's state isn't taken into account).

Return value

Number of items of the switch state.

int getStateType(int num)

Returns the type of the given state.

Arguments

  • int num

Return value

One of the STATE_* predefined variables; if an error occurs, -1 will be returned.

Ptr<Property> clone(const char * name)

Clones the current property.
Source code (UnigineScript)
// get a property to be cloned
Properties *properties = Properties::get();
// load the library and associate it with the current world
properties->addWorldLibrary("../data/unigine_project/unigine_project.prop");
PropertyPtr property = properties->findProperty("surface_base_0");
// clone the property
PropertyPtr cloned = property->clone("cloned_surface_base_0");
// perform something on the cloned pointer
// ...
// delete the pointer
cloned.grab();
cloned.destroy();

Arguments

  • const char * name - Name of the new property.

Return value

Cloned property smart pointer.

int findParameter(const char * name)

Searches for a parameter by the given name among all parameters of the current property and also among all parameters of the parent property that aren't overridden in the current property.

Arguments

  • const char * name - Name of the parameter.

Return value

The number of the parameter, if it is found; otherwise, -1.

int findState(const char * name)

Searches for a state by the given name among all states of the current property and also among all states of the parent property that aren't overridden in the current property.

Arguments

  • const char * name - Name of the target state.

Return value

The number of the state, if it is found; otherwise, -1.

void grab()

Sets the owner flag to 1 for the Property pointer. The Property should not be handled by the class after this function is called

Ptr<Property> inherit(const char * name)

Inherits a property from the current one.

Arguments

  • const char * name - Name of the new property.

Return value

Inherited property smart pointer.

int load(const Ptr<Xml> & xml)

Loads data of the property (all its options, states and parameters) from the given instance of the Xml class.

Arguments

  • const Ptr<Xml> & xml - Xml class instance in which the property data is stored.

Return value

1 if the property data is loaded successfully; otherwise, 0.

int loadWorld(const Ptr<Xml> & xml)

Loads data of the current property (all its options, states and parameters) from the given instance of the Xml class.

Arguments

  • const Ptr<Xml> & xml - Xml class instance in which the property data is stored.

Return value

1 if the property data is loaded successfully; otherwise, 0.

void release()

Releases the Property (sets the owner flag to 0 for the pointer). The Property should be handled by the class after this function is called.

int restoreState(const Ptr<Stream> & stream, int force = 0)

Restores data of the current property (all its options, states and parameters) from a binary stream.
Warning
This function is deprecated and will be removed in the next release.

Arguments

  • const Ptr<Stream> & stream - The stream in which the saved property data is stored.
  • int force - A value indicating if forced restoring of property data is used: 1 to enable forced saving, 0 to disable it.

Return value

1 if the property data is restored successfully; otherwise, 0.

int saveState(const Ptr<Stream> & stream, int force = 0)

Saves data of the current property (all its options, states and parameters) into a binary stream.
Warning
This function is deprecated and will be removed in the next release.

Arguments

  • const Ptr<Stream> & stream - Stream into which the property data will be saved.
  • int force - A value indicating if forced saving of property data is used: 1 to enable forced saving, 0 to disable it.

Return value

1 if the property data is saved successfully; otherwise, 0.

int save(const Ptr<Xml> & xml)

Saves data of the property (all its options, states and parameters) to the given instance of the Xml class.

Arguments

  • const Ptr<Xml> & xml - Xml class instance into which the property data will be saved.

Return value

1 if the property data is saved successfully; otherwise, 0.

int saveWorld(const Ptr<Xml> & xml, int force = 0)

Saves data of the current property (all its options, states and parameters) into the given instance of the Xml class.

Arguments

  • const Ptr<Xml> & xml - Xml class instance into which the property data will be saved.
  • int force - A value indicating if forced saving of property data is used: 1 to enable forced saving, 0 to disable it.

Return value

1 if the property data is saved successfully; otherwise, 0.

int PARAMETER_AUX

Description

Parameter of the auxiliary type.

int PARAMETER_COLOR

Description

Type of the property parameter that allows specifying the material color (a vec4 value).

int PARAMETER_DOUBLE

Description

Type of the property parameter that allows accepting any double value in a given range.

int PARAMETER_FLOAT

Description

Type of the property parameter that allows accepting float value in a given range.

int PARAMETER_INT

Description

Type of the property parameter that allows accepting any integer value in a given range.

int PARAMETER_MASK

Description

Type of the property parameter that allows specifying a mask (an integer value).

int PARAMETER_STRING

Description

Type of the property parameter that allows accepting any string value.

int PARAMETER_SWITCH

Description

Type of the property parameter that allows specifying a set of several possible values (more than 2).

int PARAMETER_TOGGLE

Description

Type of the property parameter that allows only 2 possible values.

int PARAMETER_VEC3

Description

Type of the property parameter that allows accepting any vec3 value.

int PARAMETER_VEC4

Description

Type of the property parameter that allows accepting any vec4 value.

int STATE_AUX

Description

State of the auxiliary type.

int STATE_SWITCH

Description

State in which the property can have a set of several possible values (more than 2).

int STATE_TOGGLE

Description

State in which the property can have only 2 possible values.
Last update: 2017-10-20
Build: ()