Reading Coard data from a txt file into max

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  02 February 2010
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
  02 February 2010
wow just remembered why i dont post here
  02 February 2010
For starters there are "how to" example scripts in the maxscript reference, even one about to import coordinates.
  02 February 2010
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
 	close thefile

  02 February 2010
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 01:11 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.