PDA

View Full Version : How to load VRML into opengl?



Lanfear
03-10-2004, 01:19 AM
Hi, I have to load a vrml object into my opengl codes, but i do not know anything at all about vrml, so any advice from any of you would be deeply appreciated.

To load a vrml file into opengl, do people just write a code and load it (like in the case of bitmap images), or do they have to link to external software?

Having load a vrml file into opengl, do i then treat it like a normal 3d object? that is, can i apply glRotate,glTranslate etc to it?

Thanks in advance...

Relic
03-10-2004, 02:16 AM
The specifications are here: http://www.web3d.org/x3d/spec/index.html#vrml97
You either need to find some freware which loads the data you need, or you need to write a loader yourself.

I did it once in C it's pretty straightforward, though some tideous typing.

All you need to do (ha!) is to parse all the nodes and keep the ones you need in the model hierarchy.

Unfortunately most VRML models don't specify normals, so you need to smooth yourself depending on the crease angle given in the file.

I've seen C++ class implementations for all nodes as source somewhere. This seemed an elegant way. There are also full VRML browsers as source, you might to look how they do it.