Page 1 of 1

[MAX]Tire tracks

Posted: Fri Oct 24, 2008 10:13 am
by Carl Buhre
Tire tracks

Description: This is a script that can be used to generate tire track particles.

-- 0. Create a PF Source for each tire and place them slightly above the tire bottoms and then link each
-- PF Source to its respective "WheelCenterMesh" (PF Source arrow pointing downwards).
-- 1. Open the Particle Flow dialog (press 6).
-- 2. For each PF Source remove all operators except the "Display" operator and change its "View" type to Geometry.
-- 3. Now add a BirthScript operator to each, press the "edit script" button and replace the code with this script.
-- In the script function "on Init pCont do", set the "initFrame" as the start frame.
-- Change $'PF Source 01' to the name of your PF Source.
-- Set the "distBetweenParticles" to be slightly smaller than your geometry.
-- 4. Add a Shape Instance operator and select the geometry instance you wish to output, eg an alpha mapped face with your track mark.
-- 5. Add a Cache operator and set it to "use at: viewport/render"
-- 6. Before rendering you must play back the whole scene for the particles to be correctly cached.
-- 7. Also play back with "Real Time" unchecked in the "Time Configuration" dialog.

NB: This script is a bit crude since the rotations are not interpolated.

Created: sep 2006
Last Updated: oct 2008

Author : Luigi Tramontana @ Craft Animations
Version: 3ds max 7 and up

Code: Select all

-- Tire tracks
-- 
-- Description: This is a script that can be used to generate tire track particles.
-- 
-- 0. Create a PF Source for each tire and place them slightly above the tire bottoms and then link each 
--     PF Source to its respective "WheelCenterMesh" (PF Source arrow pointing downwards).
-- 1. Open the Particle Flow dialog (press 6).
-- 2. For each PF Source remove all operators except the "Display" operator and change its "View" type to Geometry.
-- 3. Now add a BirthScript operator to each, press the "edit script" button and replace the code with this script. 
--     In the script function "on Init pCont do", set the "initFrame" as the start frame. 
--     Change $'PF Source  01' to the name of your PF Source. 
--     Set the "distBetweenParticles" to be slightly smaller than your geometry.
-- 4. Add a Shape Instance operator and select the geometry instance you wish to output, eg an alpha mapped face with your track mark.
-- 5. Add a Cache operator and set it to "use at: viewport/render"
-- 6. Before rendering you must play back the whole scene for the particles to be correctly cached. 
-- 7. Also play back with "Real Time" unchecked in the "Time Configuration" dialog. 
-- 
-- NB: This script is a bit crude since the rotations are not interpolated.
-- 
-- Created: sep 2006
-- Last Updated: oct 2008
-- 
-- Author : Luigi Tramontana @ Craft Animations
-- Version: 3ds max 7 and up
-- 
on ChannelsUsed pCont do
(
	 pCont.useTime = true
	 pCont.useAge = true
	 pCont.usePosition = true
	 pCont.useOrientation = true
	 pCont.useSpeed = true
)

on Init pCont do 
(
	global initFrame = 0f --sliderTime as float
	global PFSource = $'PF Source 01'
	global distBetweenParticles = 0.3

	global initTime = initFrame as float
	global distToPrevParticle = 0.0 
	global PFEuler = 0.0

)

on Proceed pCont do 
(
	sTime = sliderTime as float
	previousParticlePos =  pCont.particlePosition
	previousParticleTime =  pCont.particleTime

	if( sliderTime < initFrame + 1f and sliderTime >= initFrame) then
	(
		pCont.AddParticle()
		pCont.particleIndex = pCont.NumParticles() -- last particle that was added
		pCont.particleTime = sTime
		pCont.particleAge = 0
		pCont.particlePosition = PFSource.pos
		PFEuler = PFSource.rotation as eulerAngles
		pCont.particleOrientation = [PFEuler.x,PFEuler.y,PFEuler.z]
		pCont.particleSpeed = [0, 0, 0]
		previousParticlePos =  pCont.particlePosition
		previousParticleTime =  pCont.particleTime
	)
	if( sliderTime >= initFrame + 1f) then
	(
		particlesSinceLastDrop = ((length (PFSource.pos - previousParticlePos))/distBetweenParticles) as float
		particlesSinceLastDrop_int = particlesSinceLastDrop as integer 
		i = particlesSinceLastDrop as integer
		while ( i > 0) do 
		(
			pCont.AddParticle()
			pCont.particleIndex = pCont.NumParticles() -- last particle that was added
			pCont.particleTime = previousParticleTime + (particlesSinceLastDrop_int + 1 - i)*(sTime - previousParticleTime)/(particlesSinceLastDrop) 
			pCont.particleAge = 0
			pCont.particlePosition = previousParticlePos + (particlesSinceLastDrop_int + 1 - i)*(PFSource.pos - previousParticlePos)/(particlesSinceLastDrop)
			PFEuler = PFSource.rotation as eulerAngles
			pCont.particleOrientation = [PFEuler.x,PFEuler.y,PFEuler.z]
			pCont.particleSpeed = [0, 0, 0]
			i = i - 1
		)
	)
)



on Release pCont do 
(
 
)
You can also download the script here: TireTracks
------------------------------------------------------------------------------------------------------------------------------

Re: Useful Scripts for SpeedAnimation: 3ds MAX

Posted: Tue Dec 09, 2008 9:39 pm
by trimvein
Hello, I am getting this error message from the PF Source Script.

UNHANDLED EXCEPTION: Calling EvalWorldState() for node PF Source -03>Event 01' at time 3360
Last Marker is at . \src\staticmeshinfo.cpp, line 475: staticmeshInfo::buildNormals()


Can you help me????

Thanks

JT

Re: Useful Scripts for SpeedAnimation: 3ds MAX

Posted: Thu Dec 11, 2008 2:01 am
by trimvein
I have followed the steps you stated and i am still having some issues. I have some decent knowledge of particles in max and some useful scripting however....

My tread is being created but it's not going straight and it's all over the place. I mean literally it follows it's parent, but the tread itself is all over the place in circles and flipping all randomly along the path. In the Event of the PF Source do I need to have the POSITION, SPEED, ROTATION?


Image

Image

Image

Re: Useful Scripts for SpeedAnimation: 3ds MAX

Posted: Fri Dec 12, 2008 11:53 am
by Luigi Tramontana
Ok, I see I forgot to add some steps. Please read the instructions again (:
(ps. my guess is that your particles were both rotating and flying away)

Re: [MAX]Tire tracks

Posted: Wed Mar 17, 2010 3:16 pm
by niksoftarg
Hi I can´t seem to make this works, I am using 3dsmax 2009, I basically get instanced copys of the whole tire, not the tread, do I have to remodel the tread and put it into a path deform?

Image

Re: [MAX]Tire tracks

Posted: Wed Mar 17, 2010 6:14 pm
by niksoftarg
Hi again, I think I understand now, I have to model the basic pattern of the tire as a mesh, then the particle flow with make the array automatically, my new question is: do I really need the script?, a birth operator won´t do the same thing?

Re: [MAX]Tire tracks

Posted: Sat Jan 29, 2011 8:52 am
by chillyche
niksoftarg wrote:Hi I can´t seem to make this works, I am using 3dsmax 2009, I basically get instanced copys of the whole tire, not the tread, do I have to remodel the tread and put it into a path deform?
]
I think you're supposed to be using a special particle that's a simple plane or single face, with a map of your tire track. Not actually using your tire's mesh.