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 / Fake matrix using memblocks

Author
Message
kevil
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 10th May 2003 01:13
This is just me learning memblocks. And I think I did quite well after only 2 days of using memblocks. (I recently received DBPro ). This code makes an object using memblocks, with which you can use most of the standard matrix commands on. I also added a few:
-set matrix color (setmatrixcolor(matrix,x,z,color))
-texture matrix (texturematrix(matrix,image,xscale,zscale))
With texture matrix you can easily put a texture over the "matrix" without having to deal with tiles.
It's a bit basic (and maybe quite useless), but maybe this can help you trying to understand how to make a mesh using memblocks.

Source+media:
http://www.realgametools.net/forums/attachments/memmatrix.zip

Screenie:


Kevil
Firesea
21
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 10th May 2003 01:59
Excellent work - gotta review what you did but a couple of quick questions:

1) Can your matrix exceed 128x128 divisions? Normal matrix cannot and only draws a partial matrix - see thread in DBpro limit onmatrix tiles.

2)Can I individually color or texture a single tile - seems that's what you said - just checking
3) DO you make an object from the memblock that resenbles the matrix? That opens alot of additional things to do with it.

Firesea
kevil
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 10th May 2003 02:37
Tnx

1)Unfortunately I don't think it can exceed the 128x128 limit. I think that is an object poly limit. You'll have to make more matrices.
2)Yes, you can. You can set the color of a vertex point. And about texturing the matrix. You can use the texturematrix method, but you can also use the original method using preparematrixtexture and setmatrixtile. It all works fine.
3)Yes, it's an object made with memblocks.

Kevil

Attreid
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 10th May 2003 12:07
WOW
it is the best code I have ever seen for making a ground

Bu$herie
How many civilians is he going to kill ? he's going to burn in hell, and I hope that his pain will make him inderstand !
Rob K
Retired Moderator
21
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 10th May 2003 12:24 Edited at: 10th May 2003 12:26
@Kevil

Considering that you have been working on this for such a short time that is amazing. It is far faster than the built-in matrices plus you can use all the object commands on it. Fantastic stuff.

If you are wondering where to go from here, it would be nice if some form of occlusion could be implemented (to up the speed a little). I suggest looking an Dimitros' mouse-pick code for this.

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_101.zip
Cras
21
Years of Service
User Offline
Joined: 15th Oct 2002
Location: United Kingdom
Posted: 10th May 2003 13:57
looks amazing... dont understand the code tho... maybe you should write a tutorial on memblocks after 2 days of learning too. the water goes all weird on my comp... well the edges where it hits the land. but still great stuff.
Attreid
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 10th May 2003 15:39 Edited at: 10th May 2003 17:33
do you have an editor for your matrix ? I can write one

Bu$herie
How many civilians is he going to kill ? he's going to burn in hell, and I hope that his pain will make him inderstand !
kevil
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 10th May 2003 19:41
Thanx

No, I do not have an editor for my matrix. If you could write one...

And occlusion should be quite hard, because the change mesh command is not that fast unfortunately. It would be possible I think, but I don't know if it will be fast enough. I mean, updating the "matrix" more than a few times a second would give a huge slowdown. I hope they could make the change mesh command a little bit faster.

Kevil

Attreid
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 10th May 2003 21:04
I think that it is possible to do that
and I have a system that allow the user to make a whole matrix by changing the height of only 100-120 tiles (okay, it take time, but it is for a 100*100 tiles matrix)
if you want, I can try to do that
(and even if the command is slow, it isn't a problem, I think that there's a way to do a faster system )

Bu$herie
How many civilians is he going to kill ? he's going to burn in hell, and I hope that his pain will make him inderstand !
kevil
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 10th May 2003 22:05
Please try if you want to!

Kevil

D Man
21
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 10th May 2003 22:48
Do you know what I hate about this code?
It's not from me.

God is real, unless declared integer.
kevil
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 11th May 2003 00:37
LOL, I've seen the commercial .

"There is only one thing I hate about this car."
"It's not ours."



Kevil

kevil
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 13th May 2003 13:00 Edited at: 13th May 2003 13:02
On the other forum I was asked to make as many polys as possible with this to test the limits of my computer. Here it is, 135000 polys running at a steady 60 fps on my comp.

I hope it works for you too.
http://www.realgametools.net/forums/attachments/giantmatrix.zip

Kevil

Dostej
21
Years of Service
User Offline
Joined: 21st Jan 2003
Location: Switzerland
Posted: 13th May 2003 13:31
Impressiv

Firesea
21
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 13th May 2003 15:39
Kevil,

Is the large matrix composed of 4 matrix? Just out of curiosity, have you tried making one with more than 128x128 grids as was asked earlier?

I know you said it was a limitation on objects, just seems odd that using multiple matrix can give higher object counts vs. just one.
kevil
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 13th May 2003 15:51
Well, there are 16 matrices in this demo. But I tried to make one huge one. But as soon as I wanted to make one bigger than 128x128 there was no matrix anymore. So it must be some sort of object limit. I believe it has to do with the amount of data stored for each object. Just like you have a limit on the amount of objects.

Kevil

Attreid
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 13th May 2003 16:29
Kevil, how do you make your matrix so smooth ? there isn't a big height difference between two tiles
I tried to make a system that use an image file to set the height of a matrix, but the results aren't very good
here's the code if you want to look at it :


Kevil, I don't understand how work a memblock .. do you can explain me how to make a very simple object please ? a triangle for example, the easier possible ^^

