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.

AppGameKit Classic Chat / AGK Tier 1 Heightmap terrain solution

Author
Message
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 8th Apr 2014 20:22 Edited at: 14th Apr 2014 06:25
Hello together,


currently I'm working on a custom .OBJ ASCII importer for the AGK.
The reason I do this is to be able to modify the vertex and the normals of the object and apply a simple heightmap.











This is a simple plain obj file:





So there should be no problems to apply a heightmap to the verticles. But my problem is to recalculate the normals.
Currently Iam stuck with my 100% perfect code, but I think that
AGK don't uses them anyway.



Contributions:


I would like to thank anwserman for his String Split Command
http://forum.thegamecreators.com/?m=forum_view&t=192516&b=41



The commandset should be like that:


` should create a 2d terrain with a given heightmap and a texture

make_terrain(terrainunm,heightmap,texture,xpos#,ypos#,scale)



` should create a 2d terrain from scratch

make_new_terrain(terrainunm,type,xpos#,ypos#,scale)



` should create a 2d terrain from scratch

make_new_terrain(terrainunm,type,xpos#,ypos#,scale)



` set terrain height

set_terrain_height(terrainunm,x,y,height#)


` get terrain height

get_terrain_height(terrainunm,xpos#,ypos#)





` this command should recalculate all normals of the new terrain

update_terrain_normals(terrainunm)




` this command will save the terrain to a custom folder with all the generated media and the updated obj model

built_terrain(terrainnum)




` So you could simply load a 3d model as terrain:
terrain=loadobject("CustpomTerrain.obj")


Pro:
Load a custom terrain in Tier1 apps
Generate gigant 3d worlds with small media

Contra:
Slow - realtime modification not recommended
Will be possibly replaced and useless in AppGameKit 2.0

So well, is it worth it?

Attachments

Login to view attachments
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 9th Apr 2014 06:24 Edited at: 10th Apr 2014 22:05
I will definitly have fun with this one.

* new command added - now you can manually modify the height of a verticle.


set_terrain_height(terrnum,x,y,height#)

I will release the code once I cleaned up this mess a little bit.

f

Attachments

Login to view attachments
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 9th Apr 2014 07:59 Edited at: 9th Apr 2014 11:21
I will definitly have fun with this one.

* new command added - now you can manually modify the height of a verticle.


set_terrain_height(terrnum,x,y,height#)

I will release the code once I cleaned up this mess a little bit.



[/center]

Attachments

Login to view attachments
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 9th Apr 2014 09:32 Edited at: 9th Apr 2014 11:20
* Heightmap support added.


Now you simply have to run some code to create a terrain from a heightmap in about 3 lines







What do you think about this?
I hope I could help to improve the functionality of 1.08 Tier 1

[/center]

Attachments

Login to view attachments
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 9th Apr 2014 11:14 Edited at: 9th Apr 2014 14:14
Code V1 enjoy..



This project was inspired by this thread:
http://forum.thegamecreators.com/?m=forum_view&t=210562&b=48

Edit: Are there any other workarounds you can image for AppGameKit?
Is there any way to get transparency working on a 3d texture?
Maybe a pixel shader? IDK temporary

[/center]

Attachments

Login to view attachments
Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 9th Apr 2014 13:55
It looks briljant Jack, will definately test this when I get home tonight!
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 9th Apr 2014 15:39
I've just given this a brief test, it's pretty cool and it's definitely worth spending some more time on.

Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 9th Apr 2014 23:54 Edited at: 10th Apr 2014 14:22
Thank you for the comments! Please give me more feedback, once you have tried this out.


I have got to learn more about the obj format to update the normals aswell. But with AGK2 the major part of the code and the work would be useless, once you can transform a mesh to a memblock

Are there any obj experts who could tell me how I could recalculate the normals by given vertricles? I don't understand the obj format so well.

How can I get 3 verticles from the plane obj together to calculate the normals?



From the Workflow my solution looks like this:

Import object as file to array => Modify the Y Coords of the plain => Recalculate normals => Bake Terrain


Recalculate normals:

Need: 3 Verticles to calculate one normal

Save recalculation


Edit: New command added:
Get_terrain_height(x#,y#)


Are the texture errors on the trees a result of the mipmap command?


Attachments

Login to view attachments
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 10th Apr 2014 13:44
Quote: "But with AGK2 the major part of the code and the work would be useless"


I disagree as it really depends what you're trying to achieve.

I tend to look on things like this as a learning experience. So you're learning about .obj, you're practicing coding in general and learning to problem solve and probably all sort of other things, all of which you may never do if you just to stick to using AppGameKit in a more obvious way.

Also, we don't know what the full functionality of V2 is going to be, how good that functionality is going to be or when it's going to happen. At the moment we only have what we have and now, thanks to you, we can see that it's possible to create procedurally generated terrain.

I think by experimenting like this with V1 you'll be in a better position to get more out of V2's new 3D commands (when they arrive) than someone who doesn't venture outside the perceived limits.

So I'd keep at it.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 10th Apr 2014 14:16
Hehe, like DBPro had good terrains from the start

I remember the terrible terrain system that was originally in DBPro, then we discovered the joys of memblock meshes, shader terrains, vertex coloured terrains - then when we got vertex mod commands we could optimize things and take it even further. Then we got advanced terrain which is real handy, but I'm still a fan of making my own terrains, procedural generation etc etc.

So I would say that you should definitely keep at it... if we get vertex mod commands in AGKv2 then the system would transfer without the need to export the data, but wouldn't change very much. I am not convinced that terrains in AGKv2 is the sort of thing TGC will concentrate on right now, it will probably be a long time before there's any sort of built in support. Keep at it and adapt it - I'm saying the same thing to people making their own animation systems and stuff like that - do not procrastinate waiting on AGKv2 making your work redundant, that won't happen... if we don't make these tools and share them, then we are all screwed in the long run.

I am the one who knocks...
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 14th Apr 2014 06:24 Edited at: 14th Apr 2014 06:26
Thank you 29 games and Van B. You are right. Maybe someone could find this useful. I will keep that system and try to build more stuff. Maybe I should open an own thread for the 3d Engine based on the terrain

A new demonstration for the terrain and support for 64x64 terrain will be added soon.


This videos were made during the project. They show a nice useage of the terrain system.









Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 15th Apr 2014 04:35 Edited at: 15th Apr 2014 04:36
Hello, me again, with a small update of the package:

Now you are able to build a terrain with 96x96 fields.
Bigger Resolutions are also possible, but for me this is enough




working resolutions
1=8x8, 2=16x16, 3=24x24 ,4=32x32, 8=64x64, 12=96x96 (fields)
=>9x9 =>17x17 =>25x25 =>33x33 =>65x65 =>97x97 (image size)

Just download the package. There you find anything you need

BTW if you try this snippet you will see, that the player will always
be forced to slide to the deepest point of the map. :S
Has anyone a good player collision and control code with gravity for uneven ground?


Currently Iam working on a 3d particle engine, that I'll also release
I would be glad, if someone could help me to improve the commands of this snippet to build a great start for beginners

Attachments

Login to view attachments
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 17th Apr 2014 05:14 Edited at: 17th Apr 2014 05:19
Maybe this post can help you for your loading times problems and add shader support ? (i have posted this in january 2013)

you can easily random your map by generating heightmap and colormap bitmaps with memblocks (a 256x256 bitmaps will create a 256x256 units terrain)

http://forum.thegamecreators.com/?m=forum_view&t=203224

Sample Code & T1 Sources attached to this old post (also ported in T2 by The Zoq in the thread (or in the AppGameKit codebase i don't remember))



--------------
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 17th Apr 2014 18:01 Edited at: 17th Apr 2014 18:07
Damn you are fast you realized my concept erlier
Really nice work and thank you for the link


Quote: "EDIT2 : i'm so lazy to add vertices normals#)"


Dito

Login to post a reply

Server time is: 2024-03-28 15:49:21
Your offset time is: 2024-03-28 15:49:21