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"

Set location of Destructible Component's chunks

Hello ! How to get the skeleton of a Destructible mesh ? (My final goal is to set the location of the individual chunks, and I think getting the skeleton is the best way to do this, because I have tested to set the locations of the PxActors of the Chunks, and it had awful bugs, the chunks were not at the targeted location. So, if getting the skeleton is not the best way, please tell me)

Thanks !

Product Version: Not Selected
Tags:
more ▼

asked Jan 12 '16 at 05:17 PM in C++ Programming

avatar image

Evols
119 12 11 16

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

3 answers: sort voted first

Finally, I found out by myself. Yes, there is a function to set the pose, but it's not the same way : First, I have to get the PxActor of the Chunk. Then, I have to set its pose.

 // These two lines are from Rama
 int32 ChunkCount = DestructibleComponent->ApexDestructibleActor->getNumVisibleChunks();
 const uint16* ChunkIdxs = DestructibleComponent->ApexDestructibleActor->getVisibleChunks();
 
 for (int32 ThisIdx = 0; ThisIdx < ChunkCount; ThisIdx++)
 {
     FVector NewChunkLocation = GetActorLocation(); // Set whatever you want here
 
     PxRigidDynamic* PxChunkActor = DestructibleComponent->ApexDestructibleActor->getChunkPhysXActor(ChunkIdxs[ThisIdx]);
 
     PxTransform ChunkTransfrom = PxChunkActor->getGlobalPose(); // Useless beacause the two properties are overriden
     ChunkTransfrom.p = PxVec3(NewChunkLocation.X, NewChunkLocation.Y, NewChunkLocation.Z);
     ChunkTransfrom.q = PxQuat::createIdentity(); // Rotation has to be zeroed, because otherwise chunks will rotate at a high speed. You can set it, but don't use the actual rotation of the chunk
             
     PxChunkActor->setGlobalPose(ChunkTransfrom);
 }
more ▼

answered Jan 13 '16 at 08:49 PM

avatar image

Evols
119 12 11 16

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

UDestructibleComponent is derived from USkinnedMeshComponent class. There's a variable called SkeletalMesh in USkinnedMeshComponent.

That said, to get the location of a chunk, I added this function to the UDestructibleMesh class:

 FTransform UDestructibleComponent::GetChunkTransform(const int32 index, bool isChunkInfoIndex /*= false*/) const
 {
     int32 chunkIndex = index;
     if (isChunkInfoIndex)
     {
         verify(index < ChunkInfos.Num());
         chunkIndex = ChunkInfos[index].ChunkIndex;
     }
 
     FTransform returnTransform;
 
     if (ApexDestructibleActor != nullptr)
     {
         const physx::PxMat44 ChunkPoseRT = ApexDestructibleActor->getChunkPose(chunkIndex);
         const physx::PxTransform Transform(ChunkPoseRT);
 
         // Get rotation
         FQuat chunkRotation(Transform.q.x,
             Transform.q.y,
             Transform.q.z,
             Transform.q.w);
 
         returnTransform.SetRotation(chunkRotation);
 
         // Get location
         const FVector chunkLocation(ChunkPoseRT.getPosition().x,
             ChunkPoseRT.getPosition().y,
             ChunkPoseRT.getPosition().z);
 
         returnTransform.SetLocation(chunkLocation);
     }
 
     return returnTransform;
 }

more ▼

answered Jan 13 '16 at 06:07 AM

avatar image

Ryan Darcey
821 47 42 67

avatar image Evols Jan 13 '16 at 01:34 PM

Thanks, but, my question was about setting the chunks locations, not getting it. I already know there is a SkeletalMesh variable, but, it is only a reference to the mesh we are using, not its real-time instance ;)

avatar image Ryan Darcey Jan 13 '16 at 06:15 PM

If you take a look at the function I pasted above, I'm accessing the real time chunk location here:

 const physx::PxMat44 ChunkPoseRT = ApexDestructibleActor->getChunkPose(chunkIndex);

I can check later, but maybe look in ApexDestructibleActor for a function to set the chunk pose?

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

So in order to get the chunks, I need the ApexDestructibleActor, which is always NULL. Is this ApexDestructibleActor type only available, when I import Apex assets?

more ▼

answered Jul 11 '16 at 03:27 PM

avatar image

rotwang
251 13 22 41

avatar image rootally Mar 23 '18 at 11:38 PM

How to avoid this NULL problem?

avatar image EvoPulseGaming Mar 25 '18 at 10:04 PM

bump, this is an issue. ApexDestructibleActor is null when using destructible mesh

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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