Bu$herie
How many civilians is he going to kill ? he's going to burn in hell, and I hope that his pain will make him inderstand !
Firesea
21
Years of Service
User Offline
Joined: 7th Apr 2003
Location:
Posted: 13th May 2003 16:42
I keep hoping Kevil will write a tutorial for all of us - and he can get paid for it - just get it cleared with Rich.
kevil
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 13th May 2003 17:25 Edited at: 13th May 2003 18:51
Well, I would make a tutorial for this, if I had the time. But right now I have to learn for my exams. So I could only make a tutorial after two weeks from now. I spoke to Rich if he needed any tutorial makers after two weeks. He told me that he didn't need it, unless some tutorials won't get finished.
Anyway, I will ask him again in two weeks. If he still needs some tutorials, I will definately make one about this. If he doesn't need a tutorial anymore, I might make one anyhow, but that's not sure yet.

Attreid:
If I have some time left tonight, I will take a look at your code. BTW I use an image as heightmap too. I only stored the height data in a .dat file, because I had a DBC program that could do that.

Kevil

kevil
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 14th May 2003 00:36
Attreid:
I tried your code and it seems to be fine. A few minor changes tho.


This will produce pretty low heights. Change it to:


And then this:


Should be changed to:

Because a bitmap starts at 1,1 while the matrix starts at point 0,0

Because of this you should also change:

to


And then it works fine. But the preparematrixtexture(1,1,10,10) looks a bit odd, unless you have a texture with 10x10 tiles. You could better use something like texturematrix(1,1,32,32.

That's all.

Kevil

kevil
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 14th May 2003 01:07
And a little "make a triangle with memblocks" tutorial.



Writing this, I found out that you can actually set the transparency for a vertex point. Could be used for cool effect (vertex points slowly fading away as a dying effect or as a teleportation effect)


Kevil

Attreid
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 24th May 2003 15:09
thank you very much for the tuto, now I understand better how it work

I'm doing my best for the editor, and now I'm working on a system that create a ground without the randomize so we'll have smooth hills

Bu$herie
How many civilians is he going to kill ? he's going to burn in hell, and I hope that his pain will make him inderstand !
Rob K
Retired Moderator
21
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 24th May 2003 16:59
Oh! - So DBP does support vertex alpha!

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_102.zip
Rob K
Retired Moderator
21
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 24th May 2003 17:05
@Kevil

I tried replacing the colour DWORD with 4 bytes to experiment with alpha, but it didn't make any difference what value I set the alpha byte to. Could you give a demo for alpha like this?

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_102.zip
n3t3r453r
21
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Russia
Posted: 24th May 2003 18:24
@Rob:
Have you tried to set object transparency to one or two?

I'd like to change the world, but God doesn't want to give me sources!
kevil
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 24th May 2003 18:37
Yeah, you have to set the object transparency to 1, but after some testing, I found out that vertex alpha only works when you don't have a texture on the object.

Kevil

Rob K
Retired Moderator
21
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 24th May 2003 18:59 Edited at: 24th May 2003 19:02
Kevil - I got vertex alpha to work after applying a texture. However, I set up vertex alpha + transparency, THEN applied the texture.

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_102.zip
Rob K
Retired Moderator
21
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 24th May 2003 19:12 Edited at: 24th May 2003 19:17
OK Got it!

After altering vertex alpha, you must:

1) Recall SET OBJECT TRANSPARENCY
2) Retexture the object

Eg: An addition to your code (swap the image for one on your HD)



With P4.1 - I can do this in realtime

This could be VERY useful. For example, you could have water which gets darker and more opaque as it gets deeper.

Another use for this would be a beam effect. You could use vertex alpha to make the ends of the trail more and more feint.

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_102.zip
kevil
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 24th May 2003 19:52
Oh cool! That could definately be useful.

Kevil

The Communist
21
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Cyberspace
Posted: 24th May 2003 20:12
gr8 code comrade

Arise ye workers from your slumbers, Arise ye prisoners of want, For reason in revolt now thunders, And at last ends the age of cant!

Workers of all lands, Unite!
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th May 2003 00:01
Kevil, look at mikes diary entry a few weeks back for the reason for size restrictions
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 25th May 2003 01:25
@ The Communist
Your avatar pops up a password box when viewed.
n3t3r453r
21
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Russia
Posted: 25th May 2003 10:02
> you could have water which gets darker and more opaque as it gets deeper
Have you just understood it?

I'd like to change the world, but God doesn't want to give me sources!
Rob K
Retired Moderator
21
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 25th May 2003 19:22
"Have you just understood it?"

[Goes red-faced]

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_102.zip
Attreid
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 25th May 2003 20:44
I don't have understood

Bu$herie
How many civilians is he going to kill ? he's going to burn in hell, and I hope that his pain will make him inderstand !
n3t3r453r
21
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Russia
Posted: 27th May 2003 12:26
> [Goes red-faced]
sorry

I'd like to change the world, but God doesn't want to give me sources!
pugmartin
21
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 27th May 2003 19:19 Edited at: 27th May 2003 19:20
Oooh. Ive just gone all goosebumply over the mention of a tutorial for this...

Sounds great. Along with rudimentory Physics stuff, i reckon everyone needs to learn this. Good luck. Excellent stuff. And please, that tutorial... x-d

Login to post a reply

Server time is: 2024-04-25 17:39:42
Your offset time is: 2024-04-25 17:39:42