Skip to content
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

Add a picking system #59

Closed
Zifiv opened this issue Dec 30, 2015 · 8 comments
Closed

Add a picking system #59

Zifiv opened this issue Dec 30, 2015 · 8 comments
Assignees
Milestone

Comments

@Zifiv
Copy link
Contributor

Zifiv commented Dec 30, 2015

I don't saw the picking system/engine into your game engine. I think that isn't optional for a game engine.

@sriharshachilakapati
Copy link
Owner

This is a good enhancement, but I think I'm not going with this as my first priority. My first priority still remains to get a HTML5 backend. I'd definitely like to see a PR if you want to contribute to the engine.

@Zifiv
Copy link
Contributor Author

Zifiv commented Apr 9, 2016

I've not the time for now to help you with this, but when it's done for me, I will help you obviously. First I need to understand all of your nice work, SilenceEngine.

I've send you a mail, can you give me a answer fast. TY :)

@sriharshachilakapati sriharshachilakapati modified the milestones: 1.0.1, 0.4.1 Apr 9, 2016
@sriharshachilakapati sriharshachilakapati self-assigned this Apr 9, 2016
@sriharshachilakapati
Copy link
Owner

As you can see, I'm now working on the HTML5 backend in the new silenceengine-1.0.1 branch, and SilenceEngine at the current state is getting a major rewrite to support HTML5. In the future I have plans to integrate Android backend as well. You can see the current HTML5 tests in action online at http://silenceengine.goharsha.com/tests/

The picking system is indeed important, and I will be working on this once I get the basic framework letting you to run the game on all the platforms without any modifications. Once I get this done, then I will implement all the existing base graphics and audio code, along with collision engine to the new system. From then, I will start working on the features.

I've seen your mail, will reply with more information in the e-mail itself.

@Zifiv
Copy link
Contributor Author

Zifiv commented Apr 9, 2016

Ok thanks you for this information, NICE WORK about your HTM5 backend, seriously great job 👍 !!

@Zifiv
Copy link
Contributor Author

Zifiv commented Apr 15, 2016

I think that we can use your Collision's classes to create the picking system. I will begin soon developping into my github from your last release.

@sriharshachilakapati sriharshachilakapati modified the milestones: 1.1.1, 1.0.1 Sep 5, 2016
@sriharshachilakapati sriharshachilakapati modified the milestones: Future, 1.1.1 Nov 18, 2016
@sriharshachilakapati
Copy link
Owner

Postponed once again as the priority now was on making a release, and modularize the engine with extensions, that will allow integrations with more native libraries.

@sriharshachilakapati
Copy link
Owner

sriharshachilakapati commented Jan 1, 2017

@beaucoralk

This is now implemented in a way that it doesn't affect the performance of OpenGL. SilenceEngine now includes a Ray class get the testing. For mouse picking, the process is as follows:

  • Create a Ray from the mouse position:

    Ray mouseRay = new Ray(); // Create once, and cache it
    camera.createRayFromScreenPoint(Mouse.x, Mouse.y, mouseRay);
  • Use the ray to query the objects that intersect from the broadphase

    // Cache the broad phase (DynamicTree3D) that you pass to SceneCollider3D
    List<CollisionComponent3D> rayHits = dynamicTree3D.retrieve(mouseRay);

    You get all the objects in the broad phase that are intersected by the ray.

  • Sort the components based on the distance from the origin of the ray. This is to pick the object which is close to the screen.

    // Note that List.sort is not available under GWT, so we have to use Collections.sort
    Collections.sort(rayHits, (c1, c2) ->
            c1.entity.position.distance(mouseRay.origin)
                 - c2.entity.position.distance(mouseRay.origin));

And then the first object in the list will be your picked object, it will be the closest to the screen. In the case of 2D, you don't need all this, you can use the x and y values of the ray origin, and it will be the point in world coordinates. Which object contains that point will be the picked object.

@Zifiv
Copy link
Contributor Author

Zifiv commented Jan 1, 2017

Just... Wahoo. One more time, great job :D ! I'm sorry I did not have time to help you on this, and not having time to look at your code.

Finally this sentence make me happy :
"This is now implemented in a way that it doesn't affect the performance of OpenGL."

Thank you for this !

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