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.

Author
Message
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 27th Jul 2011 21:09
Hello, I'm having a really hard time getting to grips with the vertexdata commands. Basically I just want to combine lots of cubes into one object for a minecraft clone I'm making.

I've been experimenting with it, and so far I've managed this much.




I see the cube I've added. But I expected the set vertexdata position to move one of the vertices, yet it doesn't. Have I gotten the wrong end of the stick here?

Thanks.

Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 27th Jul 2011 21:36
Use an extra flag of 2 in your lock vertexdata command so it will update


But I think it would be easier to just add limbs to the object.
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 27th Jul 2011 21:43 Edited at: 27th Jul 2011 21:48
I've just tried that, it still doesn't have an effect. Am I using the set vertexdata position command incorrectly?
EDIT: Disregard that, I've made progress. :3


From what I've seen of the open source minecraft engine on these forums, using vertexdata instead of limbs gives a massive performance increase.

Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 27th Jul 2011 22:00
Found the problem, you are creating a plain first as a base object and adding the cube later. But you are moving vertex #2. Vertices 0 to 6 belong to the plain, try moving vertex 10 and you will see something
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 27th Jul 2011 22:08
Ah, I thought at plain had 4 vertices, but now I think about it, of course it has 6. xD

Thanks. Do you know of a way I can make this work without having a plain as a base object? I don't want to use any plugins because I'm actually using GDK in my project, but dark basic for testing.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 27th Jul 2011 22:18
In the vertex data of a box, we have 24 vertex...when you add vertex data to your object plain(6 vertex), in this case 24 more vertex, you finally have 30 vertex...then if you want to separate those vertex, you will have to separate from vertex 7 to vertex 30 from the initial mesh...in this example I play with the vertex 7 of your final mesh. I hope it can help



I'm not a grumpy grandpa
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 27th Jul 2011 22:26
You can use DELETE MESH FROM VERTEXDATA Vertex Start, Vertex End, Index Start, Index End:
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 27th Jul 2011 22:29 Edited at: 27th Jul 2011 22:40
Ah, thanks chafari. I'm starting to understand now.



Is there anything here that stands out as being particularly problematic?

Edit: posted the same time as you Max. Thanks, that should work brilliantly.

Now, the only problem I've having is when I add twenty of the meshes to the object, if the first one goes out of view, they all disappear. I assume this is something to do with the culling system.

Any way around this?

Example:




Sorry for all the questions man, Thanks a lot for helping me out.

Indi.

Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 27th Jul 2011 22:44 Edited at: 27th Jul 2011 22:46
looks good, maybe adding an array with the vertexdata start for every cube would be handy, so you can edit the cubes later if you want to:


edit
Didn't read your edit yet when i replied

use calculate object bounds
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 27th Jul 2011 22:49
Sorry made a small mistake in the previous code, here is new code, including calculate object bounds

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 27th Jul 2011 22:50
Adding an array is probably a good idea, yes. But for now I just want to toy about with the vertexdata commands. I usually like to think I know what I'm doing, but I've never used them before.

That command worked perfectly. There's definitely a performance increase, I get over 500fps with 2000 cubes! Compared to about 30fps using limbs. xD Now I want to experiment with making the cubes out of plains, so I can control them individually.

If you don't mind, could you explain how I would go about texturing each individual cube within the mesh?

