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

C++ NewtonBodyGetUserData函数代码示例

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

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



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

示例1: NewtonBodyGetUserData

	//-----------------------------------------------------------------------
	int cPhysicsMaterialNewton::BeginContactCallback(const NewtonMaterial* material,
									const NewtonBody* apBody1, const NewtonBody* apBody2,
									int alThreadIndex)
	{
		iPhysicsBody* pContactBody1 = (cPhysicsBodyNewton*) NewtonBodyGetUserData(apBody1);
		iPhysicsBody* pContactBody2 = (cPhysicsBodyNewton*) NewtonBodyGetUserData(apBody2);

        if(pContactBody1->GetCollide()==false) return 0;
		if(pContactBody2->GetCollide()==false) return 0;

		if(pContactBody1->IsActive()==false) return 0;
		if(pContactBody2->IsActive()==false) return 0;

		if(pContactBody1->IsRagDoll() && pContactBody2->GetCollideRagDoll()==false) return 0;
		if(pContactBody2->IsRagDoll() && pContactBody1->GetCollideRagDoll()==false) return 0;

		if(pContactBody1->IsCharacter() && pContactBody2->GetCollideCharacter()==false) return 0;
		if(pContactBody2->IsCharacter() && pContactBody1->GetCollideCharacter()==false) return 0;

		//Log("----- Begin contact between body '%s' and '%s'.\n",mpContactBody1->GetName().c_str(),
		//													mpContactBody2->GetName().c_str());

		if(pContactBody1->OnBeginCollision(pContactBody2) == false) return 0;
		if(pContactBody2->OnBeginCollision(pContactBody1) == false) return 0;

		return 1;
	}
开发者ID:DirtYiCE,项目名称:HPL1Engine,代码行数:28,代码来源:PhysicsMaterialNewton.cpp


示例2: GenericContactProcessCompatible

    void GenericContactProcessCompatible(const void* const newtonContactJoint, float64 timestep, int threadIndex)
    {
        con_assert(newtonContactJoint != nullptr, "zero pointer")

            NewtonBody* body0 = NewtonJointGetBody0(static_cast<const NewtonJoint*>(newtonContactJoint));
        NewtonBody* body1 = NewtonJointGetBody1(static_cast<const NewtonJoint*>(newtonContactJoint));

        con_assert(body0 != nullptr && body1 != nullptr, "zero pointers")

            if (body0 != nullptr && body1 != nullptr)
            {
                iPhysicsBody* physicsBody0 = static_cast<iPhysicsBody*>(NewtonBodyGetUserData(static_cast<const NewtonBody*>(body0)));
                iPhysicsBody* physicsBody1 = static_cast<iPhysicsBody*>(NewtonBodyGetUserData(static_cast<const NewtonBody*>(body1)));

                con_assert(physicsBody0 != nullptr && physicsBody1 != nullptr, "zero pointers");

                void* contact = NewtonContactJointGetFirstContact(static_cast<const NewtonJoint*>(newtonContactJoint));
                NewtonMaterial* materialCombo = NewtonContactGetMaterial(contact);
                iPhysicsMaterialCombo* physicsMaterialCombo = static_cast<iPhysicsMaterialCombo*>(NewtonMaterialGetMaterialPairUserData(materialCombo));

                if (physicsMaterialCombo != nullptr && physicsBody0 != nullptr && physicsBody1 != nullptr)
                {
                    physicsMaterialCombo->contact(physicsBody0, physicsBody1);
                }
            }
    }
开发者ID:tanzfisch,项目名称:Igor,代码行数:26,代码来源:iPhysics.cpp


示例3: dAssert

int dNewton::OnBodiesAABBOverlap (const NewtonMaterial* const material, const NewtonBody* const body0, const NewtonBody* const body1, int threadIndex)
{
	dAssert (NewtonBodyGetWorld (body0) == NewtonBodyGetWorld (body1));
	dNewton* const world = (dNewton*) NewtonWorldGetUserData(NewtonBodyGetWorld (body0));
	dNewtonBody* const dBody0 = (dNewtonBody*) NewtonBodyGetUserData (body0);
	dNewtonBody* const dBody1 = (dNewtonBody*) NewtonBodyGetUserData (body1);

	return world->OnBodiesAABBOverlap(dBody0, dBody1, threadIndex);
}
开发者ID:Kaoswerk,项目名称:newton-dynamics,代码行数:9,代码来源:dNewton.cpp


示例4: collisionCallback_onAABBOverlap

