From: Jamie R. <jam...@gm...> - 2009-07-29 16:56:52
|
Sure, here is a scaled down version of the surface demo. I expect to see only one triangle after the "clearSurface" but I still see two. Thanks - jamie from __future__ import division from PyQt4.QtCore import * from PyQt4.QtGui import * from visual import * newframe = frame class Object(object): def __init__(self, parent=None, frame=None, pos=(0,0,0), axis=(1,0,0), color=color.green): self.frame = newframe(frame=frame, pos=pos, axis=axis) self.surface = faces(frame=self.frame) self.color = color self.vertexList = [] self.normalList = [] self.colorList = [] def clearSurface(self): del self.surface self.surface = faces(frame=self.frame) self.vertexList = [] self.normalList = [] def addTri(self, p1, p2, p3): """Add a triangle to the model""" v1 = vector(p1) v2 = vector(p2) v3 = vector(p3) try: normal = norm( cross(v2-v1, v3-v1) ) except: normal = vector(0,0,0) self.vertexList = self.vertexList + [v1,v2,v3] self.normalList = self.normalList + [normal,normal,normal] self.colorList = self.colorList + [self.color,self.color,self.color] def computeSurface(self): """ Create faces out of vertex, normal and color info""" self.surface = faces(frame=self.frame, pos=self.vertexList, normal=self.normalList, color=self.colorList) if __name__ == '__main__': # origin sphere for reference sphere(radius=0.1) p1 = (-2, -1, 0) p2 = (-1, 1, 0) p3 = (-2, 1, 0) p4 = (3, -1, 0) p5 = (5, -1, 0) p6 = (4, 2, 0) x=Object() x.addTri(p1, p2, p3) x.computeSurface() print "new surface" x.clearSurface() x.addTri(p4, p5, p6) x.computeSurface() print x.vertexList On Wed, Jul 29, 2009 at 8:52 AM, Bruce Sherwood<Bru...@nc...> wrote: > Could you please post a short test routine that illustrates the problem? > Thanks. > > Bruce Sherwood > > Jamie Riotto wrote: >> I have a VPython faces based object. I would like the user to be able to change >> fundamental parameters that affect its shape (like setting numSides on >> a Polygon), >> but I can't seem to get VPython to re-render the new shape. I've tried >> to "Del" the >> existing face list, then create a new one, but the old object is still >> shown. Any suggestions? >> >> Thank - Jamie Riotto >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day >> trial. Simplify your report design, integration and deployment - and focus on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> Visualpython-users mailing list >> Vis...@li... >> https://lists.sourceforge.net/lists/listinfo/visualpython-users > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |