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 »

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: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: How to change center of mass

Post by Norbo »

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 »

Thank you.:3
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: How to change center of mass

Post by parapoohda »

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: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: How to change center of mass

Post by Norbo »

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 »

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