int _CDECL MaterialPair::collisionCallback_onAABBOverlap( const NewtonMaterial* material, const NewtonBody* newtonBody0, const NewtonBody* newtonBody1, int threadIndex )
{
    MaterialPair* me;
    me = (MaterialPair*)NewtonMaterialGetMaterialPairUserData( material );

    Body* body0 = (OgreNewt::Body*)NewtonBodyGetUserData( newtonBody0 );
    Body* body1 = (OgreNewt::Body*)NewtonBodyGetUserData( newtonBody1 );

    return me->m_contactcallback->onAABBOverlap( body0, body1, threadIndex );
}
开发者ID:BackupTheBerlios,项目名称:dsa-hl-svn,代码行数:10,代码来源:OgreNewt_MaterialPair.cpp


示例5:

	int PhysWorld3D::OnAABBOverlap(const NewtonMaterial* const material, const NewtonBody* const body0, const NewtonBody* const body1, int threadIndex)
	{
		RigidBody3D* bodyA = static_cast<RigidBody3D*>(NewtonBodyGetUserData(body0));
		RigidBody3D* bodyB = static_cast<RigidBody3D*>(NewtonBodyGetUserData(body1));
		assert(bodyA && bodyB);

		Callback* callbackData = static_cast<Callback*>(NewtonMaterialGetMaterialPairUserData(material));
		assert(callbackData);
		assert(callbackData->aabbOverlapCallback);

		return callbackData->aabbOverlapCallback(*bodyA, *bodyB);
	}
开发者ID:DigitalPulseSoftware,项目名称:NazaraEngine,代码行数:12,代码来源:PhysWorld3D.cpp


示例6: contactBegin

int _CDECL ContactCallback::contactBegin( const NewtonMaterial* material, const NewtonBody* body0, const NewtonBody* body1 )
{
	ContactCallback* me;

	me = (ContactCallback*)NewtonMaterialGetMaterialPairUserData( material );

	me->m_material = (NewtonMaterial*)material;

	//save the bodies...
	me->m_body0 = (OgreNewt::Body*)NewtonBodyGetUserData( body0 );
	me->m_body1 = (OgreNewt::Body*)NewtonBodyGetUserData( body1 );

	return me->userBegin();
}
开发者ID:BackupTheBerlios,项目名称:dsa-hl-svn,代码行数:14,代码来源:OgreNewt_ContactCallback.cpp


示例7: PostUpdate

	void PostUpdate(dFloat timestep, int threadIndex)
	{
		int count = 1;
		void* nodes[32];
		dMatrix parentMatrix[32];
		nodes[0] = NewtonInverseDynamicsGetRoot(m_kinematicSolver);

		parentMatrix[0] = dGetIdentityMatrix();

		NewtonWorld* const world = GetManager()->GetWorld();
		DemoEntityManager* const scene = (DemoEntityManager*)NewtonWorldGetUserData(world);

		while (count) {
			dMatrix matrix;

			count --;
			void* const rootNode = nodes[count];
			NewtonBody* const body = NewtonInverseDynamicsGetBody(m_kinematicSolver, rootNode);
			NewtonBodyGetMatrix (body, &matrix[0][0]);
			dMatrix localMatrix (matrix * parentMatrix[count]);

			DemoEntity* const ent = (DemoEntity*)NewtonBodyGetUserData(body);

			dQuaternion rot(localMatrix);
			ent->SetMatrix(*scene, rot, localMatrix.m_posit);

			matrix = matrix.Inverse();
			for (void* node = NewtonInverseDynamicsGetFirstChildNode(m_kinematicSolver, rootNode); node; node = NewtonInverseDynamicsGetNextChildNode(m_kinematicSolver, node)) {
				nodes[count] = node;
				parentMatrix[count] = matrix;
				count ++;
			}
		}
	}
开发者ID:Hurleyworks,项目名称:newton-dynamics,代码行数:34,代码来源:SixAxisManipulators.cpp


示例8: __setTransformCallback

void Body::__setTransformCallback(const NewtonBody* body, const dFloat* matrix, int threadIndex)
{
	//std::cout << "\ttransform " << threadIndex << " " << body << std::endl;
	Body* _body = (Body*)NewtonBodyGetUserData(body);
	_body->m_matrix = Mat4f(matrix);
	//std::cout << "\ttransform end " << threadIndex << " " << body << std::endl;
}
开发者ID:Huebn0r,项目名称:dominator,代码行数:7,代码来源:body.cpp


示例9: EventCallback

	virtual void EventCallback (const CustomTriggerController* const me, TriggerEventType event, NewtonBody* const visitor) const
	{
		// send this message to the entity
		DemoEntity* const entity = (DemoEntity*) NewtonBodyGetUserData(visitor);
		if (entity) {
			// map the event massage 
			int message = -1;
			switch (event) 
			{
				case m_enterTrigger:
					message = ENTER_TRIGGER;
					break;

				case m_exitTrigger:
					message = EXIT_TRIGGER;
					break;

				case m_inTrigger:
					message = INSIDE_TRIGGER;
					break;
			}
				
			// pass the controller pointer as the user data of this massage
			entity->MessageHandler(me->GetBody(), message, (void*)me);
		}
	}
开发者ID:Magic73,项目名称:newton-dynamics,代码行数:26,代码来源:AdvancedPlayerController.cpp


示例10: NewtonBodyGetMassMatrix

void CProjectile::OnHit( const NewtonBody* body, vector3df vImpactVel, f32 fImpactMass )
{
    dFloat mass;
    dFloat Ixx;
    dFloat Iyy;
    dFloat Izz;

    NewtonBodyGetMassMatrix( body, &mass, &Ixx, &Iyy, &Izz );

    if ( mass != 0.0f )
    {
      CNewtonNode* newtonNode = 0;
      newtonNode = ( CNewtonNode * )NewtonBodyGetUserData( body );
      if ( newtonNode )
      {
        OnHitNewtonNode( newtonNode, vImpactVel, fImpactMass );
      }

      vector3df vImpulse = vImpactVel* fImpactMass* fImpactMass* fImpactMass * 0.00001f; //TEMP: 0.00

      NewtonAddBodyImpulse( body, &vImpulse.X, &Pos.X );
    }
    else
    {
      OnHitLevel( vImpactVel, fImpactMass );
    }
}
开发者ID:master4523,项目名称:crimsonglory,代码行数:27,代码来源:projectile.cpp


示例11: OnReconstructMainMeshCallBack

static void OnReconstructMainMeshCallBack (NewtonBody* const body, NewtonFracturedCompoundMeshPart* const mainMesh, const NewtonCollision* const fracturedCompoundCollision)
{
	DemoEntity* const entity = (DemoEntity*)NewtonBodyGetUserData(body);
	DemoMesh* const visualMesh = (DemoMesh*)entity->GetMesh();
	dAssert (visualMesh->IsType(DemoMesh::GetRttiType()));
	
	dAssert (NewtonCollisionGetType(fracturedCompoundCollision) == SERIALIZE_ID_FRACTURED_COMPOUND);

	DemoEntityManager* const scene = (DemoEntityManager*)NewtonWorldGetUserData(NewtonBodyGetWorld(body));
	dAssert (scene);

	visualMesh->RemoveAll();
	for (void* segment = NewtonFracturedCompoundMeshPartGetFirstSegment(mainMesh); segment; segment = NewtonFracturedCompoundMeshPartGetNextSegment (segment)) {
		DemoSubMesh* const subMesh = visualMesh->AddSubMesh();

		int material = NewtonFracturedCompoundMeshPartGetMaterial (segment); 
		int indexCount = NewtonFracturedCompoundMeshPartGetIndexCount (segment); 

		subMesh->m_textureHandle = AddTextureRef ((GLuint)material);
		subMesh->m_shader = scene->GetShaderCache().m_diffuseEffect;

		subMesh->AllocIndexData (indexCount);
		subMesh->m_indexCount = NewtonFracturedCompoundMeshPartGetIndexStream (fracturedCompoundCollision, mainMesh, segment, (int*)subMesh->m_indexes); 
	}

	visualMesh->OptimizeForRender();
}
开发者ID:MADEAPPS,项目名称:newton-dynamics,代码行数:27,代码来源:StructuredConvexFracturing.cpp


示例12: newtonRaycastPreFilter

    unsigned _CDECL Raycast::newtonRaycastPreFilter(const NewtonBody *body, const NewtonCollision *collision, void* userData)
    {
        // get our object!
        Raycast* me = (Raycast*)userData;

        Body* bod = (Body*)NewtonBodyGetUserData( body );
        const World* world = bod->getWorld();


        me->m_treecollisioncallback_bodyalreadyadded = false;
        me->m_treecollisioncallback_lastbody = bod;

        if (me->userPreFilterCallback( bod ))
            return 1;
        else
        {

            if( world->getDebugger().isRaycastRecording() && world->getDebugger().isRaycastRecordingHitBodies() )
            {
                world->getDebugger().addDiscardedBody(bod);
            }

            return 0;
        }
    }
开发者ID:akadjoker,项目名称:gmogre3d,代码行数:25,代码来源:OgreNewt_RayCast.cpp


示例13: newtonRaycastFilter

    float _CDECL Raycast::newtonRaycastFilter(const NewtonBody* body, const float* hitNormal, int collisionID, void* userData, float intersectParam)
    {
        // get our object!
        Raycast* me = (Raycast*)userData;

        Body* bod = (Body*)NewtonBodyGetUserData( body );
        const World* world = bod->getWorld();
        Ogre::Vector3 normal = Ogre::Vector3( hitNormal[0], hitNormal[1], hitNormal[2] );


        if( me->m_treecollisioncallback_bodyalreadyadded )
            return intersectParam;


        if( world->getDebugger().isRaycastRecording() && world->getDebugger().isRaycastRecordingHitBodies() )
        {
            world->getDebugger().addHitBody(bod);
        }


        if (me->userCallback( bod, intersectParam, normal, collisionID ))
            return intersectParam;
        else
            return 1.1;

    }
开发者ID:akadjoker,项目名称:gmogre3d,代码行数:26,代码来源:OgreNewt_RayCast.cpp


示例14: NewtonBodyGetUserData

void dNewtonTriggerManager::EventCallback (const dCustomTriggerController* const trigger, dTriggerEventType event, NewtonBody* const guess) const
{
	dNewtonTrigger* const callback = (dNewtonTrigger*) trigger->GetUserData();
	dNewtonBody* const guessBody = (dNewtonBody*) NewtonBodyGetUserData(guess);
	switch (event) 
	{
		case m_enterTrigger:
		{
			callback->OnEnter(guessBody);
			break;
		}

		case m_exitTrigger:
		{
			callback->OnExit(guessBody);
			break;
		}

		case m_inTrigger:
		{
			callback->OnInside(guessBody);
			break;
		}
	}
}
开发者ID:Hurleyworks,项目名称:newton-dynamics,代码行数:25,代码来源:dNewtonTriggerManager.cpp


示例15: MagneticField

	static void MagneticField (const NewtonJoint* contactJoint, dFloat timestep, int threadIndex)
	{
		dFloat magnetStregnth;
		const NewtonBody* body0;
		const NewtonBody* body1; 
		const NewtonBody* magneticField;
		const NewtonBody* magneticPiece;

		body0 = NewtonJointGetBody0 (contactJoint);
		body1 = NewtonJointGetBody1 (contactJoint);

		// get the magnetic field body
		magneticPiece = body0;
		magneticField = body1;
		if (NewtonCollisionIsTriggerVolume (NewtonBodyGetCollision(body0))) {
			magneticPiece = body1;
			magneticField = body0;
		}
		_ASSERTE (NewtonCollisionIsTriggerVolume (NewtonBodyGetCollision(magneticField)));

		// calculate the magnetic force field

		dMatrix center;
		dMatrix location;

		NewtonBodyGetMatrix (magneticField, &center[0][0]);
		NewtonBodyGetMatrix (magneticPiece, &location[0][0]);

		Magnet* magnet;
		magnet = (Magnet*)NewtonBodyGetUserData(magneticField);

		magnetStregnth = magnet->m_magnetStregnth;

		// calculate the magnetic force;

		dFloat den;
		dVector force (center.m_posit - location.m_posit);

		den = force % force;
		den = magnetStregnth / (den * dSqrt (den) + 0.1f);
		force = force.Scale (den);

		// because we are modifiing one of the bodies membber in the call back, there uis a chace that 
		// another materail can be operations on the same object at the same time of aother thread
		// therfore we need to make the assigmnet in a critical section.
		NewtonWorldCriticalSectionLock (NewtonBodyGetWorld (magneticPiece));
		
		// add the magner force
		NewtonBodyAddForce (magneticPiece, &force[0]);

		force = force.Scale (-1.0f);
		NewtonBodyAddForce (magnet->m_magneticCore, &force[0]);

		// also if the body is sleeping fore it to wake up for this frame
		NewtonBodySetFreezeState (magneticPiece, 0);
		NewtonBodySetFreezeState (magnet->m_magneticCore, 0);

		// unlock the critical section
		NewtonWorldCriticalSectionUnlock (NewtonBodyGetWorld (magneticPiece));
	}
开发者ID:Naddiseo,项目名称:Newton-Dynamics-fork,代码行数:60,代码来源:TriggersAndForceFields.cpp


示例16: _convexCastBodyFilter

		unsigned _convexCastBodyFilter(const NewtonBody* body, const NewtonCollision* collision, void* userData)
		{
			tPlayerController * ctrl = (tPlayerController *)userData;
			tBody * tbody = (tBody *)NewtonBodyGetUserData(body);

			return 1;
		}
开发者ID:ak4hige,项目名称:myway3d,代码行数:7,代码来源:NewtonPlayerController.cpp


示例17: newtonForceTorqueCallback

void _cdecl Body::newtonForceTorqueCallback( const NewtonBody* body )
{
	OgreNewt::Body* me = (OgreNewt::Body*)NewtonBodyGetUserData( body );

	if (me->m_forcecallback)
		(*me->m_forcecallback)( me );
}
开发者ID:brettminnie,项目名称:BDBGame,代码行数:7,代码来源:OgreNewt_Body.cpp


示例18: NewtonUpdate

void RigidBodyWorld::UpdatePhysics ()
{
	RigidBodyWorldDesc* const desc = (RigidBodyWorldDesc*) RigidBodyWorldDesc::GetDescriptor();

	float timestep = 1.0f / desc->m_minFps;
	if (timestep > 1.0f / 60.0f) {
		timestep = 1.0f / 60.0f;
	}


	desc->m_updateRigidBodyMatrix = false;
	NewtonUpdate(desc->m_newton, timestep);
	TimeValue t (GetCOREInterface()->GetTime());

	float scale = 1.0f / float (GetMasterScale(UNITS_METERS));
	for (NewtonBody* body = NewtonWorldGetFirstBody(desc->m_newton); body; body = NewtonWorldGetNextBody(desc->m_newton, body))	{
		dMatrix matrix;
		INode* const node = (INode*)NewtonBodyGetUserData(body);
		NewtonBodyGetMatrix(body, &matrix[0][0]);

		matrix = desc->m_systemMatrix * matrix * desc->m_systemMatrixInv;
		matrix.m_posit = matrix.m_posit.Scale (scale);

		Matrix3 maxMatrix (GetMatrixFromdMatrix (matrix));
		node->SetNodeTM(t, maxMatrix);
	}
	
	UpdateViewPorts ();

	desc->m_updateRigidBodyMatrix = true;
}
开发者ID:Hurleyworks,项目名称:newton-dynamics,代码行数:31,代码来源:RigidBodyWorld.cpp


示例19: NewtonBodyGetUserData

unsigned dNewtonRayCast::PrefilterCallback(const NewtonBody* const body, const NewtonCollision* const collision, void* const userData)
{
	dNewtonRayCast* const me = (dNewtonRayCast*) userData;
	const dNewtonBody* const myBody = (dNewtonBody*) NewtonBodyGetUserData(body);
	const dNewtonCollision* const myCollision = (dNewtonCollision*) NewtonCollisionGetUserData(collision);
	return me->OnPrefilter (myBody, myCollision);
}
开发者ID:Rick16bit,项目名称:newton-dynamics,代码行数:7,代码来源:dNewtonRayCast.cpp


示例20: SetTransformCallback

// Transform callback to set the matrix of a the visual entity
void SetTransformCallback (const NewtonBody* body, const float* matrix, int threadIndex)
{
	NewtonEntity* ent;

	// Get the position from the matrix
	glm::vec4 position (matrix[12], matrix[13], matrix[14], 1.0f);
	glm::quat rotation;

	// we will ignore the Rotation part of matrix and use the quaternion rotation stored in the body
	NewtonBodyGetRotation(body, &rotation[0]);

	// get the entity associated with this rigid body
	ent = (NewtonEntity*) NewtonBodyGetUserData(body);

	// since this tutorial run the physics and a different fps than the Graphics
	// we need to save the entity current transformation state before updating the new state.
	ent->prevPosition = ent->curPosition;
	ent->prevRotation = ent->curRotation;

	if (glm::dot(ent->curRotation,rotation) < 0.0f) {
		ent->prevRotation *= -1.0f;
	}

	// set the new position and orientation for this entity
	ent->curPosition = position;
	ent->curRotation = rotation;
}
开发者ID:scanberg,项目名称:engine,代码行数:28,代码来源:Physics.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ NextArg函数代码示例发布时间:2022-05-30
下一篇:
C++ NewtonBodyGetMatrix函数代码示例发布时间: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