mattjakob
02-03-2010, 07:28 PM
In an attempt to solve a tedious issue (see my previous post) about having particles instantiated with different shape nodes (and each shape made of multiple meshes/materials) I went for hardcode/bruteforce creating an array of copies of my "template" shapes and then assigning each of the copies a corresponding TM matrix based on a corresponding particle.
It works, my only problem is that the automatic duplication of my objects happens twice (so I end up having double the number of meshes... which since Im planning to use several thousands objects turns out to be problematic)
on ChannelsUsed pCont do
(
pCont.useTM = true
)
on Init pCont do
(
global theMesh = #()
theCount = $Birth01.Amount
tmp = theMesh.count
if (tmp == 0 ) then
(
for i = 1 to theCount do
(
switch = mod i 12
case of
(
(switch == 12) : theMesh[i] = snapshot $SRC_01
( (switch == 3) or (switch == 6) or (switch == 9) ) : theMesh[i] = snapshot $SRC_03
default : theMesh[i] = snapshot $SRC_02
)
)
)
)
on Proceed pCont do
(
count = pCont.NumParticles()
theMesh.pos = [0,0,-10000]
for i in 1 to count do
(
pCont.particleIndex = i
theID = pCont.particleID
theMesh[theID].transform = pCont.particleTM
)
)
on Release pCont do
(
)
the problem is with the on Init pCont that gets executed twice. Really have no idea why.
Thanks,
It works, my only problem is that the automatic duplication of my objects happens twice (so I end up having double the number of meshes... which since Im planning to use several thousands objects turns out to be problematic)
on ChannelsUsed pCont do
(
pCont.useTM = true
)
on Init pCont do
(
global theMesh = #()
theCount = $Birth01.Amount
tmp = theMesh.count
if (tmp == 0 ) then
(
for i = 1 to theCount do
(
switch = mod i 12
case of
(
(switch == 12) : theMesh[i] = snapshot $SRC_01
( (switch == 3) or (switch == 6) or (switch == 9) ) : theMesh[i] = snapshot $SRC_03
default : theMesh[i] = snapshot $SRC_02
)
)
)
)
on Proceed pCont do
(
count = pCont.NumParticles()
theMesh.pos = [0,0,-10000]
for i in 1 to count do
(
pCont.particleIndex = i
theID = pCont.particleID
theMesh[theID].transform = pCont.particleTM
)
)
on Release pCont do
(
)
the problem is with the on Init pCont that gets executed twice. Really have no idea why.
Thanks,
