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 CLOSED
 
Thread Tools Search this Thread Display Modes
Old 02 February 2010   #1
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
 
Old 02 February 2010   #2
wow just remembered why i dont post here
 
Old 02 February 2010   #3
For starters there are "how to" example scripts in the maxscript reference, even one about to import coordinates.
 
Old 02 February 2010   #4
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!
 
Old 02 February 2010   #5
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 12:14 AM.


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