An-Cadsolutions      Imgsystems

Kirjoittaja Aihe: [3dsMax] Fake Point Cloud  (Luettu 264 kertaa)

xcx

  • Administrator
  • *****
  • Viestejä: 2302
  • Sukupuoli: Mies
    • Profiili
    • Verajankorva.com
    • Sähköposti
[3dsMax] Fake Point Cloud
« : Tammikuu 12, 2011, 11:33:51 am »
Tarvitsen point cloudin näköistä höttöä 3d scenestä, joten modasin BoBon raytrace rendaajasta fake point cloud scriptin.

Scripti ampuu randomisti säteitä kamerasta valitun viewportin alueelle ja pistää pallon siihen kohtaan mihin säde osuu (jos osuu mihinkään).

iRayCount on säteiden määrä. Isompi luku tähän niin tulee enempi palloja ( ja varovaisuutta, maxi menee tosi nopsaan polvilleen ).

Koodia: [Valitse]
(
iRayCount = 20000

progressStart "Raytracing"
st = timestamp()
theObjects = for o in geometry where not o.isHidden and classof o != TargetObject collect o
meshSel = mesh_select()
for o in theObjects do
addModifier o meshSel
theView = getViewSize()
for i = 1 to iRayCount do
(
for o = 1 to theObjects.count do
(
x = floor (random 0.0 1.0 * ((getViewSize()).x-1))
y = floor (random 0.0 1.0 * ((getViewSize()).y-1))
theObj = theObjects[o]
        theInt = intersectRayEx theObj (mapScreenToWorldRay [x,y])
if theInt != undefined do
(
s = Sphere()
s.segments = 4
s.radius = 0.1
s.pos = theInt[1].pos
--selectMore s
)
)
progressUpdate (100.0/(iRayCount as float) * (i as float))
)

for o in theObjects do deleteModifier o meshSel

pushprompt ("RayScript: " + ((timestamp() - st)/1000) as string + " sec.")
progressEnd()

gc()
)

Senior Technical Artist - Remedy Games
http://www.verajankorva.com