Compare commits

..

3 Commits

14 changed files with 1646 additions and 104 deletions

View File

@ -144,7 +144,7 @@ mat4 = {
end,
translation_from_vector = function(v)
return translation(v.f[0], v.f[1], v.f[2])
return mat4.translation(v.f[0], v.f[1], v.f[2])
end,
scaling = function(x, y, z)
@ -172,7 +172,7 @@ mat4 = {
end,
scaling_from_vector = function(v)
return scaling(v.f[0], v.f[1], v.f[2])
return mat4.scaling(v.f[0], v.f[1], v.f[2])
end,
rotation_x = function(angle)
@ -450,6 +450,42 @@ mat4 = {
return M
end,
perspective_fov_rh = function(fov_angle_y, aspect_ratio, near_z, far_z)
assert(near_z > 0.0 and far_z > 0.0)
assert(not scalar.near_equal(fov_angle_y, 0.0, 0.00001 * 2.0))
assert(not scalar.near_equal(aspect_ratio, 0.0, 0.00001))
assert(not scalar.near_equal(far_z, near_z, 0.00001))
local sin_fov = sin(fov_angle_y)
local cos_fov = cos(fov_angle_y)
local height = cos_fov / sin_fov
local width = height / aspect_ratio
local f_range = far_z / (near_z - far_z)
local M = mat4()
M.m[0 * 4 + 0] = width
--M.m[0 * 4 + 1] = 0.0
--M.m[0 * 4 + 2] = 0.0
--M.m[0 * 4 + 3] = 0.0
--M.m[1 * 4 + 0] = 0.0
M.m[1 * 4 + 1] = height
--M.m[1 * 4 + 2] = 0.0
--M.m[1 * 4 + 3] = 0.0
--M.m[2 * 4 + 0] = 0.0
--M.m[2 * 4 + 1] = 0.0
M.m[2 * 4 + 2] = f_range
M.m[2 * 4 + 3] = -1.0
--M.m[3 * 4 + 0] = 0.0
--M.m[3 * 4 + 1] = 0.0
M.m[3 * 4 + 2] = f_range * near_z
--M.m[3 * 4 + 3] = 0.0
return M
end,
near_equal = function(M1, M2, epsilon)
local d00 = abs(M1.m[0 * 4 + 0] - M2.m[0 * 4 + 0])
local d01 = abs(M1.m[0 * 4 + 1] - M2.m[0 * 4 + 1])
@ -806,4 +842,5 @@ return {
scalar = scalar,
mat4 = mat4,
vec3 = vec3,
vec4 = vec4,
}

185
collada_scene.lua Normal file
View File

@ -0,0 +1,185 @@
local _math = require '_math'
local mat4 = _math.mat4
local vec3 = _math.vec3
local vec4 = _math.vec4
local scalar = _math.scalar
local collada_types = require 'collada_types'
local geometries_meshes = {}
local pixel_data = love.filesystem.newFileData("pixel.glsl")
local vertex_data = love.filesystem.newFileData("vertex.glsl")
local shader = love.graphics.newShader(pixel_data, vertex_data)
local images_textures = {}
local node_instances = {}
local collada_scene
collada_scene = {
load_geometries = function(vertex_buffer, index_buffer, geometries)
for _, geometry in ipairs(geometries) do
local offset = geometry.mesh.vertex_buffer_offset / (4 * 3 * 3)
local attribute_list = pnt_attribute_list(vertex_buffer, offset)
local draw_mode = "triangles"
local mesh = love.graphics.newMesh(attribute_list, draw_mode)
mesh:setIndexBuffer(index_buffer)
geometries_meshes[geometry] = mesh
end
end,
load_images = function(base_path, images)
local image_index = 0
for _, image in ipairs(images) do
assert(string.sub(image.uri, 1, 1) == ".")
path = base_path .. string.sub(image.uri, 2)
print("load image", path)
local image_data = love.image.newImageData(path)
local texture = love.graphics.newTexture(image_data)
images_textures[image_index] = texture
image_index = image_index + 1
end
end,
node_world_transform = function(node)
local world
if node.parent_index >= 0 then
world = node_instances[node.parent_index].world
assert(world ~= nil)
else
world = mat4.identity()
end
for _, transform in ipairs(node.transforms) do
local m
if transform.type == collada_types.transform_type.LOOKAT then
assert(false)
elseif transform.type == collada_types.transform_type.MATRIX then
m = mat4.load_table(transform.matrix)
elseif transform.type == collada_types.transform_type.ROTATE then
local rotate = vec4.load_table(transform.rotate)
local w = rotate.f[3]
m = mat4.rotation_axis(rotate, scalar.convert_to_radians(w))
elseif transform.type == collada_types.transform_type.SCALE then
m = mat4.scaling_from_vector(vec3.load_table(transform.scale))
elseif transform.type == collada_types.transform_type.TRANSLATE then
m = mat4.translation_from_vector(vec3.load_table(transform.translate))
else
assert(false)
end
world = m * world
end
return world
end,
load_node_world_transforms = function(nodes)
local node_index = 0
for _, node in ipairs(nodes) do
world = collada_scene.node_world_transform(node)
node_instances[node_index] = { world = world }
node_index = node_index + 1
end
end,
set_color_or_texture = function(color_or_texture, color_uniform, sampler_uniform)
if color_or_texture.type == collada_types.color_or_texture_type.COLOR then
shader:send(color_uniform, color_or_texture.color)
elseif color_or_texture.type == collada_types.color_or_texture_type.TEXTURE then
shader:send(sampler_uniform, images_textures[color_or_texture.texture.image_index])
else
assert(false)
end
end,
set_instance_material = function(instance_material)
local effect = instance_material.material.effect
if effect.type == collada_types.effect_type.BLINN then
collada_scene.set_color_or_texture(effect.blinn.emission, "emission_color", "emission_sampler");
collada_scene.set_color_or_texture(effect.blinn.ambient, "ambient_color", "ambient_sampler");
collada_scene.set_color_or_texture(effect.blinn.diffuse, "diffuse_color", "diffuse_sampler");
collada_scene.set_color_or_texture(effect.blinn.specular, "specular_color", "specular_sampler");
shader:send("shininess", effect.blinn.shininess);
elseif effect.type == collada_types.effect_type.LAMBERT then
collada_scene.set_color_or_texture(effect.lambert.emission, "emission_color", "emission_sampler");
collada_scene.set_color_or_texture(effect.lambert.ambient, "ambient_color", "ambient_sampler");
collada_scene.set_color_or_texture(effect.lambert.diffuse, "diffuse_color", "diffuse_sampler");
elseif effect.type == collada_types.effect_type.PHONG then
collada_scene.set_color_or_texture(effect.phong.emission, "emission_color", "emission_sampler");
collada_scene.set_color_or_texture(effect.phong.ambient, "ambient_color", "ambient_sampler");
collada_scene.set_color_or_texture(effect.phong.diffuse, "diffuse_color", "diffuse_sampler");
collada_scene.set_color_or_texture(effect.phong.specular, "specular_color", "specular_sampler");
shader:send("shininess", effect.phong.shininess);
elseif effect.type == collada_types.effect_type.CONSTANT then
shader:send("emission_color", effect.constant.color)
else
assert(false)
end
local texture_channel = {
instance_material.emission.input_set,
instance_material.ambient.input_set,
instance_material.diffuse.input_set,
instance_material.specular.input_set,
}
shader:send("texture_channel", texture_channel)
end,
draw_geometry = function(geometry, instance_materials)
local base_index_buffer_offset = geometry.mesh.index_buffer_offset / 4
local mesh = geometries_meshes[geometry]
for _, instance_material in ipairs(instance_materials) do
collada_scene.set_instance_material(instance_material)
local triangles = geometry.mesh.triangles[instance_material.element_index + 1]
local index_offset = base_index_buffer_offset + triangles.index_offset
local index_count = triangles.count * 3
mesh:setDrawRange(1 + index_offset, index_count)
love.graphics.draw(mesh, 0, 0, 0, 0, 0)
end
end,
draw_node = function(node_index, node, transform)
if node.type ~= collada_types.node_type.NODE then
return
end
if node.instance_geometries_count == 0 and node.instance_controllers_count == 0 then
return
end
local world = node_instances[node_index].world
transform = world * transform
shader:send("world_transform", "column", world.data)
shader:send("transform", "column", transform.data)
for _, instance_geometry in ipairs(node.instance_geometries) do
collada_scene.draw_geometry(instance_geometry.geometry, instance_geometry.instance_materials)
end
end,
draw_nodes = function(nodes, transform)
love.graphics.setShader(shader)
shader:send("view_position", {-88.57101, -71.71298, 104.5738, 1.0})
shader:send("light_position", {0.0, -56.804, 58.237, 1.0})
local node_index = 0
for _, node in ipairs(nodes) do
collada_scene.draw_node(node_index, node, transform)
node_index = node_index + 1
end
end,
}
return {
draw_nodes = collada_scene.draw_nodes,
load_geometries = collada_scene.load_geometries,
load_node_world_transforms = collada_scene.load_node_world_transforms,
load_images = collada_scene.load_images,
}

79
collada_types.lua Normal file
View File

@ -0,0 +1,79 @@
local input_format = {
FLOAT1 = {},
FLOAT2 = {},
FLOAT3 = {},
FLOAT4 = {},
INT1 = {},
INT2 = {},
INT3 = {},
INT4 = {}
}
local light_type = {
AMBIENT = {},
DIRECTIONAL = {},
POINT = {},
SPOT = {}
}
local color_or_texture_type = {
COLOR = {},
TEXTURE = {}
}
local effect_type = {
BLINN = {},
LAMBERT = {},
PHONG = {},
CONSTANT = {}
}
local transform_type = {
LOOKAT = {},
MATRIX = {},
ROTATE = {},
SCALE = {},
SKEW = {},
TRANSLATE = {}
}
local node_type = {
JOINT = {},
NODE = {}
}
local interpolation = {
LINEAR = {},
BEZIER = {}
}
local target_attribute = {
A = {}, -- alpha color component
ANGLE = {}, -- euler angle
B = {}, -- blue color component
G = {}, -- green color component
P = {}, -- third texture component
Q = {}, -- fourth texture component
R = {}, -- red color component
S = {}, -- first texture coordinate
T = {}, -- second texture coordinate
TIME = {}, -- time in seconds
U = {}, -- first generic parameter
V = {}, -- second generic parameter
W = {}, -- fourth cartesian coordinate
X = {}, -- first cartesian coordinate
Y = {}, -- second cartesian coordinate
Z = {}, -- third cartesian coordinate
ALL = {}
}
return {
input_format = input_format,
light_type = light_type,
color_or_texture_type = color_or_texture_type,
effect_type = effect_type,
transform_type = transform_type,
node_type = node_type,
interpolation = interpolation,
target_attribute = target_attribute,
}

156
main.lua
View File

@ -1,4 +1,3 @@
local mesh
local rotation
local texture
@ -6,47 +5,10 @@ local ffi = require 'ffi'
local _math = require '_math'
local mat4 = _math.mat4
local vec3 = _math.vec3
local pixelcode = [[
#pragma language glsl3
varying vec4 PixelNormal;
varying vec4 PixelTexture;
uniform sampler2D texture_sampler;
out vec4 outData;
void pixelmain()
{
vec4 texColor = texture(texture_sampler, PixelTexture.xy);
float intensity = min(max(dot(vec3(1, 1, 1), PixelNormal.xyz), 0), 1);
outData = vec4(texColor.xyz * (0.1 + intensity * intensity), 1.0);
}
]]
local vertexcode = [[
#pragma language glsl3
layout (location = 0) in vec4 VertexPosition;
layout (location = 1) in vec4 VertexNormal;
layout (location = 2) in vec4 VertexTexture;
uniform mat4 transform;
varying vec4 PixelNormal;
varying vec4 PixelTexture;
void vertexmain()
{
PixelNormal = VertexNormal * 0.5 + 0.5;
PixelTexture = VertexTexture;
love_Position = transform * vec4(VertexPosition.xyz, 1);
}
]]
local shader = love.graphics.newShader(pixelcode, vertexcode)
local vec4 = _math.vec4
local scalar = _math.scalar
local scene_test = require 'scene.test.test'
local collada_scene = require 'collada_scene'
local vertexformat = {
{ name = 'VertexPosition', format = 'floatvec3', location = 0 },
@ -54,48 +16,47 @@ local vertexformat = {
{ name = 'VertexTexture', format = 'floatvec3', location = 2 },
}
function pnt_attribute_list(vertex_buffer, offset)
return {
{
buffer = vertex_buffer,
location = 0,
name = "VertexPosition",
nameinbuffer = nil,
step = "pervertex",
startindex = 1 + offset,
},
{
buffer = vertex_buffer,
location = 1,
name = "VertexNormal",
nameinbuffer = nil,
step = "pervertex",
startindex = 1 + offset,
},
{
buffer = vertex_buffer,
location = 2,
name = "VertexTexture",
nameinbuffer = nil,
step = "pervertex",
startindex = 1 + offset,
},
}
end
function love.load(args)
love.window.setMode(1024, 1024, {depth=true})
local vertexdata = love.filesystem.newFileData("position_normal_texture.vtx")
local indexdata = love.filesystem.newFileData("index.idx")
local vertex_data = love.filesystem.newFileData("scene/test/test.vtx")
local index_data = love.filesystem.newFileData("scene/test/test.idx")
local vertexbuffer = love.graphics.newBuffer(vertexformat, vertexdata, { vertex = true, usage = "static" })
local indexbuffer = love.graphics.newBuffer("uint32", indexdata, { index = true, usage = "static" })
local vertex_buffer = love.graphics.newBuffer(vertexformat, vertex_data, { vertex = true, usage = "static" })
local index_buffer = love.graphics.newBuffer("uint32", index_data, { index = true, usage = "static" })
attributelist = {
{
buffer = vertexbuffer,
location = 0,
name = "VertexPosition", -- the name this vertex attribute will use in a shader
nameinbuffer = nil, -- the name of the attribute in the vertex buffer. Defaults to the name field.
step = "pervertex", -- vertex attribute step ("pervertex" or "perinstance"), defaults to "pervertex".
startindex = 1, -- 1-based array index within the given vertex buffer where the attribute data will start being pulled from during rendering. Defaults to 1.
},
{
buffer = vertexbuffer,
location = 1,
name = "VertexNormal", -- the name this vertex attribute will use in a shader
nameinbuffer = nil, -- the name of the attribute in the vertex buffer. Defaults to the name field.
step = "pervertex", -- vertex attribute step ("pervertex" or "perinstance"), defaults to "pervertex".
startindex = 1, -- 1-based array index within the given vertex buffer where the attribute data will start being pulled from during rendering. Defaults to 1.
},
{
buffer = vertexbuffer,
location = 2,
name = "VertexTexture", -- the name this vertex attribute will use in a shader
nameinbuffer = nil, -- the name of the attribute in the vertex buffer. Defaults to the name field.
step = "pervertex", -- vertex attribute step ("pervertex" or "perinstance"), defaults to "pervertex".
startindex = 1, -- 1-based array index within the given vertex buffer where the attribute data will start being pulled from during rendering. Defaults to 1.
},
}
drawmode = "triangles"
mesh = love.graphics.newMesh(attributelist, drawmode)
mesh:setIndexBuffer(indexbuffer)
local image_data = love.image.newCompressedData('bird.dds')
texture = love.graphics.newTexture(image_data)
collada_scene.load_geometries(vertex_buffer, index_buffer, scene_test.descriptor.geometries)
collada_scene.load_node_world_transforms(scene_test.descriptor.nodes)
collada_scene.load_images("scene/test", scene_test.descriptor.images)
end
local rotation = 0.0
@ -105,36 +66,27 @@ function love.draw()
local mx, my = love.mouse.getPosition()
width, height = love.graphics.getDimensions()
-- shader:send("projection", "column", mat4.perspective_rh(width / width * 0.25,
-- height / width * 0.25,
-- 0.1,
-- 1000.0).data)
-- shader:send("view", "column", mat4.look_at_rh(vec3(0, -2, 0),
-- vec3(0, 0, 0),
-- vec3(0, 0, 1)).data)
-- shader:send("model", "column", mat4.rotation_x(rotation).data)
-- shader:send("model2", "column", mat4.rotation_z(rotation * 0.5).data)
-- local projection = mat4.perspective_rh(width / width * 0.1,
-- height / width * 0.1,
-- 0.1,
-- 1000.0)
local aspect_ratio = width / height
local projection = mat4.perspective_fov_rh(scalar.convert_to_radians(45 / 2),
aspect_ratio,
0.1,
1000.0)
local projection = mat4.perspective_rh(width / width * 0.25,
height / width * 0.25,
0.1,
1000.0)
local view = mat4.look_at_rh(vec3(0, -2, 0),
vec3(0, 0, 0),
local view = mat4.look_at_rh(vec3(-88.57101, -71.71298, 104.5738),
vec3(-19.90239, -27.72767, 54.6898),
vec3(0, 0, 1))
local world1 = mat4.rotation_x(rotation)
local world2 = mat4.rotation_z(rotation * 0.5)
local world3 = mat4.translation(0, 0, -0.5)
--local world3 = mat4.translation(0, 0, -0.5)
local transform = world3 * world2 * world1 * view * projection
local transform = view * projection
shader:send("transform", "column", transform.data)
shader:send("texture_sampler", texture)
rotation = rotation + 0.01
love.graphics.setShader(shader)
love.graphics.setDepthMode("less", true)
love.graphics.draw(mesh, mx, my, 0, radius, radius)
collada_scene.draw_nodes(scene_test.descriptor.nodes, transform)
end

65
pixel.glsl Normal file
View File

@ -0,0 +1,65 @@
#pragma language glsl3
varying vec4 PixelNormal;
varying vec4 PixelTexture;
varying vec4 PixelWorldPosition;
uniform vec4 emission_color;
uniform vec4 ambient_color;
uniform vec4 diffuse_color;
uniform vec4 specular_color;
uniform float shininess;
uniform sampler2D emission_sampler;
uniform sampler2D ambient_sampler;
uniform sampler2D diffuse_sampler;
uniform sampler2D specular_sampler;
uniform vec4 view_position;
uniform vec4 light_position;
uniform ivec4 texture_channel;
out vec4 out_color;
void pixelmain()
{
vec3 normal = normalize(PixelNormal.xyz);
vec3 view_direction = normalize(view_position.xyz - PixelWorldPosition.xyz);
vec3 light_direction = normalize(light_position.xyz - PixelWorldPosition.xyz);
vec3 reflect_light_direction = reflect(-light_direction, normal);
vec4 emission;
vec4 ambient;
vec4 diffuse;
vec4 specular;
if (texture_channel.x >= 0) { // emission
emission = texture(emission_sampler, PixelTexture.xy);
} else {
emission = emission_color;
}
if (texture_channel.y >= 0) { // ambient
ambient = texture(ambient_sampler, PixelTexture.xy);
} else {
ambient = ambient_color;
}
if (texture_channel.z >= 0) { // diffuse
diffuse = texture(diffuse_sampler, PixelTexture.xy);
} else {
diffuse = diffuse_color;
}
if (texture_channel.w >= 0) { // specular
specular = texture(specular_sampler, PixelTexture.xy);
} else {
specular = specular_color;
}
float diffuse_intensity = max(dot(normal, light_direction), 0.0);
float specular_intensity = pow(max(dot(view_direction, reflect_light_direction), 0.0), shininess);
vec3 color = emission.xyz * 0;
color += ambient.xyz * 0;
color += diffuse.xyz * diffuse_intensity;
color += specular.xyz * specular_intensity * 0.3;
out_color = vec4(color, 1.0);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

528
scene/test/test.DAE Normal file

File diff suppressed because one or more lines are too long

BIN
scene/test/test.idx Normal file

Binary file not shown.

661
scene/test/test.lua Normal file
View File

@ -0,0 +1,661 @@
local collada_types = require 'collada_types'
local camera_camera_camera = {
xfov = 45.0,
yfov = 0.0,
znear = 1.0,
zfar = 1000.0,
aspect_ratio = 0.0,
}
local light_environmentambientlight = {
type = collada_types.light_type.AMBIENT,
color = {0.0, 0.0, 0.0},
}
local light_omni001_light = {
type = collada_types.light_type.POINT,
color = {1.0, 1.0, 1.0},
}
-- logOnly_png
local image_logonly_png = {
uri = "./images/0_logOnly.png",
}
local images = {
image_logonly_png,
}
local effect_material__47 = {
type = collada_types.effect_type.BLINN,
blinn = {
emission = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.0, 0.0, 0.0, 1.0},
},
ambient = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.588, 0.588, 0.588, 1.0},
},
diffuse = {
type = collada_types.color_or_texture_type.TEXTURE,
texture = { image_index = 0 }, -- logOnly_png
},
specular = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.36, 0.36, 0.36, 1.0},
},
shininess = 37.0,
reflective = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.0, 0.0, 0.0, 1.0},
},
reflectivity = 0.0,
transparent = {
type = collada_types.color_or_texture_type.COLOR,
color = {1.0, 1.0, 1.0, 1.0},
},
transparency = 1.0,
index_of_refraction = 0.0,
}
}
local effect_coloreffectr153g228b184 = {
type = collada_types.effect_type.PHONG,
phong = {
emission = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.0, 0.0, 0.0, 0.0},
},
ambient = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.6, 0.8941176, 0.7215686, 1.0},
},
diffuse = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.6, 0.8941176, 0.7215686, 1.0},
},
specular = {
type = collada_types.color_or_texture_type.COLOR,
color = {1.0, 1.0, 1.0, 1.0},
},
shininess = 10.0,
reflective = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.0, 0.0, 0.0, 1.0},
},
reflectivity = 0.0,
transparent = {
type = collada_types.color_or_texture_type.COLOR,
color = {1.0, 1.0, 1.0, 1.0},
},
transparency = 1.0,
index_of_refraction = 0.0,
}
}
local effect_material__46 = {
type = collada_types.effect_type.BLINN,
blinn = {
emission = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.0, 0.0, 0.0, 1.0},
},
ambient = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.6941177, 0.1921569, 0.4039216, 1.0},
},
diffuse = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.6941177, 0.1921569, 0.4039216, 1.0},
},
specular = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.27, 0.27, 0.27, 1.0},
},
shininess = 38.0,
reflective = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.0, 0.0, 0.0, 1.0},
},
reflectivity = 0.0,
transparent = {
type = collada_types.color_or_texture_type.COLOR,
color = {1.0, 1.0, 1.0, 1.0},
},
transparency = 1.0,
index_of_refraction = 0.0,
}
}
local effect_coloreffectr5g54b179 = {
type = collada_types.effect_type.PHONG,
phong = {
emission = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.0, 0.0, 0.0, 0.0},
},
ambient = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.01960784, 0.2117647, 0.7019608, 1.0},
},
diffuse = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.01960784, 0.2117647, 0.7019608, 1.0},
},
specular = {
type = collada_types.color_or_texture_type.COLOR,
color = {1.0, 1.0, 1.0, 1.0},
},
shininess = 10.0,
reflective = {
type = collada_types.color_or_texture_type.COLOR,
color = {0.0, 0.0, 0.0, 1.0},
},
reflectivity = 0.0,
transparent = {
type = collada_types.color_or_texture_type.COLOR,
color = {1.0, 1.0, 1.0, 1.0},
},
transparency = 1.0,
index_of_refraction = 0.0,
}
}
local material_coloreffectr153g228b184_material = {
effect = effect_coloreffectr153g228b184,
}
local material_coloreffectr5g54b179_material = {
effect = effect_coloreffectr5g54b179,
}
local material_material__47_material = {
effect = effect_material__47,
}
local material_material__46_material = {
effect = effect_material__46,
}
local input_elements_position_0_3_normal_0_3_texcoord_0_3 = {
{
semantic = "POSITION",
semantic_index = 0,
format = collada_types.input_format.FLOAT3,
},
{
semantic = "NORMAL",
semantic_index = 0,
format = collada_types.input_format.FLOAT3,
},
{
semantic = "TEXCOORD",
semantic_index = 0,
format = collada_types.input_format.FLOAT3,
},
}
local triangles_geom_plane = {
{
count = 20000, -- triangles
index_offset = 0, -- indices
inputs_index = 0, -- index into inputs_list
},
}
local geometry_geom_plane = {
mesh = {
triangles = triangles_geom_plane,
triangles_count = 1,
vertex_buffer_offset = 0,
vertex_buffer_size = 367236,
index_buffer_offset = 0,
index_buffer_size = 240000,
}
}
local triangles_geom_torus_knot23 = {
{
count = 4800, -- triangles
index_offset = 0, -- indices
inputs_index = 0, -- index into inputs_list
},
}
local geometry_geom_torus_knot23 = {
mesh = {
triangles = triangles_geom_torus_knot23,
triangles_count = 1,
vertex_buffer_offset = 367236,
vertex_buffer_size = 94068,
index_buffer_offset = 240000,
index_buffer_size = 57600,
}
}
local triangles_geom_torusknot25 = {
{
count = 2400, -- triangles
index_offset = 0, -- indices
inputs_index = 0, -- index into inputs_list
},
}
local geometry_geom_torusknot25 = {
mesh = {
triangles = triangles_geom_torusknot25,
triangles_count = 1,
vertex_buffer_offset = 461304,
vertex_buffer_size = 86832,
index_buffer_offset = 297600,
index_buffer_size = 28800,
}
}
local geometries = {
geometry_geom_plane,
geometry_geom_torus_knot23,
geometry_geom_torusknot25,
}
local transforms_node_environmentambientlight = {
}
local instance_geometries_node_environmentambientlight = {
}
local instance_controllers_node_environmentambientlight = {
}
local instance_lights_node_environmentambientlight = {
{
light = light_environmentambientlight,
}
}
local node_channels_node_environmentambientlight = {
}
local node_node_environmentambientlight = {
parent_index = -1,
type = collada_types.node_type.NODE,
transforms = transforms_node_environmentambientlight,
transforms_count = 0,
instance_geometries = instance_geometries_node_environmentambientlight,
instance_geometries_count = 0,
instance_controllers = instance_controllers_node_environmentambientlight,
instance_controllers_count = 0,
instance_lights = instance_lights_node_environmentambientlight,
instance_lights_count = 1,
channels = node_channels_node_environmentambientlight,
channels_count = 0,
}
local transforms_node_plane = {
}
local instance_geometry_instance_materials_node_plane_0 = {
{
element_index = 0, -- an index into mesh.triangles
material = material_material__47_material,
emission = { input_set = -1 },
ambient = { input_set = -1 },
diffuse = { input_set = 0 },
specular = { input_set = -1 },
},
}
local instance_geometries_node_plane = {
{
geometry = geometry_geom_plane,
instance_materials = instance_geometry_instance_materials_node_plane_0,
instance_materials_count = 1,
},
}
local instance_controllers_node_plane = {
}
local instance_lights_node_plane = {
}
local node_channels_node_plane = {
}
local node_node_plane = {
parent_index = -1,
type = collada_types.node_type.NODE,
transforms = transforms_node_plane,
transforms_count = 0,
instance_geometries = instance_geometries_node_plane,
instance_geometries_count = 1,
instance_controllers = instance_controllers_node_plane,
instance_controllers_count = 0,
instance_lights = instance_lights_node_plane,
instance_lights_count = 0,
channels = node_channels_node_plane,
channels_count = 0,
}
local transforms_node_torus_knot23 = {
{
type = collada_types.transform_type.TRANSLATE,
translate = {-21.94384, -1.68812e-14, 45.45129},
},
{
type = collada_types.transform_type.ROTATE,
rotate = {-1.0, -2.22051e-16, -2.22051e-16, -90.0},
},
{
type = collada_types.transform_type.SCALE,
scale = {0.5458366, 0.5458366, 0.5458366},
},
}
local instance_geometry_instance_materials_node_torus_knot23_0 = {
{
element_index = 0, -- an index into mesh.triangles
material = material_coloreffectr153g228b184_material,
emission = { input_set = -1 },
ambient = { input_set = -1 },
diffuse = { input_set = -1 },
specular = { input_set = -1 },
},
}
local instance_geometries_node_torus_knot23 = {
{
geometry = geometry_geom_torus_knot23,
instance_materials = instance_geometry_instance_materials_node_torus_knot23_0,
instance_materials_count = 1,
},
}
local instance_controllers_node_torus_knot23 = {
}
local instance_lights_node_torus_knot23 = {
}
local node_channels_node_torus_knot23 = {
}
local node_node_torus_knot23 = {
parent_index = -1,
type = collada_types.node_type.NODE,
transforms = transforms_node_torus_knot23,
transforms_count = 3,
instance_geometries = instance_geometries_node_torus_knot23,
instance_geometries_count = 1,
instance_controllers = instance_controllers_node_torus_knot23,
instance_controllers_count = 0,
instance_lights = instance_lights_node_torus_knot23,
instance_lights_count = 0,
channels = node_channels_node_torus_knot23,
channels_count = 0,
}
local transforms_node_torusknot25 = {
{
type = collada_types.transform_type.TRANSLATE,
translate = {3.281013, -28.30101, 45.45129},
},
{
type = collada_types.transform_type.ROTATE,
rotate = {0.9075136, -0.007434183, 0.4199569, -178.1592},
},
{
type = collada_types.transform_type.ROTATE,
rotate = {0.9893375, 0.0, 0.1456411, -1.382112},
},
{
type = collada_types.transform_type.SCALE,
scale = {0.5458366, 0.5458367, 0.5458366},
},
{
type = collada_types.transform_type.ROTATE,
rotate = {0.9893375, 0.0, 0.1456411, 1.382112},
},
}
local instance_geometry_instance_materials_node_torusknot25_0 = {
{
element_index = 0, -- an index into mesh.triangles
material = material_material__46_material,
emission = { input_set = -1 },
ambient = { input_set = -1 },
diffuse = { input_set = -1 },
specular = { input_set = -1 },
},
}
local instance_geometries_node_torusknot25 = {
{
geometry = geometry_geom_torusknot25,
instance_materials = instance_geometry_instance_materials_node_torusknot25_0,
instance_materials_count = 1,
},
}
local instance_controllers_node_torusknot25 = {
}
local instance_lights_node_torusknot25 = {
}
local node_channels_node_torusknot25 = {
}
local node_node_torusknot25 = {
parent_index = -1,
type = collada_types.node_type.NODE,
transforms = transforms_node_torusknot25,
transforms_count = 5,
instance_geometries = instance_geometries_node_torusknot25,
instance_geometries_count = 1,
instance_controllers = instance_controllers_node_torusknot25,
instance_controllers_count = 0,
instance_lights = instance_lights_node_torusknot25,
instance_lights_count = 0,
channels = node_channels_node_torusknot25,
channels_count = 0,
}
local transforms_node_camerahelper = {
{
type = collada_types.transform_type.TRANSLATE,
translate = {-88.57101, -71.71298, 104.5738},
},
}
local instance_geometries_node_camerahelper = {
}
local instance_controllers_node_camerahelper = {
}
local instance_lights_node_camerahelper = {
}
local node_channels_node_camerahelper = {
}
local node_node_camerahelper = {
parent_index = -1,
type = collada_types.node_type.NODE,
transforms = transforms_node_camerahelper,
transforms_count = 1,
instance_geometries = instance_geometries_node_camerahelper,
instance_geometries_count = 0,
instance_controllers = instance_controllers_node_camerahelper,
instance_controllers_count = 0,
instance_lights = instance_lights_node_camerahelper,
instance_lights_count = 0,
channels = node_channels_node_camerahelper,
channels_count = 0,
}
local transforms_node_camera = {
{
type = collada_types.transform_type.MATRIX,
matrix = {0.5124585, -0.8587118, -3.72529e-08, 0.0, 0.4546754, 0.2713395, 0.848319, 0.0, -0.7284616, -0.4347285, 0.5294855, 0.0, -5.03627, 0.0, 3.688698, 1.0},
},
}
local instance_geometries_node_camera = {
}
local instance_controllers_node_camera = {
}
local instance_lights_node_camera = {
}
local node_channels_node_camera = {
}
local node_node_camera = {
parent_index = 4,
type = collada_types.node_type.NODE,
transforms = transforms_node_camera,
transforms_count = 1,
instance_geometries = instance_geometries_node_camera,
instance_geometries_count = 0,
instance_controllers = instance_controllers_node_camera,
instance_controllers_count = 0,
instance_lights = instance_lights_node_camera,
instance_lights_count = 0,
channels = node_channels_node_camera,
channels_count = 0,
}
local transforms_node_cameratargethelper = {
{
type = collada_types.transform_type.TRANSLATE,
translate = {-19.90239, -27.72767, 54.6898},
},
}
local instance_geometries_node_cameratargethelper = {
}
local instance_controllers_node_cameratargethelper = {
}
local instance_lights_node_cameratargethelper = {
}
local node_channels_node_cameratargethelper = {
}
local node_node_cameratargethelper = {
parent_index = -1,
type = collada_types.node_type.NODE,
transforms = transforms_node_cameratargethelper,
transforms_count = 1,
instance_geometries = instance_geometries_node_cameratargethelper,
instance_geometries_count = 0,
instance_controllers = instance_controllers_node_cameratargethelper,
instance_controllers_count = 0,
instance_lights = instance_lights_node_cameratargethelper,
instance_lights_count = 0,
channels = node_channels_node_cameratargethelper,
channels_count = 0,
}
local transforms_node_camera_target = {
}
local instance_geometries_node_camera_target = {
}
local instance_controllers_node_camera_target = {
}
local instance_lights_node_camera_target = {
}
local node_channels_node_camera_target = {
}
local node_node_camera_target = {
parent_index = 6,
type = collada_types.node_type.NODE,
transforms = transforms_node_camera_target,
transforms_count = 0,
instance_geometries = instance_geometries_node_camera_target,
instance_geometries_count = 0,
instance_controllers = instance_controllers_node_camera_target,
instance_controllers_count = 0,
instance_lights = instance_lights_node_camera_target,
instance_lights_count = 0,
channels = node_channels_node_camera_target,
channels_count = 0,
}
local transforms_node_omni001 = {
{
type = collada_types.transform_type.TRANSLATE,
translate = {-2.48297e-06, -56.80384, 58.23672},
},
{
type = collada_types.transform_type.ROTATE,
rotate = {-0.5773502, 0.5773503, 0.5773503, -120.0},
},
}
local instance_geometries_node_omni001 = {
}
local instance_controllers_node_omni001 = {
}
local instance_lights_node_omni001 = {
{
light = light_omni001_light,
}
}
local node_channels_node_omni001 = {
}
local node_node_omni001 = {
parent_index = -1,
type = collada_types.node_type.NODE,
transforms = transforms_node_omni001,
transforms_count = 2,
instance_geometries = instance_geometries_node_omni001,
instance_geometries_count = 0,
instance_controllers = instance_controllers_node_omni001,
instance_controllers_count = 0,
instance_lights = instance_lights_node_omni001,
instance_lights_count = 1,
channels = node_channels_node_omni001,
channels_count = 0,
}
local nodes = {
node_node_environmentambientlight, -- 0
node_node_plane, -- 1
node_node_torus_knot23, -- 2
node_node_torusknot25, -- 3
node_node_camerahelper, -- 4
node_node_camera, -- 5
node_node_cameratargethelper, -- 6
node_node_camera_target, -- 7
node_node_omni001, -- 8
}
local inputs_list = {
{
elements = input_elements_position_0_3_normal_0_3_texcoord_0_3,
elements_count = 3,
},
}
local descriptor = {
nodes = nodes,
nodes_count = #nodes,
geometries = geometries,
nodes_count = #geometries,
inputs_list = inputs_list,
inputs_list_count = #inputs_list,
images = images,
images_count = #images,
}
return {
descriptor = descriptor
}

