Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Can you delete or hide a single poly from a 3d model

Author
Message
darkvee
20
Years of Service
User Offline
Joined: 18th Nov 2005
Location:
Posted: 3rd Oct 2012 05:26
Hi guys

I was wondering if you can delete or hide a single poly from a 3d model. That in the statistic(0) command shows it is indeed hidden.
If you can how would you do it?

darkvee
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Oct 2012 12:26 Edited at: 3rd Oct 2012 12:28
Just thinking something might help until someone with a better clue comes by... LOCK VERTEX might have a helping hand in this as far as I can remember...

Maybe look in that direction while waiting for a more solid answer

EDIT

correction...

LOCK VERTEX > LOCK VERTEXDATA MESH [or LIMB]

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 3rd Oct 2012 16:11
The command is lock vertexdata for limb and unlock vertexdata. I haven't used those commands to remove data from meshes and I think it doesn't support that anyway (correct me if I'm wrong).

If speed is not an issue then I do have an answer for you using memblocks. The commands we'll be looking at are:



Before we dive into that however, let's quickly go over the theory of what we want to achieve. Let's say you have 5 polygons in your object and want to remove one of them via memblocks. Here's a simplified structure of the data:



Say you wanted to remove polygon 3. It's not as easy as simply deleting the data, because you'll then have this:



What we have to do is shift all of the data proceeding after Polygon 3 so it overwrites it:



And then we can shorten the size of the memblock so we can drop the last polygon:



We will also have to change some of the header data in order to really remove the polygon. So how does this look with code? Let's get started. *Cracks Knuckles like always*

First of all, we need to convert the object into a memblock so we can edit it. Pretty straight forward:



As we discussed above, we will need to shift all of the data down. Depending on the flexible vertex format (FVF) the vertex is going to have different sizes in the memblock. Don't worry too much about that, the size of the vertices is saved in the header of the memblock in bytes, so we're going to read the header and then shift all of the data after the deleted polygon up. Here's the code:



I hope that works, I'll be in range of a DBP compiler in a few hours and will hopefully remember to check on this again.

TheComet

"Why geeks like computers: unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep." - Unknown
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Oct 2012 16:57
TheComet, just the guy I had in mind for this and I new I would facepalm later as i could not bring FVF to mind earlier... thanks for the reminder

Hopefully this will also bump a messge to your email to remind you to check back here

Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Oct 2012 19:11
instead of memblock you can use this command: DELETE MESH FROM VERTEXDATA

paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 3rd Oct 2012 21:13 Edited at: 4th Oct 2012 07:59
That will only work if your object doesn't use a shared vertex data format,which you can find out by checking if its index data count is zero.If its zero then all is well,if not then you would have to build the new object by looking at each of the vertex points referenced by its index data.If it is zero then an even quicker,but much dirtier way of doing it would be to just reset the vertex points of the poly you want to remove all to the same position a long way from the camera,so they just wouldn't be drawn any more,and even if you did get close enough for them to be drawn they would just appear as a single dot.On top of all that it loses all the uv data for the object so texturing is going to require a lot more work later.
darkvee
20
Years of Service
User Offline
Joined: 18th Nov 2005
Location:
Posted: 4th Oct 2012 04:00 Edited at: 4th Oct 2012 04:10
Wow! TheComet my hero!

Thank man.

By knowing how do a single poly removel I can now try out removing 100's of polys a second. Now I can finally test some things out.
Thanks so much.

Also thank you for everyone that tried to help.

darkvee

Login to post a reply

Server time is: 2026-07-08 23:02:41
Your offset time is: 2026-07-08 23:02:41