How to change center of mass

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

How to change center of mass

Post by parapoohda » Sat Dec 14, 2019 11:15 am

I want to change center of mass.
Is compond object is only way to change center of mass?
Are there other way?
Thank you. :D

Norbo
Site Admin
Posts: 4894
Joined: Tue Jul 04, 2006 4:45 am

Re: How to change center of mass

Post by Norbo » Sat Dec 14, 2019 7:53 pm

Yup, right now, Compound is the right choice. Changing the center of mass is equivalent to offsetting the collidable, so rather than having a dedicated 'collidable offset' on everything I just let the Compound handle it. Notably, the Compound (as opposed to the BigCompound) has effectively no overhead for single shapes since it has no acceleration structure.

parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: How to change center of mass

Post by parapoohda » Tue Dec 17, 2019 9:44 am

Thank you.:3

parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: How to change center of mass

Post by parapoohda » Tue Mar 03, 2020 4:00 am

Now I try to create a hitbox but seem center of mass is a little off.
1 Are there ways to assign center of mass of hull?
2 Or I want to make a point (0,0,0) center by compound object. How I get location of a point (0,0,0) from the center of mass.
Here is my points for make hull

Code: Select all

points.AllocateUnsafely() = new Vector3(0f,0f,0f);
points.AllocateUnsafely() = new Vector3(0.70710677f,0.70710677f,0f);
points.AllocateUnsafely() = new Vector3(1.847759f,0.7653669f,0f);
points.AllocateUnsafely() = new Vector3(1.847759f,-0.7653669f,0f);
points.AllocateUnsafely() = new Vector3(0.70710677f,-0.70710677f,0f);
points.AllocateUnsafely() = new Vector3(0f,0f,1f);
points.AllocateUnsafely() = new Vector3(0.70710677f,0.70710677f,1f);
points.AllocateUnsafely() = new Vector3(1.847759f,0.7653669f,1f);
points.AllocateUnsafely() = new Vector3(1.847759f,-0.7653669f,1f);
points.AllocateUnsafely() = new Vector3(0.70710677f,-0.70710677f,1f);

Norbo
Site Admin
Posts: 4894
Joined: Tue Jul 04, 2006 4:45 am

Re: How to change center of mass

Post by Norbo » Tue Mar 03, 2020 7:54 pm

1 Are there ways to assign center of mass of hull?
Same as anything else- stick them in a Compound with an offset. If you want to know the center that the ConvexHull got recentered to, the ConvexHullHelper outputs it in the 'center' out parameter.
2 Or I want to make a point (0,0,0) center by compound object. How I get location of a point (0,0,0) from the center of mass.
Not sure what you mean. If you mean making a particular point a compound's center of mass, it's always (0,0,0) in the compound's local space. To make the center of mass of a compound shift relative to its convex children, shift the children.

parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: How to change center of mass

Post by parapoohda » Wed Mar 04, 2020 2:44 am

I mean I want point (0,0,0) in points.AllocateUnsafely to be center.(I want point with x 0.70710677f to be border of cylinder radius 1)
After I move x to 1.847759f - 0.70710677f.
I succeed.
Thank you.

Post Reply