6
scene/test/test.mk Normal file
View File

@ -0,0 +1,6 @@
IMAGES += image/0_logOnly.DDS
image/0_logOnly.DDS: ./images/0_logOnly.png
@mkdir -p image
texconv10.exe -f BC1_UNORM -nologo "$<"
mv "$(<:.png=.DDS)" "$@"

5
scene/test/test.rc Normal file
View File

@ -0,0 +1,5 @@
RES_SCENES_TEST_VTX RCDATA "test.vtx"
RES_SCENES_TEST_VJW RCDATA "test.vjw"
RES_SCENES_TEST_IDX RCDATA "test.idx"
_0_LOGONLY_PNG RCDATA "image/0_logOnly.DDS"

0
scene/test/test.vjw Normal file
View File

BIN
scene/test/test.vtx Normal file

Binary file not shown.

24
vertex.glsl Normal file
View File

@ -0,0 +1,24 @@
#pragma language glsl3
layout (location = 0) in vec4 VertexPosition;
layout (location = 1) in vec4 VertexNormal;
layout (location = 2) in vec4 VertexTexture;
uniform mat4 world_transform;
uniform mat4 transform;
varying vec4 PixelNormal;
varying vec4 PixelTexture;
varying vec4 PixelWorldPosition;
varying float PixelId;
void vertexmain()
{
PixelNormal = world_transform * vec4(VertexNormal.xyz, 0);
PixelTexture = VertexTexture;
PixelId = float(gl_VertexID) / (4800 * 3);
PixelWorldPosition = world_transform * vec4(VertexPosition.xyz, 1);
love_Position = transform * vec4(VertexPosition.xyz, 1);
}