Re: [DirectPython] 3d Text
Status: Inactive
Brought to you by:
hsalo
From: Heikki S. <ho...@gm...> - 2006-12-19 21:38:15
|
_____ From: dir...@li... [mailto:dir...@li...] On Behalf Of For...@ao... Sent: 19. joulukuuta 2006 21:02 To: dir...@li... Subject: [DirectPython] 3d Text Hello, I was hoping you could help me. Is there a way to create 3d Fonts from fonts located on ones computer? I see that there are numerous examples of 2-d text. If you can create 3d text is there a way to access the vertex, texture, and normal coordinates (x,y,z). Any help would be great. Thank you in advance. Regards, Andre O'Brien It is possible from DirectPython 0.6 onwards. I'll post a little example: font = d3d.Font(u"Arial", 20) textmesh = d3d.StaticMesh.fromFont(font, u"Your text goes here") vbuffer, ibuffer = textmesh.getBuffers() #Take a temporary copy tempvb = vbuffer[:] for i, vertex in enumerate(tempvb): #Go through all vertices tmp = list(vertex) tmp[0] += 1.0 #Modify x tmp[1] += 1.0 #y tmp[2] += 1.0 #z etc. tempvb[i] = tmp #Copy temporary list back to the real buffer. vbuffer[:] = tempvb This little snippet moves each vertex 1.0-units to all (x, y, z) directions. You can modify other attributes too, normals would be located at tmp[3-5]. Text meshes have not texture coordinates so you cant access them (unless you generate them in a shader, but that does not really count). Note that this is pretty inefficient, vertex shaders are usually used to modify geometry like this. Of course if you are only generating the data once or modifying it few times it is ok. -- Heikki Salo |