/// <summary> /// The animator implementation. /// </summary> override protected void DoAnimation(float speedFactor) { // get current scaling step, and if done, skip float position = AnimatorUtils.CalcTransitionPercent(TimeAnimated, ScalingTime); // calc current scale value _GameObject.SceneNode.Scale = (FromScale * (1f - position)) + (ToScale * position); }
/// <summary> /// Called when GameObject spawns. /// </summary> protected override void OnSpawn() { // get model renderers Graphics.ModelRenderer[] targets = _GameObject.GetComponents <Graphics.ModelRenderer>().ToArray(); // random alpha if (_minAlpha != null) { float alpha = _minAlpha.Value + ((float)Random.NextDouble() * (_maxAlpha.Value - _minAlpha.Value)); foreach (var target in targets) { target.MaterialOverride.Alpha = alpha; } } // random scale if (_minScale != null) { float scale = _minScale.Value + ((float)Random.NextDouble() * (_maxScale.Value - _minScale.Value)); _GameObject.SceneNode.Scale *= scale; } // random scale by vector if (_minScaleVector != null) { Vector3 scale = AnimatorUtils.RandVector(Random, _minScaleVector.Value, _maxScaleVector.Value); _GameObject.SceneNode.Scale *= scale; } // random color if (_minColor != null) { Color color = AnimatorUtils.RandColor2(Random, _minColor.Value, _maxColor.Value); foreach (var target in targets) { target.MaterialOverride.DiffuseColor = color; } } // random position if (_positionJitter != null) { Vector3 position = AnimatorUtils.RandVector(Random, _positionJitter.Value); _GameObject.SceneNode.Position += position; } // random rotation if (_rotationJitter != null) { Vector3 rotation = AnimatorUtils.RandVector(Random, _rotationJitter.Value); _GameObject.SceneNode.Rotation += rotation; } // TBD IMPULSE STUFF // finally, destroy self Destroy(); }
/// <summary> /// The animator implementation. /// </summary> override protected void DoAnimation(float speedFactor) { // get current fade step, and if done, skip float position = AnimatorUtils.CalcTransitionPercent(TimeAnimated, ColoringTime); // calc current alpha value Color colora = (FromColor * (1f - position)); Color colorb = (ToColor * position); Color finalColor = new Color((colora.R + colorb.R), (colora.G + colorb.G), (colora.B + colorb.B)); // update renderables foreach (var renderable in ModelRenderables) { renderable.MaterialOverride.DiffuseColor = finalColor; } }
/// <summary> /// Random color value from base and rand color. /// </summary> protected Color RandColor(Color baseColor, Color randColor) { return(AnimatorUtils.RandColor(Random, baseColor, randColor)); }
/// <summary> /// Random vector direction. /// </summary> protected Vector3 RandDirection(Vector3 baseVector, Vector3 randDir) { return(AnimatorUtils.RandDirection(Random, baseVector, randDir)); }