[Closed] Reading Coard data from a txt file into max
Hi guys,
Does anyone know a little maxscript to help me out. I have an export from a game engine that exports the terrain straight into max which is great, but then all other models export in the centre of the scene. The author of the exporter tells me I need script to be wrote to parse the model location files and relocate all of the models.
The text file it exports starts with :-
ModelFile;PositionX;PositionY;PositionZ;RotationX;RotationY;RotationZ;ScaleFactor
…and then carries on with the list of models like this :-
canopylesstree01.obj;18109.13;99.02845;25778.55;0;332.1488;0;1
I know no maxscript at all, does anyone have a clue where I would start. I would be more than willing to learn this myself but i wouldnt know where to start.
cheers guys
For starters there are “how to” example scripts in the maxscript reference, even one about to import coordinates.
the script assumes the obj file contains models centered at the origin and all the models transformations is in the file given as input. critical failure of the script, the pivot point data is not supplied as input, and hence when the obj file is imported the pivot is at [0,0,0]
(
--themodel;PositionX;PositionY;PositionZ;RotationX; RotationY;RotationZ;ScaleFactor
resetMaxFile #noprompt
-- replace with full qualified name of the game file and make sure to escape back slash with another back slash = C:\\folder\\folder\\file.obj
thefile = (openfile "C:\\objfile.txt") -- input
theArray = #()
theObject = #()
i = 1
while ((not (eof thefile))) do
(
theline = readline thefile
theArray = (filterstring theline ";")
thePos = [theArray[2] as integer,theArray[3] as integer,theArray[4] as integer]
theRot = [theArray[5] as integer,theArray[6] as integer,theArray[7] as integer]
theScale = [theArray[8] as integer,theArray[8] as integer,theArray[8] as integer]
importfile theArray[1] #noprompt
theObject[i] = $
theObject[i].rotation = (eulerangles theRot[1] theRot[2] theRot[3])
theObject[i].scale = theScale
theObject[i].pos = thePos
i+=1
)
close thefile
)
cheers!