Corner Dirt

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2013   #16
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 May 2013   #17
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:


  	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 May 2013 at 06:12 AM.
 
Old 05 May 2013   #18
this function might also be of use.
 
Old 05 May 2013   #19
this is a great find



  	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 May 2013   #20
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


(
	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 May 2013   #21
got it

fn GetVectorsAngle v1 v2 = (theAngle = acos(dot (normalize v1) (normalize v2)))
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 05 May 2013   #22
Alright got that all working.


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)



fn OnChanged fValue = 
(
	PolyToolsSelect.ConvexConcave fValue PolyToolsUI.CovexConcave
	PolyToolsUI.SurfaceSelectSpinner = fValue
)
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 05 May 2013   #23
How about this!

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



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 May 2013   #24
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.....

(
	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 May 2013   #25
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 06:04 AM.


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