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....



    1. fn collect_mesh_verts_local nobj =
    2. (
    3. intm = inverse (nobj.transform);
    4. tmsh = SnapShotAsMesh nobj;
    5. verts = for v = 1 to tmsh.numVerts collect (getvert tmsh v) * intm;
    6. delete tmsh;
    7. verts;
    8. )
    9.  
    10. fn collect_mesh_verts_world nobj =
    11. (
    12. tmsh = SnapShotAsMesh nobj;
    13. verts = for v = 1 to tmsh.numVerts collect (getvert tmsh v);
    14. delete tmsh;
    15. verts;
    16. )
    17.  
    18.  
    19. for obj in objects do
    20. (
    21. -- 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
    22. -- functions and and replace tmsh with nobj
    23. --resetxform obj;
    24. --converttomesh obj
    25. verts = collect_mesh_verts_local obj;
    26. export_verts verts;
    27. )


  • noekk
    Offline / Send Message
    noekk polycounter lvl 10

    Thanks a lot Klunk, that's very helpful.

Sign In or Register to comment.