wrap.Geom

class wrap.Geom(fileName, scaleFactor=1.0, fitToView=True)

Polygonal 3D-model

Parameters:

filename : string

Filename of the obj file from which geometry will be loaded.

scaleFactor : float

If a scale of the model is very small i.e. the model size does not exceed 1.0, it might lead to round-off errors. If this is the case please pre-scale the model to some reasonable scale (say 1000.0) and downscale it back (say 1 / 1000.0) before saving.

fitToView : bool

Fit model to view in 3D-viewport immediately after loading

Examples

Loading model from file

geom = wrap.Geom("fileName.obj",scaleFactor = 1000.0)

is equal to

geom = wrap.Geom("fileName.obj")
geom.scale(1000.0)

Setting display properties:

geom.color = (128,255,0)
geom.wireframe = True
geom.shading = True

Hiding model from viewport:

geom.hide()

Fitting geometry to view:

geom.fitToView()

Assigning a texture to model:

texture = wrap.Geom("fileName.jpg")
geom.texture = texture

Copying and transforming the model:

geomCopy = geom.copy()
xSize = geom.boundingBoxSize[0]
geomCopy.translate(xSize,0,0)

Saving model to file:

geom.save("fileName.obj",scaleFactor = 1.0 / 1000)

Attributes

nVertices (int, read-only) The number of vertices in mesh
nPolygons (int, read-only) The number of polygons in mesh
nTriangles (int, read-only) The number of triangles in triangulated version of the mesh
texture (wrap.Image) Texture, defaults to None
boundingBoxSize (tuple, read-only) Size of axis-aligned bounding box of the mesh returned as tuple (x,y,z)
color (sequence of int, visual) Controls model color in viewport
wireframe (bool, visual) Defines if wireframe is visible in viewport. Defaults to True
shaded (bool, visual) Defines if the model appears shaded in viewport. Defaults to True
polygroups (list of string, read-only) List of polygroup names

Methods

copy() Copy geometry
fitToView() Fit model to view in 3D-viewport.
hide() Hide model from 3D-viewport.
nearestVertexInd(x, y, z) For point (x,y,z) returns index of nearest vertex in the mesh
pointOnTriangleToPoint(pointOnTriangle) Returns world-space 3D coordinate of PointOnTriangle
pointToPointOnTriangle(x, y, z[, maxDistance]) Convert arbitrary point in 3D to wrap.PointOnTriangle by projecting point onto closest triangle of mesh.
save(fileName[, scaleFactor]) Save model to OBJ-file with pre-scaling.
scale(scaleFactor) Scale model to scaleFactor.
selectPolygonsByPolygroup(polygroup) Select polygons by polygroup
show() Show model in 3D-viewport.
transform(transformationMatrix) Transform the model with transformation matrix.
translate(x, y, z) Translate the model in x,y,z directions.
vertexIndToPointOnTriangle(vertexInd) Convert mesh’s vertex to corresponding wrap.PointOnTriangle