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.

Code Snippets / new matrix functions

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Jun 2004 06:24 Edited at: 8th Nov 2012 16:36
Default matrix too slow for you? Then try mine!

You can now texture the matrix with various tiles. That alone I think was the biggest pain in the butt! Recently added "pick_matrix()". Code demonstrates use of this function. It gets the x,y,z coordinates on the matrix given 2d screen coordinates.(such as your mouse cursor)

Functions include:
prepare_matrix_data()
create_matrix()
prepare_matrix_texture()
set_matrix_height()
set_matrix_tile()
update_matrix()
position_matrix()
get_ground_height()
pick_matrix()


With the demo code below, I get between 460 and 500 fps.

http://www.dannywartnaby.co.uk/rgt/attachments/matrix_functions.zip


[edited: 10-14-2005]
code posted due to LLRGT server being down for an extended period


"You're not going crazy. You're going sane in a crazy world!" ~Tick
MikeS
Retired Moderator
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 7th Jun 2004 19:18
Very nice Phaelax. Have been working on memblock matrices myself as well. People should really start switching to memblock matrices for speed and the ability to manipulate landscapes as objects.

It's just great!



A book? I hate book. Book is stupid.
(Formerly known as Yellow)
PantheR RIP
21
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 7th Jun 2004 20:54
WOW... It's realy awesome! I'll try to use this one in my project - it takes a lot of work to rid off that matrices but i want to see the result =) FPS problem is most annoying problem in DBPRO. BTW it will be good to add SET_MATRIX function to your sources to have an availability to change objects options...
PantheR RIP
21
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 7th Jun 2004 21:07
ooops! I can't see that matrix... =(( Strange. Have no idea what is this!!! Just unseen... Also PICK_MATRIX function isn't optimal for FREE rotation and sizing...
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Jun 2004 02:36
pick matrix should work with any rotation, camera or object. but it could be optimized further.

"eureka" - Archimedes
PantheR RIP
21
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 8th Jun 2004 07:50
Hmmm... does PICK MATRIX function work with FOV change? Strange... Pointer sphere spawns at the camera coordinates.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Jun 2004 09:35
works perfectly find for me. same method i use for my rts.

"eureka" - Archimedes
Cian Rice
20
Years of Service
User Offline
Joined: 8th Jun 2004
Location:
Posted: 12th Jun 2004 05:22
Does this only work in Pro or will it work in Classic Enhanced too, since that supports memblocks...
Please answer, I'd love to know so I can download it...

Got anime?
I do.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 12th Jun 2004 22:16
pro only. someone is trying to convert it to classic though

"eureka" - Archimedes
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 14th Jun 2004 20:53 Edited at: 14th Jun 2004 20:56
I might just make the switch after these functions It'd mean proper ghosting at least!

Now all we needs is for some clever soul to write a routine that smoothly textures then depending upon height. Hmm.

(ps - might want to change your .dbpro file to read "main=verts.dba")

Two strings walk into a bar. I'll have a pint says the first$%ASLDJ09920D"$"$D. Excuse my friend says the second, he isn't null terminated.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 15th Jun 2004 02:13
Quote: "ps - might want to change your .dbpro file to read "main=verts.dba")"

Why's that?

Quote: "a routine that smoothly textures then depending upon height"

Started working on it last night. Van-B used the same method in his holiday tech demo that I'm currently working on. All I gotta do is add the correct normals code, and it's basically complete.

"eureka" - Archimedes
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 16th Jun 2004 20:29 Edited at: 16th Jun 2004 20:30
Quote: "Quote: "ps - might want to change your .dbpro file to read "main=verts.dba")"
Why's that?"


Because on my PC d:/whatever/verts.dba doesn't exist you get an error.

Started working on it last night. Van-B used the same method in his holiday tech demo that I'm currently working on. All I gotta do is add the correct normals code, and it's basically complete.

Looking forward to it! After that, I might finally make the switch to memblock matrices. I have an idea for a game once I finish MiS, which is currently being polished

Two strings walk into a bar. I'll have a pint says the first$%ASLDJ09920D"$"$D. Excuse my friend says the second, he isn't null terminated.
Marthik
20
Years of Service
User Offline
Joined: 25th Jan 2004
Location: Washington State, USA
Posted: 16th Jun 2004 23:03 Edited at: 17th Jun 2004 00:02
Quote: ""a routine that smoothly textures then depending upon height""


also, a routine that will do slope as well, which is more imortant in my option.
Marthik
20
Years of Service
User Offline
Joined: 25th Jan 2004
Location: Washington State, USA
Posted: 16th Jun 2004 23:13 Edited at: 17th Jun 2004 00:02
good job, on the matrix, it's really nice, i think i'll use it in my mini game i am making for the community.

