RaananW Posted November 26, 2014 Share Posted November 26, 2014 You are right, it is the world->local craziness :-) http://playground.babylonjs.com/#1VITHH#15 You were totally right with your implementation except for the conversion back from the transform to the inverse world matrix of the cube. Now it somehow works. notice how it corrects the scaling as well, this is why cam2 is not on the ray anymore. Would be interesting to find a solution for that as well. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 26, 2014 Author Share Posted November 26, 2014 But why create another sphere (cam2) rather than having to move the first sphere (cam) ?When using a camera in the place of a sphere, it is this camera that is moved. Why not use a more concrete example. Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 26, 2014 Share Posted November 26, 2014 I think the same, it was just to demonstrate that it works. I would set a fixed distance and constantly check for ray intersections with the nearest objects, depending on the direction of the camera. Then sen the camera's position according to those parameters. To prevent the camera from leaving the ray's range I would simply avoid scaling walls. I assume walls are the main objects that should be checked for intersections. A small very quick demo, that is based on the implementation so far - http://playground.babylonjs.com/#1VITHH#16 . I have removed the scale to prevent the world coordinates conversion problem. This should, of course, be improved. BTW, my patch for the Ray class is already in GitHub, a help static function Ray.CreateNewFromTo(origin, endPoint) will create a ray from a point to a point defining a given distance. I think this will help these kind of problems. Dad72 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 27, 2014 Share Posted November 27, 2014 That's a GREAT JOB that you did! I would love to see more PR like this one! Quote Link to comment Share on other sites More sharing options...
joshcamas Posted November 27, 2014 Share Posted November 27, 2014 Did a tiny bit of work on it. Made a camera's collision array, which holds all the objects to be checked. Then I made it so if the camera intersects more than one object it picks the closest one. http://playground.babylonjs.com/#1VITHH#17 Now we should to make it so we see a certain amount of the character. Idk how we would do this. Dad72 1 Quote Link to comment Share on other sites More sharing options...
Stephen Andrews Posted November 27, 2014 Share Posted November 27, 2014 Awesome work josh, That's really coming together nicely. Still, is there no way in babylon to raycast in a similar way as scene picking? (Where you don't know what mesh you'll hit) Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 27, 2014 Share Posted November 27, 2014 Still, is there no way in babylon to raycast in a similar way as scene picking? (Where you don't know what mesh you'll hit)What do you mean? scene.pick returns the picked mesh info Quote Link to comment Share on other sites More sharing options...
Stephen Andrews Posted November 27, 2014 Share Posted November 27, 2014 What do you mean? scene.pick returns the picked mesh infoSorry, that was badly phrased. xDScene.pick can pick ANY mesh in the scene, where as raycasting (so far as I can tell, there does not seem to be much information on it,) can only pick the meshes that it's already told to find. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 27, 2014 Author Share Posted November 27, 2014 Wow, the examples are really cool. I think that to reproduce this with the more concrete would be good. I mean the real wall on ground, a character and cameraRotate following it.Thank you again the guys Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 27, 2014 Share Posted November 27, 2014 scene.pick can use a predicate to specify mesh to find Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 27, 2014 Share Posted November 27, 2014 A quick implementation of what you wanted - http://playground.babylonjs.com/#VQBG2 . try rotating the camera and "losing" the sphere. It is always in sight. This is really just a "prototype". Fast check is on, so it will stop finding the next mesh if it found one. but still I do believe that if you have hundreds of walls you will have to somehow check it a bit better. there is plenty of room to improve this! //Edit - with keyboard shortcuts ('w' and 's') - http://playground.babylonjs.com/#VQBG2#1 Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 28, 2014 Author Share Posted November 28, 2014 Waw, It's really good that you have done, it works perfectly. Raananw thank you Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 28, 2014 Share Posted November 28, 2014 Love this community! Quote Link to comment Share on other sites More sharing options...
joshcamas Posted November 28, 2014 Share Posted November 28, 2014 That's Fricken Awesome!!!!! Now I think we should maybe send several rays, instead of one? This would be to remove the partly blocking: http://i.imgur.com/Q8z8tgv.png The problem with a few rays you could still have this happen if the mesh is small enough to fit between the rays. Therefor, would it make sense to create a mesh to do it instead? Kinda like this: http://i.imgur.com/XaZxaSs.png We would have parameters such as "Camera Width" and "Camera Height", and "Target Width" and "Target Height" Then the mesh would change shape every frame Would that be possible? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 28, 2014 Author Share Posted November 28, 2014 Me it suits me very well as it is. Quote Link to comment Share on other sites More sharing options...
joshcamas Posted November 29, 2014 Share Posted November 29, 2014 It's good enough to be put into the next babylon release, yes. I guess someday we should make it better Quote Link to comment Share on other sites More sharing options...
joshcamas Posted November 29, 2014 Share Posted November 29, 2014 Also: http://playground.babylonjs.com/#VQBG2#2 When the camera is intersecting two planes, it can pick the wrong one. Raananw already figured this would happen, but I think we should disable fast checking to have this not happen at all. Or have it as an option? idk! Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 29, 2014 Author Share Posted November 29, 2014 This problem can be solved with an invisible box. It can also be solved by avoiding to model objects with this scenario. http://playground.babylonjs.com/#VQBG2#3 Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 29, 2014 Share Posted November 29, 2014 It is inevitable (and not because of causality!) - you will have to check all walls for the smallest distance. The pickWithRay function simply iterates through all meshes, according to the order you added them... Without changing the framework (to return an array of pickInfo and not just the last one it finds), the best way of doing it is this : http://playground.babylonjs.com/#VQBG2#5 I did two things - I am checking if a wall is in the scene's frustum and filtering it from the picking inspection if it is not in the scene's frustum. This will prevent the pickInfo loop to run. I assume this inspection is faster than iterating through all of the meshes and not finding any pickInfo. (Note - this only works if we are using rays straight from the camera. otherwise the frustum needs to be calculated differently). I am running a pickInfo with fastCheck for EACH wall in frustum. This way I am getting the lowest distance from the object and setting it. The last implementation simply took the distance of the first object it found. This is the simplest way i see, without again changing the framework (this will be a breaking change, as suddenly an array is returned and not a single object. I am not sure this is what everyone wants :-) ) //EDIT - this has to be one of the most interesting forum thread i ever took part of :-) 300 walls and still 60fps - http://playground.babylonjs.com/#VQBG2#6 , looks like it is good enough to be used live. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 29, 2014 Author Share Posted November 29, 2014 raananw can send your first fixed :if(max == -Infinity) { max = Infinity; }I had some problem to request a pull, I do not know how I think. this is the first time I used a GitHub repository. I use bitbucket most of the time and it does not work in the same ways. DK So, it would be interesting to have a little tutorial to send patches to the deposit by that I admit there feel really stupid. Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 29, 2014 Share Posted November 29, 2014 Hi dad72, the fix is no longer needed, it doesn't work globally but only for one single case. The old implementation works fine. I wanted to improve the entire function, i'll make a pull request when i am done cleaning up my code :-) Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 7, 2015 Author Share Posted February 7, 2015 Hi, @ Raanan, Your code works very well, but it disables the zoom of the mouse wheel to arcRotatecamera. Do you have any idea why? http://playground.babylonjs.com/#VQBG2%236 Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 7, 2015 Share Posted February 7, 2015 Hi dad72,The reason it happens is that the camera's radius is set every frame. The variable "radius" is the max distance between the camera and the object. And it's set at the render loop. I guess the loop could be implemented differently to allow zooming in or out until it his a wall. Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 7, 2015 Share Posted February 7, 2015 Here you go http://playground.babylonjs.com/#VQBG2#7 You can even zoom in after being limited. The last radius where no wall was detected is the radius to which the camera will return afterwards. Dad72 and jerome 2 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 7, 2015 Author Share Posted February 7, 2015 Wow, that's great. this works like a charm. thank you very much Raanan . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.