Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8df2affe4814bc290208ec38a3f91fe566fa74525c6b70fb13de0ce658008874
size 951
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9ce97a0faf52d2069912891d26a733d76f2e1bf99ce752b7392769bcdf270ea2
size 1105
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d783b84c046f521e2f7cac9b17730f4cc13aba711e99af5d3c3a4936f2b6edd4
size 5690
@@ -0,0 +1,58 @@
----------------------------------------------------------------------------------------------------
--
-- 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.
--
--
----------------------------------------------------------------------------------------------------
local AddPhysicsImpulse =
{
Properties =
{
IncomingGameplayEventName = "",
IsRelative = {default=true, description="When true, the impulse will be applied relative to the entity's transform"},
ImpulseScale = {default=1.0, description="This will scale the vector before sending it"},
},
}
function AddPhysicsImpulse:OnActivate()
local gameplayBusId = GameplayNotificationId(self.entityId, self.Properties.IncomingGameplayEventName, "Vector3")
self.gameplayBus = GameplayNotificationBus.Connect(self, gameplayBusId)
end
function AddPhysicsImpulse:AddImpulse(vectorValue)
if self.Properties.IsRelative then
local localTM = TransformBus.Event.GetWorldTM(self.entityId)
localTM:SetTranslation(Vector3(0,0,0))
localTM:ExtractScale()
PhysicsComponentRequestBus.Event.AddImpulse(self.entityId, localTM * (vectorValue*self.Properties.ImpulseScale))
else
PhysicsComponentRequestBus.Event.AddImpulse(self.entityId, vectorValue*self.Properties.ImpulseScale)
end
end
function AddPhysicsImpulse:OnEventBegin(vectorValue)
self:AddImpulse(vectorValue)
end
function AddPhysicsImpulse:OnEventUpdating(vectorValue)
self:AddImpulse(vectorValue)
end
function AddPhysicsImpulse:OnEventEnd(vectorValue)
self:AddImpulse(vectorValue)
end
function AddPhysicsImpulse:OnDeactivate()
self.gameplayBus:Disconnect()
end
return AddPhysicsImpulse
@@ -0,0 +1,88 @@
--
--
-- 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.
--
local EntityLookAt =
{
Properties =
{
EntityTargetToFace = {default=EntityId()},
Advanced = {default="Edit this script to face a different axis towards the target"},
},
Handlers =
{
MyTransform = {},
TargetTransform = {},
}
}
function EntityLookAt:OnActivate()
if self.Properties.EntityTargetToFace:IsValid() then
-- cache properties
local myTM = TransformBus.Event.GetWorldTM(self.entityId)
self.myPos = myTM:GetPosition()
self.targetPos = TransformBus.Event.GetWorldTranslation(self.Properties.EntityTargetToFace)
self.myScale = myTM:RetrieveScale()
self.readyForRotation = true
--attach handlers
self.myTransform = TransformNotificationBus.Connect(self.Handlers.MyTransform, self.entityId)
self.targetTransform = TransformNotificationBus.Connect(self.Handlers.TargetTransform, self.Properties.EntityTargetToFace)
self.Handlers.MyTransform.parent = self
self.Handlers.TargetTransform.parent = self
self:UpdateFacing()
end
end
function EntityLookAt.Handlers.TargetTransform:OnTransformChanged(localTM, worldTM)
local distance = self.parent.targetPos - worldTM:GetPosition()
-- if our target has moved, Update our facing
if not distance:IsZero(0.0001) then
self.parent.targetPos = worldTM:GetPosition()
self.parent:UpdateFacing()
end
end
function EntityLookAt.Handlers.MyTransform:OnTransformChanged(localTM, worldTM)
-- cache the scale
self.parent.myScale = worldTM:RetrieveScale()
local distance = self.parent.myPos - worldTM:GetPosition()
-- if we've moved then update our facing
if self.parent.readyForRotation then
self.parent.myPos = worldTM:GetPosition()
self.parent:UpdateFacing()
end
end
function EntityLookAt:UpdateFacing()
self.readyForRotation = false
-- you can use Model Space relative AxisType's of
-- YPositive : face directly at targetPos,
-- YNegative : face directly away from targetPos,
-- XPositive : "right shoulder" faces targetPos,
-- XNegative : "left shoulder" faces targetPos,
-- ZPositive : top faces targetPos
-- ZNegative : bottom faces targetPos
self.axisToFaceAtTarget = AxisType.YPositive
local tm = MathUtils.CreateLookAt(self.myPos, self.targetPos, self.axisToFaceAtTarget)
tm:MultiplyByScale(self.myScale)
TransformBus.Event.SetWorldTM(self.entityId, tm)
self.readyForRotation = true
end
function EntityLookAt:OnDeactivate()
self.Handlers.MyTransform = {}
self.Handlers.TargetTransform = {}
self.myTransform = nil
self.targetTransform = nil
end
return EntityLookAt
@@ -0,0 +1,58 @@
----------------------------------------------------------------------------------------------------
--
-- 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.
--
--
----------------------------------------------------------------------------------------------------
local MoveEntity =
{
Properties =
{
IncomingGameplayEventName = "",
IsRelative = {default=true, description="When true, the velocity will be applied relative to the entity's transform"},
VelocityScale = {default=1.0, description="This will scale the vector before sending it"},
},
}
function MoveEntity:OnActivate()
local gameplayBusId = GameplayNotificationId(self.entityId, self.Properties.IncomingGameplayEventName, "Vector3")
self.gameplayBus = GameplayNotificationBus.Connect(self, gameplayBusId)
end
function MoveEntity:SetVelocity(vectorValue)
if self.Properties.IsRelative then
local localTM = TransformBus.Event.GetWorldTM(self.entityId)
localTM:SetTranslation(Vector3(0,0,0))
localTM:ExtractScale()
PhysicsComponentRequestBus.Event.SetVelocity(self.entityId, localTM * (vectorValue*self.Properties.VelocityScale))
else
PhysicsComponentRequestBus.Event.SetVelocity(self.entityId, vectorValue*self.Properties.VelocityScale)
end
end
function MoveEntity:OnEventBegin(vectorValue)
self:SetVelocity(vectorValue)
end
function MoveEntity:OnEventUpdating(vectorValue)
self:SetVelocity(vectorValue)
end
function MoveEntity:OnEventEnd(vectorValue)
self:SetVelocity(vectorValue)
end
function MoveEntity:OnDeactivate()
self.gameplayBus:Disconnect()
end
return MoveEntity
@@ -0,0 +1,68 @@
----------------------------------------------------------------------------------------------------
--
-- 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.
--
--
----------------------------------------------------------------------------------------------------
local RotateEntity =
{
Properties =
{
IncomingGameplayEventName = "",
AxisOfRotation = {default=Vector3(0,0,1), description="The axis to rotate around"},
IsRelative = {default=true, description="When true, the entity's transform will transform the AxisOfRotation"},
RotationSpeed = {default=60, description="Degrees per second."},
},
}
function RotateEntity:OnActivate()
local gameplayBusId = GameplayNotificationId(self.entityId, self.Properties.IncomingGameplayEventName, "float")
self.gameplayBus = GameplayNotificationBus.Connect(self, gameplayBusId)
end
function RotateEntity:ApplyRotation(floatValue)
local axisOfRotation = self.Properties.AxisOfRotation:GetNormalized()
local localTM = TransformBus.Event.GetWorldTM(self.entityId)
local translation = localTM:GetTranslation()
localTM:SetTranslation(Vector3(0,0,0))
local scale = localTM:ExtractScale()
if not self.Properties.IsRelative then
axisOfRotation = axisOfRotation * localTM
end
local dt = TickRequestBus.Broadcast.GetTickDeltaTime()
local rotationAmount = floatValue * dt * Math.DegToRad(self.Properties.RotationSpeed)
local finalTM = localTM * Transform.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(axisOfRotation, rotationAmount):GetNormalized())
finalTM:SetPosition(translation)
finalTM:MultiplyByScale(scale)
TransformBus.Event.SetWorldTM(self.entityId, finalTM)
end
function RotateEntity:OnEventBegin(floatValue)
self:ApplyRotation(floatValue)
end
function RotateEntity:OnEventUpdating(floatValue)
self:ApplyRotation(floatValue)
end
function RotateEntity:OnEventEnd(floatValue)
self:ApplyRotation(floatValue)
end
function RotateEntity:OnDeactivate()
self.gameplayBus:Disconnect()
end
return RotateEntity
+12
View File
@@ -0,0 +1,12 @@
#
# 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.
#
add_subdirectory(Code)
@@ -0,0 +1,43 @@
#
# 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.
#
ly_add_target(
NAME StartingPointMovement.Static STATIC
NAMESPACE Gem
FILES_CMAKE
startingpointmovement_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Source
PUBLIC
Include
BUILD_DEPENDENCIES
PRIVATE
AZ::AzCore
)
ly_add_target(
NAME StartingPointMovement ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
NAMESPACE Gem
OUTPUT_NAME Gem.StartingPointMovement.73d8779dc28a4123b7c9ed76217464af.v0.1.0
FILES_CMAKE
startingpointmovement_shared_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Source
PUBLIC
Include
BUILD_DEPENDENCIES
PRIVATE
Gem::StartingPointMovement.Static
AZ::AzCore
AZ::AzFramework
)
@@ -0,0 +1,25 @@
/*
* 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.
*
*/
#pragma once
namespace Movement
{
//////////////////////////////////////////////////////////////////////////
/// These are intended to be used as an index and needs to be implicitly
/// convertible to int. See StartingPointMovementUtilities.h for examples
enum AxisOfRotation
{
X_Axis = 0,
Y_Axis = 1,
Z_Axis = 2
};
} //namespace Movement
@@ -0,0 +1,33 @@
/*
* 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.
*
*/
#pragma once
#include <AzCore/Math/Vector3.h>
#include "StartingPointMovement/StartingPointMovementConstants.h"
#include <AzCore/Math/Quaternion.h>
#include <AzCore/Math/Transform.h>
namespace Movement
{
//////////////////////////////////////////////////////////////////////////
/// This will calculate an AZ::Transform based on an axis of rotation and an angle
//////////////////////////////////////////////////////////////////////////
static AZ::Transform CreateRotationFromAxis(AxisOfRotation rotationType, float radians)
{
static const AZ::Transform(*s_createRotation[3]) (const float) =
{
&AZ::Transform::CreateRotationX,
&AZ::Transform::CreateRotationY,
&AZ::Transform::CreateRotationZ
};
return s_createRotation[rotationType](radians);
}
} //namespace Movement
@@ -0,0 +1,75 @@
/*
* 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.
*
*/
#include "StartingPointMovement_precompiled.h"
#include <AzCore/Module/Module.h>
#include <AzFramework/Metrics/MetricsPlainTextNameRegistration.h>
#include <AzCore/Serialization/SerializeContext.h>
namespace StartingPointMovement
{
// Dummy component to get reflect function
class StartingPointMovementDummyComponent
: public AZ::Component
{
public:
AZ_COMPONENT(StartingPointMovementDummyComponent, "{6C9DA3DD-A0B3-4DCB-B77B-E93C4AF89134}");
static void Reflect(AZ::ReflectContext* context)
{
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->ClassDeprecate("Event Action Bindings", "{2BB79CFC-7EBC-4EF4-A62E-5D64CB45CDBD}");
serializeContext->Class<StartingPointMovementDummyComponent, AZ::Component>()
->Version(0)
;
}
}
void Activate() override { }
void Deactivate() override { }
};
class StartingPointMovementModule
: public AZ::Module
{
public:
AZ_RTTI(StartingPointMovementModule, "{AE406AE3-77AE-4CA6-84AD-842224EE2188}", AZ::Module);
StartingPointMovementModule()
: AZ::Module()
{
m_descriptors.insert(m_descriptors.end(), {
StartingPointMovementDummyComponent::CreateDescriptor(),
});
// This is an internal Amazon gem, so register it's components for metrics tracking, otherwise the name of the component won't get sent back.
// IF YOU ARE A THIRDPARTY WRITING A GEM, DO NOT REGISTER YOUR COMPONENTS WITH EditorMetricsComponentRegistrationBus
AZStd::vector<AZ::Uuid> typeIds;
typeIds.reserve(m_descriptors.size());
for (AZ::ComponentDescriptor* descriptor : m_descriptors)
{
typeIds.emplace_back(descriptor->GetUuid());
}
EBUS_EVENT(AzFramework::MetricsPlainTextNameRegistrationBus, RegisterForNameSending, typeIds);
}
};
}
// DO NOT MODIFY THIS LINE UNLESS YOU RENAME THE GEM
// The first parameter should be GemName_GemIdLower
// The second should be the fully qualified name of the class above
AZ_DECLARE_MODULE_CLASS(Gem_StartingPointMovement, StartingPointMovement::StartingPointMovementModule)
@@ -0,0 +1,12 @@
/*
* 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.
*
*/
#include "StartingPointMovement_precompiled.h"
@@ -0,0 +1,13 @@
/*
* 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.
*
*/
#pragma once
@@ -0,0 +1,17 @@
#
# 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.
#
set(FILES
Include/StartingPointMovement/StartingPointMovementConstants.h
Include/StartingPointMovement/StartingPointMovementUtilities.h
Source/StartingPointMovement_precompiled.cpp
Source/StartingPointMovement_precompiled.h
)
@@ -0,0 +1,14 @@
#
# 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.
#
set(FILES
Source/StartingPointMovementGem.cpp
)
+20
View File
@@ -0,0 +1,20 @@
{
"Dependencies": [
{
"Uuid": "ff06785f7145416b9d46fde39098cb0c",
"VersionConstraints": [
"~>0.1"
],
"_comment": "LmbrCentral"
}
],
"GemFormatVersion": 3,
"Uuid": "73d8779dc28a4123b7c9ed76217464af",
"Name": "StartingPointMovement",
"Version": "0.1.0",
"LinkType": "Dynamic",
"DisplayName": "Starting Point Movement [PREVIEW]",
"Summary": "The Starting Point Movement Gem includes a series of Lua scripts that listens for input events that then triggers a transform operation such as movement or rotation.",
"Tags": ["Movement", "Starting Point"],
"IconPath": "preview.png"
}
+3
View File
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7917fbf6e4e3a89e3432b8f48822b660bb245d2b84bb8efdf9f715593c0973df
size 38792