#1 4. Juni 2008 brauche hilfe zu python-visual / 3D objekte also ich will etwas zum thema EM mit python erstellen, ich hab da schon was kleines: Code: import math import time import visual as vis scene = vis.display(width=800, height=500) scene.center = (0, 2.5, 0) distance = 4 sphere = vis.sphere(pos=(distance, 2.5, 0), radius=2, color=vis.color.white) scene.autoscale = False while True: for step in range(0, 360): phi = step * 2*math.pi/360. sphere.x = distance * math.cos(phi) sphere.z = distance * math.sin(phi) time.sleep(0.02) jetzt weiß ich aber nicht weiter ich möchte das der ball schwarz weiß ist : http://ww3.cad.de/foren/ubb/uploads/wago/Fussball-wago.jpg der ball sollte dann noch möglichst um das wort "EM 08" kreisen. dazu hab ich schon mal eine kleine ergänzung zu oben: Code: import math import time import visual as vis scene = vis.display(width=800, height=500) scene.center = (0, 2.5, 0) distance = 4 rod = vis.cylinder(pos=(0, 0, 0), axis=(0, 5, 0), radius=1, color=vis.color.white) sphere = vis.sphere(pos=(distance, 2.5, 0), radius=2, color=vis.color.white) scene.autoscale = False while True: for step in range(0, 360): phi = step * 2*math.pi/360. sphere.x = distance * math.cos(phi) sphere.z = distance * math.sin(phi) time.sleep(0.02) ich hoffe mir kenn jemand möglichst schnell helfen hier sind doch so viele jute programmierer danke mfg buterfly + Multi-Zitat Zitieren
#2 12. Juni 2008 AW: brauche hilfe zu python-visual / 3D objekte Hab leider keine erfahrungen in Python... aber wie wärs wenn du deinen Cylinder einfach mit einer Textur versehen würdest?. Surface textures (30 Sek, Google) Spoiler You can create a texture object and then apply it to the surface of an object. This capability is currently limited to boxes and spheres. A surface texture is an M by N array of 1, 2, 3, or 4 numerical values (a list or tuple). M and N must be powers of 2 (1, 2, 4, 8, 16, 32, etc.). Here are the possible values for each slot in the array: 1 value: texture type must be "luminance" (how bright) or "opacity" 2 values (opacity,luminance): texture type must be "opacity_luminance" 3 values (red,green,blue): texture type must be "rgb" 4 values (red,green,blue,opacity or alpha): texture type must be "rgbo" A VPython texture is basically a mask. For example, if you apply a texture to a box that is red, any cyan region of the texture will display as black, because the cyan (0,1,1) doesn't overlap at all with the red (1,0,0). You can create a numeric array of zeros in various formats, then assign values: zeros([...], ubyte) means an 8-bit unsigned integer 0-255 zeros([...], short) means a 16-bit iinteger plus or minus 0-32767 zeros([...], int) means a 32-bit integer plus or minus 0-2147483648 zeros([...], float) means a floating-point (fractional) number Here is an example program in which a checkerboard texture is created and applied to a box: from visual import * M=4 # must be a power of 2 (1, 2, 4, 8, 16, 32, etc.) N=4 # must be a power of 2 (1, 2, 4, 8, 16, 32, etc.) checks = zeros([M,N], float) # create a numeric array of floating-point zeros (0.0) for i in range(M): for j in range(N): if ((i&1) ^ (j&1)): # true for every alternate square of the checkerboard checks[j] = 1.0 print checks lum = texture(data=checks, type="luminance") box(color=color.cyan, texture=lum) If you wanted to create a texture containing "rgb" values, you would start with zeros([M,N,3], float), and entries into this array would be the usual (red,green,blue) triples, with values for each color in the range 0-1 inclusive. See the contributed section of vpython.org for an example of a program to create, save, and use a wood-grain texture. Such a texture is included in the examples and used by the program texture_and_lighting.py. Quelle : http://www.vpython.org/webdoc/texture-opacity-lighting.html Mfg, Inqui. + Multi-Zitat Zitieren