Sign in to follow this  
Pryme8

hitboxes not lining up with mesh

Recommended Posts

https://github.com/Pryme8/Monster_Truck_for_DrewJr
http://pryme8.github.io/Monster_Truck_for_DrewJr
 

I am working on a little game for my son, and for some reason the hit boxes for the tires are all sorts of wonky...  anyone have any idea why this is? Also what route should I go down to program suspension for the tires in Oimo?  I assume, I will need to apply force to the chassis in relation to the distance from the natural point of a spring for each tire.

First I need to figure out what is going on with these hit boxes!

Share this post


Link to post
Share on other sites

Hi!

That's quite a nice task :)

A few notes about your implementation (that will eventually end in me apologizing)

1) The Oimo version we are currently using does not support cylinder impostors. Onle boxes and spheres. For some reason the newest Oimo version doesn't play well with the bjs physics architecture. I am trying to solve this and will update as soon as i can.

2) The correct joint to use in your case is Oimo's wheel joint or hinge joint. It depends on the degrees of freedom you want for your wheels. This is already possible with the new physics architecture. And this is where I apologize - I haven't got the chance to write the documentation yet, so... How would you know that? :)

3) Oimo has a nice Car demo, where you can see the code that they are using. It can be found here - https://github.com/lo-th/Oimo.js/blob/gh-pages/test_car.html and is using cylinders. You can use psheres instead, they should give the same results. Create invisible spheres and  attach them to the actually cylinders that are the wheels. This way you have impostors and nice meshes together.

4) I have shown already how to implement a car using cannon js - http://www.babylonjs-playground.com/#UGMIH#2 . I will soon integrate it as a custom physics body in babylon js, so it will all be simplified.

If you want, we can try implementing a car together in the playground. start a new playground, create the neded meshes etc', impostors and so on, and we'll see how to improve it together. It is rather hard for me to work with the github code. 

Share this post


Link to post
Share on other sites

thanks for the advice!

I am on it and should have the truck driving by tonight hopefully...  I will take a look at the information and methods you have provided and get at it!

Also I updated the GIT

Quick question though after looking at the link https://github.com/lo-th/Oimo.js/blob/gh-pages/test_car.html

how do I implement the hinge joints and wheel joints in babylon?  as the way to call the methods seems a little different then their example.

and sure on the playground, go ahead and grab my models and textures off the git if you would like and use them in place of primitives if possible?

Share this post


Link to post
Share on other sites

BUMP***

 

i need examples of oimo wheel joints and motors in Babylon if possible or examples of how to convert the three.js examples on oimos docs to Babylon.js.  I do not want to learn three.js just to do this but may have to unless someone can describe the methodology behind switching over from three to Babylon.

i just read your post again I miss understood initially I'll make a new playground today when I get a chance and post it here so we can troubleshoot 

Share this post


Link to post
Share on other sites

Demanding little turd, aren't ya?  :)  I doubt that ANYONE here will respond well to "or else" threats.  ("may have to unless")

But yeah, since the change in Oimo version, all the http://playground.babylonjs.com/#1VITPM#0 series #0 - #29  found in a few posts... starting at:   

http://www.html5gamedevs.com/topic/2571-the-wingnut-chronicles/?do=findComment&comment=105225

...are failing. 

But "primate"... think about what Raanan has done recently, AND his normal day-job, AND raising a family.  He installed the newest CannonJS, and activated meshImposters (a huge task in itself).  Then he started implementing all the new power from the newest Cannon, and found he needed to completely overhaul the plugins... to expose those new features.  Then he tested and activated some tips given to him by Schteppe, the author of CannonJS.

Now he takes-on a new OimoJS, (which is fighting with the BJS framework), re-writing ITS plugin so that it reasonably mirrors the CannonJS plugin, AND it needs to inform users of the differences between Oimo and Cannon, AND try to keep both plugins... backwards compat.

Really, you COULD assist Raanan instead of pressuring him.  I am guilty of pressuring folks, too... but... at some point, we need to catch our breath, stop "racing" in some kind of hurry, and come-to-grips-with (self-realize) the task at hand.  Or, at least love the ones who ARE coming to grips with it.  :)  You COULD run the newest Oimo thru JSDoc, and build a really nice API docs for it.  That would help yourself, and Raanan, and everyone else who uses the new Oimo.  It's easy to forget that if we help "team", we help self.  Conversely, if we damage team, we damage self.

Now, if I could just get all the people of planet Earth to realize that, then we would REALLY have something cool.  :)  The USA military realized it LONG ago, and that's why the military policy-of-conduct is... team 1st, self later.  They have been seen adopting one another and making sure each other "gets down the trail safely and happily".  Commune-ity, rocks!  Call me a Christian-like commie, as needed.  I consider it a compliment.  :)

Share this post


Link to post
Share on other sites

@Wingnut they shouldn't fail... I tried making everything backwards compatible :) 

But I did find out why it happens - you are changing internal functions (http://playground.babylonjs.com/#1VITPM#31 , line 127 and up), which don't exist anymore. So this might be a problem. The error you get is because of line 123 (http://playground.babylonjs.com/#1VITPM#1) - the physics plugin can now be retrieved using getPhysicsEngine().getPhysicsPlugin() (instead of using private variables). I didn't keep private methods backwards compatible and this is the reason it doesn't work...

Right now http://playground.babylonjs.com/#1VITPM#31 is failing because of the getDescendents error, which I hope will be updated pretty soon in the playground (already fixed in Code). After this is fixed I can see how to get your demos to work again, because they should.

@Pryme8 - I am terribly sorry, but I will take some time. As Wingnut said, life has a toll on my time :) The link I gave you (Oimo's way of handling this) should actually work, if you create the impostors using Babylon'S code and the wheel joints as Oimo describes. I committed yesterday a few further changes that get us all closer to a babylon.js native car implementation. When the playground will be updated (maybe today or tomorrow) I will be able to play a bit with the implementation and show you how to make a simple car.

Share this post


Link to post
Share on other sites

Well thanks R... that was real nice of you to fix that PG.  Yep, many of those demos went "under" the plugin and talked directly to Oimo, and that has changed.  Personally, I am not concerned that the demos are failing.  I just went there to see if I could show Pryme8 an Oimo hinge joint in action, and maybe turn-on a wheel joint, too.  Prior to those demos, I don't think there were ever any publicized joint tests done, except for the joints that happen with a setPhysicsLinkWith()  (which produces two hinge joints, I believe).

After the dust settles, I'll get them working again, easy... now that Raanan did all the troubleshooting FOR me.  :)  The important thing is that we are getting updated physics packages installed in BJS.  From what I have seen so far, performance has vastly improved, and so have plugin features and ease-of-use.  I have tons of patience for things like that to happen.  If there's anything I can do to help, you just let me know, R.  I consider the work you do on our physics... AnimatedStar.gifgoldAnimatedStar.gif.

Also, for the youngsters, I THINK that the "hit box" term, as used by Pryme8...is the same as "physics impostor" or "physics body".  Currently, I think we only use "rigid" bodies.  "Soft" bodies are... something else.  Flexible rigid bodies, I suppose.  I think the term "rod" gets involved somewhere in that, too.  I dunno.  I'm just completely happy that I get to play with ANY physics within a JS env, and with a great visualizer such as BJS webGL.  How totally cool!

Share this post


Link to post
Share on other sites

Thanks everyone, I am really excited for the updates!  As soon as I have more documentation I'll make up some good demos and really try to expand the community's knowledge base.  

Eventually here I'll do some polished scenes but for right now I'm trying to learn the ins and outs of Babylon at least to the level I know Unity once I feel comfortable that I'm not a fool I'll post some step by step video tutorials with explanations of why things work not just "do this and it's magic!" 

Sorry if I post a lot of questions but I live and breath problem solving.

thank you for all the time you guys take in developing and maintaining Babylon, I really appreciate it!

Share this post


Link to post
Share on other sites

Hey @Wingnut - http://playground.babylonjs.com/#1ND6TH#15 

your demo is working :) with a bit of modifications. But working. You could use this PG as a basis for creating some more wonderful demos. 

After the changes I commited yesterday, I am pretty satisfied with the current state of things. so I can start documenting without making major changes. And that's nice ;)

 

Share this post


Link to post
Share on other sites

