/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. // Description : 'Vec3' explicit specialization of the class template // 'TAnimSplineTrack' #ifndef CRYINCLUDE_CRYMOVIE_ANIMSPLINETRACK_VEC3SPECIALIZATION_H #define CRYINCLUDE_CRYMOVIE_ANIMSPLINETRACK_VEC3SPECIALIZATION_H #pragma once template <> inline TAnimSplineTrack::TAnimSplineTrack() { AllocSpline(); m_flags = 0; m_defaultValue = Vec3(0, 0, 0); m_fMinKeyValue = 0.0f; m_fMaxKeyValue = 0.0f; m_bCustomColorSet = false; m_node = nullptr; m_trackMultiplier = 1.0f; } template <> inline void TAnimSplineTrack::GetValue(float time, Vec3& value, bool applyMultiplier) { if (GetNumKeys() == 0) { value = m_defaultValue; } else { m_spline->interpolate(time, value); } if (applyMultiplier && m_trackMultiplier != 1.0f) { value /= m_trackMultiplier; } } template <> inline EAnimCurveType TAnimSplineTrack::GetCurveType() { return eAnimCurveType_TCBVector; } template <> inline EAnimValue TAnimSplineTrack::GetValueType() { return eAnimValue_Vector; } template <> inline void TAnimSplineTrack::SetValue(float time, const Vec3& value, bool bDefault, bool applyMultiplier) { if (!bDefault) { ITcbKey key; if (applyMultiplier && m_trackMultiplier != 1.0f) { key.SetValue(value * m_trackMultiplier); } else { key.SetValue(value); } SetKeyAtTime(time, &key); } else { if (applyMultiplier && m_trackMultiplier != 1.0f) { m_defaultValue = value * m_trackMultiplier; } else { m_defaultValue = value; } } } template <> inline void TAnimSplineTrack::OffsetKeyPosition(const Vec3& offset) { // Iterate over all keys and offet them. ITcbKey key; for (int i = 0; i < GetNumKeys(); i++) { // Offset each key. GetKey(i, &key); key.SetVec3(key.GetVec3() + offset); SetKey(i, &key); } } ////////////////////////////////////////////////////////////////////////// template <> inline void TAnimSplineTrack::GetKeyInfo(int index, const char*& description, float& duration) { duration = 0; static char str[64]; description = str; assert(index >= 0 && index < GetNumKeys()); Spline::key_type& k = m_spline->key(index); sprintf_s(str, "%.2f %.2f %.2f", k.value[0], k.value[1], k.value[2]); } #endif // CRYINCLUDE_CRYMOVIE_ANIMSPLINETRACK_VEC3SPECIALIZATION_H