Invalid Mesh Face

Questions and answers about the how and why of making maps.
Post Reply
User avatar
Tanner
Private First Class
Private First Class
Posts: 575
Joined: Sat Sep 17, 2005 3:46 am
Location: Atl, GA
Contact:

Invalid Mesh Face

Post by Tanner »

Hi,

When I added a mesh to a map I got this when I started the server:

Code: Select all

invalid mesh face (0.000000)
How do I fix that?

Edit: Here's the code:

Code: Select all

#Right
mesh
        Vertex -5  25  50.5
        Vertex -5  25  10
        Vertex -5  -25  50.5
        Vertex -5  -25  10
face
        vertices 0 1 2 3
endface
face
        vertices 3 2 1 0
endface
end
#Left
mesh
        Vertex 5  25  50.5
        Vertex 5  25  10
        Vertex 5  -25  50.5
        Vertex 5  -25  10
face
        vertices 0 1 2 3
endface
face
        vertices 3 2 1 0
endface
end
#Front
mesh
        Vertex -5  25  50.5
        Vertex -5  25  10
        Vertex 5  25  50.5
        Vertex 5  25  10
face
        vertices 0 1 2 3
endface
face
        vertices 3 2 1 0
endface
end
#Back
mesh
        Vertex -5  -25  50.5
        Vertex -5  -25  10
        Vertex 5  -25  50.5
        Vertex 5  -25  10
face
        vertices 0 1 2 3
endface
face
        vertices 3 2 1 0
endface
end
#Top
mesh
        Vertex -5  25  50.5
        Vertex -5  25  50.5
        Vertex -5  -25  50.5
        Vertex -5  -25  50.5
        Vertex 5  25  50.5
        Vertex 5  25  50.5
        Vertex 5  -25  50.5
        Vertex 5  -25  50.5
face
        vertices 0 1 2 3 4 5 6 7
endface
face
        vertices 7 6 5 4 3 2 1 0
endface
end
#Bottom
mesh
        Vertex -5  25  10
        Vertex -5  25  10
        Vertex -5  -25  10
        Vertex -5  -25  10
        Vertex 5  25  10
        Vertex 5  25  10
        Vertex 5  -25  10
        Vertex 5  -25  10
face
        vertices 0 1 2 3 4 5 6 7
endface
face
        vertices 7 6 5 4 3 2 1 0
endface
end
-Tanner
User avatar
ClayOgre
Private First Class
Private First Class
Posts: 227
Joined: Mon Apr 18, 2005 3:17 am
Location: Southern Indiana (originally from Alaska)

Post by ClayOgre »

Without going through your code line by line...

Does it say what line the error occured on? That might tell you something. Just guessing, you might have a face specified where all the vertices aren't co-planar.

What is the shape supposed to be of? Did you model this or hand code it?
Respectfully,
I Beg to Remain,
Cordially Yours,
Regards....

Image
User avatar
Tanner
Private First Class
Private First Class
Posts: 575
Joined: Sat Sep 17, 2005 3:46 am
Location: Atl, GA
Contact:

Post by Tanner »

ClayOgre wrote:Without going through your code line by line...

Does it say what line the error occured on? That might tell you something. Just guessing, you might have a face specified where all the vertices aren't co-planar.

What is the shape supposed to be of? Did you model this or hand code it?
Nope it doesn't say what line it occured on. Co-planar?

It's a box. It was created by a program I made (see the forum Map-Editors).

-Tanner
User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5196
Joined: Fri Dec 13, 2002 4:11 am

Post by JeffM »

take out meshes till you find out what one it is, you have more then one mesh there.
ImageJeffM
User avatar
Tanner
Private First Class
Private First Class
Posts: 575
Joined: Sat Sep 17, 2005 3:46 am
Location: Atl, GA
Contact:

Post by Tanner »

JeffM2501 wrote:take out meshes till you find out what one it is, you have more then one mesh there.
Ok, did that and I found it was the top and bottom meshes. Now what? Whats coplanar?

-Tanner
User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5196
Joined: Fri Dec 13, 2002 4:11 am

Post by JeffM »

what meshes are those? we need to see the code for just one of the bad faces.

coplanar means that all the points of the face lie in the same mathamatical plane ( aka flat ).

