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 / Combining objects into one

Author
Message
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 21st Mar 2011 11:02
I have a piece of floor, piece of wall and a corner and I want to make a room from them. Room as single object, without limbs. Pieces have 2 different UV channels. Although I can make one unwrap texture on all pieces or 3 separate textures. So, can you give me advice how to do that if it is available to do at all?

Jimmy
22
Years of Service
User Offline
Joined: 20th Aug 2003
Location: Back in the USA
Posted: 21st Mar 2011 14:27
This is rather simple to do with vertex commands.

The code below is a test program I made a while back which shows the difference in performance between 100 objects and those 100 objects combined into one. I don't have time to explain it all now, but I'll come back to this thread in a bit.

The simplest way to deal with texturing is to have every object use the same texture file, that way you don't have to deal with changing UV data.



NaGaFailMo.
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 21st Mar 2011 14:37 Edited at: 21st Mar 2011 14:53
Well, thanks!
As I understand, the result is single mesh.
I have not tested yet, but:
1) can I "cut" certain object from big mesh?
2) can I have 2 or more UV channels?
3) does this code weld vertexes between objects?

Also, does ADD MESH TO VERTEXDATA the same thing?

Jimmy
22
Years of Service
User Offline
Joined: 20th Aug 2003
Location: Back in the USA
Posted: 21st Mar 2011 18:49
1) I'm sure you could. You'd just have to keep track of which vertices belong to which object, then use the DELETE MESH FROM VERTEXDATA command.

2) I think you can? This low-level vertex manipulation stuff is still pretty new to me, so I couldn't give you a straight answer. But if it is possible, I'd imagine it'd involve choosing the correct FVF value and size for the memblock being converted to a mesh, which, in my code, is done here:

mapMem = MakeMemblock(12+32*(numVerts))
Write Memblock Dword mapMem, 0, 274

Each vertex holds 32 bytes of information (8 dwords) and 274 is my FVF (Flexible Vertex Format) value. If you look into FVF values, I'm sure you can find something to fit your needs.

3) The only "welding" that occurs with this code is if two vertices have the same coordinates, otherwise the objects are completely separate, but still part of one single mesh.

NaGaFailMo.
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 21st Mar 2011 19:51 Edited at: 21st Mar 2011 19:53
Hmm sounds very complicated, surely PERFORM CSG UNION 1,2 would work? Then rinse and repeat to add more stuff. Couldn't say if it adds limbs or not offhand though. I have used that command to join blocks together.

http://s6.bitefight.org/c.php?uid=103081
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 22nd Mar 2011 15:35
Quote: "The only "welding" that occurs with this code is if two vertices have the same coordinates, otherwise the objects are completely separate, but still part of one single mesh."

Oh, sounds good. Is it "true" welding, like two or more vertices in same place weld into one?

@DVader
afair union requires two solid objects like cubes not plains or triangles

and what about ADD MESH TO VERTEXDATA command? is it useful for me?

Brendy boy
21
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 22nd Mar 2011 15:57
Quote: "Oh, sounds good. Is it "true" welding, like two or more vertices in same place weld into one?"

There's is no welding in that code. If you convert object to memblock or create a new object from memblock the newly created object will have only vertexdata thus no welding is possible. For welding object needs to have indexdata aswell and that's not possible using memblocks. If you want welding you will need to use vertexdata commands.

Login to post a reply

Server time is: 2026-07-17 14:12:50
Your offset time is: 2026-07-17 14:12:50