[edit]
you seem to have forgotten, a very important function Randomize Matrix, so i won't be able to use it after all.
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 17th Jun 2004 00:08 Edited at: 17th Jun 2004 00:09
Quote: "you seem to have forgotten, a very important function Randomize Matrix, so i won't be able to use it after all. "


That's easy!



Two strings walk into a bar. I'll have a pint says the first$%ASLDJ09920D"$"$D. Excuse my friend says the second, he isn't null terminated.
jwurmz
21
Years of Service
User Offline
Joined: 6th Oct 2003
Location: Arizona, USA
Posted: 17th Jun 2004 04:01 Edited at: 17th Jun 2004 22:26
David T:
i think just one "randomize timer()" at the beginning of the program will suffice. it'll free up a little cpu if you didn't reseed every time you set the height. but good job otherwise

"Creativity is knowing how to hide your sources" - Einstein
jwurmz
21
Years of Service
User Offline
Joined: 6th Oct 2003
Location: Arizona, USA
Posted: 17th Jun 2004 22:29
Phaelax, one quick question about your code...
what does "get pick vector x()" refer to? it looks like a command, but the GUI editor doesn't change its color. i thought it might be a function, but i didn't see it. nice code btw, very fast!

"Creativity is knowing how to hide your sources" - Einstein
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Jun 2004 10:30
After calling pick object(), the data from that method call is stored in a vector. You retrieve that data from the get pick vector commands. Basically, its a vector of the distance from the camera to where the intersecting coordinates are.

"eureka" - Archimedes
Marthik
20
Years of Service
User Offline
Joined: 25th Jan 2004
Location: Washington State, USA
Posted: 18th Jun 2004 11:30
Quote: "That's easy!"


i know, just didn't feel like thinking about it, for some reason...
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 18th Jun 2004 19:51
Quote: "David T:
i think just one "randomize timer()" at the beginning of the program will suffice. it'll free up a little cpu if you didn't reseed every time you set the height. but good job otherwise "


I always thought that calling multiple rnd() commands with the same seed returned the same results... may just have been me. If I was wrong then yes just put randomize timer() at the beginning.

But, if rnd(constant) always returned different results, then what's point for randomize()?

Two strings walk into a bar. I'll have a pint says the first$%ASLDJ09920D"$"$D. Excuse my friend says the second, he isn't null terminated.
Marthik
20
Years of Service
User Offline
Joined: 25th Jan 2004
Location: Washington State, USA
Posted: 19th Jun 2004 08:55 Edited at: 19th Jun 2004 08:57
no, it just does the same sequence, so if did randomize 101 then every time i ran the program, it would be the same.



/edit

btw there is a topic around here somewhere on random numbers, and randomize, it explains it a little bit.
Marthik
20
Years of Service
User Offline
Joined: 25th Jan 2004
Location: Washington State, USA
Posted: 20th Jun 2004 01:18
mmm your get ground height function doesn't seem to work, it keeps puting the building at the same height no matter, what the height of the ground is.
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 20th Jun 2004 01:38
I know that rnd(whatever) will produce the same result without randomize [whatever] being called - however does anybody know if you do this:

randomize timer()
print rnd(10)
print rnd(10)
print rnd(10)

then will all the results be the same?

Lol, I suppose it's easy enough to find out; don't feel like going on DB now though

Two strings walk into a bar. I'll have a pint says the first$%ASLDJ09920D"$"$D. Excuse my friend says the second, he isn't null terminated.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 20th Jun 2004 02:09
anyone else have problems with get ground height()? Cause its working fine here.

"eureka" - Archimedes
jwurmz
21
Years of Service
User Offline
Joined: 6th Oct 2003
Location: Arizona, USA
Posted: 20th Jun 2004 05:04
David T:
i have no idea what the chances of all three being the same (7,7,7) are, probably like 1 in 1,000,000,000 or something.
the chances of those commands yielding the same results on different occasions (7,2,4 and 7,2,4 again) is 1 in 1000. reason - the random number generator is seeded by TIMER() which is always the system times' millisecond reading. so the only time the numbers will be the same on two different occasions would be if the program seeded the RNG at the same exact millisecond-time each time. i think...

"Creativity is knowing how to hide your sources" - Einstein
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 20th Jun 2004 19:56
Okay - the only reason I asked is that I read somewhere once that in order to get different results for the same value you need to radnomze each time. Silly person

Two strings walk into a bar. I'll have a pint says the first$%ASLDJ09920D"$"$D. Excuse my friend says the second, he isn't null terminated.
jwurmz
21
Years of Service
User Offline
Joined: 6th Oct 2003
Location: Arizona, USA
Posted: 21st Jun 2004 06:49
actually, after further testing the timer() function returned a 7-digit number so the chances are more like 1 in 9999999. don't take my word for it though. just know that a single "randomize timer()" command is enough to get random results, no matter where or when you use a "rnd(whatever)" function thereafter.

