vahith Posted March 25, 2015 Share Posted March 25, 2015 hi all;i want to rotate meshes when it collision with other mesh... for eg i am having cube with different face color when the cube will collide with wall cube should rotate with given face..this is the reference playground linkhttp://www.babylonjs-playground.com/#LGY91and here i am attaching some screen short i am trying Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted March 25, 2015 Share Posted March 25, 2015 Hey vahith I think you can use actions managers like this : http://www.babylonjs-playground.com/#LGY91#1 at line 157 This is not a final idea but I think you can try some things with thatI moved the wall and I can get the source mesh (box) intersecting the left wall Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 25, 2015 Share Posted March 25, 2015 Hi guys... I've been playing: http://www.babylonjs-playground.com/#LGY91#2 click is still active, and so is drag... but this one starts moving automatically. click (or drag) the box and it picks a random direction of four... and starts moving again. Box stops when it impacts a wall (even though a continuous move is still happening). Console msg on impacts. I just expanded Luaacro's idea, which is a good idea. In the line 180 area... I added 3 more registered actions (total of 4, now), so there is a trigger->action function for all 4 walls. I'm not doing any rotation adjusting (yet). I just wanted to get 4 different collision functions, and then Vahith can play-with rotations. He can check his box "purple-side", get it aimed correctly, and then do more, with these 4 "impact functions". There may be problems, Vahith. What happens if you move into a corner, so two different intersects are happening at the same time? Might be a problem. They might keep interrupting each others' actions. *shrug* Also, the box MIGHT "struggle" to rotate because collision events might be happening WHILE you are doing a "slow rotation". I don't know IF you are planning a slow rotation, or an "instant rotate". Instant rotate, no problems. Slow rotate, maybe too many collision events with a wall... during rotate. Might be "jumpy". So, IF you do slow rotation, then maybe UN-register the action for the wall that the box is touching, THEN rotate, then re-register the action for that wall. Or, there might be a cheat way. Maybe "collapse" the box.ellipsoid to (0,0,0) size, THEN rotate the box, THEN repair/reset the correct box.ellipsoid again. By collapsing the ellipsoid, the collisions should stop. BUT... this demo has moveWithCollision inside the animation loop... so... collapsing the box.ellipsoid COULD make the box move thru the wall and into outer space. So... hehe... you might want to set way = BABYLON.Vector3.Zero(); (maybe IMMEDIATELY when an impact happens). That doesn't stop the moveWithCollsions, but it makes it continuously move "here". After that, collapse the ellipsoid (the box should stay positioned), place a proper animated rotation function on the registerBeforeRenderLoop, and wait for it to complete. Once complete, put the ellipsoid back to normal, and maybe start a new move or wait for a user click. *shrug* Issues issues issues. Maybe there is some useful "steering" code in Wingy's World's-Worst Flight Sim. And maybe not. In this forum post, Temechon showed me "something". (ignore "applyImpulse", that's a physics engine thruster). The important part would be v2... which is possibly a "forward" vector. (I should learn this stuff someday. Directional vectors and magnitudes... kind of suck. I don't do directions well.) All in all, I think there is steering happening to v2. I have heard of people "calculating an UP vector" and a "forward vector"... so forum searches might be helpful. Quote Link to comment Share on other sites More sharing options...
vahith Posted March 30, 2015 Author Share Posted March 30, 2015 hi wingnut/luaacro thank for your suggestion.. now i am able to rotate mesh when collision with wall..this is the reference palygroundhttp://www.babylonjs-playground.com/#LGY91#4 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.