x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Set center of mass relative to origin OR get default CoM

In my game, players construct ships from triangular surfaces, which are then converted to a mesh for physics and rendering. Surfaces can be different substances (such as wood or steel) and vary in thickness, which means the center of mass needs to be calculated dynamically based on the player's design. The problem is, I can get where the center of mass should be relative to the origin, but using UActorComponent::SetCenterOfMass() only sets the offset relative to some default center of mass calculated based on the mesh vertices. In order for the calculation to work, I need to do one of the following:

  • Find a function to set the center of mass relative to the origin, not the default center of mass

  • Find the default center of mass so I can adjust the calculated one accordingly

Anyone know of a way to do one or both of these things?

Here's an image to visualize the problem. This box is symmetrical, but one side is made from wood and the other from steel, so the CoM should not be perfectly in the center but closer to the steel side. The editor cursor shows the mesh's origin. The green sphere is the default CoM, calculated automatically by the engine. You can see that it's at the geometric center of the mesh. The red sphere is where the CoM should be, based on the fact that steel is several times heavier than wood. alt text

EDIT: Upon further experimentation I can confirm the default center of mass is not any of the following:

  • The center of the ship's bounding box

  • The average of all vertices

  • The above, but not counting duplicate vertices

So, whatever calculation is used to guess the CoM is either more complicated than these, or it's using data I don't have access to.

Product Version: UE 4.14
Tags:
more ▼

asked Feb 10 '17 at 04:41 AM in C++ Programming

avatar image

BaronVonSatchel
8 3 6 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question