Posted: 10th May 2003 1: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
Posted: 10th May 2003 1: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
Posted: 10th May 2003 2: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
Posted: 10th May 2003 12:07
WOW
it is the best code I have ever seen for making a ground
Posted: 10th May 2003 12:24
@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.
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.
Posted: 10th May 2003 15:39
do you have an editor for your matrix ? I can write one
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
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 )
Posted: 10th May 2003 22:05
Please try if you want to!

Kevil
Posted: 10th May 2003 22:48
Do you know what I hate about this code?
It's not from me.
Posted: 11th May 2003 0:37
LOL, I've seen the commercial .

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



Kevil
Posted: 13th May 2003 13:00
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
Posted: 13th May 2003 13:31
Impressiv
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.
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
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 :
+ Code Snippet
   rem input "Which image do you want to use ? ",img$
      rem img$ = "terrain.bmp"
rem THE IMAGE MUST BE BLACK AND WHITE OR RED AND WHITE
   img$ = "terrain2.jpg"
   rem input "Choose the size of the matrix ",size
   size = 1000
   rem input "Choose the texture> ",texture$
   texture$ = "grass2.bmp"
   load bitmap img$,1
   tilex = bitmap width(1)
   tilez = bitmap height(1)
   makematrix(1,size,size,tilex,tilez)
      rem to set the height
      set current bitmap 1
      for x=1 to tilex
         for z=1 to tilex
            rem because the bitmap is in black and white : red = blue = green
            rem I'll work only on the red
            y# = rgbr(point(x,z))/(size/100)
            setmatrixheight(1,x,z,y#)
         next z
      next x

   set current bitmap 0
   load image texture$,1
   preparematrixtexture(1,1,10,10)
updatematrix(1)


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 ^^
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.
Posted: 13th May 2003 17:25
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
Posted: 14th May 2003 0:36
Attreid:
I tried your code and it seems to be fine. A few minor changes tho.
+ Code Snippet
rgbr(point(x,z))/(size/100)


This will produce pretty low heights. Change it to:
+ Code Snippet
rgbr(point(x,z))*(size/1000)


And then this:
+ Code Snippet
   
tilex = bitmap width(1)
tilez = bitmap height(1)


Should be changed to:
+ Code Snippet
   tilex = bitmap width(1)-1
   tilez = bitmap height(1)-1

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

Because of this you should also change:
+ Code Snippet
setmatrixheight(1,x,z,y#)

to
+ Code Snippet
setmatrixheight(1,x-1,z-1,y#)


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