twist setting

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
  04 April 2013
twist setting

Looking to solve my twist issue in the math equation?
Thank you for the help guys.

Below is a function I'm using to generate verts between a start and end radius of verts. The twist function is collapsing the verts instead of retaining it's volume. The problem lies in my math question below somewhere. I looking for some help.




	fn genTweenSegs numHeightSegs:0 startHeight:0.0 maxHeight:0.0 startVerts:#() endVerts:#() biasHeight:0.0 powerHeight:0.0 biasRad:0.0 powerRad:0.0 =
	(
		local tmpVerts = #()
		
		for eachSeg = 1.0 to numHeightSegs-1 do
		(
			f = eachSeg/numHeightSegs
			h = maxHeight*(fastValue f bias:biasHeight power:powerHeight)+startHeight
			
			for v = 1 to startVerts.count do
			(
				bottomRadius = startVerts[v]
				topRadius = endVerts[v]
				
				r = bottomRadius + (topRadius - bottomRadius)*(fastValue f bias:biasRad power:powerRad)
				
				mPos = [r[1],r[2],h]
				append tmpVerts mpos
			)
		)
		return tmpVerts
	)
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
  04 April 2013
i don't have time to debug your code now, but here is a function that does do twist:

fn twistPolyAboutZ node angle:45 = if iskindof node editable_poly do
(
	tm = node.objecttransform
	itm = inverse tm

	bb = nodeGetBoundingBox node tm

	for v=1 to node.numverts do
	(
		p = (polyop.getvert node v) * itm 
		a = (bb[2].z - p.z)/(bb[2].z - bb[1].z)*angle
		t = p * (rotatez (matrix3 1) a) * tm
		polyop.setvert node v t
	)
	update node 
)
delete objects
c = cylinder radius:20 height:40 heightsegs:8 sides:24 wirecolor:orange pos:[10,10,10] rotation:(eulerangles 40 20 50)
twistPolyAboutZ (converttopoly c) angle:45
c = cone radius1:20 radius2:5 height:40 heightsegs:8 sides:24 wirecolor:green pos:[-10,-10,-10] rotation:(eulerangles -40 -20 -50)
twistPolyAboutZ (converttopoly c) angle:90
 
  04 April 2013
here is an expended version for all three axis
fn twistPoly node angle:45 axis:#z = if iskindof node editable_poly do
(
	k 
	rotate = case axis of 
	(
		#x: (k = 1; rotatex)
		#y: (k = 2; rotatey)
		#z: (k = 3; rotatez)
	)
	tm = node.objecttransform
	itm = inverse tm

	bb = nodeGetBoundingBox node tm

	for v=1 to node.numverts do
	(
		p = (polyop.getvert node v) * itm 
		a = (bb[2][k] - p[k])/(bb[2][k] - bb[1][k])*angle
		t = p * (rotate (matrix3 1) a) * tm
		polyop.setvert node v t
	)
	update node 
)
delete objects
c = cylinder radius:20 height:40 heightsegs:8 sides:24 wirecolor:orange pos:[10,10,10] rotation:(eulerangles 40 20 50)
twistPoly (converttopoly c) angle:65 axis:#x
c = cone radius1:20 radius2:5 height:40 heightsegs:8 sides:24 wirecolor:green pos:[-10,-10,-10] rotation:(eulerangles -40 -20 -50)
twistPoly (converttopoly c) angle:180 axis:#z
twistPoly c angle:45 axis:#y
 
  04 April 2013
I ended up messing with it a bit last night and I got a similar setup.

I'm going to add bias and what not to this as well.
I'll post that version.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
  04 April 2013
Denis

Denis here is an idea. I've taken your script and added just a few lines to show what a bend would look like.

How would the function be modifier to replicate that of the actual bend modifier, assuming the base pivot of the rotation is always at the base center of the object like in the example?



fn twistPoly node angle:45 axis:#z = if iskindof node editable_poly do
(
	k 
	rotate = case axis of 
	(
		#x: (k = 1; rotatex)
		#y: (k = 2; rotatey)
		#z: (k = 3; rotatez)
	)
	tm = node.objecttransform
	itm = inverse tm

	bb = nodeGetBoundingBox node tm

	for v=1 to node.numverts do
	(
		p = (polyop.getvert node v) * itm 
		a = (bb[2][k] - p[k])/(bb[2][k] - bb[1][k])*angle
		t = p * (rotate (matrix3 1) a) * tm
		polyop.setvert node v t
	)
	update node 
)
delete objects
c = cylinder radius:10 height:40 heightsegs:8 sides:24 wirecolor:orange pos:[0,0,0] rotation:(eulerangles 0 0 0)
twistPoly (converttopoly c) angle:90 axis:#x

c = cylinder radius:10 height:40 heightsegs:8 sides:24 wirecolor:orange pos:[0,60,0] rotation:(eulerangles 0 0 0)
addmodifier c (bend angle:90 direction:90)
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
  04 April 2013
simplified for testing

use for testing



(
	local startRadius = 10.0
	local endRadius = 5.0
	local height = (units.decodevalue "30.0cm")
	local heightSegs = 20
	local columns = 8
	local columnAngle = 360.0 / columns
	local bendAngle = 45.0
	clearlistener()
	delete objects
		
	for row = 1.0 to heightSegs do
	(
		f = row/heightSegs
		stepHeight = height*f
		curRadius = startRadius + (endRadius - startRadius)*f
		curBend = bendAngle*f --*(fastValue f bias:0.0 power:10.0)
		
		col = random white white
		for c = 1 to columns do
		(
			calcX = curRadius * cos((c-1) * columnAngle)
			calcY = curRadius * sin((c-1) * columnAngle)
			
			orgPos = [calcX,calcY,stepHeight]
				
			/* BENDING */
			tm = rotateY (transmatrix orgPos) curBend
			bentPos = (tm *  (matrix3 1)).pos
				
			point pos:bentPos size:1 wirecolor:col
		)
	)
	c = cone radius1:10 radius2:5 pos:[0,0,0]
	addmodifier c (Bend angle:bendAngle)
)
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com

Last edited by JokerMartini : 04 April 2013 at 09:02 PM.
 
  04 April 2013
anyone have any ideas on how to properly do a bend on an objects verts without using the the bend modifier?
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
  04 April 2013
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 10:48 PM.


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