What's the name of the storage paradigm that uses cubes subdivided into 8 smaller cubes ad infinitum?
Date : March 29 2020, 07:55 AM
Hope that helps Do you mean octree?

cubes created by three.js are interfere ,parts of those cubes become transparency when rotating the camera,
Date : March 29 2020, 07:55 AM
Hope this helps What you are seeing is a limitation of CanvasRenderer due to the way it handles depthsorting. While WebGLRenderer sorts at the pixel level, CanvasRenderer sorts at the polygon level. var geometry = new THREE.CubeGeometry(width, height, depth, 1, 10, 1);

Break down cubes into 8 smaller cubes recursively (when the cubes are defined by a mid point and size)
Date : March 29 2020, 07:55 AM
I wish this helpful for you I'm still not quite sure if this is what you want, but here is how I woud do it: First, I would create a class representing points in 3D space: class Point3D:
"""Representation of a point in 3D space."""
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def __add__(self, other):
"""Add two points.
>>> Point3D(1, 2, 3) + Point3D(100, 200, 300)
Point3D(101, 202, 303)
"""
x = self.x + other.x
y = self.y + other.y
z = self.z + other.z
return Point3D(x, y, z)
def __mul__(self, a):
"""Multiply a point with a number.
>>> Point3D(1, 2, 3) * 2
Point3D(2, 4, 6)
"""
x = self.x * a
y = self.y * a
z = self.z * a
return Point3D(x, y, z)
def __rmul__(self, a):
"""Multiply a number with a point.
>>> 2 * Point3D(1, 2, 3)
Point3D(2, 4, 6)
"""
return self.__mul__(a)
def __repr__(self):
return 'Point3D({p.x}, {p.y}, {p.z})'.format(p=self)
from __future__ import division
from itertools import product
class Cube:
"""Representation of a cube."""
# directions to all eight corners of a cube
DIR = [Point3D(*s) for s in product([1, +1], repeat=3)]
def __init__(self, center, size, depth=0):
if not isinstance(center, Point3D):
center = Point3D(*center)
self.center = center
self.size = size
self.depth = depth
def __repr__(self):
return 'Cube(center={c.center}, size={c.size}, depth={c.depth})'.format(c=self)
def _divide(self):
"""Divide into eight cubes of half the size and one level deeper."""
c = self.center
a = self.size/2
d = self.depth  1
return [Cube(c + a/2*e, a, d) for e in Cube.DIR]
def divide(self, target_depth=0):
"""Recursively divide down to the given depth and return a list of
all 8^d cubes, where d is the difference between the depth of the
cube and the target depth, or 0 if the depth of the cube is already
equal to or less than the target depth.
>>> c = Cube(center=(0, 0, 0), size=2, depth=1)
>>> len(c.divide(0))
8
>>> len(c.divide(1))
64
>>> c.divide(5)[0] is c
True
>>> c.divide(1)[0].size
0.5
"""
if self.depth <= target_depth:
return [self]
smaller_cubes = self._divide()
return [c for s in smaller_cubes for c in s.divide(target_depth)]
# minDepthLevel = 0
# grid = {}
# grid[(1.5,0,0)] = [1,2]
# not sure what this ^ 1 means
cube = Cube((1.5, 0, 0), 4, 2)
grid = {c.center: [1, c.depth] for c in cube.divide(0)}

how to create a row of cubes with a random width in python
Date : March 29 2020, 07:55 AM
Hope this helps You have to make the script automatically find the name of your object and previous object each time you're iterating. Then you compute the space between the current tile and all the previous created tiles. Here is the code: import maya.cmds as cmds
import random
cubeList = cmds.ls( 'Tiles*' )
if len(cubeList) > 0:
cmds.delete( cubeList )
#create row and col list
cols = 10 # number of tiles to create
x = 1 # increment variable
arr = []
allTilesSpace = [] # cumalated space between tiles
for col in xrange (cols):
# if there is no tile to create, do nothing
if not cols:
break
# get the names of the objects
currentTile = 'Tiles%d' % x
previousTile = "Tiles%d" % (x  1)
# set random width
width_rand_Size = random.uniform(0.8,3)
arr.append(cmds.polyCube (ax = (0,0,1), w = width_rand_Size, h = 1, d =1 , n=currentTile))
# Move the tiles
currentTileWidth = cmds.polyCube(currentTile, q = 1, w = 1)
if cmds.objExists(previousTile):
previousTileWidth = cmds.polyCube(previousTile, q = 1, w = 1)
allTilesSpace.append(previousTileWidth)
tilesSpace = sum(allTilesSpace) + (currentTileWidth / 2)
cmds.setAttr(currentTile + ".tx",tilesSpace)
else:
cmds.setAttr(currentTile + ".tx", currentTileWidth / 2)
x += 1 # increment

Python script replacing objects with the cubes
Tag : python , By : appdelivery
Date : March 29 2020, 07:55 AM

