Simulation (XSISDK)

Particle Events

Examples


'VBScript example of manipulating the Emission and Goal positions via a particle event
'In this case the particles set their Goal to be their initial emission point,
'so that they chase the emitter as it moves.

NewScene

' Just lengthening the scene
SetValue "PlayControl.Out", 400

' Emitting particles from a nurbs sphere. This will work best with 
' nurbs as they have a defined parametric domain.
CreatePrim "Sphere", "NurbsSurface"
CreateParticleCloud "sphere"
SetValue "sphere.sphere_emission.Rate", 10
SetValue "sphere.sphere_emission.Speed", 2


' Setting the emitter as a goal
AddParticleGoal "cloud", "sphere"

' Particles live forever to see the effect better
SetValue "ParTypes.PType.LiveForever", True

' Add an event to set the GOAL_N_UVWI
AddParticleEvent "ParTypes.PType"
SetValue "ParTypes.PType.PEvent.EventTrigger", 2
SetValue "ParTypes.PType.PEvent.TriggerValue", 1
SetValue "ParTypes.PType.PEvent.EventAction", 6


eventCode = "set uvw = inParticle.uvw" & vbCrLf & _
	vbCrLf & _
	"set goaluvw = inParticle.attributes(" & Chr(34) & "Goal_0_UVWI" & Chr(34) & ").value" & vbCrLf & _
	vbCrLf & _
	"goaluvw.x = uvw.x" & vbCrLf & _
	"goaluvw.y = uvw.y" & vbCrLf & _
	"goaluvw.z = uvw.z" & vbCrLf & _
	vbCrLf & _
	"inParticle.attributes(" & Chr(34) & "Goal_0_UVWI" & Chr(34) & ").value = goaluvw" & vbCrLf 

SetValue "ParTypes.PType.PEvent.Script", eventCode

' A bit of animation on the sphere
SelectObj "sphere", , True
SaveKey "sphere.kine.local.posx,sphere.kine.local.posy,sphere.kine.local.posz", 1
Translate , -6.1, 0, 0, siRelative, siView, siObj, siXYZ, , , , , , , , , , 0
SaveKey "sphere.kine.local.posx,sphere.kine.local.posy,sphere.kine.local.posz", 128
Translate , 0, 7.4, 0, siRelative, siView, siObj, siXYZ, , , , , , , , , , 0
SaveKey "sphere.kine.local.posx,sphere.kine.local.posy,sphere.kine.local.posz", 264

'This example illustrates how to set the goal UVW value from the emission uv

CreatePrim "Grid", "MeshSurface"
DeselectAll
DeselectAll
SelectObj "grid", , True
CreateParticleCloud "grid"
AddParticleGoal "ParTypes.PType", "grid"
AddParticleEvent "ParTypes.PType"
SetValue "cloud.cloud.ParticlesOp.PEvent.TriggerValue", 0
SetValue "cloud.cloud.ParticlesOp.PEvent.EventAction", 6


eventCode = "set oUVW = inParticle.UVW" & vbCrLf & _
	"set oGoalUVWAttrib = inParticle.Attributes(""Goal_0_UVWI"")" & vbCrLf & _
	"set oGoalUVW = oGoalUVWAttrib.value" & vbCrLf & _
	"" & vbCrLf & _
	"oGoalUVW.x = oUVW.x" & vbCrLf & _
	"oGoalUVW.y = oUVW.y" & vbCrLf & _
	"oGoalUVWAttrib.value = oGoalUVW" & vbCrLf 

SetValue "ParTypes.PType.PEvent.Script", eventCode


This page was last modified 16:32, 6 Dec 2010.
This page has been accessed 8375 times.

© Copyright 2009 Autodesk Inc. All Rights Reserved. Privacy Policy | Legal Notices and Trademarks | Report Piracy