Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a new debug scene for surface normals #341

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions Core/NativeClient/DebugDraw/Scenes/walls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
local Mesh = require("Core.NativeClient.WebGPU.Mesh")
local Plane = require("Core.NativeClient.DebugDraw.Plane")
local NormalsVisualization = require("Core.NativeClient.DebugDraw.NormalsVisualization")
local WorldAxis = require("Core.NativeClient.DebugDraw.WorldAxis")

local worldAxesVisualizationMesh = WorldAxis()

local groundMesh = Plane({ dimensions = { x = 4, z = 4 }, translation = { x = 0, y = 0, z = 0 } })

local function createWallSurfaceEast()
local wallEast = Mesh("WallEast")

wallEast.vertexPositions = { 2, 0, -2, 2, 2, -2, 2, 2, 2, 2, 0, 2 }
wallEast.triangleConnections = { 0, 1, 2, 0, 2, 3 }
wallEast.vertexColors = { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 }
wallEast.surfaceNormals = { -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0 }
wallEast.diffuseTextureCoords = { 0, 0, 0, 0, 0, 0, 0, 0 }

return wallEast
end

local function createWallSurfaceNorth()
local wallNorth = Mesh("WallNorth")

wallNorth.vertexPositions = { -2, -2, -2, -2, 0, -2, 2, 0, -2, 2, -2, -2 }
wallNorth.triangleConnections = { 0, 1, 2, 0, 2, 3 }
wallNorth.vertexColors = { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 }
wallNorth.surfaceNormals = { 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1 }
wallNorth.diffuseTextureCoords = { 0, 0, 0, 0, 0, 0, 0, 0 }

return wallNorth
end

local wallEast = createWallSurfaceEast()
local normalsVisualizationEast = NormalsVisualization(wallEast)
local wallNorth = createWallSurfaceNorth()
local normalsVisualizationNorth = NormalsVisualization(wallNorth)

local scene = {
displayName = "Visualization of Wall Surfaces",
meshes = {
worldAxesVisualizationMesh,
groundMesh,
wallEast,
wallNorth,
normalsVisualizationEast,
normalsVisualizationNorth,
},
}

return scene
Loading