I'm trying to build a scene and render it via script using lua scripting. Why textures are not loaded to the .obj file? I've tested the script with two different .obj-models, and the textures are loaded only to the other. The script:
- Code: Select all
rt = octane.node.create{ type=octane.NT_RENDERTARGET, name="Impl RT" } -- implicit in the root graph
mesh=octane.node.create{type=octane.NT_GEO_MESH, name="mesh1"}
mesh:setAttribute(34,"D:/Projects/visudevel/Octane/VT7/vt7.obj",true)
print(rt:getProperties().graphOwned, rt:getProperties().graphOwner)
daylightEnv=octane.node.create{type=octane.NT_ENV_DAYLIGHT, name="daylight"}
daylightEnv.setPinValue(daylightEnv,"sundir",{63.0,23.4,6.00,20,12.00,2.00})
daylightEnv.setPinValue(daylightEnv,120,0.5)
placement=octane.node.create{type=octane.NT_GEO_PLACEMENT, name="placement1"}
print(placement:getProperties().graphOwned, placement:getProperties().graphOwner)
transform=octane.node.create{type=octane.NT_TRANSFORM_3D, pinOwnerNode=placement, pinOwnerId=octane.P_TRANSFORM}
transform.setPinValue(transform,"rotationOrder",2)
transform.setPinValue(transform,"rotation",{-90,90,0})
placement:connectTo("geometry",mesh)
rt:connectTo("mesh",placement)
rt:connectTo("environment",daylightEnv)
print(transform:getProperties().pinOwned, transform:getProperties().pinOwnerNode)
-- create a panoramic camera in the camera pin of the render target
-- we need to specify both the node that has the pin and the pin itself
rt:setPinValue(198,{8192,2048})
pcam = octane.node.create{ type=octane.NT_CAM_PANORAMIC, pinOwnerNode=rt, pinOwnerId=octane.P_CAMERA}
pcam:setPinValue(228,3)
pcam.setPinValue(pcam,20,0)
pcam.setPinValue(pcam,87,true)
--[[pcam.setPinValue(pcam,133,{-19,410,-353})--]]
-- see if the file exists
function file_exists(file)
local f = io.open(file, "rb")
if f then f:close() end
return f ~= nil
end
function lines_from(file)
if not file_exists(file) then return {} end
lines = {}
for line in io.lines(file) do
lines[#lines + 1] = line
end
return lines
end
lines=lines_from("D:/Projects/visudevel/Octane/VT7/vt7.txt")
function parse(line1)
--[[file=io.open(filename)
io.input(file)
line1=io.read()--]]
print("line:",line1)
index1,index2=string.find(line1," / ", 1)
print(index1,index2)
name=string.sub(line1,1,index2)
print(name)
line2=string.sub(line1,index2+1,string.len(line1))
print(line2)
index3,index4=string.find(line2," / ", 1)
line3=string.sub(line2,index4+1,string.len(line2))
print(line3)
index5,index6=string.find(line3," / ", 1)
x=string.sub(line3,1,index5)
print(x)
line4=string.sub(line3,index6+1,string.len(line3))
index7,index8=string.find(line4," / ",1)
y=string.sub(line4,1,index7)
print(y)
line5=string.sub(line4,index8+1,string.len(line4))
index9,index10=string.find(line5," / ",1)
z=string.sub(line5,1,index9)
print(z)
return x,y,z
end
for i=1,#lines,1
do
x1,y1,z1=parse(lines[i])
print(x1,y1,z1)
pcam.setPinValue(pcam,"pos",{-y1,z1,-x1})
print("D:/Projects/visudevel/Octane/VT7/vt7_"..i..".png")
print(pcam.getNodeInfo(pcam).takesPinDefaultValues)
print(pcam:getProperties().pinOwned, pcam:getProperties().pinOwnerNode, octane.apiinfo.getPinTypeName(8), pcam:getPinValue(20), pcam:getPinCount())
octane.render.start{renderTargetNode=rt}
print(octane.render.saveImage("D:/Projects/visudevel/Octane/VT7/vt7_"..i..".png",octane.render.imageType.PNG8,false))
end