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.

DarkBASIC Professional Discussion / Alternative to MATRIX commands using objects?

Author
Message
Alaror
12
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 11th Jan 2012 18:29
Up until now I've been okay with displaying my terrain using the MATRIX commands, but I've come to realize it won't suffice moving forward. My game is 2d using the 3d commands (such as object plains) for speed, but to ensure the objects are displayed correctly I set them all at a Y depth of 0 and use the following command to force them to be displayed in the order of their object number instead of depth: "SET GLOBAL OBJECT CREATION 4".

This fixed the issue of objects being displayed in the correct order, but now I need to display some matrices above all of the objects and there seems to be no way to do so. I tried using the command "SET MATRIX PRIORITY MatrixNumber, 1" on the matrices that need to be displayed above everything, but it doesn't seem to make a difference.

Here's an example of the code I'm using to create the matrices:



...and the code for creating an object:




With all that said, if there's no way to get matrices to display over objects then I need to find an alternative. Are there any plugins or commands that allow you to display terrain using object plains? I've tried using individual object plains for each tile in the past but that proved to be very slow. I have to be able to edit what tile is displayed in real time as is allowed with the MATRIX commands.

Thanks in advance for any and all help with this

Alaror
12
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 14th Jan 2012 16:29
Bump!

Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 14th Jan 2012 17:08 Edited at: 14th Jan 2012 17:09
You could try using Advanced Terrain or Blitz Terrain, and store the tile date in your own array. The plugins are included or to be downloaded respectively. They will generate a terrain out of a height map stored in an image.

Otherwise, create a plain object at every N number of coordinates on the X and Z terrain; then treat the array of objects as a DIY matrix. Vertex data and memblock commands are available for manipulation.

Here is a diagram of the memblock mesh construction process from my website.



Alaror
12
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 15th Jan 2012 19:32 Edited at: 15th Jan 2012 21:17
My concern with Advanced Terrain/Blitz Terrain is that I doubt they'd work with the "SET GLOBAL OBJECT CREATION" command since--as I understand it--terrains are a different entity than objects. Since I'm using the object number to decide which should appear above or below the other objects, wouldn't the terrain need to be converted into an object plain? Is that even possible?

As to your second recommendation, I think I'm misunderstanding you. Do you mean that I should create an individual object plain for each tile (48 x 48) and reposition them as the player moves along the terrain? Or is it possible to create a single object that's 1536 x 1536 pixels (since each tile is 32 pixels) and texture parts of each separately using the 3d math commands (those will be a hoot to learn haha =P).

I've also found this DLL which should allow me to edit images in real time, which I could then use to retexture object plains that use them. Are there any downsides to this solution that you could see?

Thanks again for your time! I don't have much experience manipulating objects/images beyond the basic commands so far is really valuable to me.


EDIT: This is the updated version of the DLL I linked to; hadn't realized I was looking at the old one. I'm going to be playing around with it for a little while and will let you know what the result is. Hopefully it'll work for me!

Quel
15
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 16th Jan 2012 09:52
Load in a premade plain from a 3D editor, and move its vertices around with vertexdata to get the required shape.

It's not a bad thing the Matrix commands are still in the program, but it should be told in the help files, that you can't really make anything that worthy with them, so people switch to something else early on, just when they got some experience from them.

-Mental Hybrid: A unique heavy story based shoot'em ~40% (primary project)
-CoreFleet: An underground commander unit based RTS (canned) ~15%
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 16th Jan 2012 11:24
Couldn't you just vary the y position on the matrixes you need in front of everything? (Or have I misunderstood what you want to do).

Failing that using IanM's Matrix1 Plugin set, you could create a plane(IanM's version of the command allows you to select the number of rows and columns used to create it) and achieve a similar effect to a Matrix by texturing it and randomizing the vertices a little.

This would be able to be manipulated using the normal object commands and shouldn't mess with your depth sorting stuff.

Alaror
12
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 17th Jan 2012 04:58 Edited at: 17th Jan 2012 05:00
@Quel

I'm only using matrices because of how easy and quick it is to re-texture them using a tile-based system. They'd work perfectly for my game if I could set what order they displayed relative to the other objects. I've yet to find a way to do this


@PRoF

The command "SET GLOBAL OBJECT CREATION" changes the order the objects are displayed from their height to their object number. Matrices seem to be affected by this as well, but I think they're an entity separate from objects. Because of this there is no object number to go off of, so it gets sent to the back.

I actually asked IanM about his OBJECT PLANE command, but he said it would not work because there's no way to texture each row/column individually. I'm at a loss as to what you would even use those commands for in that case.


As to the Image Kit plugin I tried out, it would work except for the fact that it is nowhere near fast enough for what I'm trying to do. I'd love to know what processes the Matrix commands use to keep them so fast, seeing as the Image Kit plugin couldn't handle a single layer of terrain let alone the multiple layers I currently have working without any slow down using the Matrix commands. I'm going to do a little more research and ask some questions in the Image Kit thread, but as of right now it doesn't look like a viable solution.

