Code Monkey home page Code Monkey logo

Comments (10)

makc avatar makc commented on May 25, 2024 1

you say there's an enhancement

@Snky I think it means the issue label - it was labelled an "enhancement", meaning this is a nice-to-have-in-the-future thing that is not available right now.

from oimophysics.

Dev-MarkoF avatar Dev-MarkoF commented on May 25, 2024

Unfortunatly if i understand it correctly it is not possible to change the center of mass in OIMO.
There seems to be an old enhancement which describes what you trying to achieve. issue #28

Unfortunatly it seems @saharan does not look frequently into issues anymore, since the engine basically works fine.
Be aware that car physics can be wonky since it's a heavy object, due to a bug only happening on heavy objects issue #60

I use a workaround to achieve those kinda things with multiple rigidbodies and connecting them with welding joints.
(meaning a joint that allows no movement/rotation between the bodies, basically connecting them to one), In that case you can make the car heavier at the front (which is realistic since the engine is the heaviest part) and then a middle and rear rigidbody.

from oimophysics.

Snky avatar Snky commented on May 25, 2024

I think you are understanding correctly, I'm not very good with GitHub, you say there's an enhancement, are you able to drop it here or contact me outside of GitHub, it's quite an important thing I want. I read about offsetting the shapes, but if I do that, I also change the location the rotation starts from? I want that to be separate from the centre of mass location. Please help if you can.

from oimophysics.

Dev-MarkoF avatar Dev-MarkoF commented on May 25, 2024

Yeah as @makc said, there is a feature that is in planning but was never done so far.
This engine works fine but you probably won't see the issues labeled "enhancement" implemented in the near future, so if you really need some very sophisticated features you should look into ammo which is a "port" of the bullet physics engine, which is a industry proven c++ physics engine.

OIMO can do pretty much everything but you have to combine certain techniques to achieve them.
OIMO for example does not have a readily available "car" body like some engines, e.g. Bullet, do, but you can combine joints/raycasts with bodies to achieve it by yourself.

I mentioned a workaround, which i found, because i'm using oimo in some projects, that are somewhat realisitic.
Use multiple rigidbodies and weld them together through joints, a joint has degrees of freedom for rotation/movement, if you set them to 0 on the general joint the objects are held together.
I can't offer more than that, since the inner workings of OIMO are too much of a mystery too me to improve on it myself (i only managed to implement a trigger collider type in my fork).
This workaround is also the way you can create concave shapes since the engine only works with convex shapes.

This workaround resembles reality in some way, since a car is "one" entity in the broader sence, but consists of several others like a front, middle and rear, which by themselves would consist of parts.
You can rotate the front of the car to simulate steering and since the middle and rear are attached to it, through the "unmoving" but linking joint, they rotate with, while also acting like the front of the car is heavier than the back.

In general the idea is:
To have a body where you rotate around, when you want to steer, and multiple bodies that have their center of mass where OIMO wants it to be but change the actual "center of mass" of the combined "body" by changing masses of each body until you're satisfied.
Like imagine multiple water balloons on a stick, you can swing from any balloon but the "center of mass" is defined by all balloons and you could fill each balloon with variable amount of water to change the center.

from oimophysics.

Snky avatar Snky commented on May 25, 2024

I will try weld joints, sad that there isn't an easier solution available without creating more bodies, splitting the shapes up.. my shapes are generated based on .obj vertices / faces.

Off topic (not sure how else to contact you atm):
I have a similar isSensor to your isTrigger, I'm currently trying your isTrigger setup, but when I set _rb.isTrigger = true (on one object), the two objects are still colliding, isn't the object supposed to pass through without colliding and just send an event?

Using my old way (works):
if ((_b1._isSensor == false && _b2._isSensor == false) && (_s1._isSensor == false && _s2._isSensor == false)
One line above:
if (_touching) {
Worked for me, but I feel like overall you may know what you're doing better than me, can you assist?

from oimophysics.

Snky avatar Snky commented on May 25, 2024

Oops, accidentally closed.

from oimophysics.

Dev-MarkoF avatar Dev-MarkoF commented on May 25, 2024

It's unfortunate, but i think OIMO get's no significant updates, java/-typescript 3D physics engines seem to be rare and seldomly updated in general. There is a version of the old cannon-js physics that is updated relatively frequently cannon-es. Cannon in general is a very robust engine, but i personally found OIMO first and had an easier time doing the things i needed, so i stayed with OIMO and actively try to answer questions about it, but i'm not associated with it and do not have contact with the developer.

Yeah trigger was the only thing that was relatively simple to implement, OIMO is well not documented enough for someone to take over easily.
I started to integrate a terrain collider, but i have not figured out collisions yet (probably never will, as i'm short on time), only raycasts. Currently trying to develop my own physics engine to get more of an understanding how OIMO works.

Unless i have a bug in it, there is nothing to be done than for usage, just setting "_isTrigger" on the body, and it works in the Game Engine where i implemented OIMO
(my build i used there definetly works, since it's used daily in education, but this is only in my fork/build, i never made a pull request).

My _isTrigger setup is handling collision the normal way until the moment where the manifold is given to the solver,
then it's ignored so the solver thinks there was no collision happening but everything else beforehand happens, so you can get exact points/speed where it triggered etc.
On the way there is a "isTriggering" set, so i can send OnTriggerEnter and OnTriggerExit events.

For that i have changes in World.hx, ContactManager.hx, ContactCallback.hx, Contact.hx, RigidBody.hx and ContactConstraint.hx, if you want to take a look at it.

from oimophysics.

Snky avatar Snky commented on May 25, 2024

Actually maybe there isn't a bug with your isTrigger and I'll continue to try it, I just got back into BitFlag for mask/group and I'll see over time the behaviour and which way I prefer. I had one more question, you said to weld two objects together for the mass issue, how would you recommend welding two RigidBody's together, what type of joint/jointconfig? What settings?

from oimophysics.

Dev-MarkoF avatar Dev-MarkoF commented on May 25, 2024

Welding means a joint that has no degrees of freedom, so a generic joint with it's base config should do the trick.
The 2 bodies are connected and can not on any axis for any amount of distance, the force pulling them together is effectively infinite, so they act as one body.

from oimophysics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.