CGTalk > Software > 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-24-2011, 04:47 PM   #1
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,859
contour generator

Hi

This is a small toy that expands one of the examples from the maxscript help file, used to generate contour splines of objects using the section shape. I needed to use this functionality for a small task, and took the time to build a UI for it.
Enjoy
Attached Images
File Type: jpg contour.jpg (81.9 KB, 80 views)
Attached Files
File Type: txt contours.ms.txt (6.8 KB, 21 views)
 
Old 05-24-2011, 05:10 PM   #2
plastic
Down With The Industry
 
plastic's Avatar
portfolio
Marc Lorenz
Vienna, Austria
 
Join Date: Dec 2002
Posts: 789
very cool, thanks for sharing!
 
Old 05-24-2011, 09:33 PM   #3
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,865
Send a message via ICQ to denisT
Quote:
Originally Posted by lo
Hi

This is a small toy that expands one of the examples from the maxscript help file, used to generate contour splines of objects using the section shape. I needed to use this functionality for a small task, and took the time to build a UI for it.
Enjoy


i would do it by slicing poly copy of the node with slice planes and creating shapes from edge selection.

like:
Code:
fn sliceAndShape node:selection[1] slices:1 curved:off dir:#z = if canconvertto node Editable_Poly do ( temp = converttopoly (copy node) bbox = nodeGetBoundingBox temp temp.transform step = (bbox[2] - bbox[1])/(slices+1) vec = case dir of ( #x: [1,0,0] #y: [0,1,0] default: [0,0,1] ) sp = #() for k=1 to slices do ( temp.slice vec (bbox[1] + vec*step*k) if (temp.createShape ("sp_" + k as string) curved node) do ( append sp shapes[shapes.count] shapes[shapes.count].parent = node ) ) delete temp sp ) /* ( gc() delete objects teapot isselected:on sliceAndShape slices:20 dir:#x ) */

Last edited by denisT : 05-24-2011 at 10:26 PM.
 
Old 05-24-2011, 10:40 PM   #4
miauu
Expert
 
miauu's Avatar
portfolio
Kostadin Kotev
Blagoevgrad, Bulgaria
 
Join Date: Sep 2009
Posts: 850
An older version of Contour Creator by Rab Gordon.
 
Old 05-25-2011, 06:20 AM   #5
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,859
very nice, denis. seems faster.
There is also no need to create the spline every step of the way, you can substitute with:
Code:
if k == slices and (temp.createShape ("sp_" + k as string) curved node) do
 
Old 05-25-2011, 08:14 AM   #6
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,865
Send a message via ICQ to denisT
Quote:
Originally Posted by lo
very nice, denis. seems faster.
There is also no need to create the spline every step of the way, you can substitute with:
Code:
if k == slices and (temp.createShape ("sp_" + k as string) curved node) do

every new slice resets edge selection...
 
Old 05-25-2011, 08:34 AM   #7
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,859
I am not sure what you mean exactly, but your code generates a redundant spline for every iteration, and the line I changed only creates the spline on the last iteration... in your example teapot it seems to work fine...
 
Old 05-25-2011, 08:47 AM   #8
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,865
Send a message via ICQ to denisT
Quote:
Originally Posted by lo
I am not sure what you mean exactly, but your code generates a redundant spline for every iteration, and the line I changed only creates the spline on the last iteration... in your example teapot it seems to work fine...

with your correction the code has to make the shape for the last slice only.
maybe the method doesn't update selection on every slice. if so it's better to do it forcing update node.

Last edited by denisT : 05-25-2011 at 08:50 AM.
 
Old 05-25-2011, 10:36 AM   #9
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,859
Quote:
Originally Posted by denisT
maybe the method doesn't update selection on every slice.

I assume it does and is additive, because the final spline is correct. Can you show a case in which it doesn't?
 
Old 05-25-2011, 12:40 PM   #10
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,865
Send a message via ICQ to denisT
Quote:
Originally Posted by lo
I assume it does and is additive, because the final spline is correct. Can you show a case in which it doesn't?

if it's additive it's a bug. i need to deselect all edges before every iteration. or update mesh after an iteration. updating is definitely slower.
 
Old 05-25-2011, 12:56 PM   #11
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,859
why not just deselect all edges before starting the loop?
 
Old 05-25-2011, 01:11 PM   #12
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,865
Send a message via ICQ to denisT
Quote:
Originally Posted by lo
why not just deselect all edges before starting the loop?


i think the better solution is to have an option - combine. if combine is true we will go your way: deselect edges, make all slices without mesh update, and make a shape; if combine is false (to have a shape per slice) we will go my way: deselect edges before every slice, make slice, and make shape on every iteration.
 
Old 05-25-2011, 01:39 PM   #13
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,859
Quote:
Originally Posted by denisT
i think the better solution is to have an option - combine. if combine is true we will go your way: deselect edges, make all slices without mesh update, and make a shape; if combine is false (to have a shape per slice) we will go my way: deselect edges before every slice, make slice, and make shape on every iteration.

I agree. Do you mind if I use your code sample as a basis for a different version of the tool?
 
Old 05-25-2011, 01:48 PM   #14
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,865
Send a message via ICQ to denisT
Quote:
Originally Posted by lo
I agree. Do you mind if I use your code sample as a basis for a different version of the tool?

sure. no problem.
 
Old 05-25-2011, 01:48 PM   #15
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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:06 PM.


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