Are there any fast ways to change the texture of an object in real time?

Brendy boy
18
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 17th Jan 2012 11:13
why do you need for every row/column to be textured individualy? that's not how a terrains in modern games work. Terrains are usualy textured with 1 to 6 textures which are then blended in a shader and for that IanM's plane command is perfect.

If you want to have a fake matrix you can. Just create an object out of many plane limbs, then you can texture each limb individualy

Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 17th Jan 2012 22:18
Following on, take it one step at a time, matrix logic gets easier the more you do it yourself; when you create your own matrix system you will not want to go back to standard matrices; there is just so much more you can do with objects and limbs.

Alaror
12
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 18th Jan 2012 00:42
@Brendy boy and @Chris Tate

I'm not at all familiar with shaders or how to use them to blend textures on objects. Like my game, I'm still very much a work in progress Is there possibly a tutorial or example you're aware of on how to use the CREATE OBJECT PLANE that comes with IanM's dll?


I think I'll try creating a single object out of limbs and texturing the limbs individually. Does anyone have an opinion as to whether I should I use the default Darkbasic Pro limb commands, or should I create a "complex" object using Matrix1 Utility 18?

Brendy boy
18
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 18th Jan 2012 01:04
Quote: "CREATE OBJECT PLANE that comes with IanM's dll?"

IanM's help files maybe?

Quote: "Does anyone have an opinion as to whether I should I use the default Darkbasic Pro limb commands, or should I create a "complex" object using Matrix1 Utility 18?"

the end result will be completely the same, use the method you are more familiar with

Alaror
12
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 18th Jan 2012 01:27 Edited at: 18th Jan 2012 01:27
@Brendy boy

Quote: "IanM's help files maybe?"


Sadly no, just a technical description. I'll just work with the default commands. Thanks for the advice!

Brendy boy
18
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 18th Jan 2012 02:05 Edited at: 18th Jan 2012 02:05
Quote: "Sadly no, just a technical description."

Whats is that you don't understand, it's quite straightforward

MAKE OBJECT PLANE object_number, width, height, tiles accross, tiles down or something like that

Alaror
12
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 18th Jan 2012 02:07
That I understand, my confusion deals with how you'd go about setting the texture for individual tiles. Sorry if I wasn't clear enough.

Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 18th Jan 2012 02:19 Edited at: 18th Jan 2012 02:20
You can set the individual polygon textures coordinates for any vertex in any limb within any object no matter what. Texture wise, UV coordinates are to objects, what matrix tiles are to matrices; just more complex and configurable.

Your problem will be the fact that the plane's faces will share vertices, if you have a large range of images you intend to use per tile. So the end of Tile A must be the start of texture of Tile B.

Instead, use individual limbs for simplicity, something like:


Brendy boy
18
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 18th Jan 2012 02:49
Quote: "That I understand, my confusion deals with how you'd go about setting the texture for individual tiles"

Well, you can't do that. When i talked about that command i was reffering to the use in terrain which has textures blended with shaders-> for that IanM's command is perfect. since you want every tile to have different texture limbs are your only option

Alaror
12
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 18th Jan 2012 02:59 Edited at: 18th Jan 2012 03:00
@Brendy boy

Alright, thanks for the clarification.


@Chris Tate

I still don't think I fully understand how it's textured, but it's probably better to hold off on those questions until I decide there's no other suitable option. I'd love to learn more about it, but I'm also easily distracted hah.

I actually threw together some code which builds a "matrix" using object limbs. Even without retexturing each limb at each step, the frame rate jumps around from around 35 to 40 to 55 and back down. It seems like DBP doesn't like the 2304 limbs active at once, though it could just be that I'm doing something wrong. The code I'm using to create the object/limbs is below.



James H
16
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 18th Jan 2012 06:11
honestly the first step to move away from matrix terrains is to learn all about object creation OR as previously suggested utilise blitz terrain as it beats the pants off advanced terrain - all depends how far you wish to look into it

regarding shaders - if you dont want to delve into them just yet then no IanM`s plugin isnt what you want

memblock meshes when put together as limbs of a terrain work fine but the code can be slightly complex, but doing so will help you understand something about object creation
as you are most likely aware objects are made of triangles - internally these consist of 3 vertices per triangle - an object has what is called a flexible vertice format(fvf) which dictates the properties that all vertices in an object has - each vertex has a world position and dependant on the order the vertices are listed in a memblock determines the direction the face of a polygon/triangle will be textured. there are additional properties it CAN have such as a diffuse color, a normal position, uv coords along with many others - have a look at the memblock mesh command in the help file if you think your up for it for more details, but you will need to become familiar with memblock usage as they are not restricted to just mesh data...chris tates diagram depicts most of what i mentioned perfectly

IanM`s plains use triangle lists which use indexes to list shared vertices(have exactly same location as another vertex) so doesnt hold the uv data as you would require(this cannot be acheived with memblock meshes afaik)

