CGTalk > Software Specific Forums > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 05-30-2011, 02:07 PM   #1
ektho
Veteran
 
ektho's Avatar
portfolio
Marco Soresina
Brescia-Milano, Italy
 
Join Date: Nov 2004
Posts: 47
Index faces?

I need help, I'm trying to do a simple mesh object, a parametric plane, but i can not make the formula for the index face, down here the script:

Code:
plugin simpleObject quad name:"Plane" category:"Extra Primitives" classID:#(0x4927806d, 0x3d9ca278) ( parameters main rollout:params ( widthVal type:#float ui:widthVal default:0 lengthVal type:#float ui:lengthVal default:0 widthSeg type:#integer ui:widthSeg default:3 lengthSeg type:#integer ui:lengthSeg default:3 ) rollout params "Parameters" ( spinner widthVal "Width: " range:[0,10000,5] fieldWidth:50 spinner lengthVal "Length : " range:[0,10000,5] fieldWidth:50 spinner widthSeg "WidthSeg: " range:[1,100,5] fieldWidth:50 spinner lengthSeg "LengthSeg : " range:[1,100,5] fieldWidth:50 ) on buildMesh do ( vert_array = #() face_array = #() for i = 1 to lengthSeg+1 do ( for ii = 1 to widthSeg+1 do ( append vert_array [ (widthVal/widthSeg)*(ii-1), (lengthVal/lengthSeg)*(i-1), 0] ) ) for j = 1 to widthSeg do ( append face_array [j,j+1,j+widthSeg+2] ) --face_array = #([1,2,6],[2,3,7],[3,4,8],[1,6,5],[2,7,6],[3,8,7]) setMesh mesh verts:vert_array faces:face_array ) tool create ( on mousePoint click do case click of (1: coordsys grid (nodeTM.translation = gridPoint);2: print LengthSeg) on mouseMove click do case click of (2:(widthVal = gridDist.x; lengthVal = gridDist.y); 3: #stop) ) )


Sorry for my english.
 
Old 06-02-2011, 06:19 PM   #2
viro
Know-it-All
 
viro's Avatar
portfolio
Michael Burgoyne
Technical Director
Infuse Medical
Salt Lake City, USA
 
Join Date: Jun 2005
Posts: 419
I did the same exact thing for a class last year. Maybe it will help you solve your problem.

Code:
plugin simpleObject customPlane name:"Custom Plane" classID:#(0x21764401, 0x55a56f86) category:"Scripted Primitives" ( local faceArray = #() local vertArray = #() rollout params "Parameters" ( spinner planeLength "Length: " type:#float range:[0,1000,0] spinner planeWidth "Width: " type:#float range:[0,1000,0] spinner lengthSegs "Length Segs: " type:#integer range:[1,10,1] spinner widthSegs "Width Segs: " type:#integer range:[1,10,1] ) parameters main rollout:params ( pLength type:#float ui:planeLength pWidth type:#float ui:planeWidth pLengthSegs type:#integer ui:lengthSegs default:1 pWidthSegs type:#integer ui:widthSegs default:1 ) on buildMesh do ( -- Create vertices vertArray = #() widthStep = pWidth / pWidthSegs lengthStep = pLength / pLengthSegs for j = 0 to pLengthSegs do ( y = (lengthStep * j) for i = 0 to pWidthSegs do ( x = (widthStep * i) append vertArray [x, y, 0] ) ) -- Put vertex numbers in face array faceArray = #() for j = 0 to (pLengthSegs - 1) do ( for i = 1 to pWidthSegs do ( v1 = i + (j * (pWidthSegs + 1)) v2 = v1 + 1 v3 = v2 + pWidthSegs + 1 append faceArray [v1,v2,v3] swap v1 v3 v2 = v1 - 1 append faceArray [v1,v2,v3] ) ) -- Create the mesh setMesh mesh verts:vertArray faces:faceArray ) -- Tells the script what to do with your mouse clicks and drags. tool create ( on mousePoint click do case click of ( 1: nodeTM.translation = gridPoint 2: #stop ) on mouseMove click do case click of ( 2: ( pWidth = gridDist.x; pLength = gridDist.y ) ) ) )
 
Old 06-06-2011, 10:28 AM   #3
ektho
Veteran
 
ektho's Avatar
portfolio
Marco Soresina
Brescia-Milano, Italy
 
Join Date: Nov 2004
Posts: 47
Thanks!

Thanks so much Viro, is what I was looking, you saved my brain!
 
Old 06-06-2011, 10:28 AM   #4
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 03:32 PM.


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