Skip to main content
gamedev.net
🔒 Locked

MAXScript UVW Export Problem

Started by alex_r Feb 18, 2005 at 9:31 AM 1 replies 700+ views
Original Post
alex_r
alex_r
AHOY! I made a small script to export models from 3DSMAX, but the UVW don't work in OpenGL. I don't know where is the problem, I read many informations about it in MAX Script help, in other topics and in the google but I don't find the where is the problem problem... Here is my code:

	for f = 1 to meshObj.numfaces do
	(
		ProgressTotal = 100.0*f/meshObj.numfaces			
		-- Grava Pontos ---------------------------------------------------
		get_face1 = getFace meshObj f
		
 		get_vert = getVert meshObj get_face1[1]
		format "% % % " get_vert[1] get_vert[2] get_vert[3] to:ostream	
		
		get_vert = getVert meshObj get_face1[2]
		format "% % % " get_vert[1] get_vert[2] get_vert[3] to:ostream	
		
		get_vert = getVert meshObj get_face1[3]
		format "% % %    " get_vert[1] get_vert[2] get_vert[3] to:ostream	
		-------------------------------------------------------------------
		
		-- Normals --------------------------------------------------------
		get_vert = getNormal meshObj get_face1[1]
		format "% % % " get_vert[1] get_vert[2] get_vert[3] to:ostream	
		
		get_vert = getNormal meshObj get_face1[2]
		format "% % % " get_vert[1] get_vert[2] get_vert[3] to:ostream			
		
		get_vert = getNormal meshObj get_face1[3]
		format "% % %    " get_vert[1] get_vert[2] get_vert[3] to:ostream	
		-------------------------------------------------------------------

		-- UVW ------------------------------------------------------------
		get_uvw = getTVert meshObj get_face1[1]
		format "% % % " get_uvw.x get_uvw.y get_uvw.z to:ostream
		
		get_uvw = getTVert meshObj get_face1[2]
		format "% % % " get_uvw.x get_uvw.y get_uvw.z to:ostream		
		
		get_uvw = getTVert meshObj get_face1[3]
		format "% % %" get_uvw.x get_uvw.y get_uvw.z to:ostream
		-------------------------------------------------------------------


		format "\n" to:ostream
	)


Here is a exported data (a cube)

12
-3.5 -3.5 -3.5 -3.5 3.5 -3.5 3.5 3.5 -3.5    0.0 0.0 -1.5708 0.0 0.0 -1.5708 0.0 0.0 -1.5708    1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
3.5 3.5 -3.5 3.5 -3.5 -3.5 -3.5 -3.5 -3.5    0.0 0.0 -1.5708 0.0 0.0 -1.5708 0.0 0.0 -1.5708    0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0
-3.5 -3.5 3.5 3.5 -3.5 3.5 3.5 3.5 3.5    0.0 0.0 1.5708 0.0 0.0 1.5708 0.0 0.0 1.5708    1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0
3.5 3.5 3.5 -3.5 3.5 3.5 -3.5 -3.5 3.5    0.0 0.0 1.5708 0.0 0.0 1.5708 0.0 0.0 1.5708    0.0 1.0 0.0 0.0 1.0 0.0 1.0 1.0 0.0
-3.5 -3.5 -3.5 3.5 -3.5 -3.5 3.5 -3.5 3.5    0.0 0.0 -1.5708 0.0 0.0 -1.5708 0.0 0.0 1.5708    1.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0
3.5 -3.5 3.5 -3.5 -3.5 3.5 -3.5 -3.5 -3.5    0.0 0.0 1.5708 0.0 0.0 1.5708 0.0 0.0 -1.5708    0.0 1.0 0.0 1.0 1.0 0.0 1.0 0.0 0.0
3.5 -3.5 -3.5 3.5 3.5 -3.5 3.5 3.5 3.5    0.0 0.0 -1.5708 0.0 0.0 -1.5708 0.0 0.0 1.5708    0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0
3.5 3.5 3.5 3.5 -3.5 3.5 3.5 -3.5 -3.5    0.0 0.0 1.5708 0.0 0.0 1.5708 0.0 0.0 -1.5708    0.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0
3.5 3.5 -3.5 -3.5 3.5 -3.5 -3.5 3.5 3.5    0.0 0.0 -1.5708 0.0 0.0 -1.5708 0.0 0.0 1.5708    0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0
-3.5 3.5 3.5 3.5 3.5 3.5 3.5 3.5 -3.5    0.0 0.0 1.5708 0.0 0.0 1.5708 0.0 0.0 -1.5708    0.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0
-3.5 3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 3.5    0.0 0.0 -1.5708 0.0 0.0 -1.5708 0.0 0.0 1.5708    0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0
-3.5 -3.5 3.5 -3.5 3.5 3.5 -3.5 3.5 -3.5    0.0 0.0 1.5708 0.0 0.0 1.5708 0.0 0.0 -1.5708    1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0


Thanks for the help Alexandre Ribeiro de Sá [Edited by - alex_r on February 18, 2005 10:53:29 AM]
alex_r
alex_r
I found the problem, I read again many thinks in MAX Script documentation, the problem is, there two index, one is the vertex index and the second is the texture vertex index...

If anyone like, here is how read the texture vertex:

get_face1 = getTVFace meshObj f
get_uvw = getTVert meshObj get_face1.z
format "% % % " get_uvw.x get_uvw.y get_uvw.z to:ostream

get_uvw = getTVert meshObj get_face1.y
format "% % % " get_uvw.x get_uvw.y get_uvw.z to:ostream

get_uvw = getTVert meshObj get_face1.x
format "% % %" get_uvw.x get_uvw.y get_uvw.z to:ostream
GamerSg
GamerSg
Max does not store it's vertex data as OpenGL/DX would. This is why it is an additional headache to convert it to what your api requires. Normals will be even tougher to get because of smoothing groups. The normals you are getting are unlikely to make objects in Max look similar in your application. Try exporting a cube.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.