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 04-30-2013, 09:59 PM   #16
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,313
Send a message via AIM to JokerMartini
Yeah,
I'm aware of the most the options relating vertex coloring or map based generation. I was just trying to possibly generate another option.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 05-01-2013, 06:07 AM   #17
jonadb
3D Artist
 
jonadb's Avatar
Jonathan de Blok
Netherlands
 
Join Date: Mar 2003
Posts: 1,315
Quote:
Originally Posted by JokerMartini
What would you be testing and collecting when calculating convexity


You can select the convex/concave faces with the build in PolySelect tools, its the code that is behind the ribbon's 'select' tab.

See maxroot\stdscripts\PolyTools.ms for example:

Code:
fn OnChanged fValue = ( PolyToolsSelect.ConvexConcave fValue PolyToolsUI.CovexConcave PolyToolsUI.SurfaceSelectSpinner = fValue )


Look up 'PolyToolsSelect' in mxs help..

edit: combine 'PolyToolsSelect.ConvexConcave' with 'PolyToolsSelect.Normal' and you're almost done
__________________
The GPU revolution will not be rasterized! - http://www.jdbgraphics.nl

Last edited by jonadb : 05-01-2013 at 06:12 AM.
 
Old 05-01-2013, 07:36 AM   #18
Klunk
Lord of the posts
 
Klunk's Avatar
portfolio
Klunk
United Kingdom
 
Join Date: Sep 2005
Posts: 701
this function might also be of use.
 
Old 05-01-2013, 02:02 PM   #19
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,313
Send a message via AIM to JokerMartini
this is a great find

Code:
fn OnChanged fValue = ( PolyToolsSelect.ConvexConcave fValue PolyToolsUI.CovexConcave PolyToolsUI.SurfaceSelectSpinner = fValue )


But lacks use-ability in a scripted tool since it has to select the object in order to work.
It's very slow and cumbersome when having to do subobject selections like this.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 05-01-2013, 02:10 PM   #20
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,313
Send a message via AIM to JokerMartini
How can I adjust this script below select faces within 15 degrees to +Z? Right now I have a min and max normal value which an angle threshold would better

Code:
( struct faceData (index , normal, upZ=false) ground = $ground numFaces = ground.numfaces upMin = .7 -- min value of 0.0 upMax = 1.0 --max value of 1.0 facesArr = #() --the faces that fall within the defined threshold values clearlistener() for f = 1 to numFaces do ( faceNormal = polyop.getFaceNormal ground f pass = if faceNormal.z >= upMin AND faceNormal.z <= upMax then true else false append facesArr (faceData index:f normal:faceNormal upZ:pass) ) )
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 05-01-2013, 03:52 PM   #21
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,313
Send a message via AIM to JokerMartini
got it

fn GetVectorsAngle v1 v2 = (theAngle = acos(dot (normalize v1) (normalize v2)))
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 05-01-2013, 04:02 PM   #22
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,313
Send a message via AIM to JokerMartini
Alright got that all working.

Code:
try(destroyDialog ::rlJunkyUp)catch() rollout rlJunkyUp "Junky Up" ( struct faceData (node, index , normal, upZ=false) local facesArr = #() spinner uiCVAngle "Concave/Convex:" fieldwidth:55 range:[-1e9,1e9,0.0] scale:.0001 spinner uiNormalAngle "Normal Angle:" fieldwidth:55 type:#float range:[-1e9,1e9,15.0] scale:1.0 fn GetVectorsAngle v1 v2 = (theAngle = acos(dot (normalize v1) (normalize v2))) fn calculateSurface = ( nodes = for o in (getCurrentSelection()) where classof o == Editable_Poly collect o facesArr = #() for n in nodes do ( for f = 1 to n.numfaces do ( faceNormal = polyop.getFaceNormal n f faceAngle = GetVectorsAngle [0,0,1] faceNormal pass = if faceAngle <= uiNormalAngle.value then true else false append facesArr (faceData node:n index:f normal:faceNormal upZ:pass) /* color face */ setCVertMode n true val = if pass then blue else orange polyOp.setFaceColor n 0 #{f} val update n ) ) ) on uiCVAngle changed val do calculateSurface() on uiNormalAngle changed val do calculateSurface() ) createDialog rlJunkyUp 200 200 style:#(#style_SysMenu, #style_ToolWindow)


now I just need to calculate the faces based on convex or concave.
I'll have to recreate the function found in the polyTools panel as it requires the faces be selected in order to work, which isn't helpful. (to slow)


Code:
fn OnChanged fValue = ( PolyToolsSelect.ConvexConcave fValue PolyToolsUI.CovexConcave PolyToolsUI.SurfaceSelectSpinner = fValue )
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 05-01-2013, 05:00 PM   #23
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,313
Send a message via AIM to JokerMartini
How about this!

How about this for finding concave faces.
It's a modified script of denis's


Code:
fn getConvexEdges node:selection[1] show:on threshold:10 ignoreHardEdges:off ignoreOpenEdges:on = if iskindof node Editable_Poly do ( local edgeFaces = polyop.getedgefaces local faceNormal = polyop.getfacenormal local faceCenter = polyop.getfacecenter local faceSmooth = polyop.getfacesmoothgroup edges = #{} for e in (node.edges as bitarray) do ( ff = edgeFaces node e if (not ignoreOpenEdges and ff.count != 2) or ( (ff.count == 2) and ( n1 = faceNormal node ff[1] n2 = faceNormal node ff[2] vc = faceCenter node ff[2] - faceCenter node ff[1] (dot n1 vc <= 0) and (acos (dot n1 n2) > threshold) and ( not ignoreHardEdges or (bit.and (faceSmooth node ff[1]) (faceSmooth node ff[2]) > 0) ) ) ) do append edges e ) if show do node.selectededges = edges edges ) edges = for e in getConvexEdges() collect e --polyop.setEdgeSelection $ selFaces = #() for f in edges do join selFaces (polyop.getEdgeFaces $ f) polyop.setFaceSelection $ (#{1..$.numFaces} - (selFaces as bitarray))
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 05-01-2013, 05:34 PM   #24
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,313
Send a message via AIM to JokerMartini
Concave faces

This is another modified version of Denis's script.

It seems like its going in the right direction but doesn't truly replicate the polytools concave selection.....
Code:
( node = $ground numEdges = polyop.getNumEdges node groupedFaces = #() threshold = 10 concaveFaces = #() for edg = 1 to numEdges do ( facesGroup = polyop.getEdgeFaces node edg --format "%\n" faces if facesGroup.count == 2 do append groupedFaces facesGroup --skip open edges which will return only 1 item in the array ) for g in groupedFaces do ( f1 = polyop.getfacenormal node g[1] f2 = polyop.getfacenormal node g[2] vec = (polyop.getfacecenter node g[2]) - (polyop.getfacecenter node g[1]) --if (dot f1 vec <= 0) and (acos (dot f1 f2) > threshold) do if (acos (dot f1 f2) > threshold) AND (dot f2 vec <= 0) do ( --format "%\n" g join concaveFaces g ) ) polyop.setFaceSelection $ concaveFaces )
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 05-01-2013, 05:34 PM   #25
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


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 10:27 AM.


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