Thank you raan my son I turning 3 and he is really really into monster trucks so I sat him down on my lap and started this project.  It was really cute he was all like "that's a pretty monster truck" to the quick model I pumped out for testing.  I am extremely excited to make something for him and can't wait to see him driving around the arena smashing cars!  

I have a ton on my plate right now, but will look at doing something with the new information this weekend.

 

one quick question though I figured out how to access oimo and cannon methods that are not documented by you guys yet, but for example in cannon if I try to access the apply torque method I am able to but drop an error due to Babylon.vector3 being incompatable with the expected vec3 format... Now I have not tried to just pass a simple xyz object to it, but I was wondering how can I get around this?  Do I need to define a vector3 class that mirrors cannons vec3 class?

 

Share this post


Link to post
Share on other sites

Would be wonderful to know where exactly you are getting this error.

If you are using cannon nativly you would have to use their own Vec3 class. but you can copy data from a babylon vector using the .copy method like this:

var vec = new Vec3().copy(babylonVector);
//or
var vec2 = new Vec3(babylonVector.x, babylonVector.y, babylonVector.z);

Personally I like the first variant, but both will result in the same vector. 

Share this post


Link to post
Share on other sites

Hey Pryme8... if I may clear-up a possible confusion...  OimoJS and CannonJS are not written by BabylonJS folks.  They are "third-party" (and this is why Oimo has no API docs for it, yet). 

So, the vec3 and quaternion class objects used in those two third-party libs... are rarely/never compatible with Babylon vec3 and quats.  That is why Raanan showed you how to convert.  :)  (Plus, he's a swell guy).

The BJS physics plugins to Cannon and Oimo... are interfaces to those third-party packages.  Lots to learn, eh?  *nod*  Been there.  :)  It's all good, though.  And, you're doing an excellent high-speed job of learning those two physics packages.  Few people dive into native code this early in their learning, or AT ALL.  We expect great physics things from you... in the future.

Share this post


Link to post
Share on other sites

quick dumb question wingnut, when using cannon how do I set my linear Velocity to 0 on a object?

Quote

Demanding little turd, aren't ya?  :)  I doubt that ANYONE here will respond well to "or else" threats.  ("may have to unless")

But yeah, since the change in Oimo version, all the http://playground.babylonjs.com/#1VITPM#0 series #0 - #29  found in a few posts... starting at:   

http://www.html5gamedevs.com/topic/2571-the-wingnut-chronicles/?do=findComment&comment=105225

...are failing. 

But "primate"... think about what Raanan has done recently, AND his normal day-job, AND raising a family.  He installed the newest CannonJS, and activated meshImposters (a huge task in itself).  Then he started implementing all the new power from the newest Cannon, and found he needed to completely overhaul the plugins... to expose those new features.  Then he tested and activated some tips given to him by Schteppe, the author of CannonJS.

Now he takes-on a new OimoJS, (which is fighting with the BJS framework), re-writing ITS plugin so that it reasonably mirrors the CannonJS plugin, AND it needs to inform users of the differences between Oimo and Cannon, AND try to keep both plugins... backwards compat.

Really, you COULD assist Raanan instead of pressuring him.  I am guilty of pressuring folks, too... but... at some point, we need to catch our breath, stop "racing" in some kind of hurry, and come-to-grips-with (self-realize) the task at hand.  Or, at least love the ones who ARE coming to grips with it.  :)  You COULD run the newest Oimo thru JSDoc, and build a really nice API docs for it.  That would help yourself, and Raanan, and everyone else who uses the new Oimo.  It's easy to forget that if we help "team", we help self.  Conversely, if we damage team, we damage self.

Now, if I could just get all the people of planet Earth to realize that, then we would REALLY have something cool.  :)  The USA military realized it LONG ago, and that's why the military policy-of-conduct is... team 1st, self later.  They have been seen adopting one another and making sure each other "gets down the trail safely and happily".  Commune-ity, rocks!  Call me a Christian-like commie, as needed.  I consider it a compliment.  :)

I did not even see this post my bad!  I do not mean to come off demanding, just trying very desperately to get the tools together to get to the point where I don't have to ask questions anymore.   I understand being busy I am a single dad raising a 2 and a half year old and run a "design" company by myself so we can eat...  If it seems like I am being aggressive or pushy very sorry its part of my personality that when I am motivated to get something done I start going crazy if I cant figure the problem out.

