Updated test scene and testing shader compilation

Signed-off-by: Robear Selwans <robear.selwans@outlook.com>
This commit is contained in:
2021-06-08 09:53:35 +02:00
parent d380e23675
commit 39f6cb87f2
9 changed files with 86 additions and 17 deletions

View File

@@ -25,5 +25,5 @@
"path": "scenes://SideScene.evsc"
}
],
"activeScene": "SideScene"
"activeScene": "MainScene"
}

View File

@@ -13,7 +13,7 @@
{
"type": "CameraComponent",
"view": "Perspective",
"fov": 120,
"fov": 60,
"near": 0.001,
"far": 1000,
"aspectRatio": 1.3333

View File

@@ -40,8 +40,9 @@
"mass": 1.0,
"restitution": 1.0,
"collisionShape": {
"type": "Sphere",
"radius": 1.0
"type": "Capsule",
"radius": 1.0,
"height": 2.0
}
},
{
@@ -79,6 +80,32 @@
}
]
},
{
"id": "Ceiling",
"components": [
{
"type": "TransformComponent",
"position": [0.0, 15.0, -15.0],
"rotation": [0.0, 0.0, 0.0],
"scale": [1.0, 1.0, 1.0]
},
{
"type": "RigidbodyComponent",
"rigidbodyType": "Ghost",
"mass": 0.0,
"restitution": 0.0,
"collisionShape": {
"type": "Box",
"halfExtents": [10.0, 10.0, 10.0]
}
},
{
"type": "ScriptComponent",
"script_name": "SideGhostController",
"script_path": "scripts://SideScene/ghost.lua"
}
]
},
{
"id": "Ground",
"components": [

View File

@@ -1,10 +1,20 @@
this.on_init = function()
this.speed = 0.1
this.original_position = this.position
this.angles = Vec3:new()
this.mouse_sens = 0.01
Input.lockCursor()
end
this.on_update = function()
local deltaMouseMovement = Input.getDeltaMousePos()
this.angles.x = this.angles.x - deltaMouseMovement.y * this.mouse_sens
this.angles.y = this.angles.y - deltaMouseMovement.x * this.mouse_sens
this.eulerAngles = this.angles
end
this.on_fixedupdate = function()
if Input.getKeyDown(Input.KeyCode.Enter) then
if Input.getKeyJustPressed(Input.KeyCode.Enter) then
gotoScene('SideScene')
end

View File

@@ -1,18 +1,28 @@
this.on_init = function()
this.speed = 0.1
this.original_position = this.position
this.cursor_locked = false
end
this.on_fixedupdate = function()
if Input.getKeyDown(Input.KeyCode.Enter) then
if Input.getKeyJustPressed(Input.KeyCode.Enter) then
gotoScene('MainScene')
end
if Input.getKeyDown(Input.KeyCode.L) then
if this.cursor_locked then
Input.unlockCursor()
else
Input.lockCursor()
end
this.cursor_locked = not this.cursor_locked
end
if Input.getKeyDown(Input.KeyCode.Up) then
this.position = this.position + Vec3:new(0, 1, 0) * this.speed
this.position = this.position - Vec3:new(0, 0, 1) * this.speed
end
if Input.getKeyDown(Input.KeyCode.Down) then
this.position = this.position - Vec3:new(0, 1, 0) * this.speed
this.position = this.position + Vec3:new(0, 0, 1) * this.speed
end
if Input.getKeyDown(Input.KeyCode.Right) then
this.position = this.position + Vec3:new(1, 0, 0) * this.speed

View File

@@ -0,0 +1,8 @@
this.on_collisionenter = function(other)
print(other.name)
end
this.on_update = function ()
local player = getObject('Player.Child')
this.position = player.position + Vec3:new(0, 10, 0)
end

View File

@@ -1,6 +1,9 @@
-- this.on_collisionenter = function(other)
-- other.position = other.position + Vec3:new(3.2, 0, 0)
-- end
this.on_init = function()
print(this:getChild('Child').position:to_string())
end
this.on_update = function ()
rb = this:getComponent(Rigidbody)

View File

@@ -0,0 +1,5 @@
#version 450
void main() {
gl_Position = vec4(0);
}

View File

@@ -18,10 +18,8 @@ DECLARE_EVENT_LISTENER(keyPressedListener, (KeyPressedEvent *event) {
if(event->keyCode == 81) // tests if Q was pressed
Window->setShouldClose(event->handle, true);
else if(event->keyCode == 49) // Numrow 1
Game->setActiveScene(Scene->getFromName("MainScene"));
else if(event->keyCode == 50) // Numrow 2
Game->setActiveScene(Scene->getFromName("SisyphusoScene"));
/* else if(event->keyCode == 49) // Numrow 1 */
/* else if(event->keyCode == 50) // Numrow 2 */
/* else if(event->keyCode == 45) // Numrow - */
/* else if(event->keyCode == 61) // Numrow = */
})
@@ -37,7 +35,7 @@ int main(int argc, char **argv)
evolmodule_t window_mod = evol_loadmodule("window"); DEBUG_ASSERT(window_mod);
evolmodule_t input_mod = evol_loadmodule("input"); DEBUG_ASSERT(input_mod);
imports(asset_mod , (AssetManager, Asset, TextLoader, JSONLoader))
imports(asset_mod , (AssetManager, Asset, TextLoader, JSONLoader, ShaderLoader))
imports(game_mod , (Game, Object, Camera, Scene))
imports(window_mod , (Window))
imports(input_mod , (Input))
@@ -63,6 +61,14 @@ int main(int argc, char **argv)
AssetManager->mount(&project_dir, &project_mountpoint);
evstring_free(project_mountpoint);
AssetHandle shader_asset = Asset->load("project://triangle.vert");
ShaderAsset shader_bin = ShaderLoader->loadAsset(shader_asset, EV_SHADERASSETSTAGE_VERTEX, "TriangleVertex", "main", EV_SHADER_BIN);
ShaderAsset shader_asm = ShaderLoader->loadAsset(shader_asset, EV_SHADERASSETSTAGE_VERTEX, "TriangleVertex", "main", EV_SHADER_ASM);
ev_log_debug("Shader Binary: %.*s", shader_bin.len, shader_bin.binary);
ev_log_debug("Shader Assembly: %.*s", shader_asm.len, shader_asm.binary);
Asset->free(shader_asset);
EV_DEFER(
AssetHandle project_config = Asset->load("project://game.proj"),
@@ -119,14 +125,14 @@ int main(int argc, char **argv)
U32 result = 0;
while(result == 0) {
ev_ProfileCPU(EventSystemProgress, 0) {
result |= EventSystem.progress();
}
ev_ProfileCPU(WindowUpdate, 0) {
result |= Window->update(windowHandle);
}
ev_ProfileCPU(EventSystemProgress, 0) {
result |= EventSystem.progress();
}
ev_ProfileCPU(GameProgress, 0) {
result |= Game->progress(0.01666667f);
}