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.

Newcomers DBPro Corner / [Tutorial] - Venom - Make memblock objects on the fly

Author
Message
LastChance
13
Years of Service
User Offline
Joined: 11th Sep 2011
Location:
Posted: 11th Sep 2011 20:08
Hi guys,

if you are a little familiar with memblocks and creating 3D objects from them, you know that it's not as easy as it looks.
You have to worry about memblock size, FVF format, offset calculation, normals and so on.

The advanced folks may laugh at that, but for beginners it costs a lot of nerves and mostly code.

Is there an easier way?

Ok, lets start.

First of all you need my header - Venom_v1.0.dba
You can get it from the code snippet below or by downloading the attached file.



Now start a new project and import the header.
Solution Explorer -> Import Existing File -> Venom_v1.0.dba

The basic template for Venom looks like that:



To see the actual results we'll use the more advanced one shown below:



Now compile and run the project. Use arrowkeys to navigate around the matrix until you see the white triangle.

To draw a mesh in the 3D world we use vertices.
In our case, we made the simplest mesh - triangle.
3 vertices form 1 triangle

Now look at the template and find the section:

begin_object(n)

vertex(x1#, y1#, z1#) 3 fertices = 1 face
vertex(x2#, y2#, y2#)
vertex(x3#, y3#, z3#)
`etc.

end_object()

Thats the place where the magic happens
To create object with Venom, you have to type begin_object(n), where n is the object number.
By definition n must be greater than 0.
Then just type the vertices you want(probably you'll need a little imagination).

As you'll see the order in which you declare your vertices counts.
But I'll explain that in other post.

You can create more complex objects using triangles.
But you can't type 4 vertices and expect to get quad,
because DBPro doesn't support that.
But there is solution to that I'll show you at the end.

-Why the triangle is visible only from one side?
Because 3 vertices form only one face. To be visible from both sides you need to add another 3 vertices in reversed order or just type dual_face() after the last one like this:



-Can I change the color of the vertices?
Yes, you can. You can use color_def(myColor as dword) to set default color for all vertices or use color(myColor as dword) after each one



In addition you can use color_rand() for random color.

To flip a face just type flip_face():



You can set uv values using uv(u#, v#) after each vertex. By default all are set to (0, 0).

Normals are calculated automatically after end_object() is reached.
You don't need to worry about them.

The limits of Venom:
- only one object at a time(you cant cycle begin_object() in another one).
But you can do this:



To simulate quads you can use the following commands:

venomTileXZ(x#, y#, z#, size)
venomTileXY(x#, y#, z#, size)
venomTileYZ(x#, y#, z#, size)

in combo with:

flip_tile()
dual_tile()

With their help you can make terrains, but at the moment they have limited usage.

But nothing stops you to implement your own functions.

That from me for now...



Bye!

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-24 01:51:41
Your offset time is: 2024-11-24 01:51:41