Creating faces.

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Post Reply
hannibar
Posts: 50
Joined: Wed Oct 16, 2002 3:02 pm

Creating faces.

Post 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 ?

theeth
Posts: 500
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Post 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
Life is what happens to you when you're busy making other plans.
- John Lennon

hannibar
Posts: 50
Joined: Wed Oct 16, 2002 3:02 pm

Post by hannibar »

Thanks

guitargeek
Posts: 0
Joined: Thu Apr 24, 2003 12:54 am
Location: Greenville,IL USA

Post by guitargeek »

if you are looking down at the face and want the normal pointing towards you, you need to go counterclockwise.

hannibar
Posts: 50
Joined: Wed Oct 16, 2002 3:02 pm

Post 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.

guitargeek
Posts: 0
Joined: Thu Apr 24, 2003 12:54 am
Location: Greenville,IL USA

Post 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

hannibar
Posts: 50
Joined: Wed Oct 16, 2002 3:02 pm

Post 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)

guitargeek
Posts: 0
Joined: Thu Apr 24, 2003 12:54 am
Location: Greenville,IL USA

Post 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 :)

guitargeek
Posts: 0
Joined: Thu Apr 24, 2003 12:54 am
Location: Greenville,IL USA

Post 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

hannibar
Posts: 50
Joined: Wed Oct 16, 2002 3:02 pm

Post by hannibar »

Thanks for making that tutorial. I couldn't use it though. I solved the problem by making a small LinkNode struct.

hannibar
Posts: 50
Joined: Wed Oct 16, 2002 3:02 pm

Post 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 ?

Post Reply