Stvsynrj Posted February 8, 2016 Share Posted February 8, 2016 Hi guyz, Can someone tell me where i'm wrong here ? The sphere should be impacted by the cube's rotation no ? Here is a PG to seen what i mean : http://www.babylonjs-playground.com/#1WURND#11 Thanks in advance guys. Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 8, 2016 Share Posted February 8, 2016 I'm on mobile right now, but looking at your code I can say that after setting a mesh impostor you will have to rotate objects using the rotate function or quaternion and not the rotation variable. Try using it and see what happens. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 9, 2016 Share Posted February 9, 2016 deja vu! Steve, I think it IS impacting, but having a pair of update calls in the render loop... is just killing your ball speeds. http://www.babylonjs-playground.com/#1WURND#13 I moved the sphere to the outside and raised it, backed the camera out, did some other minor tweaks, and NOP'd lines 60 and 63. Ball drops fairly fast, lands atop the now-not-updating impostor cube... all as-expected. Now de-NOP 60 and 63, RUN again. Believe it or not, the sphere is dropping.... but... oh so slow, at least on my box. I noticed the same issue, earlier today, over in another thread. UpdatePhysicsBodyPosition(), inside the render loop... is slooooooow for the physics. I bet the ball IS bouncing-around inside the cube. (at speeds beneath what our eyes can detect) scene.createCompoundImpostor might be a better way to make the 6-plane physics cube. Line 35 is NOP'd, so cube doesn't have physics state, but you try to update its physics body. To make that method work, you might need to updatePhysicsBodyPosition on all 6 planes, instead. Not sure. Even if cube WAS physics-active, I doubt that cube.updatePhysicsBodyPosition would propagate down through the cube's children. Ok, that's all I have. I could be wrong. Cool demo... interesting test. Quote Link to comment Share on other sites More sharing options...
Stvsynrj Posted February 9, 2016 Author Share Posted February 9, 2016 Thanks for your reply @Wingnut Just imagine a transparent box, put a ball into it. Now rotate the box. How the ball should move in that box ? That's what i'm trying to do Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 9, 2016 Share Posted February 9, 2016 Yep. It all sounds easy, eh? Physics-active sphere inside of 6 physics-active planes, easy. Impulse the sphere around, easy. Somehow attaching those 6 planes together so they can be rotated as a whole... harder. http://www.babylonjs-playground.com/#1WURND#14 hehe. That looks painful. More fun ahead. Physics engine says: "Do I LOOK like I care if something is parented to something else? pfft" heh It sort-of makes a person want to cheat... by orbiting the camera around the box, and constantly adjusting the down-vector of gravity to match the down-vector of the camera. If not strong enough to flip the world upside-down, just stand on your head. A different kind of "work-around". heh Quote Link to comment Share on other sites More sharing options...
Stvsynrj Posted February 9, 2016 Author Share Posted February 9, 2016 Sounds like we are missing mesh.updatePhysicsBodyRotation() @RaananW ? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 9, 2016 Share Posted February 9, 2016 Nope, that's working. UpdatePhysicsBodyPosition updates both position and rotation, I hear. I think it gets its rotation values from mesh.rotationQuaternion. In my version of your demo, you will see some Euler to Quat massaging I did, in your animator. Then my dog threw-up. Think about it. UPBP updates the localSpace rotation of a wall panel. The physics engine has no clue that this plane is a member of a cube. (and so it's worldSpace rotation and position must be maintained... relative to a parent). Physics engines don't care about parents/children (apparently). In order to get all 6 planes to "act" like a single box to the physics engine, it has to be given a "master" physics impostor. There are only two ways to get a master impostor for cube... 1. set its physics state and then somehow get 6 planes to child to it (as far as the physics engine is concerned, a physics engine which ignores .parent property). 2. compoundImpostor from the 6 planes, and then maybe use THAT compound... as the impostor for cube.setPhysicsState( {impostor: here...}) BUT... the physics engine might see the 6 planes as a closed volume. If you have tested putting balls in standard boxes, you know that the physics engine rejects those balls with great energy. Physics engines seem to constantly try to avoid mesh overlap. So, even with a 6-plane compoundImpostor, the physics engine might try to eject the ball... seeing it as overlapping mesh. *shrug* I could be wrong. @RaananW ? We need a term, here. The act of a solid physics object... ejecting another physics object (because of mesh overlap)... what should we call that? I'm thinking pVom. Maybe PV. Physics Vomit. Pushout Vector. Privacy Violation. heh Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 9, 2016 Share Posted February 9, 2016 as wingnut said, mesh.updatePhysicsBodyPosition is also taking the quaternion rotation into account. The minute the impostor is set, you need to use this variable and no the rotation variable. you can always use the mesh's rotate function, which changes the quaternion internally. BTW, I just pushed a small change to 2.4 - the mesh has now a new function - updatePhysicsBody() which is the same as the old updatePhysicsBodyPosition, to avoid the confusion. Wingnut - first I hope your dog is fine To make a ball move INSIDE a box, use the mesh impostor with a double-sided mesh. I made a demo with a sphere - http://www.babylonjs-playground.com/#1SZYKZ#13 , but doing that in a cube is simply changing the mesh type - http://www.babylonjs-playground.com/#1SZYKZ#14 . click on the box, the balls will start shaking inside. fun fun fun! Stvsynrj 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 9, 2016 Share Posted February 9, 2016 Wow, a meshImpostor on a double-sided box! Nice! http://www.babylonjs-playground.com/#1WURND#16 Oh so close! Or not. Quote Link to comment Share on other sites More sharing options...
Stvsynrj Posted February 9, 2016 Author Share Posted February 9, 2016 Thanks for all your answers guys ! There you go http://www.babylonjs-playground.com/#1FXRWT#0 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 10, 2016 Share Posted February 10, 2016 You rock, Captain Steve! Mind if I ruin it's simplistic beauty? http://www.babylonjs-playground.com/#1FXRWT#1 Just goofy! 1.1 on both restitutions... is about all it can handle. heh I should REALLY learn to use the particleSystem.updateFunction feature, instead of wedging onto the prototype like that. *shrug* http://www.babylonjs-playground.com/#1FXRWT#3 There, that's better. I suppose the particle trail... should rotate with the box, eh? *sigh* Stvsynrj 1 Quote Link to comment Share on other sites More sharing options...
Stvsynrj Posted February 10, 2016 Author Share Posted February 10, 2016 Haha great one ! btw, take care, you dropped water on your screen : http://www.babylonjs-playground.com/#1FXRWT#4 (clean effect : http://synergy-development.fr/watercamera/ ) jerome 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 10, 2016 Share Posted February 10, 2016 Wow! Nice! Stvsynrj 1 Quote Link to comment Share on other sites More sharing options...
Stvsynrj Posted February 10, 2016 Author Share Posted February 10, 2016 Latest thing i ended up http://www.babylonjs-playground.com/#1FXRWT#7 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 10, 2016 Share Posted February 10, 2016 This is so great So glad it worked out! Stvsynrj 1 Quote Link to comment Share on other sites More sharing options...
Stvsynrj Posted February 10, 2016 Author Share Posted February 10, 2016 Thanks @RaananW ! meshImpostor was the key (Only with CannonJS as Oimo doesn't support meshImpostor) Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 10, 2016 Share Posted February 10, 2016 Nope, this is one of the good sides about cannon If you want to use oimo, you could, as wingnut said, create 6 walls and connect them (link them). Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 10, 2016 Share Posted February 10, 2016 Oh, now, SEE? I didn't even CONSIDER keeping the 6 sides together with physics LINKS! I'm thinking compound, I'm thinking parenting, but I forgot all about linking. Damn. 10 years, Raanan! In 10 years, I'm going to be as smart as you. Would you mind stopping your learning for a decade... while I catch up? Notice how I tried to use meshImposter with Oimo, yesterday? sigh. I'm an idiot. Quote Link to comment Share on other sites More sharing options...
Stvsynrj Posted February 10, 2016 Author Share Posted February 10, 2016 The last one for the fun : http://www.babylonjs-playground.com/#1FXRWT#8 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 10, 2016 Share Posted February 10, 2016 Nice! There's times that I could have used concrete balls. What's next? Snow globe? GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 11, 2016 Share Posted February 11, 2016 http://www.babylonjs-playground.com/#1FXRWT#10 The sphere is a box, the box is a sphere, everyone is confused! "Weebles wobble but they don't fall down." (even with 100,000 friction on both surfaces) Fenomas taught us about this, though. He said (loose quote)... "SphereImpostors ain't gots no friction, cuz theys gots no surface area" The Weeble stick inside the sphere... is a sphereImpostor... and thus it can't get enough friction... to tumble. weird. I was going to put egg-shaped sphericals inside, but that requires meshImpostor against meshImpostor, and that doesn't work. Only sphereImpostors are allowed to interact with meshImpostors, so far. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 11, 2016 Share Posted February 11, 2016 Ok, so, a snow globe. hmm. Well, we need to tip-over (invert) a snow globe, so... Step #1, we need a decent drag-rotater for a mesh. Amarneethi recently asked for the same, and built a pretty good one in this thread. Then Nockawa visited that thread, and wrote this beast. I, of course, stole his code... and wedged it into YET ANOTHER rocks-in-a-box demo. Yay! Shift key is active in Nockawa's rotater. Holding it while dragging... changes axes. http://www.babylonjs-playground.com/#1FXRWT#11 It doesn't work real well, but considering I don't understand Nockawa's code much at all, I guess I shouldn't complain. See that gruesome line 124? I actually had to research that, and compose that line myself. There was no place to steal good code-from! And therefore, THAT line is probably why this box-o-rocks works only marginally. heh Of course, my dog ran under the bed again, whimpering, when I started typing it. What a thin-skin. Stvsynrj and GameMonetize 2 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.