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.

Newcomers DBPro Corner / Manipulating the height of matrix tiles

Author
Message
Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 27th Aug 2006 16:43 Edited at: 27th Aug 2006 16:44
Hi all.

I've recently been experimenting with how to manipulate the apperence of an matrix. I'm trying to understand how to set the tile heights. But it doesn't work correctly. Sometimes it works, then the matrix get heigher, but sometimes it doesn't happen anything, and sometimes it get a bit heigher but then stop. Can someone help me, I'm not too good at it. This is the function I use to change the height of the tiles:
. And this is the rest of the code:
.

And one thing more. I've discovered a strange but cool effect when I colour the matrix. I don't wish to remove it, but could someone explain why the matrix get the texture it does. I post an .jpeg image so that you can see it directly.

Image:

Attachments

Login to view attachments
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 28th Aug 2006 02:32 Edited at: 28th Aug 2006 02:50
Any time you create then modify a matrix you must update the matrix with
the changes you made with UPDATE MATRIX matrix number.

Until you know how to use the matrix commands, I would suggest using them
without creation custom functions. This may cause you more headaches right
now.

Any time you texture a matrix with an image you would use:

Quote: "
PREPARE MATRIX TEXTURE
This command will select an image of tiled textures that the matrix will eventually use. Each grid square in
the matrix can have a tile texture, located within the image. Individual tile textures can be obtained from
the single image by slicing it into sections both across and down. The tile textures are then assigned a
number starting in the top left corner of the sectioned image and working across, then down. To section
an image into 4 smaller tile textures you would specify 2 across and 2 down.

SYNTAX
PREPARE MATRIX TEXTURE Matrix Number, Image Number, Across, Down
"


You would then use the following commands to texture your matrix.

FILL MATRIX Matrix Number, Height, Tile Number
and/or
SET MATRIX TILE Matrix Number, TileX, TileZ, Tile Number

If the image is sliced into 4 equal pieces, then the first texture image tile
would be the upper left-hand corner. The second would be the upper right-
hand corner. The third would be the lower left-hand corner. The fourth
would be the lower right-hand corner.



Because the matrix was not textured and updated properly the
texture information was not referenced and you are seeing random
data from video memory.
Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 28th Aug 2006 10:13
Advice taken. I will learn more about matrixes before I create functions. However, I'm using "update matrix" at the end of the code (just above "sync"). Are you meaning that I should move it so that I update the matrix directly after I've made the changes?
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 28th Aug 2006 19:18
Yes, you should put the update matrix command after you modify the matrix inside of your function. I wouldn't put it in the main loop unless you plan on changing the matrix every pass. I wouldn't recommend doing this either for performance reasons.
Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 28th Aug 2006 19:36
I've put the "update matrix" command directly after the "set matrix height" in the function, but it didn't work. The problem is still there: sometimes the matrix get heigher or lower, sometimes nothing happens, and sometimes the heighet of the tile change a small bit, but then stop. I've tested to do it without any use of functions, but I got the same results. So it must be something else. Do anyone see the problem?

Current code:
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 28th Aug 2006 20:45
Texture looks wrong because you should not delete the image that you use to prepare matrix with.

Also, you are confused with way matrix heights work.

GET GROUND HEIGHT will tell you height at any coordinate, even within individual tiles.

GET MATRIX HEIGHT tells you height at a corner of a tile. You have 100 tiles, so you can get heights from 'tiles' 0 to 100

SET MATRIX HEIGHT lets you update height at one of the corners. You can not set height at any arbatry coordinate.

Because your ball is moving anywhere and not just selecting the corners of tiles, you are getting weird results.

This code works but will raise and lower tile corner near the ball.

Ideally you should only make ball move 100 units at once.

Hopefully this helps.



Boo!
Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 28th Aug 2006 21:35
Thanks spooky. It works now . But, however, I like the strange texture of the matrix, so I think I'll keep it.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 29th Aug 2006 03:25
I may look at your code a bit later, but I need to say this:

Matrix tiles are completely different from actual positions. They are not both the same. When you use the MAKE MATRIX command, those last 2 numbers are the amount of Tiles on the X axis and the amount on the Z Axis. A matrix can be thought of as a grid. Each tile is like a box on the grid. So, this:

Make Matrix 1,1000,1000,12,12

would make a matrix with 12 tiles on the X axis, and 12 tiles on the Z axis. Or, going back to our grid example, it would make a 12x12 grid. This:

Make Matrix 1,1000,1000,12,15

would make a 12x15 grid. Understood? Now, when you raise the height of a matrix, using the SET MATRIX HEIGHT command, when you specify the X and Z values, it will raise that tile or grid square, not the actual coordinate itself. So this:

Make MAtrix 1,1000,1000,12,12
Set MAtrix Height 1,4,6,100


would make a matrix with 12 tiles on each axis, and then it would change the height of the tile that is in tile 4 on the X axis, and 6 on the Z axis.


Sorry if you understood already. I thought I posted this earlier but then I came back a few hours later and it turns out I didn't

Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 30th Aug 2006 11:35
My code works fine now. Thanks for the help anyway, Sixty. It's a good explanaition.

Quote: "Sorry if you understood already. I thought I posted this earlier but then I came back a few hours later and it turns out I didn't "


Lol, no problem. You don't have to appologise for trying to help.
Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 3rd Sep 2006 15:13
I'm´now trying to make so objects on an matrix moves towards the lowest point, if it is positioned in a "hill". If I heigher a tile on the matrix, and a cupple of objects are on it, I want them to move down until the get to a plain surfus again. But, however, the system doesn't work, everytime I start the program it complains that
Quote: " Runtime Error 118 - Array does not exist or array subscript out of bounds at line 136"
. This is the function I use:
. The function is called in the main loop and looks like this:
. Why doesn't it work? Can anyone see the problem?
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 7th Sep 2006 02:34 Edited at: 7th Sep 2006 02:35
Ahh, did we forget to define the variable TYPES used with your arrays within the function?
Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 7th Sep 2006 15:09
No, I did not forget that. And I typed the array as I should. Here is the entire source if it would help:
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 12th Sep 2006 03:21 Edited at: 12th Sep 2006 03:30
I figured that you had typed the arrays properly, but I wanted to be sure...

The problem is due to insufficient array size.

Instead of dimensioning the arrays with:


Dimension the arrays like this:


This insures that the array is large enough to accomodate object indexes
up to your endObj limit.

Or, you could subtract the startObj from n inside the loop and leave your
original dim code the same:


Explanation:

Your loop is stepping through from startObj (2) to endObj (501) referencing
the actual objects and not the array element. Your array is dimensioned for 500
indexable elements from 0 to 499. So, if you want to store values for objects
higher than 499, then the array index will be out of bounds given that the last
object is 501 and not 499.

There is another potential problem with the rest of your code within the function.


This part of your function is outside the loop. Unless you have and object that
exists referenced as 503 (which is the last value stored in n at the end of the loop),
you will get an "Object doesn't exist error in line xxx."
Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 1st Oct 2006 15:56 Edited at: 1st Oct 2006 15:57
Thanks. It works now... at last it works quite well. A new problem has appeared. If I heigher the matrix, the objects in the affected area will disappear.

EDIT:

I know it was a time ago I responded, but it wasn't untill now that I took a look on the project again.
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 3rd Oct 2006 03:31
The object(s) are under the matrix at this point. Your problem has to be
somewhere in your positioning of the object(s). I haven't really looked at
your code since my last post. I suggest looking into this part of your code.

If I get more time, I will look at it more in depth later.

Login to post a reply

Server time is: 2024-09-25 09:27:43
Your offset time is: 2024-09-25 09:27:43