I think your faces may also be concave or degenerate.
ImageJeffM
User avatar
Tanner
Private First Class
Private First Class
Posts: 575
Joined: Sat Sep 17, 2005 3:46 am
Location: Atl, GA
Contact:

Post by Tanner »

JeffM2501 wrote:what meshes are those? we need to see the code for just one of the bad faces.

coplanar means that all the points of the face lie in the same mathamatical plane ( aka flat ).

I think your faces may also be concave or degenerate.
Here's the top:

Code: Select all

#Top
mesh
        Vertex -5  25  50.5
        Vertex -5  25  50.5
        Vertex -5  -25  50.5
        Vertex -5  -25  50.5
        Vertex 5  25  50.5
        Vertex 5  25  50.5
        Vertex 5  -25  50.5
        Vertex 5  -25  50.5
face
        vertices 0 1 2 3 4 5 6 7
endface
face
        vertices 7 6 5 4 3 2 1 0
endface
end
And bottom:

Code: Select all

#Bottom
mesh
        Vertex -5  25  10
        Vertex -5  25  10
        Vertex -5  -25  10
        Vertex -5  -25  10
        Vertex 5  25  10
        Vertex 5  25  10
        Vertex 5  -25  10
        Vertex 5  -25  10
face
        vertices 0 1 2 3 4 5 6 7
endface
face
        vertices 7 6 5 4 3 2 1 0
endface
end
-Tanner
JPT
Private First Class
Private First Class
Posts: 260
Joined: Tue Nov 29, 2005 1:21 pm
Location: Germany

Post by JPT »

Why do you have got there

Code: Select all

#Bottom 
mesh 
        Vertex -5  25  10 
        Vertex -5  25  10 
        Vertex -5  -25  10 
        Vertex -5  -25  10 
        Vertex 5  25  10 
        Vertex 5  25  10 
        Vertex 5  -25  10 
        Vertex 5  -25  10 
face 
        vertices 0 1 2 3 4 5 6 7 
endface 
face 
        vertices 7 6 5 4 3 2 1 0 
endface 
end
if just this here would be enough:

Code: Select all

#Bottom 
mesh 
        Vertex -5  25  10 
        Vertex -5  -25  10 
        Vertex 5  25  10 
        Vertex 5  -25  10 
face 
        vertices 0 1 2 3
endface 
face 
        vertices 3 2 1 0 
endface 
end

EDIT: I saw Teppic saying the same thing in a different topic.
EDIT2: Even with the changed code, i get errors like you.
EDIT3: ^-- sry, i just got errors, because the mesh had a size of 0 in my map... :oops:
User avatar
Tanner
Private First Class
Private First Class
Posts: 575
Joined: Sat Sep 17, 2005 3:46 am
Location: Atl, GA
Contact:

Post by Tanner »

Hmm.

Could someone explain my problem in pure, normal, understandable English?

-Tanner
Tanner - Segway HT i180 Red Owner - Random Map Creator - BZStocks - TS Software

Image
User avatar
ClayOgre
Private First Class
Private First Class
Posts: 227
Joined: Mon Apr 18, 2005 3:17 am
Location: Southern Indiana (originally from Alaska)

hmmmm

Post by ClayOgre »

What version of bzflag are you running...on Windows or Linux? Because I just cut, pasted and ran your code and it ran just fine... I got a large box, about 15-20 units up in the air standing on edge...no missing faces.

I am running version 2.0.4 on a linux box.
Respectfully,
I Beg to Remain,
Cordially Yours,
Regards....

Image
User avatar
Teppic
Private First Class
Private First Class
Posts: 576
Joined: Mon Mar 07, 2005 10:00 pm
Location: The North Block

Post by Teppic »

JPT wrote:
if just this here would be enough:

Code: Select all

#Bottom 
mesh 
        Vertex -5  25  10 
        Vertex -5  -25  10 
        Vertex 5  25  10 
        Vertex 5  -25  10 
face 
        vertices 0 1 2 3
endface 
face 
        vertices 3 2 1 0 
endface 
end
I quoted jpt because it has the data I wanted

