Can a triangle be flipped?

Blitz3D Forums/Blitz3D Programming/Can a triangle be flipped?

Braincell(Posted 2004) [#1]
Hi, i'm interested if any of you guys know if theres ANY way at all to flip an existing triangle or poly which is already part of a mesh, which was preloaded (such as b3d or 3ds). The only way i can choose which way the normal is pointing now is by adding the triangle myself and making the vertexes go in the proper order, but thats too slow. I need some triangles of a mesh to flip and flip back in real time.

Too bad those vertex normals are only concerned about lighting...

Edit: Problem solved, whole system was changed in favour of a better solution.


Beaker(Posted 2004) [#2]
You have to clear all the triangles (not the vertices) and rebuild them with the one(s) you want flipped using a reversed winding order.

If you want it realtime and its the same triangles each time, consider having two versions of the mesh.


Braincell(Posted 2004) [#3]
No its a few different triangles each time, they move around. There is also many of them. I already thought about what i think you suggested. That is to get the coords of each vertex around a triangle that needs to be flipped, and make a new tri there in reverse order. But that is kinda like making mesh which i read is _slow_ so any other suggestions I will try, before i head to test this one out.

If i get this right, i believe i'll manage to make a pretty nice contribution to the community so come on!


Braincell(Posted 2004) [#4]
Another question then:

How much would it slow things down to have a 100 000 poly object hidden all the time during execution of the game? Using HideEntity of course. Would it slow anything down at all?

Edit- OK I guess I'll test myself now that i get the time :)


Braincell(Posted 2004) [#5]
I'll continue talking to myself.

In case anyone needs this info:
I calculated that a hidden entity (b3d mesh in this case) costs ~ABOUT~ 1 MB of RAM for every 24000 polys (triangles) that it has. So far thats the only cost of having hidden entities that i have calculated, so again if anyone can enlighten me and tell me if there are others I'll be grateful.

Edit: Another test when they were not hidden showed 14000 polys per MB. Used planes instead of spheres too, so i cant be sure but who cares.


Beaker(Posted 2004) [#6]
Your only option is to rebuild the mesh, but you are lucky that you only have to re-build the tris and not the verts as well. Vert data is much slower to upload to the card.


Braincell(Posted 2004) [#7]
OK, can you or anyone post an idea of the most effective way re-builinding tris could be done? Code would be appreciated.


AntonyWells(Posted 2004) [#8]
I believe you can just swap verts 2 and 3 to flip a tri.


AntonyWells(Posted 2004) [#9]
Something like,

      tx#=vertexX(vertex1)
      ty#=vertexY(vertex1)
      tz#=vertexZ(vertex1)
      PositionVertex Vert2,VerteX(vert3),vertexy(vert3),vertezZ(vert3)
      PositionVertex Vert3,tx,ty,tz


Also, you need to swap vertex color/normal/tex coord data. I'd still prefer it to rebuilding the mesh from scratch though, probably alot faster.


Braincell(Posted 2004) [#10]
Mhm ok thanks for that advice guys.

But in the meanwhile i had a break and a cookie and also a revelation. So i'll use a different system altogether... Meaning this thread can go and sink. When i'm done with this i hope its good (ie fast)!


Beaker(Posted 2004) [#11]
You can't just reposition vertices like that without messing up other dependent triangles. You could of course unweld all your triangles, but as I said before, any change you make to a single vertex will be slower than rebuilding all the triangles, because it will have to re-upload all the vertices anyway.


Hujiklo(Posted 2004) [#12]
What effect are you trying to achieve here...maybe some extra lateral thinking is needed?


Braincell(Posted 2004) [#13]
I'm trying to achieve something pretty interesting and useful for the community. Don't wanna brag about it till it actually works, so it'll be my little secret!! HAh hAH! >:)


AntonyWells(Posted 2004) [#14]
Btw, if you just want to flip every tri in a mesh, FlipMesh Entity already does that. Or perhaps it just switches culling modes..but same siff.


Braincell(Posted 2004) [#15]
lol
Uhh... yea, i kinda know that SpacedMan :D i think i pretty much read the whole command refference by now about 10 times, 2d and 3d A to Z so... i know... ;)

I also found a few commands missing in A-Z and appearing in Category listing, and vice versa.