Skip to main content
gamedev.net
🔒 Locked

Mesh

Started by Gadz 4 replies 400+ views
Original Post
Gadz
Gadz
Hi all. I am fairly new to OGL. I am working on a proj that requires me to model an object from a set of surface points. 1.2 million points to be exact. I want to build a mesh from these points and have OGL automatically calculate the normals so i can apply some lighting to show structural formations in the model. Please help. How to put a a mesh together?
fractoid
fractoid
Well, if you already know the connectivity of the mesh (ie. which triangles go between which points) then you just have to calculate vertex normals (easy) and you're done.

If you just have a cloud of points, and you want to make a surface that goes through them - well, that's PhD-level material. As in, I know people who've done PhD projects on this very topic.

I'll see if I can dig up a link. :)

[edit: I'd start here. If you're not keen on reading academic papers and just want source code, try here.]
Gadz
Gadz
Do u have the maths to calculate a normal from 3 vertices?
Bradsco
Bradsco
You need a few vector operations. Look for vector subtraction, cross product and normalization.

Given points A, B and C, the answer you're looking for is the normalized result of (B - A) x (C - A)
I set the clouds in motion, turn up light and sound...Activate the window, and watch the world go 'round
Gadz
Gadz

oops. clicked new thread instead of reply...

Thanx guys. Found Some stuff to calculate the norms.
One question. the new point nx ny nz calculated after the cross product. Does glNormal3f() see that as a vector starting at (0,0,0) going thru (nx,ny,nz)?
fractoid
fractoid
Yes.

It should be normalized too, since a 'normal' is by definition a unit vector (I can't remember how, but you can probably tell OpenGL to do the normalization for you).

Topic Locked

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

Sign in to reply to this topic.