Anything I can do to help I am glad to, and as soon as I get a little bit of grasp on basic topics that I am able do in other game engines (like apply torque)  I will start giving back way more then I ever asked for.  Thanks for your support and if Im being annoying dont hesitate to say so.  I just really want to be somewhere else in life and for years dabbling in other engines has gotten me nowhere.  Babylon is kinda a light at the end of the tunnel everything advanced that I wanted to do in other engines I can do (like procedural textures and post filters) without having to pay money, but simple things that should not be bogging me down are going to make me go insane...

Share this post


Link to post
Share on other sites

It's all cool, P8.  You're certainly valuable and talented... no doubt about that.  Of course, we don't like seeing you become desperate, crazy, bogged, or insane.  I guess the main thing is... try not to blame the power-coder volunteers (such as Raanan) for causing those conditions in you.  This framework is young and people like you help to "iron-out the wrinkles"... thanks for your help with that.  But you are REALLY fast, and the ironing "night crew" is really small, so overnight bug fixes and while-you-wait PG demo troubleshooting... is limited.

To be frank, I don't know why Raanan hasn't collapsed from exhaustion, yet.  Not exhaustion caused by you, but caused by ALL the great things he does.  I'm not NEAR the coder that either of you two are.  Sometimes, the best I can do is hand-out warm wash cloths and deliver pizza.  :)  We cannot afford to lose Raanan.  But he has gotten some pressure about docs, and about physics anomalies, and probably some real life pressures, too.  If I see too much gunfire coming at Raanan... I'm going to stand in the way and block the shots.

He has shown no signs of cracking under the pressure, but I am still going to monitor him for signs of fracture.  I will be there in a flash with superglue and protective apparel for him, if needed.  :)  I like him... a lot.  *shrug*  I like everyone in our community... but some participants work REALLY HARD for team... and those people get special treatment.

Share this post


Link to post
Share on other sites

Anything I can do to alleviate some pressure from him I'd be glad to do maybe at some point we can do a webcam meeting or something and one of you guys can give me the run down of what someone like me can do to help with the documentation and bug hunting.  I would really like to be involved more directly with Babylon as it develops and kinda feel like dead weight at the moment.   Discovering this community and js library has been very exciting for me, as finally after over a decade of focus and self teaching my goal of becoming the owner and lead director of an indie game company is finally becoming a possibility.   So I again apologize if my zeal comes off cross ?.

 

on a side note do we have any web socket guys?  I'm going to have some paid operunties for a good node.js web socket person.

Share this post


Link to post
Share on other sites

Motivation and enthusiasm are always welcome here :)

I can tell you that Raanan is currently working hard to finalize the integration of the new physics infrastructure working with the last versions of OimoJs (this one seems to induct a strange bug, but he's fighting at it) and CannonJs.

Trust me, I've got a secret door to spy what he does ;)

Share this post


Link to post
Share on other sites

You would prolly be the guy to ask, how would one go about "Raycasting" collisions as apposed to the standard collision method?  Or is there another way to work around fast moving or "thin" objects?

Share this post


Link to post
Share on other sites

Not really

I haven't even started to learn about Physics engines so far ...

Or maybe I don't understand what you mean... is this related to some question about a perlin noised terrain from another thread ?

Share this post


Link to post
Share on other sites

No sir, raycasting is a method for checking distances between objects and to prevent fast objects from moving through each other before each physics calculation you do a raycast in the direction of travel and you see if your object would collide with something during the physics application and if it does you register that point and adjust your physic means to react loke a contact happens at that point between the two objects

Share this post


Link to post
Share on other sites

http://www.babylonjs-playground.com/#HHFCL#1

@RaananW, so I have been trying to follow your example, but It seems im not setting up my pivot joints up very well.... could you provide a quick explanation of the properties, especially the spring and limit, when you have a chance I know your a busy man.

Also when should one deploy a wheel joint vs a hinge joint and is there any examples of sliding joints?

One last thing, whats the best method to attach the axels to the chassis?

Share this post


Link to post
Share on other sites

Hi @Pryme8,

just saw the message.

About your demo:

1) There is no need to create the connection between the wheels. The physics hinge joint is the one that connects the wheel to the car's body.

