Notifications
Clear all

[Closed] Pipes Generator

or that ^
haha so much shorter. Nice.

you have:


	fn setNodeLocalRotation theNode theRot = (in coordsys local rotate theNode theRot)
	(for o in selection do setNodeLocalRotation o (eulerangles 0 0 15))

it’s the same as:


	fn setNodeLocalRotation theNode theRot = (in coordsys local rotate theNode theRot)
   setNodeLocalRotation selection (eulerangles 0 0 15)

but less change messages sends to the system


 if type == 1 do ...
 if type == 2 do ...
 if type == 3 do ...
 

is a case statement:


case type of:
(
  1: ...
  2: ...
  3: ...
)


  pStart = if selection.count >=1 then [selection.center.x,selection.center.y,selection.min.z] else [0,0,0]
  pEnd = if selection.count >=1 then [selection.center.x,selection.center.y,selection.max.z] else [0,0,ctrlSize*3]
  tmMax = if selection.count >=1 then [selection.max.x,selection.max.y,selection.max.z] else [ctrlSize*3,ctrlSize*3,ctrlSize*3]
  tmMin = if selection.count >=1 then [selection.min.x,selection.min.y,selection.min.z] else -[ctrlSize*3,ctrlSize*3,ctrlSize*3]
  

i would write:


  if (s = selection).count > 2 then
 (
 	pStart = [s.center.x,s.center.y,s.min.z]
 	pEnd = [s.center.x,s.center.y,s.max.z]
 	tmMax = s.max
 	tmMin = s.min
 )
 else
 (
 	pStart = [0,0,0]
 	pEnd = [0,0,ctrlSize*3]
 	tmMax = [ctrlSize*3,ctrlSize*3,ctrlSize*3]
 	tmMin = -[ctrlSize*3,ctrlSize*3,ctrlSize*3]
 )
  

it looks longer but clearer

Alright, these snippets of optimization and improvement will surely help clean things up a bit. I’m going to work on getting these all implemented today and then I’ll be sure to post it so we can all further check it out and add/improve upon it.

Thanks Denis.

Instead of doing this for each rig control


....
append rigCtrls (ctrlEndA = fnEndCtrl ctrlStart [tmMax.x,pStart.y,pEnd.z])
append rigCtrls (ctrlEndB = fnEndCtrl ctrlStart [tmMin.x,pStart.y,pEnd.z])
setNodeWorldRotation ctrlEndA (eulerangles 0 -90 0)
setNodeWorldRotation ctrlEndB (eulerangles 0 90 0)
....

I should just extent the function which creats the control to also handle rotations and just do this…


fnCreateHelper pos rot = (--all the important stuff here....
theNode = point pos:pos  rotation:rot 
theNode --return newly created node
)

fnCreateHelper [0,0,0] (eulerAngles 0 -45 0)


I’m trying to create a function which creates point helpers with undefined parents…


fn create parent:undefined = (
	point pos:[0,0,0] rotation:(eulerAngles 0 -45 0) parent:parent
)

create()

create parent:(teapot())

I’m aware of the alternative which would be something like


fn create parent:undefined = (
	ctrl = point pos:[0,0,0] rotation:(eulerAngles 0 -45 0)
	if parent != undefined then ctrl.parent = parent
	ctrl
)

create()

create parent:(teapot())

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

 fn create parent: = (
 	point pos:[0,0,0] rotation:(eulerAngles 0 -45 0) parent:parent
 )
 
 create()
 
 create parent:(teapot())
 

I was so close to. Darn.

Anyways I’ll have an updated version later this evening with cleaner and more efficient code and a few more controls for users.

mapped fn getEndChildren node ends:#() root:on = if not isvalidnode node then ends else
(
if root or node.children.count > 0 then for child in node.children do getEndChildren child ends:ends root:off
else if iskindof node Point do appendifunique ends node
ends
)
(
a = #()
getEndChildren selection ends:a
a
)

The variable ends in the function. What changes if i do

a = #()
getEndChildren selection ends:a
a

versus this

getEndChildren selection

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

in the first case the mapped function continues our array (a), in the second it begins new empty array for every next node.

Hey guys. Well here is the latest update.

Things done:

  • Updated and cleaned up much of the code
  • Reduced 3 functions to into one (removed redundancy)
  • Added some bug checks when creating template rigs
  • Added option to disable/enable “Auto Link upon rig creation”
  • Added rotation range
  • Added rotation stepping

Things to add/wishlist:

  • In same way incorporate Denis’s collision detection system or bounding box collision
  • In addition with the sentence above I’d like to add a checkbox which enables/disables intersection detection. I’m sure some of you may be asking why would you not want it always on, but trust me, there will be cases where you will want it off. Who wouldn’t want that control. It would be nice to have the detection try to rotate the object a few times in attempt to find and opening direction to grow. Those rotations falling within the boundaries of the users settings for rotation/steps.
  • Along with the two mentioned above, I’d like to add the option for the system to find the ‘endCap’ piece of geo, if available in the pipe list, and use that as the end piece to the pipes if they no longer can grow from their ends.

The bottom two methods are easy to add, my only question now is what do you guys thing would be a good method for intersection detection, the 3d grid/Denis’s or using a simple bounding box intersection detection? Off the top of my head the bounding box is pretty straight forward and simple. But I’m open to whatever.

Page 6 / 12