When defining flat planes by hand only change one co-ordinate axis at a time i.e.
Vertex -5 25 10 // fine
Vertex -5 -25 10 // moved along the y axis -50 points fine
Vertex 5 25 10 // not fine moved 50 along y *AND* 10 along x
Vertex 5 -25 10 //would be fine

this vertex list will work, but only with the face vertex list as 0 1 3 2 or 2 3 1 0

You have drawn two triangles one on top of the other, not a rhombus or trianlge, the only acceptable shapes for faces.

If this is still unclear post again and I'll make some sketches.
User avatar
Tanner
Private First Class
Private First Class
Posts: 575
Joined: Sat Sep 17, 2005 3:46 am
Location: Atl, GA
Contact:

Post by Tanner »

Teppic wrote:
JPT wrote:
if just this here would be enough:

Code: Select all

#Bottom 
mesh 
        Vertex -5  25  10 
        Vertex -5  -25  10 
        Vertex 5  25  10 
        Vertex 5  -25  10 
face 
        vertices 0 1 2 3
endface 
face 
        vertices 3 2 1 0 
endface 
end
I quoted jpt because it has the data I wanted

When defining flat planes by hand only change one co-ordinate axis at a time i.e.
Vertex -5 25 10 // fine
Vertex -5 -25 10 // moved along the y axis -50 points fine
Vertex 5 25 10 // not fine moved 50 along y *AND* 10 along x
Vertex 5 -25 10 //would be fine

this vertex list will work, but only with the face vertex list as 0 1 3 2 or 2 3 1 0

You have drawn two triangles one on top of the other, not a rhombus or trianlge, the only acceptable shapes for faces.

If this is still unclear post again and I'll make some sketches.
One co-ordinate axis at a time?

So, I'm guessing this code below would be "correct"?

Code: Select all

#Bottom 
mesh 
        Vertex -5  25  10 
        Vertex -5  -25  10 
        Vertex 5  25  10 
        Vertex 5  -25  10 
face 
        vertices 0 1 3 2
endface 
face 
        vertices 2 3 1 0 
endface 
end
Atleast I get what your saying about the triangles part..

-Tanner
Tanner - Segway HT i180 Red Owner - Random Map Creator - BZStocks - TS Software

Image
User avatar
Teppic
Private First Class
Private First Class
Posts: 576
Joined: Mon Mar 07, 2005 10:00 pm
Location: The North Block

Post by Teppic »

There still seems to be some confusion.
A face is defined by a list of vertices, that define the faces corners, and must be listed in a counter-clockwise direction around the edge of the face.
Attachments
Sketch.jpg
(199.59 KiB) Downloaded 46 times
User avatar
Tanner
Private First Class
Private First Class
Posts: 575
Joined: Sat Sep 17, 2005 3:46 am
Location: Atl, GA
Contact:

Post by Tanner »

Ah, thank you Teppic. I fixed it now.

*I also should use variable names that mean something instead of TTBX, now BottomLY*

Thank-you.

-Tanner
Tanner - Segway HT i180 Red Owner - Random Map Creator - BZStocks - TS Software

Image
Inferno
Private First Class
Private First Class
Posts: 91
Joined: Sat Jan 22, 2005 6:52 pm
Contact:

Post by Inferno »

Wow, I figured out all this threw experimenting. I also found out how bz figures out normals without you actually specifying them, maybe you should know how it works. Always facing positive Z, X, or Y the vertices of a face have to be in counter-clockwise order. Like for the top of a cube, it has to be:

1 1 1
-1 1 1
-1 -1 1
1 -1 1
(counter-clockwise)

but if you want it to face the otherway, for example the bottom of a cube use:

1 -1 -1
-1 -1 -1
-1 1 -1
1 1 -1
(clockwise)

Just thought you should know this.
User avatar
Teppic
Private First Class
Private First Class
Posts: 576
Joined: Mon Mar 07, 2005 10:00 pm
Location: The North Block

Post by Teppic »

Just as a general note, you will have less problems with meshes if the face is defined once in the right direction, as opposed to twice (once for each side), especially if the faces you are dealing with exist in 3 axis (ie not exclusivley in xy plane or zx plane etc), to see what I'm talking about jump on the mountains in my valley map and see how many tries it takes to get sucked into the mountain through a solid mesh, this odd behaviour is all but eliminated with no double sided faces .
Post Reply