Python Reference Guide
 
Loading...
Searching...
No Matches
Samples\Geometry\GeometryInstancing.py
1# Copyright 2009 Autodesk, Inc. All rights reserved.
2# Use of this software is subject to the terms of the Autodesk license agreement
3# provided at the time of installation or download, or which otherwise accompanies
4# this software in either electronic or hard copy form.
5#
6# This script is to demonstrate the ssimple geometry creation and gemoetry instancing feature.
7#
8# Topic: FBMesh, FBVector3d, FBModelTransformationType, FBModelShadingMode
9#
10from pyfbsdk import FBMesh, FBModelCube, FBVector3d, FBModelTransformationType, FBModelShadingMode
11
12# Create the custom mesh
13lMesh = FBMesh("myGeom")
14
15# Alway call GeometryBegin() / GeometryEnd() in pair when editting geometry.
16lMesh.GeometryBegin()
17
18# Call VertexInit() to resize or reserve vertex/normal array.
19# pResize = true, work with known vertex count and VertexSet() function.
20# pResize = false, work with dynamical vertex count and VertexAdd() function.
21lMesh.VertexInit(4, False, False)
22
23lMesh.VertexAdd(0, 100, 0) # vertex 0
24lMesh.VertexAdd(100,100, 0) # vertex 1
25lMesh.VertexAdd(100, 0, 0) # vertex 2
26lMesh.VertexAdd(0, 0, 0) # vertex 3
27
28# Add a Polygon
29lMesh.PolygonBegin()
30lMesh.PolygonVertexAdd(0) # add polygon vertex 0
31lMesh.PolygonVertexAdd(1) # add polygon vertex 1
32lMesh.PolygonVertexAdd(2) # add polygon vertex 2
33lMesh.PolygonVertexAdd(3) # add polygon vertex 3
34# Polygon add End
35lMesh.PolygonEnd()
36
37# Compute mesh vertex normal with Counter Clock-Wise order
38lMesh.ComputeVertexNormals(True)
39
40# Alway call GeometryBegin() / GeometryEnd() in pair when editting geometry.
41lMesh.GeometryEnd()
42
43# And we use Geometry Instancing feature to share this simple plane among multiple models.
44for lIndex in range(1, 10):
45 #create a cube but we will replace its geometry
46 lModel = FBModelCube("myModel")
47
48 # Replace the geometry instance
49 lModel.Geometry = lMesh
50
51 lModel.SetVector( FBVector3d(120*lIndex - 600, 50, 50 ) )
52
53 # Let's use a different shading mode.
54 if (lIndex > 5):
55 lModel.ShadingMode = FBModelShadingMode.kFBModelShadingWire
56
57 # The object must be set visible to be present in the system.
58 lModel.Visible = True
59 lModel.Show = True
60
61
62# Cleanup.
63del( lModel, lMesh, FBMesh, FBModelCube, FBVector3d, FBModelTransformationType, FBModelShadingMode )
Mesh class.
Definition: pyfbsdk_generated.h:10849
Cube model class.
Definition: pyfbsdk_generated.h:11337