[MAX]Tire tracks
Posted: Fri Oct 24, 2008 10:13 am
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
You can also download the script here: TireTracks
------------------------------------------------------------------------------------------------------------------------------
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
(
)
------------------------------------------------------------------------------------------------------------------------------