About Store Forum Documentation Contact
Donations:
207$/mo



Post Reply 
One-Ring Neighbours of a Vertex
Author Message
Chris Offline
Member

Post: #1
One-Ring Neighbours of a Vertex
Hi,

I "solved" my old problem, and renamed this thread as have a newer more esenthel-engine related problem as a follow-on.

For each vertex in a MeshBase, I need to calculate the surface-area of its one-ring-neighbourhood (the average surface-area of all the triangles, adjacent to the vertex) as defined here:

http://bluntobject.wordpress.com/2007/03...one-rings/

I get the area of one triangle with:
Code:
Tri getTriangle(Int i) {
    return Tri(meshbase.vtx.pos[meshbase.tri.ind[i].x],
               meshbase.vtx.pos[meshbase.tri.ind[i].y],
               meshbase.vtx.pos[meshbase.tri.ind[i].z]);
}

.area();

But, when I tried drawing points on tri.adj_face vertex positions, I got some very unexpected vertexes being highlighted, I don't understand the format used in EE or how to do this; I tried searching the header comments etc but couldn't find out much.

EDIT: Solved by creating a list of edges for each vertex in helper memory smile

Chris
(This post was last modified: 09-03-2010 02:12 AM by Chris.)
09-01-2010 06:56 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: One-Ring Neighbours of a Vertex
Hello,

You are right, the adj_face wasn't well commented, I've improved this, maybe it will help

Code:
struct MeshTris // Mesh Triangles
{
   Int    num     ; // number of triangles
   VecI  *ind     , // vertex index
         *adj_face, // adjacent face, index to faces adjacent to the triangle encoded in following way : if(adj_face==-1) -> no face, else if(adj_face&SIGN_BIT)adj_quad_index=adj_face^SIGN_BIT, else adj_tri_index=adj_face
         *adj_edge; // adjacent edge, index to edges adjacent to the triangle encoded in following way : if(adj_edge==-1) -> no edge, else adj_edge_index=adj_edge
   Vec   *nrm     ; // normal
   Byte  *flag    ; // flag
   VecI2 *id      ; // id
};
struct MeshQuads // Mesh Quads
{
   Int    num     ; // number of quads
   VecI4 *ind     , // vertex index
         *adj_face, // adjacent face, index to faces adjacent to the quad encoded in following way : if(adj_face==-1) -> no face, else if(adj_face&SIGN_BIT)adj_quad_index=adj_face^SIGN_BIT, else adj_tri_index=adj_face
         *adj_edge; // adjacent edge, index to edges adjacent to the quad encoded in following way : if(adj_edge==-1) -> no edge, else adj_edge_index=adj_edge
   Vec   *nrm     ; // normal
   Byte  *flag    ; // flag
   VecI2 *id      ; // id
};
09-03-2010 01:25 PM
Find all posts by this user Quote this message in a reply
Chris Offline
Member

Post: #3
RE: One-Ring Neighbours of a Vertex
Ah, that helps alot smile
Thanks, I can probably make use of this properly now.
09-03-2010 02:58 PM
Find all posts by this user Quote this message in a reply
Chris Offline
Member

Post: #4
RE: One-Ring Neighbours of a Vertex
This is kind of related to this thread, but if I meshbase.subdivide() all my tris() get wiped. It seems I have lots of quads though. I tried quadsToTris() but it crashes. How can I recreate tris after a subdivision?

I tried a REP(meshbase.quads()) {
Tri a = quad.x,quad.y,quad.z;
Tri b = quad.w, quad.y, quad.z;

addTri(a); addTri(b);
}

- but it crashed when I tried creating a triangle. Debugger said it didn't like making a quad from Quad(meshbase.quad.ind[i].x ... w)

Chris
09-07-2010 12:14 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: One-Ring Neighbours of a Vertex
I guess it must mean that there's some incorrectly set indexes,

like triangle/quad pointing to non-exising vertex index, or something.

you can try checking if all quads point to valid indexes.

do you manually setup the mesh? how do you do it?

if you perform some modifications maybe you need to remove previously created (if any) vertex duplicates, and adjacent faces
mesh.exclude(VTX_DUP|ADJ_ALL);
09-07-2010 08:54 PM
Find all posts by this user Quote this message in a reply
Chris Offline
Member

Post: #6
RE: One-Ring Neighbours of a Vertex
Thanks, i'll check this soon and update the post - i'm only using it to boost the quality of a mesh voxelisation process used to do skeletal extraction. Currently coding the voxel rasterizer, which manually subdivides each triangle to fill voxels between the triangles (which is similar, but different) - but I love your voxel renderer.

Did you somehow avoid the cubic memory requirement for voxelized images? I'd like to write that the implementation doesn't have cubic memory requirements in the paper, and it seems your image3d isn't cubic - but don't understand how. Is it based on a "runs" data structure or something?
(This post was last modified: 09-07-2010 09:18 PM by Chris.)
09-07-2010 09:13 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: One-Ring Neighbours of a Vertex
It's GPU based, only simple shader iterating volume texture wink so it's fast when compared to CPU
09-08-2010 11:05 AM
Find all posts by this user Quote this message in a reply
Chris Offline
Member

Post: #8
RE: One-Ring Neighbours of a Vertex
Hi, another kind of related thing:

I have a vertex v, and it has a normal n. I then move the vertex by some function to v'. Problem is, when I compute the distance by Dist(v, v') I always get positive. Is there a displacement function in esenthel such that I can calculate the signed distance?

Edit: Is this what Flt DistPointPlane(C Vec &point, C Vec &plane, C Vec &normal); - does? Or is that always positive too? Edit: Yeah this seems to be it, i'd have called it "DispPointPlane" or explained about it in the header though as Dist made me think it was positive only. But i'm still amazed by this maths library.

Thanks,
Chris
(This post was last modified: 10-07-2010 11:24 AM by Chris.)
09-19-2010 02:50 PM
Find all posts by this user Quote this message in a reply
Chris Offline
Member

Post: #9
RE: One-Ring Neighbours of a Vertex
Hi,

I'm trying to write a custom MeshBase.subdivide() function in software (used to bake semantics for for hardware processing). Problem is, its really slow - even for software:

For example (perhaps triangles aren't the right structure to iterate):

Code:
FREP(meshbase.tris()) {
    Tri tri = getTriangle(i);
    meshbase.addVtx(tri.edge0().center());
    meshbase.addVtx(tri.edge1().center());
    meshbase.addVtx(tri.edge2().center());
    ...
}

The addVtx takes, much longer than your meshbase.subdivide(); I see your method can even do laplacian/catmull/spline smoothing etc..

Can you suggest how I can write the foundation of a decent subdivide algorithm at better speeds?

Thanks again.
10-07-2010 12:19 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
RE: One-Ring Neighbours of a Vertex
each addVtx reallocates the whole vtx arrays to add space for 1 more

you can create all vtxs at once
MeshBase temp;
temp.create(new_amount_of_vtxs,..

or store vertexes using
Memc or Memb, adding new elements for containers is faster than addVtx
when you have containers you can create mesh
temp.create(vtxs.elms()
10-07-2010 12:57 PM
Find all posts by this user Quote this message in a reply
Chris Offline
Member

Post: #11
RE: One-Ring Neighbours of a Vertex
Ah no wonder it was slow. Thanks, this is much faster!
10-07-2010 02:04 PM
Find all posts by this user Quote this message in a reply
Post Reply