Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (512)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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  
  Visibility test.  (Read 442 times)
0 Members and 1 Guest are viewing this topic.
Offline trollwarrior1
« Posted 2014-04-07 05:50:11 »

I need to do some visibility test to implement node based path finding. I don't know the exact name of it, but the idea I have in mind is this.

* Developer places movement nodes around the map by hand, in a certain manner so that every node can see at least one another node;
* When doing movement, check if destination point is visible. If it is, just walk to it in a straight line;
* If it isn't do some kind of node based pathfinding algorithm and work out shortest node path to destination point, or something like that..

One big problem I can see incoming is checking if the node is visible. I have node idea how to do it properly. Here is a simple illustration showing what I want to accomplish if you don't understand..


On one of my previous games I implement vision by doing something like this:
* Pick a starting point and destination point. Compute x,y increments so each increment is of specific length, lets say increment length = 1;
* Add those increment values to starting position, until starting position is equal to destination position;
* After each increment check if current position on the level is a visible point. If not, the path is not visible.

I guess this is called ray casting or something like that. The problem I see coming with this already is that it would be reallllyyyyyyyy slow if I computed visibility check many times. Are there better ways to compute visibility, or should I also calculate which nodes are visible by a certain node before the game begins so that each nodes know which nodes it can see, since those nodes wouldn't change positions.
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #1 - Posted 2014-04-07 05:52:23 »

There is using A*. You can set each node to the corner of each object and use A* to check for the path around those nodes. It is a very flexible algorithm not just used for tile based systems.

Offline trollwarrior1
« Reply #2 - Posted 2014-04-07 06:02:44 »

Hmm I found this page somewhere. I think I will try to implement path smoothing from this page first, since it is far less work, because I already have A* implemented in my game.

http://web.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/G-Path.pdf

EDIT---------------
Lets just come back to the original question which is what is the best way to do visibility test (is it called ray casting?).
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2014-04-07 06:33:25 »

Write a line-line intersection function first. Then intersect your line-of-sight with the 4 lines comprising the edges of your rectangle.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline trollwarrior1
« Reply #4 - Posted 2014-04-07 07:24:51 »

Thanks I'm trying to write line intersection method.

I'm reading this wiki page, and I don't seem to understand one thing.
http://en.wikipedia.org/wiki/Line%E2%80%93line_intersection

I'm kinda stuck at calculating proper intersection point. I'm kinda confused. The page says that we can find the intersection point by using determinants. The thing I don't get is why is intersection point's P coordinates x,y found by the same 'method'. Is it me or is intersection point P.y always the same as X? The formula to calculate P.y is the same as the formula to calculate P.x

Is this wiki page's fault, or am I missing something here?


EDIT-------------
Ignore the post I just made Cheesy I can't read, it so seems.
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.

Longarmx (50 views)
2014-10-17 03:59:02

Norakomi (39 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (36 views)
2014-10-15 16:18:58

TehJavaDev (66 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (55 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (43 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!