Slightly simplify the Python code in the example
This is in preparation for the Python bindings manual chapter I'm writing at the moment.
This commit is contained in:
parent
1d643becc5
commit
7473cd4458
@ -39,17 +39,15 @@ sphereRadius = 30
|
||||
for z in range(vol.getDepth()):
|
||||
for y in range(vol.getHeight()):
|
||||
for x in range(vol.getWidth()):
|
||||
#Store our current position as a vector...
|
||||
v3dCurrentPos = pv.Vector3Dint32_t(x,y,z)
|
||||
#And compute how far the current position is from the center of the volume
|
||||
fDistToCenter = (v3dCurrentPos - v3dVolCenter).length()
|
||||
|
||||
uVoxelValue = 0
|
||||
#Compute how far the current position is from the center of the volume
|
||||
fDistToCenter = (pv.Vector3Dint32_t(x,y,z) - v3dVolCenter).length()
|
||||
|
||||
#If the current voxel is less than 'radius' units from the center then we make it solid.
|
||||
if(fDistToCenter <= sphereRadius):
|
||||
#Our new voxel value
|
||||
uVoxelValue = 255
|
||||
else:
|
||||
uVoxelValue = 0
|
||||
|
||||
#Write the voxel value into the volume
|
||||
vol.setVoxelAt(x, y, z, uVoxelValue);
|
||||
|
Loading…
x
Reference in New Issue
Block a user