diff --git a/.gitignore b/.gitignore index 2fa39a9..b13b36d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ __pycache__ +*.pyc # Build and test directories /.tox diff --git a/demosys/geometry/cube.py b/demosys/geometry/cube.py index 62e651c..ea623f7 100644 --- a/demosys/geometry/cube.py +++ b/demosys/geometry/cube.py @@ -3,13 +3,14 @@ from demosys.opengl import VAO -def cube(width, height, depth, normals=True, uvs=True): +def cube(width, height, depth, center=(0.0, 0.0, 0.0), normals=True, uvs=True) -> VAO: """ - Generates a cube VAO + Generates a cube VAO. The cube center is (0.0, 0.0 0.0) unless other is specified. :param width: Width of the cube :param height: height of the cube :param depth: depth of the cube + :param center: center of the cube :param normals: (bool) Include normals :param uvs: (bool) include uv coordinates :return: VAO representing the cube @@ -17,42 +18,42 @@ def cube(width, height, depth, normals=True, uvs=True): width, height, depth = width / 2.0, height / 2.0, depth / 2.0 pos = numpy.array([ - width, -height, depth, - width, height, depth, - -width, -height, depth, - width, height, depth, - -width, height, depth, - -width, -height, depth, - width, -height, -depth, - width, height, -depth, - width, -height, depth, - width, height, -depth, - width, height, depth, - width, -height, depth, - width, -height, -depth, - width, -height, depth, - -width, -height, depth, - width, -height, -depth, - -width, -height, depth, - -width, -height, -depth, - -width, -height, depth, - -width, height, depth, - -width, height, -depth, - -width, -height, depth, - -width, height, -depth, - -width, -height, -depth, - width, height, -depth, - width, -height, -depth, - -width, -height, -depth, - width, height, -depth, - -width, -height, -depth, - -width, height, -depth, - width, height, -depth, - -width, height, -depth, - width, height, depth, - -width, height, -depth, - -width, height, depth, - width, height, depth, + center[0] + width, center[1] - height, center[2] + depth, + center[0] + width, center[1] + height, center[2] + depth, + center[0] - width, center[1] - height, center[2] + depth, + center[0] + width, center[1] + height, center[2] + depth, + center[0] - width, center[1] + height, center[2] + depth, + center[0] - width, center[1] - height, center[2] + depth, + center[0] + width, center[1] - height, center[2] - depth, + center[0] + width, center[1] + height, center[2] - depth, + center[0] + width, center[1] - height, center[2] + depth, + center[0] + width, center[1] + height, center[2] - depth, + center[0] + width, center[1] + height, center[2] + depth, + center[0] + width, center[1] - height, center[2] + depth, + center[0] + width, center[1] - height, center[2] - depth, + center[0] + width, center[1] - height, center[2] + depth, + center[0] - width, center[1] - height, center[2] + depth, + center[0] + width, center[1] - height, center[2] - depth, + center[0] - width, center[1] - height, center[2] + depth, + center[0] - width, center[1] - height, center[2] - depth, + center[0] - width, center[1] - height, center[2] + depth, + center[0] - width, center[1] + height, center[2] + depth, + center[0] - width, center[1] + height, center[2] - depth, + center[0] - width, center[1] - height, center[2] + depth, + center[0] - width, center[1] + height, center[2] - depth, + center[0] - width, center[1] - height, center[2] - depth, + center[0] + width, center[1] + height, center[2] - depth, + center[0] + width, center[1] - height, center[2] - depth, + center[0] - width, center[1] - height, center[2] - depth, + center[0] + width, center[1] + height, center[2] - depth, + center[0] - width, center[1] - height, center[2] - depth, + center[0] - width, center[1] + height, center[2] - depth, + center[0] + width, center[1] + height, center[2] - depth, + center[0] - width, center[1] + height, center[2] - depth, + center[0] + width, center[1] + height, center[2] + depth, + center[0] - width, center[1] + height, center[2] - depth, + center[0] - width, center[1] + height, center[2] + depth, + center[0] + width, center[1] + height, center[2] + depth, ], dtype=numpy.float32) if normals: diff --git a/docs/source/reference/geometry.rst b/docs/source/reference/geometry.rst index c6c2295..7c6adc5 100644 --- a/docs/source/reference/geometry.rst +++ b/docs/source/reference/geometry.rst @@ -12,7 +12,7 @@ Functions .. autofunction:: quad_fs() -> VAO .. autofunction:: quad_2d(width, height, xpos=0.0, ypos=0.0) -> VAO -.. autofunction:: cube(width, height, depth, normals=True, uvs=True) -> VAO +.. autofunction:: cube(width, height, depth, center=(0.0, 0.0, 0.0), normals=True, uvs=True) -> VAO .. autofunction:: bbox(width=1.0, height=1.0, depth=1.0) -> VAO .. autofunction:: plane_xz(size=(10, 10), resolution=(10, 10)) -> VAO .. autofunction:: points_random_3d(count, range_x=(-10.0, 10.0), range_y=(-10.0, 10.0), range_z=(-10.0, 10.0), seed=None) -> VAO