Page 1 of 1

Creating faces.

Posted: Wed Jun 22, 2005 11:46 pm
by hannibar
When creating faces when I have two edges, I sometimes get wrong results using addfacelist(...). I get this then :

Code: Select all

|\     /|
|  \ /  |
|  / \  |
|/     \|
 ---------
instead of this :

Code: Select all

---------
|       |
|       |
|       |
|       |
---------
Is there a way to know in what order I should add the vertices in that function ?

Posted: Thu Jun 23, 2005 12:56 am
by theeth
Going around the normal (I can never remember if it's clockwise or counter clockwise).

Something like that:

Code: Select all

1--------2
|           |
|           |
4--------3
Martin

Posted: Thu Jun 23, 2005 9:53 am
by hannibar
Thanks

Posted: Thu Jun 23, 2005 4:59 pm
by guitargeek
if you are looking down at the face and want the normal pointing towards you, you need to go counterclockwise.

Posted: Thu Jun 23, 2005 9:24 pm
by hannibar
Thanks.
I have an other question. It's pretty basic, but I couldn't find a decent example anywhere. I would like to make a linked list with a few specific edges in it. I tried something like this, but that code doesn't work because it messes with the original list too (it changes the next's and prev's of those edges).

Code: Select all

EditMesh *em = G.editMesh;
EditEdge *eed, *nexteed;
ListBase list;

list.first= list.last= 0;
eed = em->edges.first;
while(eed){
	nexteed = eed->next;
	if (eed->f & SELECT) BLI_addtail(&list, eed);
	eed = nexteed;
}
I took a look at the LinkNode struct, but I couldn't figure out how to use it.

Posted: Thu Jun 23, 2005 10:01 pm
by guitargeek
You could use a GHash to store them, just store the EditEdge pointers as the keys and NULL as the value, then you can iterate over the GHash and get your edges.

I wrote a tutorial on using GHash here

http://wiki.blender.org/bin/view.pl/Ble ... shTutorial

Posted: Fri Jun 24, 2005 5:26 pm
by hannibar
guitargeek wrote:You could use a GHash to store them, just store the EditEdge pointers as the keys and NULL as the value, then you can iterate over the GHash and get your edges.

I wrote a tutorial on using GHash here

http://wiki.blender.org/bin/view.pl/Ble ... shTutorial
I read your tutorial, but I don't know if I'll be able to use it. The reason I wanted to use a linked list was to have the edges sorted, so I could iterate them in a specific order. Can this be done with the hashtable too ? (if so, I should be able to place a reference to an edge at the head or at the tail)

Posted: Fri Jun 24, 2005 5:31 pm
by guitargeek
You may want to look in the blenlib folder, there is BLI_linklist.h I have not used that lib before, but reading through it may show if it would be helpful to you.

Perhaps I'll read through it tonight and write another tutorial :)

Posted: Fri Jun 24, 2005 8:16 pm
by guitargeek
Ok, so a slow day at the office and a read through the code has come up with this, BLI_linklist is a basic singly linked list implementation. This is a document that I wrote today telling how to use it. Enjoy!

http://wiki.blender.org/bin/view.pl/Ble ... stTutorial

Posted: Sat Jun 25, 2005 3:20 pm
by hannibar
Thanks for making that tutorial. I couldn't use it though. I solved the problem by making a small LinkNode struct.

Posted: Thu Jun 30, 2005 9:54 pm
by hannibar
I have another question.
In a part of my code I replace two faces with one face. I want the normal of the new face to point to the same side as the normal of the original faces. The situation in the code is like this :

I have deleted the two original faces already.
I have access to the 4 vertices that will form the new face.

How can I decide whether I need to flip the face or not. Can I do something with the vertex normals? Or are they changed when I deleted the original faces ?