about it... it is what?SiENcE wrote:I'm curious about it.
Anyhow, I'm trying to add material support for loading .obj files and I can't seem to get Love to read the ambient and diffuse declarations inside the .mtl file.
Here's the code for it in case anyone else can spot the problem before I get it.
Code: Select all
--Make sure to check for mtl file
if string.sub(RAW_FILE[a], 1, 6) == "mtllib" then
local RAW_MTL = {}
for line in love.filesystem.lines(string.sub(RAW_FILE[a], 8)) do
table.insert(RAW_MTL, line)
end
--Since there was a material, let's index it
for c = 1, #RAW_MTL do
--If a new material is being declared
if string.sub(RAW_MTL[a], 1, 6) == "newmtl" then
MATER[#MATER+1] = {}
MATER[#MATER].ID = string.sub(RAW_MTL[a], 8)
end
if string.sub(RAW_MTL[a], 1, 2) == "Ka" then
local pointer = string.find(RAW_MTL[a], " ", 4)
local color1 = string.sub(RAW_MTL[a], 4, pointer - 1)
newPointer = string.sub(RAW_MTL[a], " ", pointer)
local color2 = string.sub(RAW_MTL[a], pointer, newPointer - 1)
pointer = string.sub(RAW_MTL[a], " ", newPointer)
local color3 = string.sub(RAW_MTL[a], newPointer, pointer - 1)
MATER[#MATER].AMB = {color1, color2, color3}
end
if string.sub(RAW_MTL[a], 1, 2) == "Kd" then
local pointer = string.find(RAW_MTL[a], " ", 4)
local color1 = string.sub(RAW_MTL[a], 4, pointer - 1)
newPointer = string.sub(RAW_MTL[a], " ", pointer)
local color2 = string.sub(RAW_MTL[a], pointer, newPointer - 1)
pointer = string.sub(RAW_MTL[a], " ", newPointer)
local color3 = string.sub(RAW_MTL[a], newPointer, pointer - 1)
MATER[#MATER].DIF = {color1, color2, color3}
end
end
end
--Done indexing Materials
I used some creatively placed errors to make sure of that.
It's just not recognizing Ka and Kd inside the material file.
This is how it looks in the .mtl file:
Code: Select all
newmtl Material2
Ka 0.000000 0.000000 0.000000
Kd 1.000000 1.000000 0.000000
Ks 0.330000 0.330000 0.330000
Update
Original post updated:
Added - Frustum Culling / Screen clipping
Added - Not working material loader