Thanks so much man, Indi.

Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 27th Jul 2011 23:02
That's gonna be a bit harder since it aren't sepparate limbs, but it is possible. I'll give an example in a few min
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 27th Jul 2011 23:05
I guessed it would be harder. ;3 Thanks man, I owe you one. If there's anything I can do for you, I usually hang around in Geek Culture haha.

Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 27th Jul 2011 23:40
I'm sorry but I can't get it to work here (it's getting late, need some sleep )
But I will give you the basics so you can try it

Basically you need multiple textures in one image (see attachement)

Then you need change the uv's of the cube to the right texture.
For this you need to get the amount of textures inside the image, here 3.

So for the u coordinates of the cube you need to use something like this:



For a plane you would do something like this:


Only for a cube it is a bit harder, I'll try helping you out tomorrow
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 28th Jul 2011 00:18 Edited at: 28th Jul 2011 00:41
Don't worry about it man. Thanks for trying it out. ;D I'll have a look around on the forums and see what I can find.

edit: Your explanation makes sense actually, thanks, time for me to mess abut for a few hours.

Thanks a lot for you help.

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 29th Jul 2011 02:37 Edited at: 29th Jul 2011 03:48
Hey again, sorry to double post but I guessed my edit wouldn't be seen.

I've tried to redo this with plains instead of cubes, I'm having a problem where my plains don't appear when adding them to the mesh.



Any ideas?

Btw, I got the texturing working amazingly, thanks Max!
Thanks, Indi.

Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 29th Jul 2011 14:14 Edited at: 29th Jul 2011 14:18
It took a while but I finally figured out a solution


Still don't know what the problem was exactly, but I did figure out that it doesn't work with this command:

But it does work with this one:

From the matrixUtil plugin (Matrix1Util_18.dll), this one also creates a plain with 4 vertices instead of 6.
Quote: "I don't want to use any plugins because I'm actually using GDK in my project, but dark basic for testing"

Maybe you can find a way without a dll
edit
The code for positioning the plains in a cube was taken from the open source engine: http://forum.thegamecreators.com/?m=forum_view&t=187219&b=1
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Jul 2011 15:23
Not all objects use an index buffer - some do, some don't.
Not all objects use 3-vertices-per-poly triangle list - some use a tri-strip instead.

Basically, you have to take care as you can't just mix and match. If you add a non-indexed tri-strip to an indexed triangle list you just aren't going to get a meaningful result.

Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 29th Jul 2011 15:48
Quote: "If you add a non-indexed tri-strip to an indexed triangle list you just aren't going to get a meaningful result"

That makes sence.. but how do you know if you have an index buffer and a 3-vertices-per-poly or a tri-srtip.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Jul 2011 16:01
You can't get the mesh type with standard DBPro, but you can with my own GET LIMB MESH TYPE function.

You can try converting your limb to a standard tri-list using the CONVERT LIMB TO TRILIST command.

You can detect the presence of an index buffer using the standard GET VERTEXDATA INDEX COUNT() (IIRC - I don't have a copy of DBPro with me right now).

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 29th Jul 2011 16:14 Edited at: 29th Jul 2011 18:30
Ah thanks a lot Max, it sucks that it can (seemingly) only be done with a plugin. Ian, any chance of porting your plugins to GDK? I kid of course.

edit I looked at the set vertexdata diffuse command in an attempt to make a sort of lighting system. I diffused every vertex to green, but there didn't seem to be a change in colour. Am I using it wrongly?

Thanks a lot guys.

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Jul 2011 23:43
Quote: "Am I using it wrongly?"

Only in that your objects are most likely in the wrong format - you need to ensure that the FVF format includes a diffuse component.

Quote: "Ian, any chance of porting your plugins to GDK?"

Not really. There's no point in this instance because most of this can be done in GDK directly.

The mesh type of an object can be accessed by getting the object pointer, using ppFrameList to access your limb (it's an array, one entry per limb), and then following the pMesh pointer to access the iPrimitiveType.

The CONVERT TO TRILIST, is a function already built into DBPro called ConvertLocalMeshToTriList - you just need to pass a pointer to an sMesh as an argument - see above for how to get this pointer for a limb.

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 30th Jul 2011 01:45
Quote: "you need to ensure that the FVF format includes a diffuse component."


How would I go about changing the FVF format it uses? Or have I gotten the wrong end of the stick here?

Thanks, Indi.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th Jul 2011 02:26
Have a look at:

CONVERT OBJECT FVF

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 30th Jul 2011 04:07
Thanks GG, I know it seems like I'm just trying to get you guys to do all the work for me, but I honestly have no idea with this.

I've set the fvf format to this



but the colour of the texture doesn't show diffuse of any kind.

I don't expect you to look through it, but here's the full source if it helps you determine what's wrong, if you're up to it.



If you could help me out, I'd be forever in your debt.

Thanks.

Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 30th Jul 2011 13:08 Edited at: 30th Jul 2011 13:08
When setting the fvf format you need to specify all the things you want, I use some constants to make things clearer:

Now when you change your objects fvf you can use something like this:

This will create an object with 8 texture stages, vertex diffuse data and normals. So for your objects I think you will need something like this:

With only the base texture, vertex diffuse and normals
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 30th Jul 2011 13:47
Ah brilliant! I misunderstood the command for that one, the help file needs to be a little clearer. I changed FVF_TEX0 to FVF_TEX7 and it works exactly how I want.

Everything works exactly how I want it now, I don't think I have anymore questions about vertexdata. Thanks a lot Max P, I couldn't have done any of this without you.

Thanks IanM and Chafari, I owe you guys one.

Indi.

Login to post a reply

Server time is: 2026-07-11 03:38:08
Your offset time is: 2026-07-11 03:38:08