PhysX 中Userdata的理解!
現在主要看到有著么幾種應用
1
現在主要看到有著么幾種應用
1
1
static void CreateCube(const NxVec3& pos, int size=2, const NxVec3* initialVelocity=NULL)
2

{
3
if(gScene == NULL) return;
4
5
// Create body
6
NxBodyDesc bodyDesc;
7
bodyDesc.angularDamping = 0.5f;
8
if(initialVelocity) bodyDesc.linearVelocity = *initialVelocity;
9
10
NxBoxShapeDesc boxDesc;
11
boxDesc.dimensions = NxVec3((float)size, (float)size, (float)size);
12
13
NxActorDesc actorDesc;
14
actorDesc.shapes.pushBack(&boxDesc);
15
actorDesc.body = &bodyDesc;
16
actorDesc.density = 10.0f;
17
actorDesc.globalPose.t = pos;
18
gScene->createActor(actorDesc)->userData = (void*)size_t(size);
19
//printf("Total: %d actors\n", gScene->getNbActors());
20
}
這種userdata被轉型為void* 了 不知道如何應用任意的圖像樣式,繼續看看還有什么其他方法沒有!
static void CreateCube(const NxVec3& pos, int size=2, const NxVec3* initialVelocity=NULL)2


{3
if(gScene == NULL) return; 4

5
// Create body6
NxBodyDesc bodyDesc;7
bodyDesc.angularDamping = 0.5f;8
if(initialVelocity) bodyDesc.linearVelocity = *initialVelocity;9

10
NxBoxShapeDesc boxDesc;11
boxDesc.dimensions = NxVec3((float)size, (float)size, (float)size);12

13
NxActorDesc actorDesc;14
actorDesc.shapes.pushBack(&boxDesc);15
actorDesc.body = &bodyDesc;16
actorDesc.density = 10.0f;17
actorDesc.globalPose.t = pos;18
gScene->createActor(actorDesc)->userData = (void*)size_t(size);19
//printf("Total: %d actors\n", gScene->getNbActors());20
}

