Changeset 349
- Timestamp:
- 11/01/02 14:02:17 (6 years ago)
- Files:
-
- trunk/RBRapier/RBRapier/Formats/Wavefront/MeshedObject.py (modified) (6 diffs)
- trunk/RBRapier/RBRapier/Renderer/Geometry/ArrayTraversal.py (modified) (2 diffs)
- trunk/RBRapier/demo/Wavefront/scene.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/RBRapier/RBRapier/Formats/Wavefront/MeshedObject.py
r345 r349 93 93 94 94 GeoObjectFactory = GeoObject 95 IndexedTraversal = ArrayTraversal.IndexedCollectionTraversal 95 96 96 97 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 162 163 else: 163 164 mesh = MeshFactory() 165 bTODOPrinted = 0 164 166 for FaceTraversal in Group.Faces: 167 if not bTODOPrinted and len(FaceTraversal) > 4: 168 print "TODO: teselate faces of more than 4 vertices" 169 print 170 bTODOPrinted = 1 165 171 v0,v1 = FaceTraversal[:2] 166 172 for v2 in FaceTraversal[2:]: … … 189 195 listdata = Group.Traversals.get('list') 190 196 if listdata: 191 Group.Traversals['list'] = ArrayTraversal.IndexedCollectionTraversal('trilist', [listdata])197 Group.Traversals['list'] = self.IndexedTraversal('trilist', [listdata]) 192 198 193 199 fandatacollection = Group.Traversals.get('fan') 194 200 if fandatacollection: 195 Group.Traversals['fan'] = ArrayTraversal.IndexedCollectionTraversal('tristrip', fandatacollection)201 Group.Traversals['fan'] = self.IndexedTraversal('tristrip', fandatacollection) 196 202 197 203 stripdatacollection = Group.Traversals.get('strip') 198 204 if stripdatacollection: 199 Group.Traversals['strip'] = ArrayTraversal.IndexedCollectionTraversal('tristrip', stripdatacollection)205 Group.Traversals['strip'] = self.IndexedTraversal('tristrip', stripdatacollection) 200 206 201 207 def OptimizeTraversals(self, level): … … 206 212 if listdata: 207 213 optimizer.Visit(listdata) 208 Group.Traversals['list'] = ArrayTraversal.IndexedCollectionTraversal('trilist', [listdata])214 Group.Traversals['list'] = self.IndexedTraversal('trilist', [listdata]) 209 215 elif listdata is not None: 210 216 del Group.Traversals['list'] … … 214 220 for fandata in fandatacollection: 215 221 optimizer.Visit(fandata) 216 Group.Traversals['fan'] = ArrayTraversal.IndexedCollectionTraversal('tristrip', fandatacollection)222 Group.Traversals['fan'] = self.IndexedTraversal('tristrip', fandatacollection) 217 223 elif fandatacollection is not None: 218 224 del Group.Traversals['fan'] … … 222 228 for stripdata in stripdatacollection: 223 229 optimizer.Visit(stripdata) 224 Group.Traversals['strip'] = ArrayTraversal.IndexedCollectionTraversal('tristrip', stripdatacollection)230 Group.Traversals['strip'] = self.IndexedTraversal('tristrip', stripdatacollection) 225 231 elif stripdatacollection is not None: 226 232 del Group.Traversals['strip'] trunk/RBRapier/RBRapier/Renderer/Geometry/ArrayTraversal.py
r345 r349 26 26 from OpenGL import GL 27 27 import Numeric 28 from Foundation.AspectOriented import Aspect 28 29 29 30 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 88 89 89 90 def Execute(self, context): 91 primitive = self.primitive 90 92 for data in self.datacollection: 93 self._glDrawElements(primitive, data) 94 95 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 96 97 class ColoredIndexedCollectionTraversal(IndexedCollectionTraversal): 98 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 99 #~ Constants / Variables / Etc. 100 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 101 102 colors = [] 103 104 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 105 #~ Public Methods 106 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 107 108 def __init__(self, primitive, datacollection, format=None): 109 IndexedCollectionTraversal.__init__(self, primitive, datacollection, format) 110 self.GenerateColors() 111 112 def GenerateColors(self): 113 import random 114 self.colors = [(.3 + .7*random.random(), .3 + .7*random.random(), .3 + .7*random.random()) for x in self.datacollection] 115 116 def Execute(self, context): 117 for color, data in zip(self.colors, self.datacollection): 118 GL.glColor3f(*color) 91 119 self._glDrawElements(self.primitive, data) 92 120 121 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 122 123 class ColoredIndexedCollectionAspect(Aspect.Aspect, ColoredIndexedCollectionTraversal): 124 pass trunk/RBRapier/demo/Wavefront/scene.py
r345 r349 59 59 self.Sequence.AddElement(self.Viewport, -2) 60 60 61 builder = MeshedObject.MeshedObjectBuilder() 62 GeoObj = builder.Build(open('data/oldtree.obj', 'r'), 1, 3) 63 self.Sequence.AddElement(GeoObj) 61 self.GeoObj = self.WavefrontOBJ('data/oldtree.obj') 62 #self.GeoObj = self.WavefrontOBJ('data/x29.obj') 64 63 65 64 GL.glEnable(GL.GL_LIGHTING) … … 68 67 69 68 #for each in self.Sequence.Elements: print each 69 70 def WavefrontOBJ(self, name, *args, **kw): 71 builder = MeshedObject.MeshedObjectBuilder() 72 GeoObj = builder.Build(open(name, 'r'), *args, **kw) 73 self.Sequence.AddElement(GeoObj) 74 return GeoObj 70 75 71 76 def Render(self, subject, canvas):
