From: David S. <da...@vi...> - 2002-12-13 14:36:25
|
The convex hull finding algorithm used internally by cvisual assumes that no four points in the input are coplanar. Since that is not a reasonable requirement to impose on the user, it attempts to randomly jitter the input points by a tiny amount in order to make them noncoplanar without detectably affecting the display. Unfortunately this is not being done correctly: - Since the user is free to create very large or very small convex objects, the jitter is proportional to the "magnitude" of the points used to create the object. This means that the fourth point in m2 (0,0,0) is not jittered at all. That would be fine, except: - The first three points in the object are not jittered (they are treated differently by the algorithm). I don't have a build environment for cvisual and don't have time this morning to set one up. If anyone else wants to fix the problem, it can be done by adding jitter to the three points used to create the initial two faces in recalc(). (See the code at the beginning of addpoint() that jitters a single point). I can also suggest more workarounds for you: 3.) You can create the convex object anywhere other than (0,0,0), or at least ensure that (0,0,0) is not the fourth point in a rectangle. 4.) Use the "faces" object instead of convex: it is more appropriate for rendering large nonconvex models. It is a little more difficult to set up, but *much* more efficient than convex and gives you more control over things like lighting. I think there is sample code somewhere that does extrusions with faces. Dave > -----Original Message----- > From: vis...@li... > [mailto:vis...@li...] On > Behalf Of Cettinich Edwin (LWE) > Sent: Friday, December 13, 2002 6:14 AM > To: vis...@li... > Subject: [Visualpython-users] incorrect convex objects? > > > Because extrusion objects are not supported in VPython I > create them as a set of convex objects. I found, that some > of them are not drawn correctly. > For instance, please try this code: > > from visual import * > d1=convex(pos=[( 0, 0, 0), ( 0, 1, 0), (-1, 1, 0)]) > d2=convex(pos=[(-1, 1,-1), ( 0, 1,-1), ( 0, 0,-1)]) > m0=convex(pos=[( 0, 0, 0), ( 0, 0,-1), ( 0, 1,-1), ( 0, 1, > 0)]) m1=convex(pos=[( 0, 1, 0), ( 0, 1,-1), (-1, 1,-1), (-1, > 1, 0)]) m2=convex(pos=[(-1, 1, 0), (-1, 1,-1), ( 0, 0,-1), ( > 0, 0, 0)]) > > and watch m2. It is not drawn as rectangle, instead I can > only see the triangle [(-1, 1, 0), (-1, 1,-1), ( 0, 0,-1)]. > > Rotate and shift left m2's pointlist in the above code like this: > m2=convex(pos=[(-1, 1,-1), ( 0, 0,-1), ( 0, 0, 0), (-1, 1, 0)]) > > Now m2 is fully drawn as a rectangle. > > Does anyone know what's wrong and how to get a correct convex object? > > I don't have any idea if there is something wrong and I see > only 2 workarounds: > 1.) I may create a rectangle in the XY-plane and rotate it > appropriately, or > 2.) I may split the rectangle into triangles. > > > Thanks in advance for any answer, > Edwin Cettinich > > > > ------------------------------------------------------- > This sf.net email is sponsored by: > With Great Power, Comes Great Responsibility > Learn to use your power at OSDN's High Performance Computing > Channel http://hpc.devchannel.org/ > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |