• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ P2UVector函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中P2UVector函数的典型用法代码示例。如果您正苦于以下问题:C++ P2UVector函数的具体用法?C++ P2UVector怎么用?C++ P2UVector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了P2UVector函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: check

void FKConvexElem::AddCachedSolidConvexGeom(TArray<FDynamicMeshVertex>& VertexBuffer, TArray<int32>& IndexBuffer, const FColor VertexColor)
{
#if WITH_PHYSX
	if(ConvexMesh)
	{

		int32 StartVertOffset = VertexBuffer.Num();

		// get PhysX data
		const PxVec3* PVertices = ConvexMesh->getVertices();
		const PxU8* PIndexBuffer = ConvexMesh->getIndexBuffer();
		PxU32 NbPolygons = ConvexMesh->getNbPolygons();

		for(PxU32 i=0;i<NbPolygons;i++)
		{
			PxHullPolygon Data;
			bool bStatus = ConvexMesh->getPolygonData(i, Data);
			check(bStatus);

			const PxU8* indices = PIndexBuffer + Data.mIndexBase;

			// create tangents from the first and second vertices of each polygon
			const FVector TangentX = P2UVector(PVertices[indices[1]]-PVertices[indices[0]]).SafeNormal();
			const FVector TangentZ = FVector(Data.mPlane[0], Data.mPlane[1], Data.mPlane[2]).SafeNormal();
			const FVector TangentY = (TangentX ^ TangentZ).SafeNormal();

			// add vertices 
			for(PxU32 j=0;j<Data.mNbVerts;j++)
			{
				int32 VertIndex = indices[j];

				FDynamicMeshVertex Vert1;
				Vert1.Position = P2UVector(PVertices[VertIndex]);
				Vert1.Color = VertexColor;
				Vert1.SetTangents(
					TangentX,
					TangentY,
					TangentZ
					);
				VertexBuffer.Add(Vert1);
			}

			// Add indices
			PxU32 nbTris = Data.mNbVerts - 2;
			for(PxU32 j=0;j<nbTris;j++)
			{
				IndexBuffer.Add(StartVertOffset+0);
				IndexBuffer.Add(StartVertOffset+j+2);
				IndexBuffer.Add(StartVertOffset+j+1);
			}

			StartVertOffset += Data.mNbVerts;
		}
	}
	else
	{
		UE_LOG(LogPhysics, Log, TEXT("FKConvexElem::AddCachedSolidConvexGeom : No ConvexMesh, so unable to draw."));
	}
#endif // WITH_PHYSX
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:60,代码来源:PhysDrawing.cpp


示例2: ChunkIdxToBoneIdx

void UDestructibleComponent::SetChunkVisible( int32 ChunkIndex, bool bVisible )
{
#if WITH_APEX
	// Bone 0 is a dummy root bone
	const int32 BoneIndex = ChunkIdxToBoneIdx(ChunkIndex);

	if( bVisible )
	{
		UnHideBone(BoneIndex);

		if (NULL != ApexDestructibleActor)
		{
			physx::PxShape** PShapes;
			const physx::PxU32 PShapeCount = ApexDestructibleActor->getChunkPhysXShapes(PShapes, ChunkIndex);
			if (PShapeCount > 0)
			{
				const physx::PxMat44 ChunkPoseRT = ApexDestructibleActor->getChunkPose(ChunkIndex);	// Unscaled
				const physx::PxTransform Transform(ChunkPoseRT);
				SetChunkWorldRT(ChunkIndex, P2UQuat(Transform.q), P2UVector(Transform.p));
			}
		}
	}
	else
	{
		HideBone(BoneIndex, PBO_None);
	}

	// Mark the transform as dirty, so the bounds are updated and sent to the render thread
	MarkRenderTransformDirty();

	// New bone positions need to be sent to render thread
	MarkRenderDynamicDataDirty();
#endif
}
开发者ID:johndpope,项目名称:UE4,代码行数:34,代码来源:DestructibleComponent.cpp


示例3: ExecuteOnUnbrokenJointReadOnly

void FConstraintInstance::GetConstraintForce(FVector& OutLinearForce, FVector& OutAngularForce)
{
	OutLinearForce = FVector::ZeroVector;
	OutAngularForce = FVector::ZeroVector;
#if WITH_PHYSX
	ExecuteOnUnbrokenJointReadOnly([&] (const PxD6Joint* Joint)
	{
		PxVec3 PxOutLinearForce;
		PxVec3 PxOutAngularForce;
		Joint->getConstraint()->getForce(PxOutLinearForce, PxOutAngularForce);

		OutLinearForce = P2UVector(PxOutLinearForce);
		OutAngularForce = P2UVector(PxOutAngularForce);
	});
#endif
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:16,代码来源:ConstraintInstance.cpp


示例4: FindHeightFieldOpposingNormal

static FVector FindHeightFieldOpposingNormal(const PxLocationHit& PHit, const FVector& TraceDirectionDenorm, const FVector InNormal)
{
	if (IsInvalidFaceIndex(PHit.faceIndex))
	{
		return InNormal;
	}

	PxHeightFieldGeometry PHeightFieldGeom;
	const bool bReadGeomSuccess = PHit.shape->getHeightFieldGeometry(PHeightFieldGeom);
	check(bReadGeomSuccess);	//we should only call this function when we have a heightfield
	if (PHeightFieldGeom.heightField)
	{
		const PxU32 TriIndex = PHit.faceIndex;
		const PxTransform PShapeWorldPose = PxShapeExt::getGlobalPose(*PHit.shape, *PHit.actor);

		PxTriangle Tri;
		PxMeshQuery::getTriangle(PHeightFieldGeom, PShapeWorldPose, TriIndex, Tri);

		PxVec3 TriNormal;
		Tri.normal(TriNormal);
		return P2UVector(TriNormal);
	}

	return InNormal;
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:25,代码来源:CollisionConversions.cpp


示例5: JointPos

/** Get the position of this constraint in world space. */
FVector FConstraintInstance::GetConstraintLocation()
{
#if WITH_PHYSX
	PxD6Joint* Joint = (PxD6Joint*)	ConstraintData;
	if (!Joint)
	{
		return FVector::ZeroVector;
	}

	PxRigidActor* JointActor0, *JointActor1;
	Joint->getActors(JointActor0, JointActor1);

	PxVec3 JointPos(0);

	// get the first anchor point in global frame
	if(JointActor0)
	{
		JointPos = JointActor0->getGlobalPose().transform(Joint->getLocalPose(PxJointActorIndex::eACTOR0).p);
	}

	// get the second archor point in global frame
	if(JointActor1)
	{
		JointPos += JointActor1->getGlobalPose().transform(Joint->getLocalPose(PxJointActorIndex::eACTOR1).p);
	}

	JointPos *= 0.5f;
	
	return P2UVector(JointPos);

#else
	return FVector::ZeroVector;
#endif
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:35,代码来源:ConstraintInstance.cpp


示例6: FBoxSphereBounds

FBoxSphereBounds UDestructibleComponent::CalcBounds(const FTransform& LocalToWorld) const
{
#if WITH_APEX
	if( ApexDestructibleActor == NULL )
	{
		// Fallback if we don't have physics
		return Super::CalcBounds(LocalToWorld);
	}

	const PxBounds3& PBounds = ApexDestructibleActor->getBounds();

	return FBoxSphereBounds( FBox( P2UVector(PBounds.minimum), P2UVector(PBounds.maximum) ) );
#else	// #if WITH_APEX
	return Super::CalcBounds(LocalToWorld);
#endif	// #if WITH_APEX
}
开发者ID:johndpope,项目名称:UE4,代码行数:16,代码来源:DestructibleComponent.cpp


示例7: PxVec3

void SDestructibleMeshEditorViewport::RefreshViewport()
{
	// Update chunk visibilities
#if WITH_APEX
#if WITH_EDITORONLY_DATA
	if (DestructibleMesh != NULL && DestructibleMesh->FractureSettings != NULL && DestructibleMesh->ApexDestructibleAsset != NULL && PreviewComponent->IsRegistered())
	{
		const NxRenderMeshAsset* ApexRenderMeshAsset = DestructibleMesh->ApexDestructibleAsset->getRenderMeshAsset();
		if (ApexRenderMeshAsset != NULL)
		{
			NxExplicitHierarchicalMesh& EHM =  DestructibleMesh->FractureSettings->ApexDestructibleAssetAuthoring->getExplicitHierarchicalMesh();
			if (DestructibleMesh->ApexDestructibleAsset->getPartIndex(0) < ApexRenderMeshAsset->getPartCount())
			{
				const PxBounds3& Level0Bounds = ApexRenderMeshAsset->getBounds(DestructibleMesh->ApexDestructibleAsset->getPartIndex(0));
				const PxVec3 Level0Center = !Level0Bounds.isEmpty() ? Level0Bounds.getCenter() : PxVec3(0.0f);
				for (uint32 ChunkIndex = 0; ChunkIndex < DestructibleMesh->ApexDestructibleAsset->getChunkCount(); ++ChunkIndex)
				{
					const uint32 PartIndex = DestructibleMesh->ApexDestructibleAsset->getPartIndex(ChunkIndex);

					if (PartIndex >= ApexRenderMeshAsset->getPartCount())
					{
						continue;
					}
					
					uint32 ChunkDepth = 0;			
					for (int32 ParentIndex = DestructibleMesh->ApexDestructibleAsset->getChunkParentIndex(ChunkIndex); 
						ParentIndex >= 0; 
						ParentIndex = DestructibleMesh->ApexDestructibleAsset->getChunkParentIndex(ParentIndex))
					{
						++ChunkDepth;
					}

					const bool bChunkVisible = ChunkDepth == PreviewDepth;
					PreviewComponent->SetChunkVisible(ChunkIndex, bChunkVisible);
					if (bChunkVisible)
					{
						const PxBounds3& ChunkBounds = ApexRenderMeshAsset->getBounds(PartIndex);
						const PxVec3 ChunkCenter = !ChunkBounds.isEmpty() ? ChunkBounds.getCenter() : PxVec3(0.0f);
						const PxVec3 Displacement = ExplodeAmount*(ChunkCenter - Level0Center);
						PreviewComponent->SetChunkWorldRT(ChunkIndex, FQuat(0.0f, 0.0f, 0.0f, 1.0f), P2UVector(Displacement));
					}
				}

				PreviewComponent->BoundsScale = 100;
				// Send bounds to render thread at end of frame
				PreviewComponent->UpdateComponentToWorld();
		
				// Send bones to render thread right now, so the invalidated display is rerendered with
				// uptodate information
				PreviewComponent->DoDeferredRenderUpdates_Concurrent();
			}
		}
	}
#endif // WITH_EDITORONLY_DATA
#endif // WITH_APEX

	// Invalidate the viewport's display.
	SceneViewport->InvalidateDisplay();
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:59,代码来源:SDestructibleMeshEditorViewport.cpp


示例8: GetDestructibleMesh

void UDestructibleComponent::RefreshBoneTransforms()
{
#if WITH_APEX
	if(ApexDestructibleActor != NULL && SkeletalMesh)
	{
		UDestructibleMesh* TheDestructibleMesh = GetDestructibleMesh();

		// Save a pointer to the APEX NxDestructibleAsset
		physx::NxDestructibleAsset* ApexDestructibleAsset = TheDestructibleMesh->ApexDestructibleAsset;
		check(ApexDestructibleAsset);

		{
			// Lock here so we don't encounter race conditions with the destruction processing
			FPhysScene* PhysScene = World->GetPhysicsScene();
			check(PhysScene);
			const uint32 SceneType = (BodyInstance.bUseAsyncScene && PhysScene->HasAsyncScene()) ? PST_Async : PST_Sync;
			PxScene* PScene = PhysScene->GetPhysXScene(SceneType);
			check(PScene);
			SCOPED_SCENE_WRITE_LOCK(PScene);
			SCOPED_SCENE_READ_LOCK(PScene);

			// Try to acquire event buffer
			const physx::NxDestructibleChunkEvent* EventBuffer;
			physx::PxU32 EventBufferSize;
			if (ApexDestructibleActor->acquireChunkEventBuffer(EventBuffer, EventBufferSize))
			{
				// Buffer acquired
				while (EventBufferSize--)
				{
					const physx::NxDestructibleChunkEvent& Event = *EventBuffer++;
					// Right now the only events are visibility changes.  So as an optimization we won't check for the event type.
	//				if (Event.event & physx::NxDestructibleChunkEvent::VisibilityChanged)
					const bool bVisible = (Event.event & physx::NxDestructibleChunkEvent::ChunkVisible) != 0;
					SetChunkVisible(Event.chunkIndex, bVisible);
				}
				// Release buffer (will be cleared)
				ApexDestructibleActor->releaseChunkEventBuffer();
			}
		}

		// Update poses for visible chunks
		const physx::PxU16* VisibleChunks = ApexDestructibleActor->getVisibleChunks();
		physx::PxU16 VisibleChunkCount = ApexDestructibleActor->getNumVisibleChunks();
		while (VisibleChunkCount--)
		{
			const physx::PxU16 ChunkIndex = *VisibleChunks++;
			// BRGTODO : Make a direct method to access the Px objects' quats
			const physx::PxMat44 ChunkPoseRT = ApexDestructibleActor->getChunkPose(ChunkIndex);	// Unscaled
			const physx::PxTransform Transform(ChunkPoseRT);
			SetChunkWorldRT(ChunkIndex, P2UQuat(Transform.q), P2UVector(Transform.p));
		}

		// Send bones to render thread at end of frame
		MarkRenderDynamicDataDirty();
}
#endif	// #if WITH_APEX
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:57,代码来源:DestructibleComponent.cpp


示例9: PTransform2UMatrix

FMatrix PTransform2UMatrix(const PxTransform& PTM)
{
	FQuat UQuat = P2UQuat(PTM.q);
	FVector UPos = P2UVector(PTM.p);

	FMatrix Result = FQuatRotationTranslationMatrix(UQuat, UPos);

	return Result;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:9,代码来源:PhysXSupport.cpp


示例10: P2UTransform

FTransform P2UTransform(const PxTransform& PTM)
{
	FQuat UQuat = P2UQuat(PTM.q);
	FVector UPos = P2UVector(PTM.p);

	FTransform Result = FTransform(UQuat, UPos);

	return Result;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:9,代码来源:PhysXSupport.cpp


示例11: BatchPxRenderBufferLines

static void BatchPxRenderBufferLines(class ULineBatchComponent& LineBatcherToUse, const PxRenderBuffer& DebugData)
{
	int32 NumPoints = DebugData.getNbPoints();
	if (NumPoints > 0)
	{
		const PxDebugPoint* Points = DebugData.getPoints();
		for (int32 i = 0; i<NumPoints; i++)
		{
			LineBatcherToUse.DrawPoint(P2UVector(Points->pos), FColor((uint32)Points->color), 2, SDPG_World);

			Points++;
		}
	}

	// Build a list of all the lines we want to draw
	TArray<FBatchedLine> DebugLines;

	// Add all the 'lines' from PhysX
	int32 NumLines = DebugData.getNbLines();
	if (NumLines > 0)
	{
		const PxDebugLine* Lines = DebugData.getLines();
		for (int32 i = 0; i<NumLines; i++)
		{
			new(DebugLines)FBatchedLine(P2UVector(Lines->pos0), P2UVector(Lines->pos1), FColor((uint32)Lines->color0), 0.f, 0.0f, SDPG_World);
			Lines++;
		}
	}

	// Add all the 'triangles' from PhysX
	int32 NumTris = DebugData.getNbTriangles();
	if (NumTris > 0)
	{
		const PxDebugTriangle* Triangles = DebugData.getTriangles();
		for (int32 i = 0; i<NumTris; i++)
		{
			new(DebugLines)FBatchedLine(P2UVector(Triangles->pos0), P2UVector(Triangles->pos1), FColor((uint32)Triangles->color0), 0.f, 0.0f, SDPG_World);
			new(DebugLines)FBatchedLine(P2UVector(Triangles->pos1), P2UVector(Triangles->pos2), FColor((uint32)Triangles->color1), 0.f, 0.0f, SDPG_World);
			new(DebugLines)FBatchedLine(P2UVector(Triangles->pos2), P2UVector(Triangles->pos0), FColor((uint32)Triangles->color2), 0.f, 0.0f, SDPG_World);
			Triangles++;
		}
	}

	// Draw them all in one call.
	if (DebugLines.Num() > 0)
	{
		LineBatcherToUse.DrawLines(DebugLines);
	}
}
开发者ID:didixp,项目名称:Ark-Dev-Kit,代码行数:49,代码来源:PhysScene.cpp


示例12: FindBoxOpposingNormal

static FVector FindBoxOpposingNormal(const PxLocationHit& PHit, const FVector& TraceDirectionDenorm, const FVector InNormal)
{
	// We require normal info for our algorithm.
	const bool bNormalData = (PHit.flags & PxHitFlag::eNORMAL);
	if (!bNormalData)
	{
		return InNormal;
	}

	PxBoxGeometry PxBoxGeom;
	const bool bReadGeomSuccess = PHit.shape->getBoxGeometry(PxBoxGeom);
	check(bReadGeomSuccess); // This function should only be used for box geometry

	const PxTransform LocalToWorld = PxShapeExt::getGlobalPose(*PHit.shape, *PHit.actor);
	
	// Find which faces were included in the contact normal, and for multiple faces, use the one most opposing the sweep direction.
	const PxVec3 ContactNormalLocal = LocalToWorld.rotateInv(PHit.normal);
	const float* ContactNormalLocalPtr = &ContactNormalLocal.x;
	const PxVec3 TraceDirDenormWorld = U2PVector(TraceDirectionDenorm);
	const float* TraceDirDenormWorldPtr = &TraceDirDenormWorld.x;
	const PxVec3 TraceDirDenormLocal = LocalToWorld.rotateInv(TraceDirDenormWorld);
	const float* TraceDirDenormLocalPtr = &TraceDirDenormLocal.x;

	PxVec3 BestLocalNormal(ContactNormalLocal);
	float* BestLocalNormalPtr = &BestLocalNormal.x;
	float BestOpposingDot = FLT_MAX;

	for (int32 i=0; i < 3; i++)
	{
		// Select axis of face to compare to, based on normal.
		if (ContactNormalLocalPtr[i] > KINDA_SMALL_NUMBER)
		{
			const float TraceDotFaceNormal = TraceDirDenormLocalPtr[i]; // TraceDirDenormLocal.dot(BoxFaceNormal)
			if (TraceDotFaceNormal < BestOpposingDot)
			{
				BestOpposingDot = TraceDotFaceNormal;
				BestLocalNormal = PxVec3(0.f);
				BestLocalNormalPtr[i] = 1.f;
			}
		}
		else if (ContactNormalLocalPtr[i] < -KINDA_SMALL_NUMBER)
		{
			const float TraceDotFaceNormal = -TraceDirDenormLocalPtr[i]; // TraceDirDenormLocal.dot(BoxFaceNormal)
			if (TraceDotFaceNormal < BestOpposingDot)
			{
				BestOpposingDot = TraceDotFaceNormal;
				BestLocalNormal = PxVec3(0.f);
				BestLocalNormalPtr[i] = -1.f;
			}
		}
	}

	// Fill in result
	const PxVec3 WorldNormal = LocalToWorld.rotate(BestLocalNormal);
	return P2UVector(WorldNormal);
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:56,代码来源:CollisionConversions.cpp


示例13: P2UVector

FVector UVehicleWheel::GetPhysicsLocation()
{
	if ( WheelShape )
	{
		PxVec3 PLocation = VehicleSim->PVehicle->getRigidDynamicActor()->getGlobalPose().transform( WheelShape->getLocalPose() ).p;
		return P2UVector( PLocation );
	}

	return FVector(0.0f);
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:10,代码来源:VehicleWheel.cpp


示例14: P2UVector

// NB: ElemTM is assumed to have no scaling in it!
void FKConvexElem::DrawElemWire(FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, const FVector& Scale3D, const FColor Color)
{
#if WITH_PHYSX

	FTransform LocalToWorld = ElemTM;
	LocalToWorld.SetScale3D(Scale3D);

	PxConvexMesh* Mesh = ConvexMesh;

	if(Mesh)
	{
		// Draw each triangle that makes up the convex hull
		PxU32 NbVerts = Mesh->getNbVertices();
		const PxVec3* Vertices = Mesh->getVertices();
		
		TArray<FVector> TransformedVerts;
		TransformedVerts.AddUninitialized(NbVerts);
		for(PxU32 i=0; i<NbVerts; i++)
		{
			TransformedVerts[i] = LocalToWorld.TransformPosition( P2UVector(Vertices[i]) );
		}
						
		const PxU8* PIndexBuffer = Mesh->getIndexBuffer();
		PxU32 NbPolygons = Mesh->getNbPolygons();

		for(PxU32 i=0;i<NbPolygons;i++)
		{
			PxHullPolygon Data;
			bool bStatus = Mesh->getPolygonData(i, Data);
			check(bStatus);

			const PxU8* PIndices = PIndexBuffer + Data.mIndexBase;
		
			for(PxU16 j=0;j<Data.mNbVerts;j++)
			{
				// Get the verts that make up this line.
				int32 I0 = PIndices[j];
				int32 I1 = PIndices[j+1];

				// Loop back last and first vertices
				if(j==Data.mNbVerts - 1)
				{
					I1 = PIndices[0];
				}

				PDI->DrawLine( TransformedVerts[I0], TransformedVerts[I1], Color, SDPG_World );
			}
		}
	}
	else
	{
		UE_LOG(LogPhysics, Log, TEXT("FKConvexElem::DrawElemWire : No ConvexMesh, so unable to draw."));
	}
#endif // WITH_PHYSX
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:56,代码来源:PhysDrawing.cpp


示例15: P2UVector

void UDestructibleComponent::OnDamageEvent(const NxApexDamageEventReportData& InDamageEvent)
{
	FVector HitPosition = P2UVector(InDamageEvent.hitPosition);
	FVector HitDirection = P2UVector(InDamageEvent.hitDirection);

	OnComponentFracture.Broadcast(HitPosition, HitDirection);
	if (ADestructibleActor * DestructibleActor = Cast<ADestructibleActor>(GetOwner()))
	{
		DestructibleActor->OnActorFracture.Broadcast(HitPosition, HitDirection);
	}

	SpawnFractureEffectsFromDamageEvent(InDamageEvent);

	// After receiving damage, no longer receive decals.
	if (bReceivesDecals)
	{
		bReceivesDecals = false;
		MarkRenderStateDirty();
	}
}
开发者ID:johndpope,项目名称:UE4,代码行数:20,代码来源:DestructibleComponent.cpp


示例16: FTransform

float FKConvexElem::GetVolume(const FVector& Scale) const
{
	float Volume = 0.0f;

#if WITH_PHYSX
	if (ConvexMesh != NULL)
	{
		// Preparation for convex mesh scaling implemented in another changelist
		FTransform ScaleTransform = FTransform(FQuat::Identity, FVector::ZeroVector, Scale);

		int32 NumPolys = ConvexMesh->getNbPolygons();
		PxHullPolygon PolyData;

		const PxVec3* Vertices = ConvexMesh->getVertices();
		const PxU8* Indices = ConvexMesh->getIndexBuffer();

		for (int32 PolyIdx = 0; PolyIdx < NumPolys; ++PolyIdx)
		{
			if (ConvexMesh->getPolygonData(PolyIdx, PolyData))
			{
				for (int32 VertIdx = 2; VertIdx < PolyData.mNbVerts; ++ VertIdx)
				{
					// Grab triangle indices that we hit
					int32 I0 = Indices[PolyData.mIndexBase + 0];
					int32 I1 = Indices[PolyData.mIndexBase + (VertIdx - 1)];
					int32 I2 = Indices[PolyData.mIndexBase + VertIdx];


					Volume += SignedVolumeOfTriangle(ScaleTransform.TransformPosition(P2UVector(Vertices[I0])), 
						ScaleTransform.TransformPosition(P2UVector(Vertices[I1])), 
						ScaleTransform.TransformPosition(P2UVector(Vertices[I2])));
				}
			}
		}
	}
#endif // WITH_PHYSX

	return Volume;
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:39,代码来源:BodySetup.cpp


示例17: P2UVector

void FDestructibleMeshEditorViewportClient::Draw( const FSceneView* View,FPrimitiveDrawInterface* PDI )
{
	FEditorViewportClient::Draw(View, PDI);

#if WITH_APEX
	const bool DrawChunkMarker = true;

	UDestructibleComponent* Comp = PreviewDestructibleComp.Get();
	
	if (Comp)
	{
		if (Comp->DestructibleMesh != NULL && Comp->DestructibleMesh->FractureSettings != NULL)
		{
			if (Comp->DestructibleMesh->ApexDestructibleAsset != NULL)
			{
				NxDestructibleAsset* Asset = Comp->DestructibleMesh->ApexDestructibleAsset;
				const NxRenderMeshAsset* RenderMesh = Asset->getRenderMeshAsset();

				for (uint32 i=0; i < Asset->getChunkCount(); ++i)
				{
					int32 PartIdx = Asset->getPartIndex(i);
					int32 BoneIdx = i+1;

					if ( SelectedChunkIndices.Contains(i) )
					{
						PxBounds3 PBounds = RenderMesh->getBounds(PartIdx);

						FVector Center = P2UVector(PBounds.getCenter()) + Comp->GetBoneLocation(Comp->GetBoneName(BoneIdx));
						FVector Extent = P2UVector(PBounds.getExtents());

						FBox Bounds(Center - Extent, Center + Extent);
						DrawWireBox(PDI, Bounds, FColor::Blue, SDPG_World);
					}
				}
			}
		}
	}
#endif // WITH_APEX
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:39,代码来源:SDestructibleMeshEditorViewport.cpp


示例18: GetDestructibleMesh

void UDestructibleComponent::SpawnFractureEffectsFromDamageEvent(const NxApexDamageEventReportData& InDamageEvent)
{
	// Use the component's fracture effects if the override is selected, otherwise use fracture effects from the asset
	TArray<FFractureEffect>& UseFractureEffects = (bFractureEffectOverride || !SkeletalMesh) ? FractureEffects : CastChecked<UDestructibleMesh>(SkeletalMesh)->FractureEffects;

	UDestructibleMesh* TheDestructibleMesh = GetDestructibleMesh();
	if (!TheDestructibleMesh)
	{
		return;
	}


	// We keep track of the handled parent chunks here
	TArray<int32> HandledParents;
	for(physx::PxU32 eventN = 0; eventN < InDamageEvent.fractureEventListSize; ++eventN)
	{
		const NxApexChunkData& chunkData = InDamageEvent.fractureEventList[eventN];
		if( chunkData.depth < (physx::PxU32)UseFractureEffects.Num() )
		{
			// We can get the root chunk here as well, so make sure that the parent index is 0, even for the root chunk
			int32 ParentIdx = FMath::Max(TheDestructibleMesh->ApexDestructibleAsset->getChunkParentIndex(chunkData.index), 0);
			
			// We can test a number of flags - we'll play an effect if the chunk was destroyed
			// As we only get the fractured event here for chunks that come free, we spawn fracture
			// effects only once per unique parent
			if((chunkData.flags & NxApexChunkFlag::FRACTURED) && !HandledParents.Contains(ParentIdx))
			{
				FVector Position = P2UVector(chunkData.worldBounds.getCenter());
				FFractureEffect& FractureEffect = UseFractureEffects[chunkData.depth];
				if( FractureEffect.Sound != NULL )
				{
					// Spawn sound
					UGameplayStatics::PlaySoundAtLocation( this, FractureEffect.Sound, Position );
				}
				if( FractureEffect.ParticleSystem != NULL )
				{
					// Spawn particle system
					UParticleSystemComponent* ParticleSystemComponent = UGameplayStatics::SpawnEmitterAtLocation( this, FractureEffect.ParticleSystem, Position );

					// Disable shadows, since destructibles tend to generate a lot of these
					if (ParticleSystemComponent != NULL)
					{
						ParticleSystemComponent->CastShadow = false;
					}
				}

				HandledParents.Add(ParentIdx);
			}			
		}
	}
}
开发者ID:johndpope,项目名称:UE4,代码行数:51,代码来源:DestructibleComponent.cpp


示例19: P2UVector

void FConstraintInstance::GetConstraintForce(FVector& OutLinearForce, FVector& OutAngularForce)
{
#if WITH_PHYSX
	if (PxD6Joint* Joint = GetUnbrokenJoint())
	{
		PxVec3 PxOutLinearForce;
		PxVec3 PxOutAngularForce;
		Joint->getConstraint()->getForce(PxOutLinearForce, PxOutAngularForce);

		OutLinearForce = P2UVector(PxOutLinearForce);
		OutAngularForce = P2UVector(PxOutAngularForce);
	}
	else
	{
		OutLinearForce = FVector::ZeroVector;
		OutAngularForce = FVector::ZeroVector;
	}

#else
	OutLinearForce = FVector::ZeroVector;
	OutAngularForce = FVector::ZeroVector;
#endif
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:23,代码来源:ConstraintInstance.cpp


示例20: SetupDriveHelper

void SetupDriveHelper(const UWheeledVehicleMovementComponent4W* VehicleData, const PxVehicleWheelsSimData* PWheelsSimData, PxVehicleDriveSimData4W& DriveData)
{
	PxVehicleDifferential4WData DifferentialSetup;
	GetVehicleDifferential4WSetup(VehicleData->DifferentialSetup, DifferentialSetup);
	
	DriveData.setDiffData(DifferentialSetup);

	PxVehicleEngineData EngineSetup;
	GetVehicleEngineSetup(VehicleData->EngineSetup, EngineSetup);
	DriveData.setEngineData(EngineSetup);

	PxVehicleClutchData ClutchSetup;
	ClutchSetup.mStrength = VehicleData->ClutchStrength;
	DriveData.setClutchData(ClutchSetup);

	FVector WheelCentreOffsets[4];
	WheelCentreOffsets[PxVehicleDrive4WWheelOrder::eFRONT_LEFT] = P2UVector(PWheelsSimData->getWheelCentreOffset(PxVehicleDrive4WWheelOrder::eFRONT_LEFT));
	WheelCentreOffsets[PxVehicleDrive4WWheelOrder::eFRONT_RIGHT] = P2UVector(PWheelsSimData->getWheelCentreOffset(PxVehicleDrive4WWheelOrder::eFRONT_RIGHT));
	WheelCentreOffsets[PxVehicleDrive4WWheelOrder::eREAR_LEFT] = P2UVector(PWheelsSimData->getWheelCentreOffset(PxVehicleDrive4WWheelOrder::eREAR_LEFT));
	WheelCentreOffsets[PxVehicleDrive4WWheelOrder::eREAR_RIGHT] = P2UVector(PWheelsSimData->getWheelCentreOffset(PxVehicleDrive4WWheelOrder::eREAR_RIGHT));

	PxVehicleAckermannGeometryData AckermannSetup;
	AckermannSetup.mAccuracy = VehicleData->AckermannAccuracy;
	AckermannSetup.mAxleSeparation = FMath::Abs(WheelCentreOffsets[PxVehicleDrive4WWheelOrder::eFRONT_LEFT].X - WheelCentreOffsets[PxVehicleDrive4WWheelOrder::eREAR_LEFT].X);
	AckermannSetup.mFrontWidth = FMath::Abs(WheelCentreOffsets[PxVehicleDrive4WWheelOrder::eFRONT_RIGHT].Y - WheelCentreOffsets[PxVehicleDrive4WWheelOrder::eFRONT_LEFT].Y);
	AckermannSetup.mRearWidth = FMath::Abs(WheelCentreOffsets[PxVehicleDrive4WWheelOrder::eREAR_RIGHT].Y - WheelCentreOffsets[PxVehicleDrive4WWheelOrder::eREAR_LEFT].Y);
	DriveData.setAckermannGeometryData(AckermannSetup);

	PxVehicleGearsData GearSetup;
	GetVehicleGearSetup(VehicleData->GearSetup, GearSetup);	
	DriveData.setGearsData(GearSetup);

	PxVehicleAutoBoxData AutoBoxSetup;
	GetVehicleAutoBoxSetup(VehicleData->AutoBoxSetup, AutoBoxSetup);
	DriveData.setAutoBoxData(AutoBoxSetup);
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:36,代码来源:WheeledVehicleMovementComponent4W.cpp



注:本文中的P2UVector函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ P54P_WRITE函数代码示例发布时间:2022-05-30
下一篇:
C++ P2ROUNDUP函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap