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 / VERTEXDATA UV strange error

Author
Message
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 4th Mar 2011 07:37
I have this short code, which creates a single plain, makes a mesh of it, so i can change the UV coordinates on the second blend layer for my fog of war function which is essential to make it working. (would be)

But there are some strange things, and what seems to be a bug.

First i don't get it why the vertex order is this messed up. It took hours doing nothing but guessing the vertices which triangle they belong to. (the one poly plain is made up of two triangles... just to let you know if haven't already)

The other thing is that although i recover the standard vertex positions using GET VERTEXDATA U() / V() commands, the second triangle gives messed up texture! WHY?! How can it be?

(also spent hours trying to figure out the right values manually, no luck... yeah i know UV coords. go from 0 to 1.0!)

Here is the code, please try out and give me some advice.

Jimpo
21
Years of Service
User Offline
Joined: 9th Apr 2005
Location:
Posted: 4th Mar 2011 16:37 Edited at: 4th Mar 2011 22:18
First off, the first vertex in an object is referenced as index 0, not 1. Second, the vertex ordering is based off whether the plain uses the vertex buffer or the index buffer.

I don't know about the default plains, but I know the ones made using IanM's Matrix1 Utility plugin use the index buffer. This means there are only four vertices for the plain. The first triangle is made from vertices (0,1,2) and the second is made from (1,2,3). I'd imagine the default plains work similar.

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 4th Mar 2011 17:47
This is a function I use to UV map a plain...



Used for tile sheets, so the function takes the object number, then the x and y tile coordinates, and the tile width and height. You could easily change it to take direct UV coordinates, maybe like this:



Hope this helps.

Health, Ammo, and bacon and eggs!
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 5th Mar 2011 00:11
Using this:

set vertexdata uv 1,0, get vertexdata u(1),get vertexdata v(1)
set vertexdata uv 2,0, get vertexdata u(2),get vertexdata v(2)
set vertexdata uv 3,0, get vertexdata u(3),get vertexdata v(3)
set vertexdata uv 4,0, get vertexdata u(4),get vertexdata v(4)
set vertexdata uv 5,0, get vertexdata u(5),get vertexdata v(5)
set vertexdata uv 6,0, get vertexdata u(6),get vertexdata v(6)

Shouldn't change ANYTHING, AT ALL.

No?

This is the basic problem, they get the same values they already have... and things just get messed up with the second triangle. No matter what method or structure, this seems to be an error in DBP.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Mar 2011 12:28
If you use invalid vertex numbers then all sorts of strange things can happen. Just do what the other posters have suggested, i.e. use vertices 0 to 5 not 1 to 6.

However, as it happens your code doesn't seem to mess anything up here. That could be luck though.
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 5th Mar 2011 12:42
Well, would have been just fine to point it out this plain and simple.

Thank god you are here on this forum Gandalf.

This program has the poorest documentation ever, why don't they make a decent help file for it at last? When the user wants to actually DO SOMETHING outside of spheres shooting boxes in front of a scrolling background, you suddenly find yourself out of nowhere with your own luck. Especially the Memblock section. It is there, without practically any details.
Jeff Miller
21
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: New Jersey, USA
Posted: 5th Mar 2011 12:59 Edited at: 5th Mar 2011 13:00
Since you only seem to be interested in two triangles, presumably on one side of the plane, you really should look into making your own one-sided plane with IanM's plugin as mentioned by Jimpo. That keeps it clean, with 4 vertices, not six. Also, using that method you never have to scratch your head over the order in which the vertices are placed since you have created the order yourself. A final advantage, which I use a lot, is that if the plane is intended to hold a fixed startup location, you merely use the proper coordinates when you create the plane. You do not have to position it later.

Login to post a reply

Server time is: 2026-07-16 18:24:52
Your offset time is: 2026-07-16 18:24:52