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.

3 Dimensional Chat / Is there a command to flip the UV Map?

Author
Message
Soyuz
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 14th Jan 2003 13:27
I can see commands to scroll, scale or mipmap a texture but I can't see a way to just flip it...anyone found a way for this?
Dr DooMer
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 14th Jan 2003 18:03
Memblocks - when you make a memblock from an object you have control over the UV mapping coodinates. I think a command like "0 - UCood" for each vertex would flip in the U direction.

"I am a living, thinking entity who was created in the sea of information."
Soyuz
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 14th Jan 2003 18:53
Unfortunately memblocks are somewhat alien to me - Having looked in the manual I can not figure how I could flip the memblock if indeed that is what is needed. Nothing refering to "0 - UCood" or changing mapping coords.

Any additional hints?
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 14th Jan 2003 20:59
thats because Memblocks are more generalised than that...
here's a function that should achieve what you want





Anata aru kowagaru no watashi!
Soyuz
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 15th Jan 2003 00:09
Thanks for this. This is all new to me and I would like to understand it. I'm ok with the first part and I kinda grasp the concept of what is happening, but when I try the code out it gets to the the for next loop and is bugging out with "Memblock position outside range".

Could this mean it's not loading the image from the object correctly. For the data sent to the function I can not see how "Image" is being used. Do I have to feed the function with an image number? I don't understand!
Soyuz
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 15th Jan 2003 00:42
When I chucked some stuff through it I got
vCount=275
vOfslni=60000

So presumably the error I'm getting is something to do with 60,000 being outside the range of the memblock.

Can I ask what is happening when you increment position by 4?
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 15th Jan 2003 03:37
there is an error in the code as i usually do with all of it ... i'll break it down for you

firstly using the actual function

now i've change this to be simpler to use, the first number is the model and the second is the skin|texture.
The last is now a new value, which i'm dubbing as Flip Angle...
if its 0 then it flips the U (horizontal) Coords, if its 1 then it flips the V (vertical) Coords ... and if its 2 then it flips both

Also added a small gosub incase there is an error.
I'd suggest doing as i oftenly do and make a compiled Error Array, like
Error$(1) = "Media Not Found"
Error$(2) = "Memory Block Unavailable"
(these are the only 2 you'll really need for now)

this section makes sure the object is available to use ->


you'll notice the endfunction has a 'hError' value, this is to make sure that what is returned will let us understand where and error occurred which DB isn't programmed to check for.

now you want to add in the << Code Goes Here >> spot



this simply automatically checks for the next available memoryblock position, a useful snippet if you get into the habit of releasing memoryblocks once you've finished with them

now right after this we put this


might seem silly really but is really just somewhere to put you code neatly and just double checking that the block you want to use is actually there, but as it should be this is the reason for no 'Else' for the error logging.

yay... now we can finally get into the nitty gritty of the actual code



first we add this code ... basically the aim here is to take the specified model and throw it into a memblock for use. It is far easier to populate a memory block by having DarkBasic itself mess about with the actual populating with a from a mesh rather than doing it manually.
As currently DarkBasic only has a Mesh -> Memblock command this is why we convert first.
Notice that after changing format each time firstly to mesh then to memblock i'm deleting the old values... what i'm actually doing is freeing up the values so we can use them again once we're done with the editing.
It also helps with the actual memory being used, but most programmers don't think about that kinda thing for some reason.

Now as DarkBasic only supports a single set of UV coordinates PER Vertex the next thing to do is find out how many of the little buggers are in the model

Mesh Memblock Setup
be sure to check that out for more info on Mesh Memblocks...



i'm not sure however the Calculated LNI Offset SHOULD be identical to the one in the dword position 28.
However sometimes there are discrepencies.

now we'll actually start flipping the UV points



now fCoord# is the 0.0 -> 1.0 floating point taken from the model, the fWrite# is the flipped floating point.

the pos = the memblocks byte position... you add 4 each time because a float is 4bytes.
hopefully this has now made everything a bit clearer and more importantly without some obvious flaws

now we use a 1.0 value and then subtract the original value because to produce a flip of the original you always use the Maximum Value - Current Value
and there is your flipped value

Anata aru kowagaru no watashi!
Soyuz
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 15th Jan 2003 13:31
I am very grateful for your support Raven. I still seem to have problems but maybe this is to do with something I am doing prior to entering the function. Here is the relevant code as it stands...




Now when I try this out it is returning an hError=2, so does this mean it's not finding an empty memblock? I'm not using memblocks elsewhere in my code. Could it be because the .x object already has a texture assigned to the model?

Thanks again for the guiding light!
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 15th Jan 2003 23:21
hmm... maybe there's a problem with my Automatic Memblock allocation.

Remark the While...EndWhile and the Memblock = 1, then add to the function at the end ',memblock'
then add a memblock number after it

odd how that is the current problem lol

Anata aru kowagaru no watashi!
actarus
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location: 32 Light Years away
Posted: 16th Jan 2003 16:31
That's a cool snippet there RV

Memblocks are very efficient...Along with the according coding ability of course.

Just remember that you're standing on a planet that's evolving
And revolving at nine hundred miles an hour!
Soyuz
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 24th Jan 2003 19:38
Woohoo!! Got distracted by other things but I have now come back to flipping the image (or the mesh) using memblocks and I understand what's going on and have got it to work now. Many thanks for the support Raven.

Login to post a reply

Server time is: 2024-04-20 09:39:14
Your offset time is: 2024-04-20 09:39:14