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 / How to implement multitexturing in Van-B GTA1/2 engine code??

Author
Message
Mulderman
20
Years of Service
User Offline
Joined: 8th Jan 2004
Location: C:\\
Posted: 12th Sep 2009 11:07
Hi all.


I still work on my idea to get some basics of GTA2 style to run in DBpro. Van-B code is very useful.


Now i always wondered, how to apply different textures to buildings?


His code (example) uses always the same texture for each building.
Even on roofs.

What i need is to have ability to set different texture (tile) for each side of the buildings or cubes.



What is the best way to do that?


I could even read original GTA2 GMP map file in DarkBasic Pro, because i know the map format (basically it's just array of 64x64 cubes with textures applied to each side) and i know how it works and then i could create just cube at each of the X,Y,Z coordinate.

But they must be textured, each face by it's own tile.



Any useful methods to do that?

New GTA2 Map Editor :: http://www.gta2madness.co.cc
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 12th Sep 2009 13:45
Each DBP limb can have its own texture. So if you would make your buildings that way that each side would be a limb, you could manipulate every textures individually.

Other techniques will require you to make one image containing all sides either in-game or manually.

Sven B

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Sep 2009 15:25 Edited at: 12th Sep 2009 15:31
One idea might be to use a seperate object for each face, so it would have a texture and even extra bits added if need be (fire escape for instance) - then clone the object and rotate it for the relevant face.

The split up cube idea would work perfectly too of course, but didn't GTA have signs and stuff on the buildings? - it has been a while since I played it mind you.


Health, Ammo, and bacon and eggs!
Mulderman
20
Years of Service
User Offline
Joined: 8th Jan 2004
Location: C:\\
Posted: 12th Sep 2009 16:23
Signs and stuff could be in air also.
It just would be transparent cube in that case.

Actually if i model the cubes.


In GTA2 each cube could be 63 types. Half of the 64x64 cube, just little slope, high slope, lower slope etc etc. Total of 63 types.

Of course i could model them in some software, apply the UV coords and use "load mesh" command to load them.



But what about performance?
Of course i would limit the visible area (i.e. some sort of culling) but still if there is about 100 or so cubes visible would this hit the performance?



GTA2 map is made of 64x64 cubes, all the buildings, bridges are made of cubes. Even floor is at the top side of cube on the ground.


Something like that

http://thumbs.dreamstime.com/thumb_420/1248049348DSpjoo.jpg

New GTA2 Map Editor :: http://www.gta2madness.co.cc
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Sep 2009 16:27
DBPro has automatic culling for objects outside the screen, so really I don't think there's a lot to be gained in this case by adding culling with code. Really you shouldn't have any issues with speed at these sorts of detail levels, it could handle much more than what GTA2 can throw at it.

So I say you have a good idea of what you need to do, and should'nt worry too much about performance - just try and keep the polygon count down as low as you can and it'll be fine.


Health, Ammo, and bacon and eggs!
Mulderman
20
Years of Service
User Offline
Joined: 8th Jan 2004
Location: C:\\
Posted: 12th Sep 2009 16:32 Edited at: 12th Sep 2009 16:32
Thanks alot for replies guys.


I will do some test models, will read in the map file and will try to render the cubes at the places where they should be.


I think that's the best way to start with this.


I will post here if any problems arise.

New GTA2 Map Editor :: http://www.gta2madness.co.cc
Mulderman
20
Years of Service
User Offline
Joined: 8th Jan 2004
Location: C:\\
Posted: 13th Sep 2009 14:04
One bad thing about DB is that it doesn't support animated textures.
In Blitz3D there is a command: LoadAnimTexture.
It allows to texture any mesh (entity) with this texture.



Animated textures are MUST for GTA2 type game. All peds must be animated on roads and pavements.



I have searched deeply this forum and came to conclusion that this stuff must be done in hard way.



One reason i still would like to use DB Pro is that it allows to create AI easily with DarkAI plugin. AI is needed for peds and cars. There is no such thing in Blitz3D.



But i don't know yet.

New GTA2 Map Editor :: http://www.gta2madness.co.cc
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th Sep 2009 16:39
I think the best way would be to use plains that you texture with animation frames, like a walk cycle. Then you would move these about, perhaps following a grid system that can signify pavement etc, then AI would be pretty easy to get working.

The other thing is that you would have full control over your characters then, if they get run over, use a dead guy texture, all that fun stuff. I don't think you'll miss animated textures once you have a few peds running around and being run-over. If you use plains and Y rotate them the way they are facing, then having them throw stuff and shoot at the player is easy too, DBPro is full of commands to make this straightforward, like ATANFULL and CURVEANGLE.


Health, Ammo, and bacon and eggs!
Mulderman
20
Years of Service
User Offline
Joined: 8th Jan 2004
Location: C:\\
Posted: 13th Sep 2009 17:54 Edited at: 14th Sep 2009 06:50
Well i borrowed one ped from GTA2. Created a sprite sheet.
Now i have one ped animation in BMP file.
Total of 9 frames. Walking and standing.


DPPro animates it fine. And now today i was trying to attach it to some plain. One idea i had that i would position the sprite at the same position where the plain is. So it's like plain is always under the ped and if plain collides with something then the ped also stops.


But this was rather a quick hack, i didn't tried to make it better and it was very buggy.


So at the moment i have animated ped sprite. Nothing else.


About that grid system. Very good, i just was thinking about how i will control them.


GTA2 map has flags of cube type on each cube. Like: pavement, water, air, field, road.

And hidden arrows on road for vehicles.


Vehicles are detecting the arrows directions and driving that way.
But it's too early talk about the vehicles.
I must get peds walking around first.


I found also one snippet here:
http://forum.thegamecreators.com/?m=forum_view&t=105132&b=1



EDIT: Thanks to that snippet i managed to texture plain with one tile from my tilesheet.


Let's see if i can animate it.
Will edit this post or post a new one.
I must make code snippet how to animate plain if get this working.

I see that this is requested alot but almost no answers.



EDIT2: I got animating to work.






All comments, suggestions about improving this stuff, etc. are welcome.

New GTA2 Map Editor :: http://www.gta2madness.co.cc
Mulderman
20
Years of Service
User Offline
Joined: 8th Jan 2004
Location: C:\\
Posted: 17th Sep 2009 21:06 Edited at: 17th Sep 2009 21:09
I thought that maybe i convert GTA2 map to my own format.
I.e parse the map. Calculate UV texture coords for each cube textures.

And save that all in my own map format.


Later in DBPro: Parse the new map file, find the UV coords, apply textures to cubes.
I could make functions/procedures like:




Etc, etc..



Can DBPro handle UV stuff and how fast?

New GTA2 Map Editor :: http://www.gta2madness.co.cc
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Sep 2009 22:01
Yeah, DBPro is pretty good at changing UV's - you would lock the vertex data for the limb you are changing, then step through the vertices changing the UV data.

There's also memblock meshes, which you would build as polygons with whatever UV coordinates you needed. There's lots of tutorials for memblocks if your interested.


Health, Ammo, and bacon and eggs!
Mulderman
20
Years of Service
User Offline
Joined: 8th Jan 2004
Location: C:\\
Posted: 18th Sep 2009 17:19 Edited at: 18th Sep 2009 18:03
Van-B.
You said:

Quote: "One idea might be to use a seperate object for each face"



What do you mean by that? "Make Object Cube" for each map cube?
And texture and rotate it?


It would work, but i think it wastes too much memory. Cubes have lot's of vertices and each one is textured, even if one of it's faces are hidden (inside building).


EDIT:

I have heard that DBPro "Make Matrix" is slow? They don't recommend using this. Instead load your own terrain/plain.

True or not?

But it's so easy to texture each cell of matrix and this is must have in GTA2 style game.

New GTA2 Map Editor :: http://www.gta2madness.co.cc
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 19th Sep 2009 03:21
I would use plains, like MAKE OBJECT PLAIN Obj,sizex,sizey - then it's just 2 polygons.

For a game like GTA I would say that a matrix should be fine, I wouldn't worry about that, but it depends on the number of tiles. One option would be to shift the matrix with the camera, then change the tiles to suit, this would let you use a much smaller matrix but you would have the overhead of shifting it.

If the matrix slows things down then it is quite straightforward to make a memblock matrix, I did this in an old project, used a matrix in the editor because it's so convenient, then used the same data to make a memblock matrix instead. I could certainly help in that regard if the matrix becomes a problem, but as I said I don't think it will slow things down.


Health, Ammo, and bacon and eggs!
Mulderman
20
Years of Service
User Offline
Joined: 8th Jan 2004
Location: C:\\
Posted: 28th Oct 2009 16:54 Edited at: 28th Oct 2009 17:00
Still working on my idea.

But i am very confused how should i actually lay out my map format or how should i draw GTA2 levels?


I could use boxes and plains for drawing.


I just can't continue or just there is no point working on anything else if i can't render any of GTA2 levels in DB Pro.
I can do that easily with OpenGL.


Like i said: basically GTA2 maps are just 3D array of cubes.
For each X,Y,Z coord there is a simple 64x64x64 cube with different textures / effects applied to sides at that X,Y,Z.

That's all.

Main problem is that i don't know how should i draw the city.
Do i really have to create my own map format so it will be easier to draw GTA2 map in DB Pro?


Can somebody push me to the right way?


BTW: Here are docs describing GTA2 map format(including GFX format):

http://gtamp.com/GTA2/gta2formats.zip

New GTA2 Map Editor :: http://www.gta2madness.co.cc
Mulderman
20
Years of Service
User Offline
Joined: 8th Jan 2004
Location: C:\\
Posted: 4th Nov 2009 13:01 Edited at: 4th Nov 2009 13:04
OK for first i decided to go with simple map format or levels (like for 2D games). Just put 3D house models at random or map defined coordinates, same for roads and so on.

But i need more input about the grid system you mentioned Van-B.

In GTA2 every block can be any of the following types: air, pavement, road, field.
Peds are walking on pavements, cars are on roads, fields are empty (ie. there are trees), air is air.


Because im using matrix to create big terrain my idea was that
for every matrix RECT i assign different bits and in game loop i check if any PED walking on it is in RECT that has "pavement" bits or not. If not then search for matrix RECTs that has these bits.
Same for cars, whenever they get pushed away from roads they search for roads and drive back to them.



This sounds easy in theory but what about coding it out actually?


I don't need anybody to code this out for me, i just need some push in right direction.



I have peds walking around but i want more. At the moment they walk randomly and rotate randomly. Not very interesting.


I want to implement roads and pavements and all these 4 different things (air, field, pavement, road) and that everyone knows where to walk or drive. In GTA2 when peds are walking on pavement and whenever pavement ends then they SMOOTHLY turn itself around and walk back where they come. And when they collide with main character then they also turn around.

New GTA2 Map Editor :: http://www.gta2madness.co.cc

Login to post a reply

Server time is: 2024-11-24 23:49:32
Your offset time is: 2024-11-24 23:49:32