[Closed] meshop inside script operator
Hi everyone,
I set a bitmap image on a plane in 3dsMax and from particle view i’m creating a particle flow parallel to the plane.I’m using the intersectrayex command in every particle in every frame at first, and i’m trying to collect the rgb color data of each pixel in the intersection of the ray with the plane, with the script below. I tried the following script in maxscript editor in a static scene, and it worked perfectly. However when i tried to put this in a script operator in particle view it doesn’t work and i think that it has something to do with the meshop. commands or the mesh in general. I tried both snapshotAsMesh and convertToMesh command. With snapshotAsMesh it doesn’t work at all and with convertToMesh it finds theInt value
(without the if t1==0 loop) however when i put the meshop. commands it doesn’t work either.
So, i attach the script below. Any thought or help is welcomed.
Thanks
on Proceed pCont do
(
t1 = pCont.getTimeStart() as float
t2 = pCont.getTimeEnd() as float
count = pCont.NumParticles()
if t1==0 do
(
myObj1= snapshotAsMesh $Object002
--myObj1= convertToMesh $Object002
theBitmap= openBitmap myObj1.material.diffusemap.filename
theBitmapWidth= theBitmap.width-1
theBitmapHeight= theBitmap.height-1
)
--myObj1= convertToMesh $Object002
--myObj1= snapshotAsMesh $Object002
for i in 1 to count do
(
pCont.particleIndex = i
a = pCont.particlePosition
theRay= ray a [0,0,-1]
theInt = intersectRayEx myObj1 theRay
theMapFace= meshop.getMapFace myObj1 1 theInt[2]
theMapVert1=meshop.getMapVert myObj1 1 theMapFace.x
theMapVert2=meshop.getMapVert myObj1 1 theMapFace.y
theMapVert3=meshop.getMapVert myObj1 1 theMapFace.z
theUVCoords= theMapVert1*theInt[3].x +theMapVert2*theInt[3].y +theMapVert3*theInt[3].z
theUVCoords.x= mod theUVCoords.x 1.0
theUVCoords.y= mod theUVCoords.y 1.0
thePixels= getPixels theBitmap [theUVCoords.x*theBitmapWidth, theBitmapHeight - theUVCoords.y*theBitmapHeight] 1
)
)
this should do (first make sure that $Object002 is a mesh):
on ChannelsUsed pCont do
(
pCont.useTime = true
pCont.useSpeed = true
pCont.usePosition = true
)
on Init pCont do
(
)
on Proceed pCont do
(
t1 = pCont.getTimeStart() as float
t2 = pCont.getTimeEnd() as float
count = pCont.NumParticles()
myObj1 = $Object002
theBitmap= openBitmap myObj1.material.diffusemap.filename
theBitmapWidth= theBitmap.width-1
theBitmapHeight= theBitmap.height-1
for i in 1 to count do
(
pCont.particleIndex = i
a = pCont.particlePosition
theRay= ray a [0,0,-1]
theInt = intersectRayEx myObj1 theRay
theMapFace= meshop.getMapFace myObj1 1 theInt[2]
theMapVert1=meshop.getMapVert myObj1 1 theMapFace.x
theMapVert2=meshop.getMapVert myObj1 1 theMapFace.y
theMapVert3=meshop.getMapVert myObj1 1 theMapFace.z
theUVCoords= theMapVert1*theInt[3].x +theMapVert2*theInt[3].y +theMapVert3*theInt[3].z
theUVCoords.x= mod theUVCoords.x 1.0
theUVCoords.y= mod theUVCoords.y 1.0
thePixels= getPixels theBitmap [theUVCoords.x*theBitmapWidth, theBitmapHeight - theUVCoords.y*theBitmapHeight] 1
print thePixels
)
)
on Release pCont do
(
)