update docs

This commit is contained in:
Philip Rideout 2013-02-06 21:27:16 -08:00
parent 8c6785594c
commit bb6fd9489b
5 changed files with 29 additions and 23 deletions

View File

@ -201,7 +201,7 @@ find_package(OpenCL 1.1)
find_package(CUDA 4.0)
find_package(GLFW 2.7.0)
find_package(PTex 2.0)
find_package(PythonInterp 2.6)
find_package(PythonInterp 2.7)
find_package(SWIG)
if (NOT APPLE AND OPENGL_FOUND)

View File

@ -90,10 +90,9 @@ def main():
(1,7,5,3), # 4
(6,0,2,4) ] # 5
dtype = np.dtype([
('Px', np.float32),
('Py', np.float32),
('Pz', np.float32)])
dtype = [ ('x', np.float32),
('y', np.float32),
('z', np.float32) ]
topo = osd.Topology(faces)
topo.boundaryMode = osd.BoundaryMode.EDGE_ONLY
@ -105,7 +104,7 @@ def main():
subdivider = osd.Subdivider(
topo,
vertexLayout = dtype,
vertexLayout = 'f4, f4, f4',
indexType = np.uint32,
levels = 4)
subdivider.setCoarseVertices(verts)

View File

@ -10,29 +10,35 @@ The Python module for OpenSubdiv does not provide one-to-one wrapping of the nat
We do not yet support rendering or GPU-accelerated subdivision from Python, but a demo is provided that renders a subdivided surface using ``PyOpenGL`` and ``QGLWidget``. The demo uses a "modern" OpenGL context (Core Profile).
These bindings leverage numpy_ arrays for passing data. The numpy library is a de facto standard for encapsulating large swaths of typed data in Python. However, for special attributes (such as sharpness), the OpenSubdiv wrapper exposes Pythonic interfaces, using properties and list accessors. For example::
These bindings leverage numpy_ arrays for passing data. The numpy library is the de facto standard for encapsulating large swaths of typed data in Python. However, for special attributes (such as sharpness), the OpenSubdiv wrapper exposes Pythonic interfaces, using properties and list accessors. For example::
import osd
import numpy as np
faceList = np.array([[0,1,2,3],[0,1,6,7]])
topo = osd.Topology(faceList)
topo.vertices[2].sharpness = 1.3
topo.faces[0].edges[3].sharpness = 0.6
import osd
import numpy as np
faceList = np.array([[0,1,2,3],[0,1,6,7]])
topo = osd.Topology(faceList)
topo.vertices[2].sharpness = 1.3
topo.faces[0].edges[3].sharpness = 0.6
After constructing a :class:`osd.Topology` object, clients should finalize it and pass it into a :class:`osd.Subdivider` instance::
After constructing a :class:`osd.Topology` object, simply finalize it and pass it into a :class:`osd.Subdivider` instance::
topo.finalize()
subdivider = osd.Subdivider(
topo,
vertexLayout = [np.float32] * 3,
topology = topo,
vertexLayout = np.dtype('f4, f4, f4'),
indexType = np.uint32,
levels = 4)
The final step is to perform actual refinement. This often occurs inside an animation loop or callback function::
subdivider.setCage(positions)
subdivider.setCoarseVertices(positions)
subdivider.refine()
pts = subdivider.getRefinedVertices()
Only uniform subdivision is supported from Python, which means the topology of the subdivided mesh will never change::
indices = subdivider.getRefinedQuads()
This returns a flat list of indices (four per quad) using the integer type that was specified as the ``indexType`` argument in the constructor.
.. _numpy: http://www.numpy.org

View File

@ -70,7 +70,7 @@ class Subdivider(object):
:param topo: Finalized mesh topology.
:type topo: :class:`osd.Topology`
:param vertexLayout: Describes the data structure composing each vertex.
:type vertexLayout: record-style numpy data type_ object
:type vertexLayout: numpy dtype_ object or short-hand string
:param indexType: Integer type for the indices returned from `getRefinedTopology`.
:type indexType: single numpy type_
:param levels: Number of subdivisions.
@ -80,11 +80,11 @@ class Subdivider(object):
composed of ``numpy.float32``, and ``indexType`` must be
``numpy.uint32``.
.. _types: http://docs.scipy.org/doc/numpy/user/basics.types.html
.. _type: http://docs.scipy.org/doc/numpy/user/basics.types.html
.. _dtype: http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html
'''
def __init__(self, topo, vertexLayout, indexType, levels):
def __init__(self, topology, vertexLayout, indexType, levels):
if levels < 2:
raise TopoError("Subdivision levels must be 2 or greater")
if type(vertexLayout) != numpy.dtype:
@ -92,7 +92,7 @@ class Subdivider(object):
self.vertexLayout = vertexLayout
self.indexType = indexType
self.levels = levels
self.shim = shim.Subdivider(topo.shim, vertexLayout, indexType, levels)
self.shim = shim.Subdivider(topology.shim, vertexLayout, indexType, levels)
# Calls UpdateData on the vertexBuffer.
def setCoarseVertices(self, coarseVerts, listType = None):

View File

@ -76,8 +76,9 @@ class Topology(object):
valence, clients can pass in a single integer for
``valences``.
If desired, simple Python lists can be used in lieu of numpy
arrays.
If desired, simple Python lists can be passed in rather than numpy
arrays. However they will get converted into numpy arrays
internally.
.. note:: Input data is always copied to internal storage,
rather than referenced.