Re: [PyOpenGL-Users] parse big list
Brought to you by:
mcfletch
|
From: <il...@ya...> - 2002-06-30 12:59:09
|
Hello.
--- Strato <fl...@id...> wrote: > The
import problem got solved (Thanks!) but there is
> one thing I have again.
> I want to read in a file and used "file("E111B.s",
> "R")
> and then how do I get a long list inside this file
> "point (x, y, z)"
> .....
>
So the file format is like this?:
"""point(1., 3., 3.9893824234)
point(2., 2., 3.9893824234)
point(7.2, 2.12, 3.9893824234)
point(5.31, 2.32, 3.9893824234)"""
How do you know how many sides each polygon has?
You can read a file like this:
f = open("E111B.s","r")
lines = f.readlines()
# if the last line does not have a newline at the end,
# add one.
if lines[-1][-1] != "\n":
lines[-1] += "\n"
points = []
for line in lines:
# get rid of the "point(" and ")\n"
point = line[len("point("):-2]
# convert the parts into floats
points.append( map(float, point.split(",")) )
For drawing we need to know how many points make up a
polygon.
Good luck!
> read into a variable and then do for every point a
> glVertex3f to draw the
> shape. (of an engine)
> If I have something valuable done I'll tell you
> probably open an sourceforge
> project
>
> Florian Idelberger
>
> P.S.: If you want the file as an example, tell me
> and note if I could send
> it to the list or not. (43,9kb)
>
>
>
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
|