"Creativity is knowing how to hide your sources" - Einstein
Jetmech
22
Years of Service
User Offline
Joined: 25th Oct 2002
Location: Dayton Ohio
Posted: 21st Jun 2004 07:04
Just out of curiosity, ( your functions are great) but.... Kevil made all these same functions and several more, months ago... aren't you kind of reinventing the wheel here?
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Jun 2004 11:15
I didn't know he made them until i started making them. besides, i wanted to know how to use memblocks. dont like it, dont use it.

"eureka" - Archimedes
Marthik
20
Years of Service
User Offline
Joined: 25th Jan 2004
Location: Washington State, USA
Posted: 21st Jun 2004 11:53
mmm i am not sure y it's not setting the object to the currect height, but i lowered the amound my landscape is randized by, so now it's smaller, and can't be noticed, or maybe it just works now...
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 21st Jun 2004 11:53
I could never get results with Kevil's functions. These look a lot more like normal matrix commands

Two strings walk into a bar. I'll have a pint says the first$%ASLDJ09920D"$"$D. Excuse my friend says the second, he isn't null terminated.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Jun 2004 09:06
well technically they are. but the matrix is an object now.
Just so you know, the get ground height() doesn't work for heights lower than 0.

"eureka" - Archimedes
Jetmech
22
Years of Service
User Offline
Joined: 25th Oct 2002
Location: Dayton Ohio
Posted: 22nd Jun 2004 14:33
phaelax,

wasn't trying to put down your work in any way, as I stated in my previous post, your functions work great and its obvious that that a lot of work went into them!

Sorry if I came off the wrong way!

please keep up the good work!


Jet
Steele
21
Years of Service
User Offline
Joined: 25th Oct 2003
Location: Somewhere over the rainbow
Posted: 22nd Jun 2004 18:42
Something that might be beneficial would be "set_matrix_normal" as I am using a small routine which uses it.

Just something to think about, maybe for version two.

Good job!

Steele

-- I straddle the line between genius and insanity. Guess which side I am on now? --
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Jun 2004 19:53 Edited at: 22nd Jun 2004 19:56
Well, alright. Until I get the DLL completed, and fully functional, here's the DBP source for all commands. Includes matrix normals, and an auto configure routine.(not sure how well it works) A revised version of get ground height is in the works. It should replace the current method and increase frame rates by over 100. At least it does on my machine, as intersect object is slooow. Randomize matrix added.
Yes, maybe some ppl have made programs like this before. But has anyone made it into an easy to use set of functions?
Check source button below for full source code including new functions.

"eureka" - Archimedes
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 22nd Jun 2004 21:16
Automatic normal calculation'd be nice

Two strings walk into a bar. I'll have a pint says the first$%ASLDJ09920D"$"$D. Excuse my friend says the second, he isn't null terminated.
Jetmech
22
Years of Service
User Offline
Joined: 25th Oct 2002
Location: Dayton Ohio
Posted: 23rd Jun 2004 06:18 Edited at: 23rd Jun 2004 06:28
disregard this post
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Jun 2004 09:39
Quote: "Automatic normal calculation'd be nice "



from my post just above yours:
Quote: "Includes matrix normals, and an auto configure routine"



so umm, yes its there.

"eureka" - Archimedes
jwurmz
21
Years of Service
User Offline
Joined: 6th Oct 2003
Location: Arizona, USA
Posted: 26th Jun 2004 10:28
Phaelax:
just wanted to thank you for the memblock matrix code. it works splendidly!!! i'll be sure and give credit in the event that i finish my project... the very first "old west" RPG. your method will allow me to make my landscapes MUCH larger. if you improve on it any more (than you already have), don't hesitate to update the code snippets section. thanks again

"Creativity is knowing how to hide your sources" - Einstein
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 26th Jun 2004 12:52
Quote: "from my post just above yours:

Quote: "Includes matrix normals, and an auto configure routine"


so umm, yes its there"


Hmm, well, I had a quick scan through and couldn't see anything

Two strings walk into a bar. I'll have a pint says the first$%ASLDJ09920D"$"$D. Excuse my friend says the second, he isn't null terminated.
jwurmz
21
Years of Service
User Offline
Joined: 6th Oct 2003
Location: Arizona, USA
Posted: 26th Jun 2004 15:28 Edited at: 26th Jun 2004 18:19
it's there





"Creativity is knowing how to hide your sources" - Einstein

Login to post a reply

Server time is: 2024-11-23 19:21:32
Your offset time is: 2024-11-23 19:21:32