Skip to content

Raycasting API #559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
codeanticode opened this issue Oct 16, 2019 · 3 comments
Closed

Raycasting API #559

codeanticode opened this issue Oct 16, 2019 · 3 comments

Comments

@codeanticode
Copy link
Contributor

The p5.xr library implements a number of functions for raycasting in VR/AR:

  • rayObject = {origin: p5.Vector, direction: p5.Vector}
  • generateRay(Number x1, Number y1, Number z1, Number x1, Number y2, Number z2) - returns rayObject
  • intersectsBox(Number width, [Number height], [Number depth], [rayObject ray]) - returns boolean
  • intersectsPlane([rayObject ray]) - returns p5.Vector(2D)
  • intersectsSphere(Number radius, [rayObject ray]) - returns Boolean
  • getRayFromScreen(Number screenX, Number screenY) - returns rayObject

These could be useful to add to the VR/AR libraries in the Android mode.

More information:

Implementation: https://github.com/stalgiag/p5.xr/blob/master/src/p5xr/core/raycasting.js

Examples: https://github.com/stalgiag/p5.xr/tree/master/tests/manual-test-examples/p5vr/raycasting

Doc discussing design/implementation: https://docs.google.com/document/d/1JzvLBAQuh7gydo0Wpk0UhdgbTBkSekFp-uoKKSUN5Xg

@b2renger
Copy link
Member

This is great ! maybe some feature enhancements from this could be helper functions to draw projected shadows on tracked planes ? and very probably to calculate occlusion from walls ?

@codeanticode
Copy link
Contributor Author

@b2renger thanks for the suggestions, are you referring to AR?

@codeanticode
Copy link
Contributor Author

codeanticode commented Oct 28, 2019

@stalgiag As for the ray casting API, it ports all the functions in p5.xr, so this can be considered complete (commits 7b1143e, b27d212, e16e1cc, a9cdfab, 86d562f, 9742570, ef8d5c3, 9459600, a32ede5). There are some differences in implementation, for instance, there is no generateRay equivalent, as I don't think one needs to transform origin/direction before the corresponding intersectsX() calls. We can discuss this later.

@REAS @benfry @lmccart just a heads up of the ongoing efforts to sync AR/VR between p5 and android mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants