Removed legacy PhysicsEntities gem
parent
a505ed8a51
commit
b0bb29373b
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:056f3c42226567848b7b7bd959cde0dccdcf63a79700743e55436eae35520a28
|
||||
size 80
|
||||
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5fc10f1dd377cc2663faaa6aa5503aadb8288179cddc46bb3379337167c150fc
|
||||
size 76
|
||||
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:785988d40e9af3f1f6adccc10a5a6fa1f6a78b6f6bb10647acf0f3997cd14834
|
||||
size 80
|
||||
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:76017bdaf559051a5ec6fb46a9132020ad54d35c1bdaf39511e52f0d3faeffe2
|
||||
size 87
|
||||
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2b8efdd98b365874375ea80ee02c3b8e3d951aa5f74fe50fb0cfd2a431395b23
|
||||
size 85
|
||||
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:fa1ed0cda25890a36a3f2c9f4bd2cbfbb4cef0198258f1b33a0ad3fb804c860c
|
||||
size 91
|
||||
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:38cff841ea29a428729b79667672d3825188b9eec74ce0be324c5a072958c63d
|
||||
size 68
|
||||
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:cc9ad675bca0b1446b9d3ad9b6bf53b1348f7dd96e00eb256744f82273b9f9da
|
||||
size 76
|
||||
@ -1,173 +0,0 @@
|
||||
----------------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- 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.
|
||||
--
|
||||
--
|
||||
----------------------------------------------------------------------------------------------------
|
||||
Constraint =
|
||||
{
|
||||
Properties=
|
||||
{
|
||||
radius = 0.03,
|
||||
damping = 0,
|
||||
bNoSelfCollisions = 1,
|
||||
bUseEntityFrame=1,
|
||||
max_pull_force=0,
|
||||
max_bend_torque=0,
|
||||
bConstrainToLine=0,
|
||||
bConstrainToPlane=0,
|
||||
bConstrainFully=1,
|
||||
bNoRotation=0,
|
||||
Limits = {
|
||||
x_min = 0,
|
||||
x_max = 0,
|
||||
yz_min = 0,
|
||||
yz_max = 0,
|
||||
}
|
||||
},
|
||||
numUpdates = 0,
|
||||
|
||||
Editor=
|
||||
{
|
||||
Icon="Magnet.bmp",
|
||||
ShowBounds = 1,
|
||||
},
|
||||
}
|
||||
|
||||
function Constraint:OnReset()
|
||||
--Log("%s:OnReset() idEnt: %s idConstr: %s broken: %s", self:GetName(), tostring(self.idEnt),
|
||||
-- tostring(self.idConstr), tostring(self.broken))
|
||||
|
||||
--if (self.idConstr) then
|
||||
--System.GetEntity(self.idEnt):SetPhysicParams(PHYSICPARAM_REMOVE_CONSTRAINT, { id=self.idConstr })
|
||||
--end
|
||||
|
||||
self.idEnt = nil
|
||||
self.idConstr = nil
|
||||
self.broken = nil
|
||||
self.numUpdates = 0
|
||||
self:SetFlags(ENTITY_FLAG_CLIENT_ONLY,0);
|
||||
end
|
||||
|
||||
function Constraint:Apply()
|
||||
--Log("%s:Apply() idEnt: %s idConstr: %s broken: %s", self:GetName(), tostring(self.idEnt),
|
||||
-- tostring(self.idConstr), tostring(self.broken))
|
||||
|
||||
local ConstraintParams = {pivot={},frame0={},frame1={}};
|
||||
if self.idEnt then
|
||||
elseif (not self.broken) then
|
||||
local ents = Physics.SamplePhysEnvironment(self:GetPos(), self.Properties.radius);
|
||||
if (ents[1] and ents[6]) then
|
||||
CopyVector(ConstraintParams.pivot, self:GetPos());
|
||||
if self.Properties.bUseEntityFrame==1 then
|
||||
CopyVector(ConstraintParams.frame1, ents[1]:GetAngles());
|
||||
else
|
||||
CopyVector(ConstraintParams.frame1, self:GetAngles());
|
||||
end
|
||||
CopyVector(ConstraintParams.frame0, ConstraintParams.frame1);
|
||||
ConstraintParams.entity_part_id_1 = ents[2];
|
||||
ConstraintParams.phys_entity_id = ents[6];
|
||||
ConstraintParams.entity_part_id_2 = ents[5];
|
||||
ConstraintParams.xmin = self.Properties.Limits.x_min;
|
||||
ConstraintParams.xmax = self.Properties.Limits.x_max;
|
||||
ConstraintParams.yzmin = self.Properties.Limits.yz_min;
|
||||
ConstraintParams.yzmax = self.Properties.Limits.yz_max;
|
||||
ConstraintParams.ignore_buddy = self.Properties.bNoSelfCollisions;
|
||||
ConstraintParams.damping = self.Properties.damping;
|
||||
ConstraintParams.sensor_size = self.Properties.radius;
|
||||
ConstraintParams.max_pull_force = self.Properties.max_pull_force;
|
||||
ConstraintParams.max_bend_torque = self.Properties.max_bend_torque;
|
||||
ConstraintParams.line = self.Properties.bConstrainToLine;
|
||||
ConstraintParams.plane = self.Properties.bConstrainToPlane;
|
||||
ConstraintParams.no_rotation = self.Properties.bNoRotation;
|
||||
ConstraintParams.full = self.Properties.bConstrainFully;
|
||||
self.idConstr = ents[1]:SetPhysicParams(PHYSICPARAM_CONSTRAINT, ConstraintParams);
|
||||
self.idEnt = ents[1].id;
|
||||
else
|
||||
self:SetTimer(1,1);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Constraint:OnTimer()
|
||||
if (self.numUpdates < 10) then
|
||||
self:Apply();
|
||||
self.numUpdates = self.numUpdates+1;
|
||||
end
|
||||
end
|
||||
|
||||
function Constraint:OnLevelLoaded()
|
||||
--Log("%s:OnLevelLoaded() idEnt: %s idConstr: %s broken: %s", self:GetName(), tostring(self.idEnt),
|
||||
-- tostring(self.idConstr), tostring(self.broken))
|
||||
|
||||
if ((not self.broken) and (not self.idConstr)) then
|
||||
self.numUpdates = 0
|
||||
self.idEnt = nil
|
||||
self.idConstr = nil
|
||||
self:Apply()
|
||||
end
|
||||
end
|
||||
|
||||
function Constraint:OnPropertyChange()
|
||||
self:OnReset()
|
||||
end
|
||||
|
||||
function Constraint:OnSpawn()
|
||||
self:OnReset()
|
||||
end
|
||||
|
||||
function Constraint:Event_ConstraintBroken(sender)
|
||||
--Log("%s:Event_ConstraintBroken() idEnt: %s idConstr: %s broken: %s", self:GetName(), tostring(self.idEnt),
|
||||
-- tostring(self.idConstr), tostring(self.broken))
|
||||
|
||||
if self.idEnt then
|
||||
System.GetEntity(self.idEnt):SetPhysicParams(PHYSICPARAM_REMOVE_CONSTRAINT, { id=self.idConstr });
|
||||
self.idEnt = nil
|
||||
self.idConstr = nil
|
||||
end
|
||||
|
||||
self.broken = true
|
||||
self:KillTimer(1)
|
||||
|
||||
BroadcastEvent(self, "ConstraintBroken")
|
||||
end
|
||||
|
||||
function Constraint:OnSave( props )
|
||||
--Log("%s:OnSave() idEnt: %s idConstr: %s broken: %s", self:GetName(), tostring(self.idEnt),
|
||||
-- tostring(self.idConstr), tostring(self.broken))
|
||||
|
||||
props.broken = self.broken
|
||||
props.idEnt = self.idEnt
|
||||
props.idConstr = self.idConstr
|
||||
end
|
||||
|
||||
function Constraint:OnLoad( props )
|
||||
self.broken = props.broken
|
||||
self.idEnt = props.idEnt
|
||||
self.idConstr = props.idConstr
|
||||
|
||||
--Log("%s:OnLoad() idEnt: %s idConstr: %s broken: %s", self:GetName(), tostring(self.idEnt),
|
||||
-- tostring(self.idConstr), tostring(self.broken))
|
||||
end
|
||||
|
||||
function Constraint:OnDestroy()
|
||||
end
|
||||
|
||||
Constraint.FlowEvents =
|
||||
{
|
||||
Inputs =
|
||||
{
|
||||
ConstraintBroken = { Constraint.Event_ConstraintBroken, "bool" },
|
||||
},
|
||||
Outputs =
|
||||
{
|
||||
ConstraintBroken = "bool",
|
||||
},
|
||||
}
|
||||
@ -1,289 +0,0 @@
|
||||
----------------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- 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.
|
||||
--
|
||||
--
|
||||
----------------------------------------------------------------------------------------------------
|
||||
-- #Script.ReloadScript("scripts/default/entities/player/basicplayer.lua")
|
||||
|
||||
DeadBody =
|
||||
{
|
||||
type = "DeadBody",
|
||||
temp_ModelName = "",
|
||||
|
||||
DeadBodyParams =
|
||||
{
|
||||
max_time_step = 0.025,
|
||||
sleep_speed = 0.025,
|
||||
damping = 0.3,
|
||||
freefall_damping = 0.1,
|
||||
|
||||
lying_mode_ncolls = 4,
|
||||
lying_sleep_speed = 0.065,
|
||||
lying_damping = 1.5,
|
||||
},
|
||||
|
||||
PhysParams =
|
||||
{
|
||||
mass = 80,
|
||||
height = 1.8,
|
||||
eyeheight = 1.7,
|
||||
sphereheight = 1.2,
|
||||
radius = 0.45,
|
||||
stiffness_scale = 0,
|
||||
lod = 1,
|
||||
retain_joint_vel = 0,
|
||||
},
|
||||
|
||||
Properties =
|
||||
{
|
||||
soclasses_SmartObjectClass = "",
|
||||
bResting = 1,
|
||||
object_Model = "objects/characters/human/sdk_player/sdk_player.cdf",
|
||||
lying_damping = 1.5,
|
||||
bCollidesWithPlayers = 0,
|
||||
bPushableByPlayers = 0,
|
||||
Mass = 80,
|
||||
Stiffness = 0,
|
||||
MaxTimeStep = 0.025,
|
||||
bExtraStiff = 0,
|
||||
bNoFriendlyFire = 0,
|
||||
PoseAnim = "",
|
||||
|
||||
Buoyancy=
|
||||
{
|
||||
water_density = 1000,
|
||||
water_damping = 0,
|
||||
water_resistance = 1000,
|
||||
},
|
||||
|
||||
TacticalInfo =
|
||||
{
|
||||
bScannable = 0,
|
||||
LookupName = "",
|
||||
},
|
||||
},
|
||||
|
||||
Editor =
|
||||
{
|
||||
Icon = "DeadBody.bmp",
|
||||
IconOnTop = 1,
|
||||
},
|
||||
}
|
||||
|
||||
-------------------------------------------------------
|
||||
function DeadBody:OnLoad(table)
|
||||
self.temp_ModelName = table.temp_ModelName
|
||||
self.PhysParams = table.PhysParams
|
||||
self.DeadBodyParams = table.DeadBodyParams
|
||||
end
|
||||
|
||||
-------------------------------------------------------
|
||||
function DeadBody:OnSave(table)
|
||||
table.temp_ModelName = self.temp_ModelName
|
||||
table.PhysParams = self.PhysParams
|
||||
table.DeadBodyParams = self.DeadBodyParams
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
function DeadBody:OnReset()
|
||||
--self.temp_ModelName ="";
|
||||
--self:OnPropertyChange();
|
||||
|
||||
self.bScannable = self.Properties.TacticalInfo.bScannable;
|
||||
|
||||
-- no problem in repeatedly registering or unregistering
|
||||
if (self.bScannable==1) then
|
||||
Game.AddTacticalEntity(self.id, eTacticalEntity_Story);
|
||||
else
|
||||
Game.RemoveTacticalEntity(self.id, eTacticalEntity_Story);
|
||||
end
|
||||
|
||||
self:LoadCharacter(0,self.Properties.object_Model);
|
||||
--self:StartAnimation( 0,"cidle" );
|
||||
self:PhysicalizeThis();
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
function DeadBody:Server_OnInit()
|
||||
if (not CryAction.IsServer()) then
|
||||
DeadBody.OnPropertyChange( self );
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
function DeadBody:Client_OnInit()
|
||||
DeadBody.OnPropertyChange( self );
|
||||
|
||||
self:SetUpdatePolicy( ENTITY_UPDATE_PHYSICS_VISIBLE );
|
||||
--self:Activate(1);
|
||||
|
||||
-- self:RenderShadow( 1 ); -- enable rendering of player shadow
|
||||
-- self:SetShaderFloat("HeatIntensity",0,0,0);
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
function DeadBody:Server_OnDamageDead( hit )
|
||||
--printf("server on Damage DEAD %.2f %.2f",hit.impact_force_mul_final,hit.impact_force_mul);
|
||||
--System.Log("DeadBody hit part "..hit.ipart);
|
||||
if( hit.ipart ) then
|
||||
self:AddImpulse( hit.ipart, hit.pos, hit.dir, hit.impact_force_mul );
|
||||
else
|
||||
self:AddImpulse( -1, hit.pos, hit.dir, hit.impact_force_mul );
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
function DeadBody:OnHit()
|
||||
BroadcastEvent( self,"Hit" );
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
function DeadBody:OnPropertyChange()
|
||||
--System.LogToConsole("prev:"..self.temp_ModelName.." new:"..self.Properties.object_Model);
|
||||
|
||||
self.PhysParams.mass = self.Properties.Mass;
|
||||
|
||||
if (self.Properties.object_Model ~= self.temp_ModelName) then
|
||||
self.temp_ModelName = self.Properties.object_Model;
|
||||
self:LoadCharacter(0,self.Properties.object_Model);
|
||||
end
|
||||
self:PhysicalizeThis();
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------
|
||||
function DeadBody:PhysicalizeThis()
|
||||
local Properties = self.Properties;
|
||||
local status = 1;
|
||||
|
||||
self.PhysParams.retain_joint_vel = 0;
|
||||
if (Properties.PoseAnim ~= "") then
|
||||
self:StartAnimation( 0, Properties.PoseAnim, 0,0,1,1,1,0,1 );
|
||||
self.PhysParams.retain_joint_vel = 1; --this is just to retain the positions of non-physical bones
|
||||
end
|
||||
|
||||
local bPushableByPlayers = Properties.bPushableByPlayers;
|
||||
local bCollidesWithPlayers = Properties.bCollidesWithPlayers;
|
||||
|
||||
if (status == 1) then
|
||||
bPushableByPlayers = 0;
|
||||
bCollidesWithPlayers = 0;
|
||||
end
|
||||
|
||||
self.PhysParams.mass = Properties.Mass;
|
||||
self.PhysParams.stiffness_scale = Properties.Stiffness*(1-Properties.bExtraStiff*2);
|
||||
|
||||
self:Physicalize( 0, PE_ARTICULATED, self.PhysParams );
|
||||
|
||||
self:SetPhysicParams(PHYSICPARAM_SIMULATION, self.Properties );
|
||||
self:SetPhysicParams(PHYSICPARAM_BUOYANCY, self.Properties.Buoyancy );
|
||||
|
||||
if (Properties.lying_damping) then
|
||||
self.DeadBodyParams.lying_damping = Properties.lying_damping;
|
||||
end
|
||||
self.DeadBodyParams.max_time_step = Properties.MaxTimeStep;
|
||||
self:SetPhysicParams(PHYSICPARAM_SIMULATION, self.DeadBodyParams);
|
||||
self:SetPhysicParams(PHYSICPARAM_ARTICULATED, self.DeadBodyParams);
|
||||
|
||||
local flagstab = { flags_mask=geom_colltype_player, flags=geom_colltype_player*bCollidesWithPlayers };
|
||||
if (status == 1) then
|
||||
flagstab.flags_mask = geom_colltype_explosion + geom_colltype_ray + geom_colltype_foliage_proxy + geom_colltype_player;
|
||||
end
|
||||
self:SetPhysicParams(PHYSICPARAM_PART_FLAGS, flagstab);
|
||||
flagstab.flags_mask = pef_pushable_by_players;
|
||||
flagstab.flags = pef_pushable_by_players*bPushableByPlayers;
|
||||
self:SetPhysicParams(PHYSICPARAM_FLAGS, flagstab);
|
||||
if (Properties.bResting == 1) then
|
||||
self:AwakePhysics(0);
|
||||
else
|
||||
self:AwakePhysics(1);
|
||||
end
|
||||
self:EnableProceduralFacialAnimation(false);
|
||||
self:PlayFacialAnimation("death_pose_0"..random(1,5), true);
|
||||
-- small hack: we need one update to sync physics and animation, so here it is after physicalization
|
||||
-- (our OnUpdate function should just deactivate immediately.)
|
||||
--self:Activate(1);
|
||||
end
|
||||
|
||||
--function DeadBody:OnUpdate()
|
||||
--self:Activate(0);
|
||||
--end
|
||||
|
||||
function DeadBody:Event_Hide()
|
||||
self:Hide(1);
|
||||
end;
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function DeadBody:Event_UnHide()
|
||||
self:Hide(0);
|
||||
end;
|
||||
|
||||
--------------------------------------------------------------------------------------------------------
|
||||
function DeadBody:Event_Awake()
|
||||
self:AwakePhysics(1);
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------
|
||||
function DeadBody:Event_Hit(sender)
|
||||
BroadcastEvent(self, "Hit");
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------
|
||||
DeadBody.Server =
|
||||
{
|
||||
OnInit = DeadBody.Server_OnInit,
|
||||
-- OnShutDown = function( self ) end,
|
||||
OnDamage = DeadBody.Server_OnDamageDead,
|
||||
OnHit = DeadBody.OnHit,
|
||||
OnUpdate=DeadBody.OnUpdate,
|
||||
}
|
||||
|
||||
--------------------------------------------------------------------------------------------------------
|
||||
DeadBody.Client =
|
||||
{
|
||||
OnInit = DeadBody.Client_OnInit,
|
||||
-- OnShutDown = DeadBody.Client_OnShutDown,
|
||||
OnDamage=DeadBody.Client_OnDamage,
|
||||
OnUpdate=DeadBody.OnUpdate,
|
||||
}
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
function DeadBody:HasBeenScanned()
|
||||
self:ActivateOutput("Scanned", true);
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
|
||||
DeadBody.FlowEvents =
|
||||
{
|
||||
Inputs =
|
||||
{
|
||||
Awake = { DeadBody.Event_Awake, "bool" },
|
||||
Hide = { DeadBody.Event_Hide, "bool" },
|
||||
UnHide = { DeadBody.Event_UnHide, "bool" },
|
||||
},
|
||||
Outputs =
|
||||
{
|
||||
Awake = "bool",
|
||||
Hit = "bool",
|
||||
Scanned = "bool",
|
||||
},
|
||||
}
|
||||
@ -1,120 +0,0 @@
|
||||
----------------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- 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.
|
||||
--
|
||||
--
|
||||
----------------------------------------------------------------------------------------------------
|
||||
-- Zero Gravity entity
|
||||
GravityBox =
|
||||
{
|
||||
Properties =
|
||||
{
|
||||
bActive = 1,
|
||||
BoxMin = { x=-10,y=-10,z=-10 },
|
||||
BoxMax = { x=10,y=10,z=10 },
|
||||
bUniform = 1,
|
||||
Gravity = { x=0,y=0,z=0 },
|
||||
FalloffInner = 0,
|
||||
},
|
||||
|
||||
Editor =
|
||||
{
|
||||
Icon = "GravitySphere.bmp",
|
||||
},
|
||||
_PhysTable = { Area={}, },
|
||||
}
|
||||
|
||||
-------------------------------------------------------
|
||||
function GravityBox:OnLoad(table)
|
||||
self.bActive = table.bActive
|
||||
if (self.bActive == 1) then
|
||||
self:PhysicalizeThis();
|
||||
else
|
||||
self:DestroyPhysics();
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------
|
||||
function GravityBox:OnSave(table)
|
||||
table.bActive = self.bActive
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function GravityBox:OnInit()
|
||||
self.bActive = self.Properties.bActive;
|
||||
if (self.bActive == 1) then
|
||||
self:PhysicalizeThis();
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
-- OnPropertyChange called only by the editor.
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function GravityBox:OnPropertyChange()
|
||||
if (self.bActive ~= self.Properties.bActive) then
|
||||
self.bActive = self.Properties.bActive;
|
||||
if (self.bActive == 1) then
|
||||
self:PhysicalizeThis();
|
||||
else
|
||||
self:DestroyPhysics();
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
-- OnReset called only by the editor.
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function GravityBox:OnReset()
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function GravityBox:PhysicalizeThis()
|
||||
if (self.bActive == 1) then
|
||||
local Properties = self.Properties;
|
||||
local Area = self._PhysTable.Area;
|
||||
Area.type = AREA_BOX;
|
||||
Area.box_min = Properties.BoxMin;
|
||||
Area.box_max = Properties.BoxMax;
|
||||
Area.uniform = Properties.bUniform;
|
||||
Area.falloffInner = Properties.FalloffInner;
|
||||
Area.gravity = Properties.Gravity;
|
||||
self:Physicalize( 0,PE_AREA,self._PhysTable );
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function GravityBox:Event_Activate()
|
||||
if (self.bActive ~= 1) then
|
||||
self.bActive = 1;
|
||||
self:PhysicalizeThis();
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function GravityBox:Event_Deactivate()
|
||||
if (self.bActive ~= 0) then
|
||||
self.bActive = 0;
|
||||
self:PhysicalizeThis();
|
||||
end
|
||||
end
|
||||
|
||||
GravityBox.FlowEvents =
|
||||
{
|
||||
Inputs =
|
||||
{
|
||||
Deactivate = { GravityBox.Event_Deactivate, "bool" },
|
||||
Activate = { GravityBox.Event_Activate, "bool" },
|
||||
},
|
||||
Outputs =
|
||||
{
|
||||
Deactivate = "bool",
|
||||
Activate = "bool",
|
||||
},
|
||||
}
|
||||
@ -1,131 +0,0 @@
|
||||
----------------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- 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.
|
||||
--
|
||||
--
|
||||
----------------------------------------------------------------------------------------------------
|
||||
-- Zero Gravity entity
|
||||
|
||||
GravitySphere =
|
||||
{
|
||||
Properties =
|
||||
{
|
||||
bActive = 1,
|
||||
Radius = 10,
|
||||
bUniform = 1,
|
||||
bEllipsoidal = 1,
|
||||
FalloffInner = 0,
|
||||
Gravity = { x=0,y=0,z=0 },
|
||||
Damping = 0,
|
||||
},
|
||||
|
||||
_PhysTable = { Area={}, },
|
||||
|
||||
Editor =
|
||||
{
|
||||
Icon = "GravitySphere.bmp",
|
||||
IconOnTop = 0,
|
||||
},
|
||||
}
|
||||
|
||||
-------------------------------------------------------
|
||||
function GravitySphere:OnLoad(table)
|
||||
self.bActive = table.bActive
|
||||
self:PhysicalizeThis();
|
||||
end
|
||||
|
||||
-------------------------------------------------------
|
||||
function GravitySphere:OnSave(table)
|
||||
table.bActive = self.bActive
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function GravitySphere:OnInit()
|
||||
self:OnReset();
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
-- OnPropertyChange called only by the editor.
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function GravitySphere:OnPropertyChange()
|
||||
self:DestroyPhysics();
|
||||
self.bActive = self.Properties.bActive;
|
||||
if (self.bActive ~= 0) then
|
||||
self:PhysicalizeThis();
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
-- OnReset called only by the editor.
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function GravitySphere:OnReset()
|
||||
self.bActive = self.Properties.bActive;
|
||||
self:PhysicalizeThis();
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function GravitySphere:PhysicalizeThis()
|
||||
--Log("GravitySphere:PhysicalizeThis");
|
||||
if (self.bActive == 1) then
|
||||
local Properties = self.Properties;
|
||||
local Area = self._PhysTable.Area;
|
||||
if (Properties.bEllipsoidal ~= 0) then
|
||||
Area.type = AREA_SPHERE;
|
||||
else
|
||||
Area.type = AREA_BOX;
|
||||
Area.box_min = {x = -Properties.Radius, y = -Properties.Radius, z = -Properties.Radius};
|
||||
Area.box_max = {x = Properties.Radius, y = Properties.Radius, z = Properties.Radius};
|
||||
end
|
||||
Area.radius = Properties.Radius;
|
||||
Area.uniform = Properties.bUniform;
|
||||
Area.falloffInner = Properties.FalloffInner;
|
||||
Area.gravity = Properties.Gravity;
|
||||
Area.damping = Properties.Damping;
|
||||
|
||||
self:Physicalize( 0,PE_AREA,self._PhysTable );
|
||||
|
||||
self:SetPhysicParams(PHYSICPARAM_FOREIGNDATA,{foreignData = ZEROG_AREA_ID});
|
||||
else
|
||||
self:DestroyPhysics();
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function GravitySphere:Event_Activate()
|
||||
if (self.bActive ~= 1) then
|
||||
self.bActive = 1;
|
||||
self:PhysicalizeThis();
|
||||
BroadcastEvent(self, "Activate");
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function GravitySphere:Event_Deactivate()
|
||||
if (self.bActive ~= 0) then
|
||||
self.bActive = 0;
|
||||
self:PhysicalizeThis();
|
||||
BroadcastEvent(self, "Deactivate");
|
||||
end
|
||||
end
|
||||
|
||||
GravitySphere.FlowEvents =
|
||||
{
|
||||
Inputs =
|
||||
{
|
||||
Deactivate = { GravitySphere.Event_Deactivate, "bool" },
|
||||
Activate = { GravitySphere.Event_Activate, "bool" },
|
||||
},
|
||||
Outputs =
|
||||
{
|
||||
Deactivate = "bool",
|
||||
Activate = "bool",
|
||||
},
|
||||
}
|
||||
@ -1,239 +0,0 @@
|
||||
----------------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- 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.
|
||||
--
|
||||
--
|
||||
----------------------------------------------------------------------------------------------------
|
||||
GravityValve =
|
||||
{
|
||||
Properties =
|
||||
{
|
||||
bActive = 1,
|
||||
Strength = 10,
|
||||
Radius = 10,
|
||||
bSpline = 0,
|
||||
},
|
||||
|
||||
Server = {},
|
||||
Client = {},
|
||||
|
||||
_PhysTableCyl = { Area={}, },
|
||||
_PhysTableSph = { Area={}, },
|
||||
_PhysTableSpl = { Area={points={},}, },
|
||||
_Points = {},
|
||||
_Caps = {},
|
||||
|
||||
Editor =
|
||||
{
|
||||
Icon = "GravitySphere.bmp",
|
||||
ShowBounds = 1,
|
||||
},
|
||||
}
|
||||
|
||||
-------------------------------------------------------
|
||||
function GravityValve:OnLoad(table)
|
||||
self.bActive = table.bActive
|
||||
self._Points = table._Points
|
||||
self._Caps = table._Caps
|
||||
end
|
||||
|
||||
-------------------------------------------------------
|
||||
function GravityValve:OnSave(table)
|
||||
table.bActive = self.bActive
|
||||
table._Points = self._Points
|
||||
table._Caps = self._Caps
|
||||
end
|
||||
|
||||
function GravityValve:OnSpawn()
|
||||
self:SetActive( self.Properties.bActive )
|
||||
end
|
||||
|
||||
function GravityValve:OnDestroy()
|
||||
local Caps = self._Caps
|
||||
while table.getn(Caps)>0 do
|
||||
System.RemoveEntity( Caps[1] )
|
||||
table.remove( Caps, 1 )
|
||||
end
|
||||
end
|
||||
|
||||
-- OnPropertyChange called only by the editor
|
||||
function GravityValve:OnPropertyChange()
|
||||
self:NeedSetup()
|
||||
end
|
||||
|
||||
function GravityValve:OnReset()
|
||||
self:NeedSetup()
|
||||
end
|
||||
|
||||
function GravityValve:FillPoints()
|
||||
local MAX_POINTS = 50
|
||||
local prefix = self:GetName().."_p"
|
||||
local name
|
||||
local nPoints = 1
|
||||
local Points = self._Points
|
||||
|
||||
Points[1] = self
|
||||
|
||||
for i=1,MAX_POINTS do
|
||||
name = prefix..tostring(i)
|
||||
local ent = System.GetEntityByName( name )
|
||||
if not ent then break end
|
||||
Points[i+1] = ent
|
||||
nPoints = i+1
|
||||
Log("npoints "..nPoints);
|
||||
end
|
||||
|
||||
while table.getn(Points)>nPoints do
|
||||
Log("removed");
|
||||
table.remove(Points)
|
||||
end
|
||||
|
||||
for i=1, table.getn(Points) do
|
||||
Log(".. "..Points[i]:GetName())
|
||||
end
|
||||
end
|
||||
|
||||
function GravityValve:CreateCylinderArea( from, to, radius, strength )
|
||||
local Area = self._PhysTableCyl.Area
|
||||
local axis = DifferenceVectors( to, from )
|
||||
Area.type = AREA_CYLINDER
|
||||
Area.radius = radius
|
||||
Area.height = LengthVector( axis ) * .5
|
||||
Area.center = ScaleVector( SumVectors( to, from ), 0.5 )
|
||||
Area.axis = NormalizeVector( axis )
|
||||
Area.gravity = ScaleVector( Area.axis, strength )
|
||||
Area.uniform = 1
|
||||
Area.falloff = 0
|
||||
|
||||
return Area
|
||||
end
|
||||
|
||||
function GravityValve:CreateSphereArea( radius, gravity )
|
||||
local Area = self._PhysTableSph.Area
|
||||
Area.type = AREA_SPHERE
|
||||
Area.radius = radius
|
||||
Area.uniform = 1
|
||||
Area.falloff = 0
|
||||
Area.gravity = ScaleVector( gravity, 8 )
|
||||
|
||||
return Area
|
||||
end
|
||||
|
||||
function GravityValve:NeedSetup()
|
||||
self.bNeedSetup = 1
|
||||
self:Activate(1)
|
||||
end
|
||||
|
||||
function GravityValve:OnChange( index )
|
||||
self:NeedSetup()
|
||||
end
|
||||
|
||||
function GravityValve:OnUpdate()
|
||||
--Log("GV:OU "..self:GetName())
|
||||
if self.bNeedSetup then
|
||||
local wasActive = self.bActive
|
||||
self:SetActive(0)
|
||||
self:SetActive(wasActive)
|
||||
self.bNeedSetup = nil
|
||||
self:Activate(0)
|
||||
end
|
||||
end
|
||||
|
||||
GravityValve.Server.OnUpdate = GravityValve.OnUpdate
|
||||
GravityValve.Client.OnUpdate = GravityValve.OnUpdate
|
||||
|
||||
function GravityValve:SetActive( bActive )
|
||||
if bActive == self.bActive then return end
|
||||
self:FillPoints()
|
||||
local p, n
|
||||
local Points = self._Points
|
||||
local Caps = self._Caps
|
||||
n = table.getn(Points)
|
||||
--Log("GravityValve:SetActive "..tostring(bActive).." on valve "..self:GetName())
|
||||
if bActive == 1 then
|
||||
if (self.Properties.bSpline == 1) then
|
||||
|
||||
local Area = self._PhysTableSpl.Area;
|
||||
local splinePoints = self._PhysTableSpl.Area.points;
|
||||
|
||||
for p = 1, n do
|
||||
splinePoints[p] = {x=0,y=0,z=0};
|
||||
Points[p]:GetWorldPos(splinePoints[p]);
|
||||
--Log("Gravity Stream point "..p..":"..Vec2Str(splinePoints[p]));
|
||||
end
|
||||
|
||||
Area.type = AREA_SPLINE;
|
||||
Area.radius = self.Properties.Radius;
|
||||
--Area.uniform = 1;
|
||||
Area.falloff = 0;
|
||||
Area.gravity = {x=0,y=0,z=self.Properties.Strength};
|
||||
Area.damping = 2.0;
|
||||
|
||||
self:Physicalize(0, PE_AREA, self._PhysTableSpl);
|
||||
|
||||
self:SetPhysicParams(PHYSICPARAM_FOREIGNDATA,{foreignData = ZEROG_AREA_ID});
|
||||
else
|
||||
local params = {}
|
||||
params.class = "GravityStreamCap"
|
||||
params.orientation = {x=1,y=0,z=0}
|
||||
|
||||
for p = 2, n do
|
||||
self:CreateCylinderArea( Points[p-1]:GetPos(), Points[p]:GetPos(), self.Properties.Radius, self.Properties.Strength )
|
||||
Points[p]:Physicalize(0, PE_AREA, self._PhysTableCyl)
|
||||
|
||||
Points[p]:SetPhysicParams(PHYSICPARAM_FOREIGNDATA,{foreignData = ZEROG_AREA_ID});
|
||||
|
||||
if p > 2 then
|
||||
params.position = Points[p-1]:GetPos()
|
||||
local ent = System.SpawnEntity( params )
|
||||
table.insert( Caps, ent.id )
|
||||
self:CreateSphereArea( self.Properties.Radius, self._PhysTableCyl.Area.gravity )
|
||||
ent:Physicalize(0, PE_AREA, self._PhysTableSph)
|
||||
|
||||
ent:SetPhysicParams(PHYSICPARAM_FOREIGNDATA,{foreignData = ZEROG_AREA_ID});
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif bActive == 0 and self.bActive then
|
||||
|
||||
self:DestroyPhysics();
|
||||
|
||||
for p = 2, n do
|
||||
Points[p]:DestroyPhysics()
|
||||
end
|
||||
|
||||
self:OnDestroy()
|
||||
end
|
||||
self.bActive = bActive
|
||||
end
|
||||
|
||||
function GravityValve:Event_Enable()
|
||||
--Log("GravityValve: GetEnable")
|
||||
self:SetActive(1)
|
||||
end
|
||||
|
||||
function GravityValve:Event_Disable()
|
||||
--Log("GravityValve: GetDisable")
|
||||
self:SetActive(0)
|
||||
end
|
||||
|
||||
GravityValve.FlowEvents =
|
||||
{
|
||||
Inputs =
|
||||
{
|
||||
Disable = { GravityValve.Event_Disable, "bool" },
|
||||
Enable = { GravityValve.Event_Enable, "bool" },
|
||||
},
|
||||
Outputs =
|
||||
{
|
||||
Disable = "bool",
|
||||
Enable = "bool",
|
||||
},
|
||||
}
|
||||
@ -1,77 +0,0 @@
|
||||
----------------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- 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.
|
||||
--
|
||||
--
|
||||
----------------------------------------------------------------------------------------------------
|
||||
ParticlePhysics =
|
||||
{
|
||||
Properties =
|
||||
{
|
||||
object_Model = "Objects/default/primitive_box.cgf",
|
||||
|
||||
Particle =
|
||||
{
|
||||
mass = 50.0,
|
||||
radius = 1.0,
|
||||
air_resistance = 0.0,
|
||||
gravity = {x=0.0, y=0.0, z=-9.81},
|
||||
water_resistance = 0.5,
|
||||
water_gravity = {x=0.0, y=0.0, z=-9.81*0.8},
|
||||
min_bounce_vel = 1.5,
|
||||
accel_thrust = 0,
|
||||
accel_lift = 0,
|
||||
velocity = {x=0.0, y=0.0, z=0.0},
|
||||
thickness = 1.0,
|
||||
wspin = {x=0.0, y=0.0, z=0.0},
|
||||
normal = {x=0.0, y=0.0, z=1.0},
|
||||
pierceability = 15,
|
||||
constant_orientation = false,
|
||||
single_contact = true,
|
||||
no_roll = false,
|
||||
no_spin = true,
|
||||
no_path_alignment = false,
|
||||
collider_to_ignore = 0,
|
||||
material = "", -- this is supposed to be the surface type
|
||||
},
|
||||
},
|
||||
|
||||
Editor =
|
||||
{
|
||||
Icon = "physicsobject.bmp",
|
||||
IconOnTop = 1,
|
||||
},
|
||||
}
|
||||
|
||||
function ParticlePhysics:SetFromProperties()
|
||||
local Properties = self.Properties;
|
||||
|
||||
self:FreeSlot(0);
|
||||
|
||||
if (Properties.object_Model ~= "") then
|
||||
self:LoadObject(0, Properties.object_Model);
|
||||
end
|
||||
|
||||
NormalizeVector(Properties.Particle.normal);
|
||||
self:Physicalize(0, PE_PARTICLE, Properties);
|
||||
self:SetSlotPos(0, {0.0, 0.0, -Properties.Particle.thickness*0.5});
|
||||
end
|
||||
|
||||
function ParticlePhysics:OnSpawn()
|
||||
self:OnReset();
|
||||
end
|
||||
|
||||
function ParticlePhysics:OnPropertyChange()
|
||||
self:OnReset();
|
||||
end
|
||||
|
||||
function ParticlePhysics:OnReset()
|
||||
self:SetFromProperties();
|
||||
end
|
||||
@ -1,188 +0,0 @@
|
||||
----------------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- 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.
|
||||
--
|
||||
--
|
||||
----------------------------------------------------------------------------------------------------
|
||||
Wind = {
|
||||
type = "WindController",
|
||||
Properties = {
|
||||
vVelocity={x=1.0,y=0.0,z=0.0},
|
||||
|
||||
fFadeTime = 1,--used only when the fog is triggered manually, with activate/deactivate events.
|
||||
},
|
||||
|
||||
Editor={
|
||||
Icon="Tornado.bmp",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
function Wind:OnInit()
|
||||
self.oldVelocity = {x=0.0,y=0.0,z=0.0};
|
||||
self.occupied = 0;
|
||||
self.lasttime = 0;
|
||||
|
||||
self:OnReset();
|
||||
|
||||
self:RegisterForAreaEvents(1);
|
||||
end
|
||||
|
||||
function Wind:OnPropertyChange()
|
||||
self:OnReset();
|
||||
end
|
||||
|
||||
function Wind:OnReset()
|
||||
self:RegisterForAreaEvents(1);
|
||||
end
|
||||
|
||||
function Wind:OnSave(tbl)
|
||||
tbl.bTriggered = self.bTriggered
|
||||
tbl.oldVelocity = self.oldVelocity
|
||||
tbl.fadeamt = self.fadeamt
|
||||
tbl.Who = self.Who
|
||||
end
|
||||
|
||||
function Wind:OnLoad(tbl)
|
||||
self.bTriggered = tbl.bTriggered
|
||||
self.oldVelocity = tbl.oldVelocity
|
||||
self.fadamt = tbl.fadeamt
|
||||
self.Who = tbl.Who
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- fade: 0-out 1-in
|
||||
function Wind:OnProceedFadeArea( player,areaId,fadeCoeff )
|
||||
self:Fade(fadeCoeff);
|
||||
end
|
||||
|
||||
function Wind:ResetValues()
|
||||
System.SetWind(self.oldVelocity);
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
function Wind:OnEnterArea( player,areaId )
|
||||
|
||||
if((player and (not player.actor:IsPlayer())) or self.occupied == 1) then
|
||||
return
|
||||
end
|
||||
|
||||
self.oldVelocity = System.GetWind();
|
||||
|
||||
self.occupied = 1;
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
function Wind:OnLeaveArea( player,areaId )
|
||||
|
||||
if(player and (not player.actor:IsPlayer())) then
|
||||
return
|
||||
end
|
||||
|
||||
self:ResetValues();
|
||||
|
||||
self.occupied = 0;
|
||||
end
|
||||
-----------------------------------------------------------------------------
|
||||
function Wind:OnShutDown()
|
||||
self:RegisterForAreaEvents(0);
|
||||
end
|
||||
|
||||
function Wind:Event_Enable( sender )
|
||||
|
||||
if(self.occupied == 0 ) then
|
||||
|
||||
if (self.fadeamt and self.fadeamt<1) then
|
||||
self:ResetValues();
|
||||
end
|
||||
|
||||
self:OnEnterArea( );
|
||||
|
||||
self.fadeamt = 0;
|
||||
self.lasttime = _time;
|
||||
self.exitfrom = nil;
|
||||
end
|
||||
|
||||
self:SetTimer(0, 1);
|
||||
|
||||
BroadcastEvent( self,"Enable" );
|
||||
end
|
||||
|
||||
function Wind:Event_Disable( sender )
|
||||
|
||||
if(self.occupied == 1 ) then
|
||||
|
||||
--self:OnLeaveArea( );
|
||||
self.occupied = 0;
|
||||
|
||||
self.fadeamt = 0;
|
||||
self.lasttime = _time;
|
||||
self.exitfrom = 1;
|
||||
end
|
||||
|
||||
self:SetTimer(0, 1);
|
||||
|
||||
BroadcastEvent( self,"Disable" );
|
||||
end
|
||||
|
||||
function Wind:OnTimer()
|
||||
|
||||
--System.Log("Ontimer ");
|
||||
|
||||
self:SetTimer(0, 1);
|
||||
|
||||
if (self.fadeamt) then
|
||||
|
||||
local delta = _time - self.lasttime;
|
||||
self.lasttime = _time;
|
||||
|
||||
self.fadeamt = self.fadeamt + (delta / self.Properties.fFadeTime);
|
||||
|
||||
if (self.fadeamt>=1) then
|
||||
|
||||
self.fadeamt = 1;
|
||||
self:KillTimer(0);
|
||||
end
|
||||
|
||||
----------------------------------------------
|
||||
--fade
|
||||
local fadeCoeff = self.fadeamt;
|
||||
|
||||
if (self.exitfrom) then
|
||||
fadeCoeff = 1 - fadeCoeff;
|
||||
end
|
||||
|
||||
fadeCoeff = math.sqrt( fadeCoeff );
|
||||
fadeCoeff = math.sqrt( fadeCoeff );
|
||||
|
||||
self:Fade(fadeCoeff);
|
||||
--self:OnProceedFadeArea( nil,0,self.fadeamt );
|
||||
else
|
||||
self:KillTimer(0);
|
||||
end
|
||||
end
|
||||
|
||||
function Wind:Fade(fadeCoeff)
|
||||
System.SetWind(LerpColors(self.oldVelocity, self.Properties.vVelocity, fadeCoeff));
|
||||
end
|
||||
|
||||
Wind.FlowEvents =
|
||||
{
|
||||
Inputs =
|
||||
{
|
||||
Disable = { Wind.Event_Disable, "bool" },
|
||||
Enable = { Wind.Event_Enable, "bool" },
|
||||
},
|
||||
Outputs =
|
||||
{
|
||||
Disable = "bool",
|
||||
Enable = "bool",
|
||||
},
|
||||
}
|
||||
@ -1,136 +0,0 @@
|
||||
----------------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- 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.
|
||||
--
|
||||
--
|
||||
----------------------------------------------------------------------------------------------------
|
||||
-- Wind area
|
||||
WindArea =
|
||||
{
|
||||
Properties =
|
||||
{
|
||||
bActive = 1, --[0,1,1,"Defines whether wind is blowing or not."]
|
||||
Size = { x=10,y=10,z=10 },
|
||||
bEllipsoidal = 1, --[0,1,1,"Forces an ellipsoidal falloff."]
|
||||
FalloffInner = 0, --[0,100,0.1,"Distance after which the distance-based falloff begins."]
|
||||
Dir = { x=0,y=0,z=0 },
|
||||
Speed = 20, --[0,100,0.1,"Defines whether wind is blowing or not."]
|
||||
AirResistance = 0, --[0,100,0.1,"Causes very light physicalised objects to experience a buoyancy force, if >0."]
|
||||
AirDensity = 0, --[0,100,0.1,"Causes physicalised objects moving through the air to slow down, if >0."]
|
||||
},
|
||||
Editor =
|
||||
{
|
||||
Icon = "Tornado.bmp",
|
||||
},
|
||||
_PhysTable = { Area={}, },
|
||||
}
|
||||
|
||||
-------------------------------------------------------
|
||||
function WindArea:OnLoad(table)
|
||||
self.bActive = table.bActive
|
||||
end
|
||||
|
||||
-------------------------------------------------------
|
||||
function WindArea:OnSave(table)
|
||||
table.bActive = self.bActive
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function WindArea:OnInit()
|
||||
self.bActive = self.Properties.bActive;
|
||||
if (self.bActive == 1) then
|
||||
self:PhysicalizeThis();
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
-- OnPropertyChange called only by the editor.
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function WindArea:OnPropertyChange()
|
||||
self.bActive = self.Properties.bActive;
|
||||
self:PhysicalizeThis();
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
-- OnReset called only by the editor.
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function WindArea:OnReset()
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function WindArea:PhysicalizeThis()
|
||||
if (self.bActive == 1) then
|
||||
local Properties = self.Properties;
|
||||
local Area = self._PhysTable.Area;
|
||||
if (Properties.bEllipsoidal == 1) then
|
||||
Area.type = AREA_SPHERE;
|
||||
Area.radius = LengthVector(Properties.Size) * 0.577;
|
||||
else
|
||||
Area.type = AREA_BOX;
|
||||
end
|
||||
Area.box_max = Properties.Size;
|
||||
Area.box_min = { x = -Area.box_max.x, y = -Area.box_max.y, z = -Area.box_max.z };
|
||||
if (Properties.bEllipsoidal == 1 or Properties.FalloffInner < 1) then
|
||||
Area.falloffInner = Properties.FalloffInner;
|
||||
else
|
||||
Area.falloffInner = -1;
|
||||
end
|
||||
if (Properties.Dir.x == 0 and Properties.Dir.y == 0 and Properties.Dir.z == 0) then
|
||||
Area.uniform = 0;
|
||||
Area.wind = {x = 0, y = 0, z = Properties.Speed};
|
||||
else
|
||||
Area.uniform = 2;
|
||||
Area.wind = { x = Properties.Dir.x * Properties.Speed, y = Properties.Dir.y * Properties.Speed, z = Properties.Dir.z * Properties.Speed };
|
||||
end
|
||||
Area.resistance = Properties.AirResistance;
|
||||
Area.density = Properties.AirDensity;
|
||||
self:Physicalize( 0,PE_AREA,self._PhysTable );
|
||||
else
|
||||
self:DestroyPhysics();
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
-- Event Handlers
|
||||
------------------------------------------------------------------------------------------------------
|
||||
function WindArea:Event_Activate()
|
||||
if (self.bActive ~= 1) then
|
||||
self.bActive = 1;
|
||||
self:PhysicalizeThis();
|
||||
end
|
||||
end
|
||||
|
||||
function WindArea:Event_Deactivate()
|
||||
if (self.bActive ~= 0) then
|
||||
self.bActive = 0;
|
||||
self:PhysicalizeThis();
|
||||
end
|
||||
end
|
||||
|
||||
function WindArea:Event_Speed( sender, Speed )
|
||||
self.Properties.Speed = Speed;
|
||||
self:OnPropertyChange();
|
||||
end
|
||||
|
||||
WindArea.FlowEvents =
|
||||
{
|
||||
Inputs =
|
||||
{
|
||||
Deactivate = { WindArea.Event_Deactivate, "bool" },
|
||||
Activate = { WindArea.Event_Activate, "bool" },
|
||||
Speed = { WindArea.Event_Speed, "float" },
|
||||
},
|
||||
Outputs =
|
||||
{
|
||||
Deactivate = "bool",
|
||||
Activate = "bool",
|
||||
},
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,123 +0,0 @@
|
||||
<SurfaceTypes>
|
||||
|
||||
<SurfaceType name="mat_canopy">
|
||||
<Physics friction="1.5" elasticity="0.05" pierceability="14" no_collide="1" can_shatter="1" sound_obstruction="0.5" />
|
||||
<BreakageParticles type="breakage" effect="bullet.hit_leaf.a" count_per_unit="1" count_scale="1" scale="1" />
|
||||
<BreakageParticles type="destroy" effect="bullet.hit_leaf.a" count_per_unit="1" count_scale="1" scale="1" />
|
||||
<BreakageParticles type="joint_break" effect="bullet.hit_leaf.a" />
|
||||
<BreakageParticles type="joint_shatter" effect="bullet.hit_leaf.a" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_concrete">
|
||||
<Physics friction="1" elasticity="0.2" pierceability="3" sound_obstruction="0.5" />
|
||||
<BreakageParticles type="breakage" effect="breakable_objects.joint_break.concrete" count_per_unit="1" count_scale="1" scale="1" />
|
||||
<BreakageParticles type="joint_break" effect="breakable_objects.joint_break.concrete" />
|
||||
<BreakageParticles type="joint_shatter" effect="breakable_objects.joint_break.concrete" />
|
||||
<BreakageParticles type="destroy" effect="breakable_objects.joint_break.concrete" count_per_unit="1" count_scale="1" scale="1" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_default">
|
||||
<Physics sound_obstruction="0.5" />
|
||||
<BreakageParticles type="breakage" effect="breakable_objects.Shatter.Edges" count_per_unit="1" count_scale="1" scale="1" />
|
||||
<BreakageParticles type="destroy" effect="breakable_objects.Shatter.destroy" count_per_unit="1" count_scale="1" scale="1" />
|
||||
<BreakageParticles type="joint_break" effect="breakable_objects.joint_break.generic" />
|
||||
<BreakageParticles type="joint_shatter" effect="breakable_objects.joint_break.shatter" />
|
||||
<BreakageParticles type="freeze_vapor" effect="breakable_objects.shatter.shatter_large" count_per_unit="1" count_scale="1" scale="1" />
|
||||
<BreakageParticles type="freeze_shatter" effect="breakable_objects.shatter.vapor" count_per_unit="1" count_scale="1" scale="1" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_fabric">
|
||||
<Physics friction="0.8" elasticity="0" pierceability="7" can_shatter="1" sound_obstruction="0.5" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_flesh">
|
||||
<Physics friction="0.6" elasticity="-2" pierceability="10" can_shatter="1" sound_obstruction="0.5" />
|
||||
<BreakageParticles type="destroy" effect="breakable_objects.Shatter.destroy" count_per_unit="1" count_scale="1" scale="1" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_glass" type="glass">
|
||||
<Physics friction="0.6" elasticity="0.3" pierceability="14" break_energy="2000" breakable_2d="1" can_shatter="1" hit_points="3" hit_radius="0.4" hit_maxdmg="1" hit_maxhits="4" sound_obstruction="0.5" />
|
||||
<breakable_2d rigid_body="0" cell_size="0.1" blast_radius="0.25" max_patch_tris="8" filter_angle="70" shard_density="900" />
|
||||
<AI fImpactRadius="5" fImpactSoundRadius="25" fFootStepRadius="20" proneMult="0.2" crouchMult="0.5" movingMult="2.5" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_grass" type="vegetation">
|
||||
<Physics friction="0.6" elasticity="-2" pierceability="14" no_collide="1" can_shatter="1" sound_obstruction="0.5" />
|
||||
<AI fImpactRadius="2.5" fImpactSoundRadius="20" fFootStepRadius="30" proneMult="0.2" crouchMult="0.5" movingMult="2.5" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_invulnerable" type="default">
|
||||
<Physics friction="1" elasticity="0" pierceability="0" />
|
||||
<AI fImpactRadius="5" fImpactSoundRadius="25" fFootStepRadius="15" proneMult="0.2" crouchMult="0.5" movingMult="2.5" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_metal">
|
||||
<Physics friction="0.8" elasticity="0.2" pierceability="4" sound_obstruction="0.5" />
|
||||
<BreakageParticles type="joint_break" effect="breakable_objects.joint_break.metal" />
|
||||
<BreakageParticles type="joint_shatter" effect="breakable_objects.joint_break.metal" />
|
||||
<AI fImpactRadius="5" fImpactSoundRadius="30" fFootStepRadius="20" proneMult="0.2" crouchMult="0.5" movingMult="2.5" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_metal_nofric" type="metal">
|
||||
<Physics friction="-2" elasticity="-1" pierceability="3" sound_obstruction="0.5" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_metal_RayProxy" type="metal">
|
||||
<Physics friction="0.8" elasticity="0.2" pierceability="11" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_nodraw">
|
||||
<Physics friction="0" elasticity="0" pierceability="15" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_obstruct">
|
||||
<Physics friction="1.5" elasticity="0" pierceability="10" no_collide="1" sound_obstruction="0.5" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_plastic">
|
||||
<Physics friction="0.8" elasticity="0" pierceability="5" can_shatter="1" sound_obstruction="0.5" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_player_collider">
|
||||
<Physics friction="0.6" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_rock">
|
||||
<Physics friction="0.7" elasticity="0" pierceability="3" sound_obstruction="0.5" />
|
||||
<AI fImpactRadius="2.5" fImpactSoundRadius="20" fFootStepRadius="20" proneMult="0.2" crouchMult="0.5" movingMult="2.5" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_rubber">
|
||||
<Physics friction="0.5" elasticity="1" pierceability="3" can_shatter="1" sound_obstruction="0.5" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_snow">
|
||||
<Physics friction="0.5" elasticity="-2" pierceability="7" can_shatter="1" sound_obstruction="0.5" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_soil">
|
||||
<Physics friction="0.35" elasticity="0" pierceability="7" can_shatter="1" sound_obstruction="0.5" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_vegetation">
|
||||
<Physics friction="0.5" elasticity="0" pierceability="14" no_collide="1" can_shatter="1" sound_obstruction="0.5" />
|
||||
<AI fImpactRadius="2.5" fImpactSoundRadius="20" fFootStepRadius="30" proneMult="0.2" crouchMult="0.5" movingMult="2.5" />
|
||||
<BreakageParticles type="breakage" effect="bullet.hit_leaf.a" count_per_unit="1" count_scale="1" scale="1" />
|
||||
<BreakageParticles type="destroy" effect="bullet.hit_leaf.a" count_per_unit="1" count_scale="1" scale="1" />
|
||||
<BreakageParticles type="joint_break" effect="bullet.hit_leaf.a" />
|
||||
<BreakageParticles type="joint_shatter" effect="bullet.hit_leaf.a" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_water">
|
||||
<Physics friction="1" elasticity="0" pierceability="14" sound_obstruction="0.5" />
|
||||
</SurfaceType>
|
||||
|
||||
<SurfaceType name="mat_wood" type="wood">
|
||||
<Physics friction="0.5" elasticity="0.05" pierceability="8" can_shatter="1" sound_obstruction="0.5" />
|
||||
<BreakageParticles type="joint_break" effect="breakable_objects.joint_break.wood" />
|
||||
<BreakageParticles type="joint_shatter" effect="breakable_objects.joint_break.wood" />
|
||||
<BreakageParticles type="destroy" effect="breakable_objects.joint_break.wood" count_per_unit="1" count_scale="1" scale="1" />
|
||||
<AI fImpactRadius="2.5" fImpactSoundRadius="30" fFootStepRadius="20" proneMult="0.2" crouchMult="0.5" movingMult="2.5" />
|
||||
</SurfaceType>
|
||||
|
||||
</SurfaceTypes>
|
||||
@ -1,15 +0,0 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# This will export its "SourcePaths" to the generated "cmake_dependencies.<project>.assetbuilder.setreg"
|
||||
if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
ly_create_alias(NAME PhysicsEntities.Builders NAMESPACE Gem)
|
||||
endif()
|
||||
@ -1,12 +0,0 @@
|
||||
{
|
||||
"gem_name": "PhysicsEntities",
|
||||
"GemFormatVersion": 3,
|
||||
"LinkType": "NoCode",
|
||||
"Name": "PhysicsEntities",
|
||||
"DisplayName": "Physics Entities",
|
||||
"Summary": "Provides physics entity modifiers that simulate physical events.",
|
||||
"Uuid": "99ea531451fc4f64a5a9fe8f385e8a76",
|
||||
"Version": "0.1.0",
|
||||
"Tags": ["Physics", "Entities", "Legacy"],
|
||||
"IconPath": "preview.png"
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0a5dc3f75d3a62760981c62c15c33637fee3e1953f51e330ea533694f2655a51
|
||||
size 40856
|
||||
Loading…
Reference in New Issue