As far as Im aware the control your looking for regarding uv tiles can only be gained by buying the full version of blitz terrain so you can rewrite uv data(havent checked latest free release out yet but reasonably sure you dont get uv control in free version) but ultimately thats what you need to do if you wanna use tiles, though as mentioned already its not the best method for terrains

if your looking to determine depths per tile, then a terrain solution with tiled uvs are not gonna work anyway, really hard to say not knowing what your exact end goal is or the limits imposed by it, perhaps you can provide more details? (I did look at rylod and your other posts but am not convinced thats what this is for??) I cant help but wonder for example why you would need to to sort the depths of single square tiles other than to ensure the top most one is visible which can obviously be dealt with by excluding objects not needed seeing as you already have full control on which one you need on top? maybe i have the wrong end of the stick on that one though

there are a lot of good accurate answers already posted on here but i beleive the very nature of what your doing poses the need for a lot more thought before you progress any further so that you dont waste your own time, if i had but a penny for every time I ended up rewriting something from scratch because I went about things the wrong way simply because I didnt know fully what my options where

anyway thats my thoughts for what its worth
Alaror
12
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 18th Jan 2012 17:06 Edited at: 18th Jan 2012 17:12
@James H

Thanks for your input.

I probably could have been a lot more clear as to how I would use this system; sorry about that. I do in fact need it for my project Rylod. In the videos that show the fluid system (such as the most recent one), you'll see that the liquids flow behind the player rather than in front of them. All I'm trying to do is have the fluids be displayed in front of the character, to make it look like they're submerged. Ground tiles, liquids (water, lava, acid, mud, etc), steam, and acidic gas all use their own matrix, and it's these that I want to determine the display position of, rather than individual tiles within each.

Matrices would work perfectly if it were not for the fact that they are being displayed behind the character. They don't bring down the speed of the game in the least, and are very simple to use. I'm very much willing to go with a more complex option, as long as I can be assured that it can be displayed in the correct order (using the object number) and there are no speed issues when retexturing the entire 48 x 48 tile grid. The reason I'm so adamant about using object numbers to determine the display hierarchy is because it's the only thing that worked. Messing with ZBIAS, ZDEPTH, etc didn't lead anywhere fruitful.

I've not seen any indication that I'm able to set the order of Blitz Terrain relative to objects. When I tried changing the height of matrices to get them to display above all the objects, the height did change but objects still got displayed above them (by changing the display order of objects to their object number it no longer takes into consideration the height). From what I understand the only way to determine the display order of Blitz Terrain is by using a height value; I can't do this.

This brings us to where I am today. I've tried using a "matrix" created out of limbs (the code for which is in this post), but it doesn't seem as though DarkBasic Pro likes having all those individual limbs active at once. Note that when I added texturing to the mix, there wasn't any obvious slow done compared to the fps already dropping because of all the limbs. I have used memblocks for image manipulation (it was actually my first attempt at figuring out a solution to this problem), though I've not messed with meshes before. If this is what I need to do, then I'm okay with complexity. Like you said, it's no good to keep trying possible fixes without having any idea if they'll work or not (though I do get to learn a lot of new things!). However, I'm not convinced that using memblocks will be any different than the individual limbs because I honestly don't understand enough about them. Would I still be creating an individual limb for every tile, or would memblocks allow me to combine a bunch of them into a single object, with each tile being textured differently?

James H
16
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 10th Feb 2012 00:44
Quote: "Would I still be creating an individual limb for every tile,"

no
Quote: "or would memblocks allow me to combine a bunch of them into a single object,"

yes
Quote: "with each tile being textured differently?"

yes

putting those tiles to a single mesh will work if the tiles are supposed to be same depth as one another, any other tiles belonging to a different depth should be another object(s) - where each object has 1 limb - the question is though will it be fast enough, as the mesh will have different number of tiles to it ONLY when the scene requires a change; this means altering data in memblock, make a mesh from memblock, change the mesh of the object limb, then texture it. I suggest you carry out some tests on the lowest spec hardware your prog will use - I have done something similar in the past for terrain where I move a single mesh with the camera - whenever the camera went beyond the space of the tile it was on I would change the mesh in the manner I just outlined to match a heightmap, however when it came to using a shader the method became useless as changing the mesh means reapplying the shader, although I had no major slowdowns from changing memblock data/mesh and retexture, reapplying a simple shader killed framrate totally - hardware I was using back then was ati x1300(this was bottleneck)
also same setup I found there was a limit to the number of pollies in a mesh before mesh changing killed the frame rate too(25*25grid was biggest and what I settled for in the end). Therefore give some consideration to limiting the number of tiles each object can have and just use multiple objects if needs be for the same depth.
Hope this suits your needs better - the more tiles you can fit to a mesh will improve the framrate providing you stick to not making them too large, the size doesnt hit framerate once rendered too much, its the changing of the mesh that will reduce it if the mesh is too big. Like I said, test it, but do so in a quick way ie dont be concerned with getting it perfected or you could end up wasting more effort if it doesnt suit your needs, though I suspect it will

Login to post a reply

Server time is: 2024-03-29 15:38:13
Your offset time is: 2024-03-29 15:38:13