New Wiki, Integrating PhysX Into Your Project!

Dear Community,

I’ve posted a new wiki on how you can integrate PhysX code into your project!

e7e89cef14532832bff766ea875218f4e66a80ef.jpeg

In the picture above I am using a custom DestructibleActor class to draw the world space locations of each chunk, with an offset to make them easier to see!

I give you the code for how to do this on the wiki, here’s the core code:




//Tick
void AHappyDestructible::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	//~~~~~~~~~~~~
 
 
	//Draw All Centers to the screen!
	#if WITH_PHYSX
	ScreenMsg("Got into PhysX!!!");
	for(FDestructibleChunkInfo& Each : DestructibleComponent->ChunkInfos)
	{
		physx::PxRigidDynamic* Actor = Each.Actor;
 
		if(Actor)
		{    
			PxTransform Trans = Actor->getGlobalPose();
			PxVec3& PxLoc = Trans.p;
 
			FVector Location(PxLoc.x,PxLoc.y,PxLoc.z);
 
			DrawPoint(Location);
 
			ScreenMsg("physx loc", Location.ToString());
		}
	}
	#endif // WITH_PHYSX 
}


Enjoy!

Rama

This looks very useful, thanks.

I am new to UE4 but I am quite familiar with PhysX. One thing that seems to be missing for me is retrieving uv coordinates via a trace. This should be possible with triangle mesh objects but it seems it is not possible in UE4.

If I remember correctly, in PhysX 2 there were extra steps that needed to be taken when cooking the mesh to make uv retrieval possible, maybe this extra step caused complications for the UE4 devs, or maybe it’s something else.

Anyway, to the point :slight_smile: Can you do your own raycast using the above method and can you retrieve uv coordinates for cooked triangle meshes?

It’s really strange that I can’t find info on it, PhysX provides it and it’s useful :slight_smile:

I’ve encountered a few people asking for UV ray cast support now, you should submit a request on the feedback page and include a poll so that Epic can get a read on the community to have this feature made more readily available!

Make sure to include [Request] in your thread title!

From your experience with PhysX, does the included third party library have what you need to do UV traces?

I checked out PxGeometryQuery.h but it did not seem to have what you are requesting.

Rama

@Rama - I don’t think there would be anything on the PhysX side of things for getting the UV coords by raycast - I think you’d need to interface into the material and texture to figure it out.

Perhaps I made a mistake. I implemented every feature of PhysX 2.8 into a graphics api a couple of years ago and looking back at my code it seems you could retrieve barycentric UV coordinates so there were extra steps to retrieve actual UV coordinates. Also we are now dealing with PhysX 3 so things could have changed again.

I will put a request in, it is also possible we could work it out ourselves which I may try to do. But it’s all for nothing if you can’t actually alter(draw to) the texture in real time, so I need to look into this first.

I know this is not helpful but this is really easy to do in Unity, took me about half an hour to figure out and implement drawing to a mesh. UE4 is young and perhaps in a couple of months when I really will need it, it will be possible here too :slight_smile:

Aye, I remember that too. I was just thinking it was one of those things in PhysX, like the userData you can set on it, that you have to set up to interface with the rest of your code to properly have it understand the UV coords. It may not be like that, as I haven’t looked at it for quite some time. Or Unreal may even have it set up so that it works and can figure out the UVs in a way that makes sense with the Material system.

If it’s not interfacing with the engine in some way, then the results may not be super useful due to the way materials allow you to configure the UVs. I guess you could probably query into how they’re set up and stuff though, worst case.

Wild speculation.

Video of Getting UV Info From RayCasts in UE4

Dear Community,

I explain everything in the video!

This video shows my wiki code in action / modified UE4 Engine code to get UV info from raycast hits!

The required UE4 Engine code modifications are here

Thanks Rama, I have not had a chance to look at this yet but good to know it’s there when I need it.

Sorry for long delay, I came back today since there have been lots of updates since I needed this and I notice they include updates from the community, including yourself Rama. So has this functionality been added officially yet?

Edit: I am referring to the uv raycast stuff :slight_smile:

Wait, why haven’t i seen this PhysX wiki yet?

Have you tried creating some fluid, like blood running down the hill as in Borderlands Rama?
I have 0 experience with PhysX, so it would be awesome to know if someone played around with it.