Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

robertgamble

3D raycasting engine in java-script/DHTML...

This topic is 5882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
That''s pretty neat !

quote:

96 + (224-191)/Math.tan(60), should be about 115 right?


Uh, are you sure that Math.tan() expects the parameter to be in degrees, and not in radians ? In the later case, the result would be 199.11

Share this post


Link to post
Share on other sites
Neither of those links work in galeon(gecko/ns6 based browser).

Pitty, sounded interesting.

Share this post


Link to post
Share on other sites
It worked in Mozilla the last time I tried, but now it''s broken. I guess he changed something that broke the compatibility ?

Share this post


Link to post
Share on other sites
It is waaaay (Waaay) too slow to use in anything but IE.. I had it working in Mozilla but it was atleast 20 times slower than IE

Yann L, hey you''re right I feel silly now, thanks for that

Share this post


Link to post
Share on other sites
That''s pretty nifty. I think java-script is an area where the old optimization tricks come in handy. Avoid modulus operators when possible, avoid division when possible, definitely remove them from loops. Use multiplication and addition instead when possible. The judicious use of bitmasks and bitshifts can also help. Unrolling loops can result in speed increases as well. I''ve found that sets of 8 work very well - but coding them up can be a pain. I haven''t done any java-scripting lately - so I can''t speak as directly regarding the document object model and so forth as I once was able to - but in the past I found that setting up all the containers during initialization and then tweeking their parameters during execution produced better results than rebuilding them as strings and then "blitting" them (so to speak). Especially if the total number of containers is constant or isn''t too large. The definition of "too large" varies according to the machine.

I wasn''t able to get either version to work correctly in Mozilla. Works fine in IE though. Keep up the good work!

Share this post


Link to post
Share on other sites
Yeah, I''ve used loop unrolling before.. It did seem to give a bit of a speed increase. But you''re right, writing it would be a pain.. Resizing and moving objects did seem a bit faster than "blitting" them every frame.

I''ve started on a new version http://www.elephantsneverforget.co.uk/hroberts/editor/gmen.asp, but I can''t get it to display stuff properly. Even without any optimisations at all it seems waaay faster than the other one though. I''d be really grateful if someone could take a quick look through the source and see if they can spot whats wrong. Cheers..

Share this post


Link to post
Share on other sites
You might want to check out these "the5k" entries... they are all java-script raycasters:

http://www.the5k.org/description.asp/entry_id=946
http://www.the5k.org/description.asp/entry_id=1283
http://www.the5k.org/description.asp/entry_id=1302

Share this post


Link to post
Share on other sites
quote:
Original post by robertgamble
I''d be really grateful if someone could take a quick look through the source and see if they can spot whats wrong. Cheers..


It''s faster. It still doesn''t work in Mozilla. I looked through the source but I don''t have as keen an eye for js as I used to so I didn''t spot anything wrong.

Share this post


Link to post
Share on other sites
Works in Mozilla now (and is very fast too!), still can''t get it to work properly though. I think the problem is here:


//find first x intersection (vert)
ray.vx=(correct<0)?Math.floor(player.x/map.scale) * (map.scale) - 1:Math.floor(player.x/map.scale) * (map.scale) + map.scale;
vxa=(correct<0)?-map.scale:map.scale;



//find first y intersection (vert)
ray.vy = player.y + (player.x-ray.x)*Math.tan(rad(ang));
vya=map.scale*Math.tan(rad(ang));


But I really don''t know


I looked at those contest entries, but sadly I don''t think they''ll be much help Thanks though.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!