Home Coding, Scripting, Shaders

[3ds MaxScript] Simple Vertex Position Exporter

noekk
polycounter lvl 10
Offline / Send Message
noekk polycounter lvl 10

Hi guys, I'm making a simple MaxScript exporter for just the vertex positions. It usually works fine but sometimes I have to Reset XForm for the vertices to not be offset. I know I'm missing something. Here's the important part:


obj = objects[i]

mesh = obj (or mesh = obj.mesh for editable poly)

face = getface mesh j

vert = (getvert mesh face[1] + obj.objectoffsetpos) * obj.transform


Thanks a lot.

Replies

  • Klunk
    Offline / Send Message
    Klunk ngon master

    what space do you want the positions in world or local ?

  • noekk
    Offline / Send Message
    noekk polycounter lvl 10

    Maybe you can show me how to do both in case I run in to problems? Thanks.

  • Klunk
    Offline / Send Message
    Klunk ngon master

    I'd probably do something like....



    fn collect_mesh_verts_local nobj =
    (
    	intm = inverse (nobj.transform);
    	tmsh = SnapShotAsMesh nobj;
    	verts = for v = 1 to tmsh.numVerts collect (getvert tmsh v) * intm;
    	delete tmsh;
    	verts;
    )	
    
    fn collect_mesh_verts_world nobj =
    (
    	tmsh = SnapShotAsMesh nobj;
    	verts = for v = 1 to tmsh.numVerts collect (getvert tmsh v);
    	delete tmsh;
    	verts;
    )	
    
    
    for obj in objects do
    (
    -- if you still have xform troubles you can uncomment the following (if you do that you can remove the snapshot and delete from the previous
    -- functions and and replace tmsh with nobj	
    	--resetxform obj;
    	--converttomesh obj
    	verts = collect_mesh_verts_local obj;
    	export_verts verts;
    )		
    


  • noekk
    Offline / Send Message
    noekk polycounter lvl 10

    Thanks a lot Klunk, that's very helpful.

Sign In or Register to comment.