/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include #include #include #include #include #include #include #include namespace EMotionFX { SimpleJointChainActor::SimpleJointChainActor(size_t jointCount, const char* name) : Actor(name) { if (jointCount) { AddNode(0, "rootJoint"); GetBindPose()->SetLocalSpaceTransform(0, Transform::CreateIdentity()); } for (uint32 i = 1; i < jointCount; ++i) { AddNode(i, ("joint" + AZStd::to_string(i)).c_str(), i - 1); Transform transform = Transform::CreateIdentity(); transform.m_position = AZ::Vector3(static_cast(i), 0.0f, 0.0f); GetBindPose()->SetLocalSpaceTransform(i, transform); } } AllRootJointsActor::AllRootJointsActor(size_t jointCount, const char* name) : Actor(name) { for (uint32 i = 0; i < jointCount; ++i) { AddNode(i, ("rootJoint" + AZStd::to_string(i)).c_str()); Transform transform = Transform::CreateIdentity(); transform.m_position = AZ::Vector3(static_cast(i), 0.0f, 0.0f); GetBindPose()->SetLocalSpaceTransform(i, transform); } } PlaneActor::PlaneActor(const char* name) : SimpleJointChainActor(1, name) { SetMesh(0, 0, CreatePlane({ AZ::Vector3(-1.0f, -1.0f, 0.0f), AZ::Vector3(1.0f, -1.0f, 0.0f), AZ::Vector3(-1.0f, 1.0f, 0.0f), AZ::Vector3(1.0f, -1.0f, 0.0f), AZ::Vector3(-1.0f, 1.0f, 0.0f), AZ::Vector3(1.0f, 1.0f, 0.0f) })); } Mesh* PlaneActor::CreatePlane(const AZStd::vector& points) const { const auto vertCount = static_cast(points.size()); AZStd::vector indices(vertCount); std::iota(indices.begin(), indices.end(), 0); AZStd::vector normals {vertCount, {0.0f, 0.0f, 1.0f}}; return EMotionFX::MeshFactory::Create( indices, points, normals ); } PlaneActorWithJoints::PlaneActorWithJoints(size_t jointCount, const char* name) : PlaneActor(name) { for (uint32 i = 1; i < jointCount; ++i) { AddNode(i, ("joint" + AZStd::to_string(i)).c_str(), i - 1); Transform transform = Transform::CreateIdentity(); transform.m_position = AZ::Vector3(static_cast(i), 0.0f, 0.0f); GetBindPose()->SetLocalSpaceTransform(i, transform); } } } // namespace EMotionFX