Kaynağa Gözat

More work on user manuals

BearishSun 8 yıl önce
ebeveyn
işleme
508ce0444b

+ 3 - 2
Documentation/Doxygen/Native.doxyconfig

@@ -2086,7 +2086,7 @@ INCLUDE_FILE_PATTERNS  =
 # recursively expanded use the := operator instead of the = operator.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-PREDEFINED             = 
+PREDEFINED             = BS_SCRIPT_EXPORT()=
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
 # tag can be used to specify a list of macro names that should be expanded. The
@@ -2095,7 +2095,8 @@ PREDEFINED             =
 # definition found in the source code.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-EXPAND_AS_DEFINED      = 
+EXPAND_AS_DEFINED      = BS_SCRIPT_EXPORT() \
+                         BS_SCRIPT_EXPORT(Options)
 
 # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
 # remove all references to function-like macros that are alone on a line, have

+ 11 - 7
Documentation/Doxygen/doxystyle.css

@@ -1,6 +1,10 @@
 /* Global */
 body, table, div, p, dl {
-	font: 14px/22px Lato,Roboto,sans-serif;
+	font: 14px/22px Segoe UI,Roboto,sans-serif;
+}
+
+h1, h2, h3, h4, h5, h6 {
+	font-family: 'Segoe UI', 'Helvetica Neue', Arial, Helvetica, sans-serif;
 }
 
 h1 {
@@ -161,11 +165,11 @@ div.headertitle {
 /* TOC */
 
 div.toc li {
-	font: 10px/1.2 Lato,Verdana,DejaVu Sans,Geneva,sans-serif;
+	font: 10px/1.2 Segoe UI,Verdana,DejaVu Sans,Geneva,sans-serif;
 }
 
 div.toc h3 {
-	font: bold 12px/1.2 Lato,Arial,FreeSans,sans-serif;
+	font: bold 12px/1.2 Segoe UI,Arial,FreeSans,sans-serif;
 }
 
 div.toc {
@@ -179,7 +183,7 @@ div.toc {
 	border-top: 1px solid black;
 	border-bottom: 1px solid black;
 	top: -1px;
-    font: 9pt Lato, Arial, Verdana, sans-serif;
+    font: 9pt Segoe UI, Arial, Verdana, sans-serif;
 }
 
 #MSearchBox {
@@ -229,7 +233,7 @@ blockquote {
 }
 
 .title {
-	font: bold 24px/28px Lato,Roboto,sans-serif;
+	font: bold 24px/28px Segoe UI,Roboto,sans-serif;
 }
 
 .icon {
@@ -238,7 +242,7 @@ blockquote {
 }
 
 table.directory {
-    font: 400 14px Lato,Roboto,sans-serif;
+    font: 400 14px Segoe UI,Roboto,sans-serif;
 }
 
 table.doxtable {
@@ -336,7 +340,7 @@ blockquote {
 
 #projectname
 {
-	font: 300% Lato, Tahoma, Arial,sans-serif;
+	font: 300% Segoe UI, Tahoma, Arial,sans-serif;
 	margin: 0px;
 	padding: 2px 0px;
 }

+ 128 - 9
Documentation/Manuals/Native/User/advancedAnimation.md

@@ -1,9 +1,128 @@
-CAnimation
- -> sample
- -> blendAdditive
- -> blend1D
- -> blend2D
- -> blendAdditive
- -> crossFade
- -> setState
- -> stop(layer)
+Advanced animation				{#advancedAnimation}
+===============
+
+So far we have shown how you can use the **CAnimation** component to play a single animation clip at once. When it comes to skeletal animation the system is capable of a few more advanced features that allow you to play and blend multiple animation clips at once, as well as other advanced functionality.
+
+# Cross fade
+Often your animation system might need to transition from playing one animation clip to another (e.g. moving from a walk to a run animation). In that case you can use @ref bs::CAnimation::crossFade "CAnimation::crossFade()" instead of **CAnimation::play()**. Cross fade will slowly fade in the new animation clip while fading out the previously playing one, over the specified time period.
+
+~~~~~~~~~~~~~{.cpp}
+CAnimation animation = ...; // Set up animation component
+
+// Play some clip normally
+animation->play(animationClip);
+
+// Then after some time you decide to switch to a new clip, and cross fade it over 1 second
+animation->crossFade(animationClip2, 1.0f);
+~~~~~~~~~~~~~
+
+# Sampling
+Sometimes it is useful to sample just a single frame from an animation clip (e.g. "freezing" an enemy in place). For such purpose you can use @ref bs::CAnimation::sample "CAnimation::sample()". Just provide the animation clip and the time to sample at.
+
+~~~~~~~~~~~~~{.cpp}
+// Sample animation clip at specified point
+animation->sample(animationClip, 2.0f);
+~~~~~~~~~~~~~
+
+# Blending
+Blending comes in multiple various forms, and all of them allow you to somehow play multiple animation clips at once.
+
+## 1D blending
+In this form of blending multiple animation clips are placed linearly one after another. The user can then use a weight value in order to interpolate between the animations. The two animations closest to the weight value are choosen and blended together. 
+
+For example if you had different versions of walk/run animations that alternate depending on how fast the character is moving, you could set them up as a 1D blend, and then use the characters speed as the weight, ensuring the system plays the right animation depending on the speed.
+
+To start a 1D blend operation call @ref bs::CAnimation::blend1D "CAnimation::blend1D()". This method expects a @ref bs::Blend1DInfo "Blend1DInfo" structure, containing a list of animations to blend between, and their positions. It also expects the weight value that determines which animations are blended together.
+
+~~~~~~~~~~~~~{.cpp}
+// Set up a 1D blend that blends between three animations on a [0, 1] range
+BlendClipInfo blendClips[3];
+blendClips[0].clip = animationClip0;
+blendClips[0].position = 0.0f;
+
+blendClips[1].clip = animationClip1;
+blendClips[1].position = 0.5f;
+
+blendClips[2].clip = animationClip2;
+blendClips[2].position = 1.0f;
+
+Blend1DInfo blendInfo;
+blendInfo.clips = blendClips;
+blendInfo.numClips = 3;
+
+// Blend with weight of 0.75f. This will play both animationClip1 and animationClip2, each contributing 50% of the animation
+animation->blend1D(blendInfo, 0.75f);
+~~~~~~~~~~~~~
+
+## 2D blending
+2D blending works similarly as 1D blending, except it uses a two-dimensional value for the weight. It also interpolates between four animation clips at once instead of two. It is limited to four clips, and a [0, 1] range. Therefore the clips can be imagined as being on corners of a square.
+
+For example you can use this blend type to interpolate between character aiming animations in a third party game. You would adjust the 2D weight based on the vertical and horizontal directions the character is aiming and the system would interpolate between look up/down/left/right animations to animate the character in the direction the user is aiming.
+
+To start a 2D blend operation call @ref bs::CAnimation::blend2D "CAnimation::blend2D()". This method expects a @ref bs::Blend2DInfo "Blend2DInfo" structure, containing four animation clips to blend between, as well as a 2D weight determining how the animations are blended together.
+
+~~~~~~~~~~~~~{.cpp}
+// In this case you can imagine the blend square as a diamond instead (rotated 45 degrees), so its corners map with the animation directions, for a more intuitive understanding
+Blend2DInfo blendInfo;
+blendInfo.topLeftClip = lookLeftClip;
+blendInfo.topRightClip = lookUpClip;
+blendInfo.botLeftClip = lookDownClip;
+blendInfo.botRightClip = lookRightClip;
+
+// Horizontal look direction is fully towards the left (x = 0.0f), while the vertical direction is in the middle (y = 0.5f), neither up nor down.
+animation->blend2D(blendInfo, Vector2(0.0f, 0.5f));
+~~~~~~~~~~~~~
+
+## Additive blending
+Additive blending serves a different purpose than from what we have seen so far. It is used to play a special type of animations called additive animations. Such animation clips need to be imported with the special additive property, as discussed earlier.
+
+Such animation clips can then be played on top of another primary animation. For example imagine that your character has three primary animations: standing, walking and running. Now imagine you wanted to add a weapon reload animation in the game. Instead of creating three new separate animations, you can instead create an additive animation, which can then be played on top of any of the existing three primary animations.
+
+To play an additive animation call @ref bs::CAnimation::blendAdditive "CAnimation::blendAdditive()". This method expects the following parameters:
+ - A clip to play
+ - Optional weight in [0, 1] range of how much should the animation affect the result
+ - Optional fade length which serves a similar purpose as the **CAnimation::crossFade()** method, allowing you to slowly increase the effect of the additive animation over time
+ - Layer to play the animation on. Each additive animation can be played on its own layer - playing another additive animation on the same layer replaces the previous one.
+ 
+~~~~~~~~~~~~~{.cpp}
+// Play some clip normally
+animation->play(walkClip);
+
+// Play a reload animation additively, slowly blending it over one second, on 0th layer
+animation->crossFade(reloadClip, 1.0f, 1.0f);
+~~~~~~~~~~~~~
+
+To stop an additive animation you can call @ref bs::CAnimation::stop() "CAnimation::stop()". It accepts a layer index as a parameter and determines which clip to stop. Calling **CAnimation::stopAll()** will stop all clips, additive or otherwise.
+
+# Animation states
+**CAnimation** component allows you to retrieve and set animation states. Animation states tell you the current state of an animation clip queued for playing in some way, including whether it is currently playing, current play time, wrap mode and more.
+
+Call @ref bs::CAnimation::getState "CAnimation::getState()" with an animation clip as the parameter to retrieve information about that clip. The method outputs an @ref bs::AnimationClipState "AnimationClipState" that can be used to query various information about the clip.
+
+~~~~~~~~~~~~~{.cpp}
+AnimationClipState state;
+
+// Returns true if the clip was queued for playback (in any way) on the component
+if(animation->getState(animationClip, state))
+	gDebug().logDebug("Animation is currently at time: " + toString(state.time));
+~~~~~~~~~~~~~
+
+More important that querying information, states can be used for starting playback, as well as having full control over blending and similar operations. Essentially all animation playback methods discussed so far can be implemented just by using states.
+
+To set a clip state call @ref bs::CAnimation::setState "CAnimation::setState()". If a particular clip is already playing its state will be updated, and if the clip isn't currently playing, playback will start according to the assigned state.
+
+The state has the following relevant properties:
+ - @ref bs::AnimationClipState::time "AnimationClipState::time" - Allows you to seek animation playback to a specific point.
+ - @ref bs::AnimationClipState::speed "AnimationClipState::speed" - Scale to speed up or slow down animation clip playback.
+ - @ref bs::AnimationClipState::weight "AnimationClipState::weight" - Influence of the animation clip on the final pose. Useful for additive animations primarily.
+ - @ref bs::AnimationClipState::wrapMode "AnimationClipState::wrapMode" - Wrap mode same as **CAnimation::setWrapMode()** except it can be set for each clip individually.
+ - @ref bs::AnimationClipState::layer "AnimationClipState::layer" - Layer used for additive animations.
+ - @ref bs::AnimationClipState::stopped "AnimationClipState::stopped" - When true the system will not advance the animation past the specified time.
+
+~~~~~~~~~~~~~{.cpp}
+AnimationClipState state;
+state.time = 2.0f;
+
+// Start animation playback from 2 second mark
+animation->setState(animationClip, state);
+~~~~~~~~~~~~~

+ 1 - 1
Documentation/Manuals/Native/User/animation.md

@@ -31,7 +31,7 @@ if(animation->isPlaying())
 	gDebug().logDebug("Animation is playing!");
 ~~~~~~~~~~~~~
 
-You can control the speed of the playback through @ref bs::CAnimation::setSpeed "CAnimation::setSpeed()". The default value is 1, which represents normal speed, while lower values slow down playback accordingly (e.g. 0.5 is half speed) and higher values speed it up (2 is double speed). You can change animation speed during or before you start playing a clip.
+You can control the speed of the playback through @ref bs::CAnimation::setSpeed "CAnimation::setSpeed()". The default value is 1, which represents normal speed, while lower values slow down playback accordingly (e.g. 0.5 is half speed) and higher values speed it up (2 is double speed). Use negative values to play animation in reverse. You can change animation speed during or before you start playing a clip. 
 
 ~~~~~~~~~~~~~{.cpp}
 animation->setSpeed(2.0f);

+ 48 - 0
Documentation/Manuals/Native/User/bones.md

@@ -0,0 +1,48 @@
+Bones				{#bones}
+===============
+
+The @ref bs::CBone "Bone" component allows you to expose a bone in a skeleton used for skeletal animation, for external use. A **SceneObject** with such a component attached will mimic the transformations the bone undergoes during animation. This allows you to:
+ - Attach other scene objects as children of the bone, ensuring you can animate other objects depending on the skeletal animation (e.g. a character holding a sword would have the sword attached to the hand bone, assuming the sword is modeled as a separate object)
+ - Manipulate the bone's transform manually, ensuring you can control the animation manually (e.g. for purposes of inverse kinematics)
+ 
+A bone component must always be added on a scene object that is a child of a scene object containing the **CAnimation** component. 
+
+~~~~~~~~~~~~~{.cpp}
+HSceneObject animRenderableSO = SceneObject::create("Animated 3D object");
+// Set up renderable...
+animation = animRenderableSO->addComponent<CAnimation>();
+
+HSceneObject boneSO = SceneObject::create("Bone");
+boneSO->setParent(animRenderableSO);
+
+HBone bone = boneSO->addComponent<CBone>();
+~~~~~~~~~~~~~
+
+After the component has been added to the scene you must specify the name of the bone it will mimic. You can find information about all bones in a specific **Mesh** by calling @ref bs::Mesh::getSkeleton() "Mesh::getSkeleton()". This will return a @ref bs::Skeleton "Skeleton" object which allows you to enumerate all bones.
+
+~~~~~~~~~~~~~{.cpp}
+HMesh mesh = ...;
+
+// Assuming our skeleton has a bone named "Hand"
+bone->setName("Hand");
+
+// Or query the skeleton information and search for the bone you need
+// SPtr<Skeleton> skeleton = mesh->getSkeleton();
+// ...
+~~~~~~~~~~~~~
+
+After it is set-up, you can now attach scene objects as children of the bone, and ensure they animate with animation playback. 
+
+~~~~~~~~~~~~~{.cpp}
+// Set up a sword to animate with the hand bone
+HSceneObject swordSO = SceneObject::create("Sword");
+// Set up renderable...
+
+swordSO->setParent(boneSO);
+~~~~~~~~~~~~~
+
+Or you can manually manipulate the transform of the bone.
+~~~~~~~~~~~~~{.cpp}
+// Rotate the bone manually
+boneSO->setRotation(Quaternion(Degree(0), Degree(90), Degree(0)));
+~~~~~~~~~~~~~

+ 4 - 4
Source/BansheeCore/Include/BsAnimation.h

@@ -358,8 +358,8 @@ namespace bs
 		 *
 		 * @param[in]	info	Information about the clips to blend.
 		 * @param[in]	t		Parameter that controls the blending, in range [(0, 0), (1, 1)]. t = (0, 0) means top left
-		 *						animation has full influence, t = (0, 1) means top right animation has full influence,
-		 *						t = (1, 0) means bottom left animation has full influence, t = (1, 1) means bottom right
+		 *						animation has full influence, t = (1, 0) means top right animation has full influence,
+		 *						t = (0, 1) means bottom left animation has full influence, t = (1, 1) means bottom right
 		 *						animation has full influence.
 		 */
 		void blend2D(const Blend2DInfo& info, const Vector2& t);
@@ -415,8 +415,8 @@ namespace bs
 		bool getState(const HAnimationClip& clip, AnimationClipState& state);
 
 		/**
-		 * Changes the state of a playing animation clip. If animation clip is not currently playing the state change is
-		 * ignored.
+		 * Changes the state of a playing animation clip. If animation clip is not currently playing the playback is started
+		 * for the clip.
 		 *
 		 * @param[in]	clip	Clip to change the state for.
 		 * @param[in]	state	New state of the animation (e.g. changing the time for seeking).

+ 1 - 1
Source/BansheeUtility/Include/BsRTTIField.h

@@ -82,7 +82,7 @@ namespace bs
 	 * It is up to the caller to ensure that pointer is of proper type.
 	 */
 	struct BS_UTILITY_EXPORT RTTIField
-	{
+	{	
 		Any valueGetter;
 		Any valueSetter;