function readFile = (
-- Browse For File
dataFile = getOpenFileName caption:"Select File"
-- Check
if(dataFile == undefined) then return "No File Selected"
-- Open File In "read" Mode
fileId = openFile dataFile mode:"r"
-- If It Opened, Load Data
dataArray = #()
if (fileId != undefined) then (
while (not eof fileId) do (
myLine = readLine fileId
append dataArray myLine
)
)
-- Close File
close fileId
-- Loop Through The Data Array
for a = 1 to dataArray.count do (
-- Filter String This Line
row = filterString dataArray[a] ";"
-- Row Example
-- canopylesstree01.obj;18109.13;99.02845;25778.55;0;332.1488;0;1
objName = row[1]
floatValue1 = row[2] as float
floatValue2 = row[3] as float
floatValue3 = row[4] as float
floatValue4 = row[5] as float
floatValue5 = row[6] as float
floatValue6 = row[7] as float
floatValue7 = row[8] as float
print dataArray[a]
)
)
ModelFile;PositionX;PositionY;PositionZ;RotationX;RotationY;RotationZ;ScaleFactor
canopylesstree01.obj;18109.13;99.02845;25778.55;0;332.1488;0;1
elwynntreecanopy03.obj;18109.8;80.35624;25836.58;0;32;0;1
elwynntreecanopy03.obj;18105.33;75.75277;25914.53;0;278;0;1
elwynnbush09.obj;18129.26;68.40128;26081.71;0;315.3062;0;1
elwynncliffrock01.obj;18313.37;259.7162;25596.63;-0.5;146.639;-7.5;1
ogremoundrock03.obj;18303.02;262.2205;25598.46;5.5;205.4286;-28.5;1
elwynncliffrock01.obj;18312.07;259.7454;25604.57;-2.5;324.645;15;1
elwynncliffrock01.obj;18231.89;242.4893;25641.26;20.5;12.75879;-7;1
ogremoundrock03.obj;18290.43;221.7971;25653.88;2.5;205.4286;-13.5;1
ogremoundrock03.obj;18282.8;217.5751;25656.78;2.5;256.4286;-13.5;1
elwynncliffrock01.obj;18317.77;222.8927;25662.27;20.5;-103.2412;-7;1
humantentmedium.obj;18304.91;224.7274;25664;0.5;-44.5;8;1
function importAndPositionObjs objPath dataFile = (
-- Check
if(objPath == undefined) then return "No Obj File Given."
if(dataFile == undefined) then return "No Data File Given."
-- Open File In "read" Mode
fileId = openFile dataFile mode:"r"
-- If It Opened, Load Data
dataArray = #()
if (fileId != undefined) then (
while (not eof fileId) do (
myLine = readLine fileId
append dataArray myLine
)
)
-- Close File
close fileId
-- Loop Through The Data Array
for a = 1 to dataArray.count do (
-- Filter This Line By Semi-Colon
row = filterString dataArray[a] ";"
--Extract Data From Line
obj = row[1]
posX = row[2] as float
posY = row[3] as float
posZ = row[4] as float
rotX = row[5] as float
rotY = row[6] as float
rotZ = row[7] as float
scaleFac = row[8] as float
-- Filter Object Name
nameRow = filterString obj "."
objName = nameRow[1]
-- Import Obj
importFile (objPath+"/"+obj) #noPrompt
-- ************************************************
-- NOTE: This assumes the OBJ filename is
-- the same as the actual Object Name.
-- ************************************************
-- Get Obj Name
myObj = getNodeByName objName
-- Position Obj
myObj.pos = [posX, posY, posZ]
-- Rotate Obj
objRots = eulerAngles rotX rotY rotZ
rotate myObj objRots
-- Scale Obj
scale myObj [scaleFac,scaleFac,scaleFac]
)
)