2) It was hard for me to follow the code (not sure why jQuery functions suddenly pop in :) ), I would personally organize the code a bit differently, but this is really a personal opinion. I like the CAR object thou, keeps everything configured in one single object.

About the hinge2joint:

Main demo - http://www.babylonjs-playground.com/#1MSQGK

This image would be a nice representation of a hinge2joint:

loc_eps_hinge2joint.gif

Oimo's hinge2joint is a bit more advanced, and accepts two anchor/pivot points instead of one:

1) main pivot - the point in which the hinge joint will be connected on the main object. So if it is a wheel, it will be the relative point on the car's body to which the wheel will be connected. 

2) connected pivot - this is the point to which the joint be connected with the second object (the wheel). In the case of a wheel, it will be connected in the middle of the wheel, so 0,0,0 is in order. Setting it to something else will make a funky car : http://www.babylonjs-playground.com/#1MSQGK#1 (one wheel has a connected pivot set)

Now about the axis:

1) main axis is the one in connected to the body. like in this picture, and like in a regular car, this axis will be on the y axis. it is relative(!) to the main body, so the rotation of the object should not be taken into account.

2) connected axis - now it depends on the position of your wheels, and how you decided to place them relative to the car's body. In my demo, they are on the "left" and "right" sides of the body, when it is facing to the z-direction. which means they rotate around the x axis. and this is why the axis in my demo (the connected axis) is on the x axis (0,-1,0), pointing towards the car's body. setting it to 1,0,0 will simply change the rotation direction of the wheel. so you will only need to adjust the backwards and forward to be the opposite of what I did.

About motors and springs - 

Springs will somehow emulate suspensions - http://www.babylonjs-playground.com/#1MSQGK#2 , notice how the wheels move a bit when the car is on top of the blocking spheres. Oimo's spring doesn't work really as expected (don't think this will create a nice suspension effect, it won't :) ).

About limits - this is the angle limit of the wheel's rotation. In my example I change it in the update loop. 0 means no rotation (wheels move straight), an angle (in radians) means the wheel can rotate up to this angle. If I disable the rotation 0 of the back wheels, this will happen: http://www.babylonjs-playground.com/#1MSQGK#3 (move forward, you will see the wheels go crazy)

Motors: This will get the wheels going. It's just what it describes :) there are two parameters - the speed in which is will rotate, and tha max force that will be applied on the hinge/ body that is connected to it.

Both set motors and limits accept an extra 3rd parameter - which part of the hinge joint would you like to change. The first is the one connected to the car's body. notice the update function, when I change the wheel's angle. I don't provide the 3rd parameter, which means - the first axis, the one connected to the body. When I want to move the car forward and backwards, I use the 2nd part of the hinge joint, and therefore provide the 3rd parameter (1) which is the joint's index (a hinge2 joint is, eventually, 2 hinge joints connected in one :) )

 

I hope this makes everything a bit more clear. It only shows me how hard it sill be to actually document this entire thing ;) 

 

Share this post


Link to post
Share on other sites

I think this is how we would do suspension https://github.com/saharan/OimoPhysics/blob/master/dev/src/com/element/oimo/physics/constraint/joint/PrismaticJoint.as
or : https://github.com/saharan/OimoPhysics/blob/master/dev/src/com/element/oimo/physics/constraint/joint/DistanceJoint.as

The one thing that I am disconnecting is how to interact with the physics engine without using BABYLON functions... like accessing OIMOs properties directly.  Ive done it with cannon, so it cant be to much different. 

I think maybe I need to be doing research on how BABYLON really works in incorporating the external physics cause its still kinda aloof to me.  Id really like to be able to help with documentation and implementing native babylon methods for the creation of other styles of joints... but I really feel like this is over my head and Im not conventionally trained so Id be afraid to contribute.

Think im just gonna dabble in a playground scene and figure some of this stuff out isolate what I want to do and start gaining an understanding.  So I think I will worry about just a single wheel mount (wheel, axle, suspension) and see the effective difference between using a distance joint or a prismatic or a linear for the suspension.
Id also be interested in seeing the effects of a wheel joint vs a hinge joint set up, so I may do some side by side comparisons.

After I finish my work today, ill come up with something...

Kinda wanna do a tank tread as well (which may actually be fairly easy)

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.