Skip to main content
GameDev.net gamedev.net
🔒 Locked

OpenGl - shape from a file

Started by melol Jan 27, 2012 at 10:21 AM 0 replies 1.9k views
Original Post
melol
melol
Hello!
I've got a problem with loading a shape from a file.
Beginning of the file (which is 5MB) is as follows:

v
from 0.1 0.1 0.25
at -0.01 0.085 0.02
up 0 1 0
angle 50
hither 1
resolution 1024 1024
b 0.0 0.0 0.0
l 0.4 0.3 0.2 0.25 0.25 0.25
f 0.753 0.753 0.753 1 0 0 0 1
p 3
-0.092314 0.132364 0.018222
-0.092180 0.132348 0.017224
-0.092767 0.130992 0.017231
p 3
-0.087168 0.110390 0.018362
-0.088961 0.111861 0.018336
-0.087443 0.110454 0.017341
p 3
-0.087840 0.105023 0.014367
-0.087237 0.106355 0.014359
-0.087251 0.106353 0.013364


I don't have any idea how to load it in OpenGL project or even what keywords to google.
So far I have a OpenGL project, with a teapot rendered thanks to glutWireTeapot()
Does anyone know if I could in a simple way comment in my code the glutWireTeapot(), an write instead a function which loads my shape form file.

I will appreciate your help very much!
Ruggostein
Ruggostein
Yes, just learn how to draw a triangle in openGL, and write a function to do it, using glBegin glEnd etc, it is easy.
Parsing your fle should be easy too, you should be familiar with the file format, looking at it it seems that each p 3 means a polygon with 3 sides, followed by a list of 3 vertices positions. Possibly the format allows for n-sides polygons, in that case write a function that can draw a polygon with a variable number of sides.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.