Trigger physics update

This commit is contained in:
Antoine Pilote
2021-06-26 13:13:52 -04:00
parent c7dc3cc476
commit 8f4c5f8b08
32 changed files with 431 additions and 128 deletions

View File

@@ -1,17 +1,13 @@
{
"Entities": [
{
"CameraComponent": {
"CameraInstance": {
"AspectRatio": 1.774647831916809,
"Exposure": 1.0,
"Fov": 88.0,
"Speed": 1.0,
"m_Type": 1
}
"CharacterControllerComponent": {
"Height": 1.2000000476837158,
"Mass": 2500.0,
"Radius": 0.20000000298023224
},
"NameComponent": {
"Name": "Camera"
"Name": "Player"
},
"ParentComponent": {
"HasParent": false
@@ -28,15 +24,15 @@
"z": 1.0
},
"Translation": {
"x": -25.119064331054688,
"y": 19.491336822509766,
"z": 4.5285515785217285
"x": 2.5405828952789307,
"y": 0.0,
"z": 0.0
},
"Type": "TransformComponent"
},
"WrenScriptComponent": {
"Class": "CamScript",
"Script": "Scripts/Cam.wren"
"Class": "PlayerScript",
"Script": "Scripts/Player.wren"
}
},
{
@@ -95,7 +91,7 @@
},
"QuakeMapComponent": {
"HasCollisions": true,
"Path": "C:\\Dev\\Nuake\\Editor\\resources\\Maps\\texture_test.map"
"Path": "C:\\Dev\\Nuake\\Editor\\resources\\Maps\\debug.map"
},
"TransformComponent": {
"Rotation": {
@@ -109,21 +105,25 @@
"z": 1.0
},
"Translation": {
"x": 9.199999809265137,
"y": -11.569494247436523,
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"Type": "TransformComponent"
}
},
{
"CharacterControllerComponent": {
"Height": 1.2000000476837158,
"Mass": 2500.0,
"Radius": 0.20000000298023224
"CameraComponent": {
"CameraInstance": {
"AspectRatio": 1.774647831916809,
"Exposure": 1.0,
"Fov": 88.0,
"Speed": 1.0,
"m_Type": 1
}
},
"NameComponent": {
"Name": "Player"
"Name": "Camera"
},
"ParentComponent": {
"HasParent": false
@@ -141,14 +141,14 @@
},
"Translation": {
"x": -25.119064331054688,
"y": 18.649978637695313,
"y": 19.491336822509766,
"z": 4.5285515785217285
},
"Type": "TransformComponent"
},
"WrenScriptComponent": {
"Class": "PlayerScript",
"Script": "Scripts/Player.wren"
"Class": "CamScript",
"Script": "Scripts/Cam.wren"
}
}
],

View File

@@ -18,7 +18,7 @@ class CamScript is ScriptableEntity {
_deltaTime = 0
Input.HideMouse()
//Input.HideMouse()
}
init() {}
@@ -63,7 +63,7 @@ class CamScript is ScriptableEntity {
velocity = velocity.Sqrt()
var amount = (Math.Sin(_deltaTime * (velocity * 0.01)) / 2 + 1) * _BobHeight
Engine.Log("BobAmount: %(amount)")
//Engine.Log("BobAmount: %(amount)")
var pTransform = player.GetComponent("Transform")
var pPos = pTransform.GetTranslation()

View File

@@ -26,6 +26,10 @@ class PlayerScript is ScriptableEntity {
Engine.Log("Player init")
}
update(ts) {
}
fixedUpdate(ts) {
this.CheckInput()

View File

@@ -28,7 +28,9 @@ class Scene {
return TransformComponent.new(id)
} else if (component == "Script") {
return this.GetScript_(id)
}
} else if (component == "Trigger") {
return Trigger.new(id)
}
}
@@ -63,7 +65,8 @@ class Scene {
foreign static IsCharacterControllerOnGround_(e)
//foreign static IsOnGround_(e)
foreign static TriggerGetOverlappingBodyCount_(e)
foreign static TriggerGetOverlappingBodies_(e)
}
class Entity {
@@ -78,31 +81,6 @@ class Entity {
GetComponent(component) {
return Scene.EntityGetComponent(_entityId, component)
}
// Foreign engine functions
/*
// Transform
foreign static SetTranslation_(e, x, y, z)
foreign static SetRotation_(e, x, y, z)
foreign static SetScale_(e, x, y, z)
// Character controller
foreign static SetVelocity(e, x, y, z)
foreign static SetStepHeight(e, x, y, z)
foreign static IsOnGround(e)
*/
// Light
//
/*
foreign static SetLightIsVolumetric_(e, bool)
foreign static SetLightSyncDirectionWithSky_(e, bool)
foreign static SetLightColor_(e, r, g, b)
// Camera
foreign static SetCameraFov_(e, fov)
foreign static SetCameraType(e, type)
foreign static SetCameraDirection_(e, x, y, z)
*/
}
class TransformComponent {
@@ -181,3 +159,23 @@ class Camera {
}
}
class Trigger {
construct new(id) {
_entityId = id
}
GetOverlappingBodyCount() {
return Scene.TriggerGetOverlappingBodyCount_(_entityId)
}
GetOverlappingBodies() {
bodies = Scene.TriggerGetOverlappingBodies_(_entityId)
entities = []
for(b in bodies) {
entities.add(Entity.new(b))
}
return entities
}
}

View File

@@ -0,0 +1,29 @@
import "Scripts/ScriptableEntity" for ScriptableEntity
import "Scripts/Engine" for Engine
import "Scripts/Scene" for Scene, Trigger
import "Scripts/Math" for Vector3
import "Scripts/Input" for Input
import "Scripts/Physics" for Physics, CollisionResult
class TriggerScript is ScriptableEntity {
construct new() {
}
init() {
Engine.Log("Hello, I'm a trigger")
}
update(ts) {
}
fixedUpdate(ts) {
var trigger = this.GetComponent("Trigger")
Engine.Log("Current overlap: %(trigger.GetOverlappingBodyCount())")
}
exit() {
}
}

View File

@@ -77,7 +77,7 @@ struct Light {
// Debug
uniform int u_ShowNormal;
const int MaxLight = 20;
const int MaxLight = 24;
uniform int LightCount = 0;
uniform Light Lights[MaxLight];