10 Replies - 716 Views - Last Post: 17 February 2013 - 03:07 PM Rate Topic: -----

#1 rolen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 13-February 13

cant understand raycasting

Posted 14 February 2013 - 06:49 PM

i tried understanding the premandi tut, i got it but couldnt implement it.

the most readable code i found was.

http://dev.opera.com...can-1/#comments

but his comments and explanations a vague i got stock with the castRays and castSingleRay.

i also had a long qbasic tut (i have qb on my win7).

cant find any good book about it (couldn't find any download so maybe ill buy one).

i really wrestled with this interesting subject the hole week and coldent reach full understanding.

what do i need to learn to understand it?

please can anyone help me ill give you more detailes if you need more.

Is This A Good Question/Topic? 0
  • +

Replies To: cant understand raycasting

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: cant understand raycasting

Posted 14 February 2013 - 09:33 PM

It's an old technique, not quite sure why you're spending so much time with it when clipping and culling techniques are the modern game development approaches. But anyway, have you read the following link?

http://www.permadi.c...cast/index.html
Was This Post Helpful? 0
  • +
  • -

#3 rolen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 13-February 13

Re: cant understand raycasting

Posted 15 February 2013 - 05:21 AM

"i tried understanding the premandi tut, i got it but couldnt implement it."

premandi suck for beginners.

i read it and still cant implement it.
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: cant understand raycasting

Posted 15 February 2013 - 08:19 AM

That is because you don't have the foundation to understand it. Secondly, not every tutorial out there is for beginners.
Was This Post Helpful? 0
  • +
  • -

#5 rolen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 13-February 13

Re: cant understand raycasting

Posted 15 February 2013 - 11:29 AM

ok what fundation do i need?
i have some programming experience,in game programming ive built a td in flashpunk and a small bullet hell game.

do i need to learn some advance math or algoritem?
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8911
  • View blog
  • Posts: 33,423
  • Joined: 12-June 08

Re: cant understand raycasting

Posted 15 February 2013 - 11:50 AM

That's a darn good question. You have not conveyed any information on what part you don't understand or can't implement. At best all we can recommend is a recursive function...

- start at the beginning
- read until you find something you don't understand.
- research what you don't understand.
- start over
- implement.
Was This Post Helpful? 0
  • +
  • -

#7 rolen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 13-February 13

Re: cant understand raycasting

Posted 15 February 2013 - 12:34 PM

ok
var rayScreenPos = (-numRays/2 + i) * stripWidth;


thats the pos of the ray on the "screen".first time of the loop it returns 160 (which is the x on the "3d screen" 160 is the middle).the screen is where the rays are renderd.

now this:

	var rayViewDist = Math.sqrt(rayScreenPos*rayScreenPos + viewDist*viewDist); 


the view? the camera? the screen? whos the viewer?

	var rayAngle = Math.asin(rayScreenPos / rayViewDist);

i know its trigonometry but where the angle is? its probbly on the 2d screen(mini map) but what dose it have to do with the rayScreenPos?
after that its simple math and logic(not somthing i havent seen).

hers the code:
http://dev.opera.com...can-1/#comments
function castRays() {
	var stripIdx = 0;

	for (var i=0;i<numRays;i++) {
		// where on the screen does ray go through?
		var rayScreenPos = (-numRays/2 + i) * stripWidth;
                /**
                alert('numRays'+numRays);
                alert('numRays'+numRays/2);
                alert('i'+i);
                alert('i'+(-numRays/2 + i));
                alert('stripWidth'+stripWidth); */
                //alert('rayScreenPos'+rayScreenPos);

		// the distance from the viewer to the point on the screen, simply Pythagoras.
		var rayViewDist = Math.sqrt(rayScreenPos*rayScreenPos + viewDist*viewDist);  
                  //alert('rayViewDist'+rayViewDist);
		// the angle of the ray, relative to the viewing direction.
		// right triangle: a = sin(A) * c
		var rayAngle = Math.asin(rayScreenPos / rayViewDist);
                // alert('rayAngle'+rayAngle);
		castSingleRay(
			player.rot + rayAngle, 	// add the players viewing direction to get the angle in world space
			stripIdx++
		);
	}
}

Was This Post Helpful? 0
  • +
  • -

#8 rolen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 13-February 13

Re: cant understand raycasting

Posted 17 February 2013 - 07:42 AM

no one can help me?

i have tried to understand premandi didnt work.

couldn't find any books on the subject.

searched in google posted a post in stack overflow.

found an old tut in qb

but no one explained it in a way i could understand

is there no way to learn thi thing?
Was This Post Helpful? 0
  • +
  • -

#9 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: cant understand raycasting

Posted 17 February 2013 - 11:06 AM

View Postrolen, on 17 February 2013 - 10:42 AM, said:

no one can help me?

To be honest, no. You don't have the foundation to understand, and no-one is going to hold your hand through and effectively redundant technique either.
Was This Post Helpful? 0
  • +
  • -

#10 rolen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 13-February 13

Re: cant understand raycasting

Posted 17 February 2013 - 02:49 PM

ok so what foundation do i need.

a name of the subject (sub subgect i guess).

or a modern book i can find on the subject.
Was This Post Helpful? 0
  • +
  • -

#11 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: cant understand raycasting

Posted 17 February 2013 - 03:07 PM

Just general mathematics. To not understand ray casting point to weaknesses in trigonometry and geometry.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1