Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Apply grids on a terrain  (Read 1845 times)
0 Members and 1 Guest are viewing this topic.
Offline Son Of Cain

Junior Member





« Posted 2006-02-13 11:51:48 »

Hi, everyone.

I'm new to game programming, so I don't have the experience to tackle this problem. I do have a hint of what might be the solution, but I don't know if this is the optimal (or standard) way of solving the matter at hand.

Let me explain: In a TBS game, I will use A* for the pathfinding. Since my map is designed in 3D using Blender, how can I apply an invisible grid on it, to map its coordinates as "tiles", in order to do the pathfinding? Must this be done in Blender, or in my 3D engine (JME)?

Also, how to map cost information to each "tile" in the terrain?

Or even, is the best approach to model only a "block" of the terrain, attaching cost information in a class representing this block, and render the entire map using a set of blocks?

Sorry for the questions if they're noob, but I've searched in Google for insight and could not find something applying to my problem. Embarrassed

Thanks in advance,

Son Of Cain
Offline Son Of Cain

Junior Member





« Reply #1 - Posted 2006-02-16 19:36:24 »

... no one?  Undecided
Online Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2006-02-16 21:49:58 »

"Hey, i'm new to cars, i want to build a car! How should I connect the steer to the wheels? Should the doors open horizontally or vertically? Which engine do I need, I asked the local garage but they didn't know..."

This is the style your questions have (IMO) and I wouldn't have a clue how anybody could answer them, without asking you what you really mean.



You have to break down your problem in little pieces, and try to build every piece yourself first.

If you have any problem with actual code, feel free to post and you'll get useful answers.

HTH Undecided

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Son Of Cain

Junior Member





« Reply #3 - Posted 2006-02-17 12:18:58 »

Hi,

Well, sorry then, I'll try to be more specific.

My doubt does not rely on the engine I'm using, nor the format of my maps, or whatever; rather, All I hoped with the post was for someone to comment the standard solution used by games of the same sort, and then I would research it myself and try to tackle the problem while learning about it. That's how I learn things, anyway.

I do know about A*, heuristics, and general pathfinding problems applied to it. I'm just asking if anyone has a tip on how to wire cost information on maps built on 3D tools like Blender. I don't know if I should break my map into chunks and analyze the path from "chunk A" to "chunk B", or if should do some sort of "scanning" on it prior to rendering in order to store cost information somewhere... all I want is a bit of advice from someone who has more experience than me.

And I'm not native of an english speaking country, so it is not so easy to express myself - I'm short where I should explain with more details, and I tend to overcomplicate what should be said simple and straightforward  Undecided

So I hope someone can give me tips on how one would wire A* cost information in scenarios for a TBS game.

Thanks in advance,
Son Of Cain
Offline rdcarvallo

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #4 - Posted 2006-02-17 13:10:30 »

Hi,
   Even if your  terrain model is imported from a File, you must have some kind
of 'data model'  of it.  This data model contains information like enemy spawn places,
treasure chest, etc.
    About your project, is the terrain defined logically as 2D or 3D?? (Can two units be
on the same 'tile'  but diferent heights?)
    If 2D, I should make a editor tool with a top view of the terrain and a grid (the data
model)  in wich you can set your values for the walk cost and other options.

     Hope this helps.
          Rafael .-

Offline Son Of Cain

Junior Member





« Reply #5 - Posted 2006-02-17 13:52:24 »

Hi Rafael,

My maps are in 3D, and it is possible for an unit to be on the same tile on different heights ( say, a small cave, where an unit can be inside de entrance of the cave, and another one may be above it, or even a castle wall with a hole, which might picture the same case).

I understand the need of such a data model, so what's the best approach to store information about terrain cost? Also, I need to control the map as a grid, because only one unit can stand one grid position at a time.

So, what should I store? A 3D matrix of "Vector3f" containing the position for each "block" of my terrain, with cost information and etc..?

Thanks for the help!

Son Of Cain
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #6 - Posted 2006-02-17 14:47:55 »

The terrain is effectively a 2D plane with height information. If you slow (or stop) the character on steeper slopes, you should generate a cost that is the inverse of how fast the character can move. i.e. If your character can move 100 units per second, a flat area would have a cost of 0 while a sheer rock face would have a cost of 100.

Since you're likely to have a coordinate system in place (it's impossible not to), you can create "cells" by mapping the coordinate system to a small grid. e.g. If you have a 1000x1000 unit terrain and you want to use 10x10 unit cells (making the grid a 100x100 cell grid), you can always convert a character's position with this code:

1  
2  
cellx = x/10;
celly = y/10;


The concept works the same in three dimensional space, except that there are dirrections above your head that are impossible to traverse. Normally, empty cells in the third dimension would be non-traversable. However, you may have to reevaluate the costs at runtime if you give certain characters the ability to fly.

In 3D space (say 1000x1000x1000 units with 10x10x10 unit cells which would make a volume of 100x100x100 cells) the computations to convert between coordinates and cells would be:


1  
2  
3  
cellx = x/10;
celly = y/10;
cellz = z/10;

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Son Of Cain

Junior Member





« Reply #7 - Posted 2006-02-17 15:04:22 »

** coding **

The flying character cost modifier can be attained by changing the heuristic used based on who is calling the algorithm, right? I store each heuristic as a class, and I apply a different heuristic in the calculation based on the "problem" I'm facing. Or is there a better way to handle this?

Thanks for the replies, guys! I appreciate your help!

Son Of Cain
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #8 - Posted 2006-02-17 15:11:59 »

The flying character cost modifier can be attained by changing the heuristic used based on who is calling the algorithm, right? I store each heuristic as a class, and I apply a different heuristic in the calculation based on the "problem" I'm facing.

Or to put it in simpler terms, you have a different cost tables for different capabilities. Smiley

Java Game Console Project
Last Journal Entry: 12/17/04
Offline VeaR

Junior Member





« Reply #9 - Posted 2006-02-17 21:48:45 »

Hi!
For what TBS stands for? The following might not be quite suitable, but i use it for (mostly) open terrain FPS bots.

My concept, although prety much home-made and result of lots of experimentation is as follows: divide the terrain into areas. Areas can be collected by tracking player movement, and combining into larger areas.
Each area has some attributes (air, water, foliage, urban, inside building, VIP objective), position, size, and can contain child areas. Each area collects (learns?) statistics happening during actual gameplay, thus modifies the resulting cost. Areas are connected to other areas, representing passable terrain. The connections themselves collect statistics. Each AI has its own weights. The resulting cost of traversing from one area to the other is the sum of statistics each multiplied with a corresponding weight. A genetic algorithm could be applied to AI weights, thus making the AI more fit for the actual played map, but i'm not there yet.

Just realized that TBS stands for Turn Based Strategy, LOL. Forget this, this is for something on the other end of the games spectrum. LOL. And sorry, english isnt my native language either.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ask_Hjorth_Larsen

Junior Member




Java games rock!


« Reply #10 - Posted 2006-02-18 01:08:55 »

I suppose TBS is Turn Based Strategy, but I used some time to figure it out too.
Offline Jeff

JGO Coder




Got any cats?


« Reply #11 - Posted 2006-02-18 02:19:14 »

What you are reaching for is a "walkmesh."

There have been quite a few of articles on them recently in varying depth because NWN used one.

Keep in mind that a wealk mesh only works for 2.5D games, which is to say games where the player/monster objects feet are glued to the ground.

Id suggest googling "walkmesh".  You might also  try flipping the indexes of books on RPG programmign in your local bookstore.

FInally, we just put back wlakmesh support in JNWN.  At this point Im workign on an internally forked version but the last one I put abck to the external version I believe loads the walkmeshes and uses them for blocking tests.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Son Of Cain

Junior Member





« Reply #12 - Posted 2006-02-18 16:24:37 »

The search for "walk mesh" was a good shot, thanks Jeff.

I'll stick to jbanes suggestion as of now, it seems to work nice for my requirements (at least I didn't run into any problems, as of now =).

Thanks guys,

Son Of Cain

PS: BTW, TBS stands for "Turn Based Strategy". Games like old Tactics Ogre and Final Fantasy Tactics are good examples, as well as most board games like chess. It is the counterpart of RTS (Real Time Strategy) games, where players take action concurrently. Obviously, in TBS, each player has a turn to act, either in sucession or randomly.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (15 views)
2014-09-19 03:14:18

Dwinin (33 views)
2014-09-12 09:08:26

Norakomi (58 views)
2014-09-10 13:57:51

TehJavaDev (81 views)
2014-09-10 06:39:09

Tekkerue (40 views)
2014-09-09 02:24:56

mitcheeb (63 views)
2014-09-08 06:06:29

BurntPizza (46 views)
2014-09-07 01:13:42

Longarmx (33 views)
2014-09-07 01:12:14

Longarmx (38 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!