Notifications
Clear all

[Closed] How could I solve this rotation problem?

Hey there so I was wondering if you have any tips how to solve this path follow problem. I basically need 3 different bricks to follow a long road, so I used Forest Pack plugin, unfortunately the bricks don’t rotate on the Z axis, so they look like stairs. Does anyone have any tips how to go about this? Spacing tool doesn’t work because it only uses a single object, object paint doesn’t work because it has maximum count of 500, and I need like 20000 objects.
Stairs

10 Replies

you can use spacing tool and then replace random blocks with some other

1 Reply
(@tipasz)
Joined: 10 months ago

Posts: 0

Could you elaborate on that? Spacing tool only allows 1 object to be scattered along spline, and I need 3 objects. Replacing by hand doesn’t work as I have thousands and thousands of these blocks to lay down. http://imgur.com/Cq2EQEI

do you need mesh deformation along the path as well? probably pathdeform will work for you + a little help of a script (clone objects and apply pathdeform modifier with a specified percent)
one can make something ‘tool-like’ from this snippet:

delete objects
(
	b = chamferbox width:10 length:30 height:5 widthsegs:4 lengthsegs:10 heightsegs:2 fillet:1
	c = Arc radius:50 from:300 to:200 pie:off reverse:off
	-- c = helix radius1:50 radius2:40 turnes:3 height:20 -- from:300 to:200 pie:off reverse:off
	c = converttosplineshape c
	t = tangentCurve3D c 1 0.0 
	p = interpCurve3D c 1 0.0

	b.dir = t
	b.pos = p
	in coordsys local rotate b (eulerangles 0 -90 -90)

	num = 23
	for k=0.0 to num-1 do
	(
		f = k/(num-1)
		b0 = reference b wirecolor:(b.wirecolor * (1-f*0.9))
		m = PathDeform path:c axis:0
		addmodifier b0 m
		m.percent_along_path = 100.0*f
	)
	hide b
)

If bricks have all the same length, making a working script is quite easy (but it takes time). If not, too.
Just align bricks to the spline tangent and espace their length in each iteration.
Giving randomness to them can be done too.

Well basically I have 3 different blocks modelled on my own so that’s all I want to use. I give you suggestions a shot and the script too. Basically the spacing tool works exactly how I need, but the only problem is that it obviously only takes one mesh, and I have 3 different meshes (same length but just different sculpt). If anyone has any more suggestions, fire away (This is quite urgent)

you can setup you objects with path constraint and after that just snapshot using time-range.
(it’s how I would do it if i couldn’t script)

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0
try(destroydialog passThePath) catch()
rollout passThePath "Pass The Path with denisT" width:200
(
	spinner number_things_sp "Number Things: " range:[1,100000,100] type:#integer fieldwidth:56 align:#right offset:[4,0]
	button doit_bt "Scatter Things" width:184 align:#right offset:[4,0]
	button delete_bt "Delete Things" width:184 align:#right offset:[4,0]
	
	on delete_bt pressed do undo "Delete" on
	(
		nodes = $things* as array
		if nodes.count > 0 then
		(
			select nodes
			delete selection
		)
	)
	
	on doit_bt pressed do undo "Pass The Path" on 
	(
		paths = #()
		things = #()
		for node in selection do 
		(
			append (if iskindof node shape then paths else things) node
		)
		if paths.count == 1 and things.count > 0 do
		(
			num = number_things_sp.value
			step = 1.0/(num-1)
			
			pc = path_constraint path:paths[1] axis:1 follow:on constantVel:on 
			
			for k=0 to num-1 do
			(
				maxops.clonenodes things cloneType:#instance newNodes:&newNodes
				gr = group newNodes name:(uniquename #things)
				
				c = gr.position.controller = copy pc
				c.percent.controller.keys[2].time = num

				c.percent = k*100.0*step
				tm = gr.transform
				gr.controller = createinstance prs
				gr.transform = tm
			)
		)
	)
)
createdialog passThePath


/********** the sample scene ************

delete objects
(
	c = cylinder radius:30 height:130 wirecolor:green
	centerpivot c
	rotate c (eulerangles 0 90 0)

	b1 = box width:33 length:65 height:150 wirecolor:orange
	move b1 [-75,0,0]
	b2 = box width:33 length:65 height:100 wirecolor:yellow
	move b2 [75,0,0]

	p = helix radius1:1000 radius2:300 turns:1.5 height:0 wirecolor:red
)

**********************************************/

make a sample scene
run script
select all
set the number of things
press the button “Scatter Things”

PS. THIS IS NOT A TOOL! it’s only a teaching material.

try (destroydialog X ) catch ()
 rollout X "" (
	 
	button getblocks "get nodes"
	button replacebtn "replace"	 
	local nodes
	
	on getblocks pressed do if selection.count > 0 then ( nodes = selection as array; getblocks.text = "nodes: " + nodes.count as string)
		
	on replacebtn pressed do if selection.count > 0 then (

		for s in selection as array do ( b = instance nodes[random 1 nodes.count]; b.transform = s.transform; delete s )
		
		nodes = undefined
		getblocks.text = "get nodes"
		
	)
	 
)
 createDialog X pos:[100,100]

select your three blocks, press get nodes
then select all roadblocks and replace

1 Reply
(@tipasz)
Joined: 10 months ago

Posts: 0

That’s actually perfect, thank you so much.

hmm… how can it work?