summaryrefslogtreecommitdiffstats
path: root/src/runtime/behaviorapi
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2018-05-18 10:33:28 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2018-05-18 10:33:34 +0200
commit8bb3378d0d7c82eb1896ac043570ddab7c2edae9 (patch)
treef3fe8bce8b4df108c1cc9766fdbafea95c3bd490 /src/runtime/behaviorapi
parent78ab305d5ca59a158232a8b47070ef35ae803033 (diff)
parent186e8bf9ec08b1aca289a23b93290bf4cd5521fe (diff)
Merge remote-tracking branch 'origin/2.0'
Diffstat (limited to 'src/runtime/behaviorapi')
-rw-r--r--src/runtime/behaviorapi/q3dsbehaviorobject.cpp166
1 files changed, 166 insertions, 0 deletions
diff --git a/src/runtime/behaviorapi/q3dsbehaviorobject.cpp b/src/runtime/behaviorapi/q3dsbehaviorobject.cpp
index 75ac946..9a31ce8 100644
--- a/src/runtime/behaviorapi/q3dsbehaviorobject.cpp
+++ b/src/runtime/behaviorapi/q3dsbehaviorobject.cpp
@@ -265,4 +265,170 @@ void Q3DSBehaviorObject::setDataInputValue(const QString &name, const QVariant &
m_engine->setDataInputValue(name, value);
}
+/*!
+ \qmltype Behavior
+ \inqmlmodule QtStudio3D
+ \ingroup 3dstudioruntime2
+
+ \brief Technology Preview Behavior Integration
+
+ This is a technology preview (API may change in upcoming version) of how
+ Qt 3D Studio could support writing custom behavior scripts using QML and
+ JavaScript. It enables interacting with the runtime using the Behavior
+ QML class exposed to each behavior script.
+
+ In QML behavior script, the integration to Qt 3D Studio is established by using
+ the metadata tag system similar to the \l {file-formats-effects.html}{effect}
+ and \l {file-formats-material.html}{material} files.
+
+ \badcode
+[[
+<Property name="somePropertyName" ... />
+
+<Handler name="someHandlerName" ... />
+
+<Event name="onSomeEvent" ... />
+...
+]]
+ \endcode
+
+ Secondly, the QML behavior script needs access to the QML module.
+ \badcode
+import QtStudio3D.Behavior 2.0
+ \endcode
+
+ Finally, the Behavior type needs to be implemented in the qml script.
+ \badcode
+Behavior {
+ id: mybehavior
+
+ function onInitialize() {
+ ...
+ }
+
+ function onActivate() {
+ ...
+ }
+
+ function onUpdate() {
+ ...
+ }
+
+ function onDeactivate() {
+ ...
+ }
+
+ function someHandlerName() {
+ ...
+ fireEvent("onSomeEvent")
+ }
+}
+ \endcode
+*/
+
+/*!
+ \qmlmethod float Behavior::getDeltaTime()
+
+ Returns the delta time between this and previous frame in milliseconds.
+*/
+
+/*!
+ \qmlmethod var Behavior::getAttribute(string attribute)
+
+ Returns the value of the given \a attribute.
+*/
+
+/*!
+ \qmlmethod var Behavior::getAttribute(string handle, string attribute)
+
+ Returns the value of the given \a attribute for a given \a handle.
+*/
+
+/*!
+ \qmlmethod void Behavior::setAttribute(string attribute, var value)
+
+ Sets the \a value of the given \a attribute.
+*/
+
+/*!
+ \qmlmethod void Behavior::setAttribute(string handle, string attribute, var value)
+
+ Sets the \a value of the given \a attribute for a given \a handle.
+*/
+
+/*!
+ \qmlmethod void Behavior::fireEvent(string event)
+
+ Fires the given \a event.
+*/
+
+/*!
+ \qmlmethod void Behavior::registerForEvent(string event, QJSValue function)
+
+ Registers the script for an \a event with the handler \a function.
+*/
+
+/*!
+ \qmlmethod void Behavior::registerForEvent(string handle, string event, QJSValue function)
+
+ Registers the script for an \a event with the handler \a function for a given \a handle.
+*/
+
+/*!
+ \qmlmethod void Behavior::unregisterForEvent(string event)
+
+ Unregisters the script from an \a event.
+*/
+
+/*!
+ \qmlmethod void Behavior::unregisterForEvent(string handle, string event)
+
+ Unregisters the script from an \a event for a given \a handle.
+*/
+
+/*!
+ \qmlmethod void Behavior::setDataInputValue(string name, variant value)
+
+ Sets the \a value of the data input identified with the \a name.
+ */
+
+/*!
+ \qmlsignal void Behavior::onInitialize()
+
+ This signal is emitted when the script becomes active the first time.
+ If multiple behaviors match this, the signal for parent elements will
+ occur before their children/descendants. \note Each behavior will
+ only have its \c{onInitialize} signaled once, even if it is deactivated and
+ later reactivated.
+ */
+
+/*!
+ \qmlsignal void Behavior::onActivate()
+
+ This signal is emitted when the script becomes active.
+ Any behaviors which were not active last frame that are active
+ this frame will have their \c{onActivate} signaled. If
+ multiple behaviors match this, the signal for parent elements will
+ occur before their descendants.
+ */
+
+/*!
+ \qmlsignal void Behavior::onDeactivate()
+
+ This signal is emitted when the script becomes inactive.
+ Any behaviors which were active last frame that are not active
+ this frame will have their \c{onDeactivate} signaled. If
+ multiple behaviors match this, the signal for parent elements will
+ occur before their descendants.
+ */
+
+/*!
+ \qmlsignal void Behavior::onUpdate()
+
+ This signal is emitted on each frame when the script is active.
+ Any behaviors that are active this frame will have their
+ \c{onUpdate} signaled. If multiple behaviors match this, the signal
+ for parent elements will occur before their descendants.
+ */
+
QT_END_NAMESPACE