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 z in range(vol.getDepth()):
|
||||||
for y in range(vol.getHeight()):
|
for y in range(vol.getHeight()):
|
||||||
for x in range(vol.getWidth()):
|
for x in range(vol.getWidth()):
|
||||||
#Store our current position as a vector...
|
#Compute how far the current position is from the center of the volume
|
||||||
v3dCurrentPos = pv.Vector3Dint32_t(x,y,z)
|
fDistToCenter = (pv.Vector3Dint32_t(x,y,z) - v3dVolCenter).length()
|
||||||
#And compute how far the current position is from the center of the volume
|
|
||||||
fDistToCenter = (v3dCurrentPos - v3dVolCenter).length()
|
|
||||||
|
|
||||||
uVoxelValue = 0
|
|
||||||
|
|
||||||
#If the current voxel is less than 'radius' units from the center then we make it solid.
|
#If the current voxel is less than 'radius' units from the center then we make it solid.
|
||||||
if(fDistToCenter <= sphereRadius):
|
if(fDistToCenter <= sphereRadius):
|
||||||
#Our new voxel value
|
#Our new voxel value
|
||||||
uVoxelValue = 255
|
uVoxelValue = 255
|
||||||
|
else:
|
||||||
|
uVoxelValue = 0
|
||||||
|
|
||||||
#Write the voxel value into the volume
|
#Write the voxel value into the volume
|
||||||
vol.setVoxelAt(x, y, z, uVoxelValue);
|
vol.setVoxelAt(x, y, z, uVoxelValue);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user