当前位置: 首页>>代码示例>>C++>>正文


C++ NxScene::setGroupCollisionFlag方法代码示例

本文整理汇总了C++中NxScene::setGroupCollisionFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ NxScene::setGroupCollisionFlag方法的具体用法?C++ NxScene::setGroupCollisionFlag怎么用?C++ NxScene::setGroupCollisionFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NxScene的用法示例。


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

示例1: GetScene

NxScene* plSimulationMgr::GetScene(plKey world)
{
    if (!world)
        world = GetKey();

    NxScene* scene = fScenes[world];

    if (!scene)
    {
        NxSceneDesc sceneDesc;
        sceneDesc.gravity.set(0, 0, -32.174049f);
        sceneDesc.userTriggerReport = &gSensorReport;
        sceneDesc.userContactReport = &gContactReport;
        scene = fSDK->createScene(sceneDesc);

        // See "Advancing The Simulation State" in the PhysX SDK Documentation
        // This will cause PhysX to only update for our step size. If we call simulate
        // faster than that, PhysX will return immediately. If we call it slower than that,
        // PhysX will do some extra steps for us (isn't that nice?).
        // Anyway, this should be a good way to make us independent of the framerate.
        // If not, I blame the usual suspects (Tye, eap, etc...)
        scene->setTiming(kDefaultStepSize);

        // Most physicals use the default friction and restitution values, so we
        // make them the default.
        NxMaterial* mat = scene->getMaterialFromIndex(0);
        float rest = mat->getRestitution();
        float sfriction = mat->getStaticFriction();
        float dfriction = mat->getDynamicFriction();
        mat->setRestitution(0.5);
        mat->setStaticFriction(0.5);
        mat->setDynamicFriction(0.5);

        // By default we just leave all the collision groups enabled, since
        // PhysX already makes sure that things like statics and statics don't
        // collide.  However, we do make it so the avatar and dynamic blockers
        // only block avatars and dynamics.
        for (int i = 0; i < plSimDefs::kGroupMax; i++)
        {
            scene->setGroupCollisionFlag(i, plSimDefs::kGroupAvatarBlocker, false);
            scene->setGroupCollisionFlag(i, plSimDefs::kGroupDynamicBlocker, false);
            scene->setGroupCollisionFlag(i, plSimDefs::kGroupLOSOnly, false);
            scene->setGroupCollisionFlag(plSimDefs::kGroupLOSOnly, i, false);
        }
        scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupAvatar, false);
        scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupAvatarBlocker, true);
        scene->setGroupCollisionFlag(plSimDefs::kGroupDynamic, plSimDefs::kGroupDynamicBlocker, true);
        scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupStatic, true);
        scene->setGroupCollisionFlag( plSimDefs::kGroupStatic, plSimDefs::kGroupAvatar, true);
        scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupDynamic, true);
        
        // The dynamics are in actor group 1, everything else is in 0.  Request
        // a callback for whenever a dynamic touches something.
        scene->setActorGroupPairFlags(0, 1, NX_NOTIFY_ON_TOUCH);
        scene->setActorGroupPairFlags(1, 1, NX_NOTIFY_ON_TOUCH);

        fScenes[world] = scene;
    }

    return scene;
}
开发者ID:branan,项目名称:Plasma-nobink,代码行数:61,代码来源:plSimulationMgr.cpp

示例2: if


//.........这里部分代码省略.........
					{
						if (physicslib_group_cont[i][j] != physicslib_group_cont[j][i])
						{
							::Logger::getInstance()->error("PhysicsLib - Improperly mirrored physics contacts data (group1 -> group2 does not have same flag as group2 -> group1).");
							::Logger::getInstance()->debug("contacts data group numbers follow:");
							::Logger::getInstance()->debug(int2str(i));
							::Logger::getInstance()->debug(int2str(j));
						}
						if (physicslib_group_cont[i][j] == PHYSICSLIB_GROUP_CONTACT_FLAGS1)
							scene->setActorGroupPairFlags(i, j, contactFlags1);
						else if (physicslib_group_cont[i][j] == PHYSICSLIB_GROUP_CONTACT_FLAGS2)
							scene->setActorGroupPairFlags(i, j, contactFlags2);
					}
				}

				if (params->scriptRunner != NULL)
				{
					bool ok = params->scriptRunner->runPhysicsLibScript("physics_init", "set_collisions");
					if (!ok)
						::Logger::getInstance()->error("PhysicsLib - Failed to run physics_init:set_collision script (script/sub may not be loaded or did not return expected value).");
				}

				for (int i = 0; i < PHYSICS_MAX_COLLISIONGROUPS; i++)
				{
					for (int j = 0; j < PHYSICS_MAX_COLLISIONGROUPS; j++)
					{
						if (physicslib_group_coll[i][j] != physicslib_group_coll[j][i])
						{
							::Logger::getInstance()->error("PhysicsLib - Improperly mirrored physics collision data (group1 -> group2 does not have same flag as group2 -> group1).");
							::Logger::getInstance()->debug("collision data group numbers follow:");
							::Logger::getInstance()->debug(int2str(i));
							::Logger::getInstance()->debug(int2str(j));
						}
						scene->setGroupCollisionFlag(i, j, physicslib_group_coll[i][j]);
					}
				}

// OLD SCHEISSE...
/*
				// Contact groups
				{
					int contactFlags1 = NX_NOTIFY_ON_START_TOUCH | NX_NOTIFY_ON_TOUCH | NX_NOTIFY_FORCES;
#ifdef PHYSICS_FEEDBACK
					int contactFlags2 = NX_NOTIFY_ON_START_TOUCH | NX_NOTIFY_ON_TOUCH | NX_NOTIFY_FORCES;
#else
					int contactFlags2 = NX_NOTIFY_ON_START_TOUCH | NX_NOTIFY_FORCES;
#endif
					//int contactFlags3 = NX_NOTIFY_ON_START_TOUCH | NX_NOTIFY_FORCES;

					scene->setActorGroupPairFlags(PHYSICS_COLLISIONGROUP_STATIC, PHYSICS_COLLISIONGROUP_MODEL_PARTICLES_WO_UNIT_COLL, contactFlags2);
					scene->setActorGroupPairFlags(PHYSICS_COLLISIONGROUP_STATIC, PHYSICS_COLLISIONGROUP_MODEL_PARTICLES, contactFlags2);
					scene->setActorGroupPairFlags(PHYSICS_COLLISIONGROUP_STATIC, PHYSICS_COLLISIONGROUP_DYNAMIC_TERRAINOBJECTS, contactFlags1);
					scene->setActorGroupPairFlags(PHYSICS_COLLISIONGROUP_MODEL_PARTICLES_WO_UNIT_COLL, PHYSICS_COLLISIONGROUP_DYNAMIC_TERRAINOBJECTS, contactFlags2);
					scene->setActorGroupPairFlags(PHYSICS_COLLISIONGROUP_MODEL_PARTICLES, PHYSICS_COLLISIONGROUP_DYNAMIC_TERRAINOBJECTS, contactFlags2);
					//scene->setActorGroupPairFlags(PHYSICS_COLLISIONGROUP_DYNAMIC_TERRAINOBJECTS, PHYSICS_COLLISIONGROUP_DYNAMIC_TERRAINOBJECTS, contactFlags2);
scene->setActorGroupPairFlags(PHYSICS_COLLISIONGROUP_DYNAMIC_TERRAINOBJECTS, PHYSICS_COLLISIONGROUP_DYNAMIC_TERRAINOBJECTS, contactFlags1);
					scene->setActorGroupPairFlags(PHYSICS_COLLISIONGROUP_DYNAMIC_TERRAINOBJECTS, PHYSICS_COLLISIONGROUP_UNITS, contactFlags2);
scene->setActorGroupPairFlags(PHYSICS_COLLISIONGROUP_STATIC, PHYSICS_COLLISIONGROUP_UNITS, contactFlags2);
scene->setActorGroupPairFlags(PHYSICS_COLLISIONGROUP_CLAW, PHYSICS_COLLISIONGROUP_STATIC, contactFlags1);
					//scene->setActorGroupPairFlags(PHYSICS_COLLISIONGROUP_DYNAMIC_TERRAINOBJECTS, PHYSICS_COLLISIONGROUP_UNITS, contactFlags3);
				}

				// Collision groups
				{
					// claw
					scene->setGroupCollisionFlag(PHYSICS_COLLISIONGROUP_CLAW, PHYSICS_COLLISIONGROUP_CLAW, false);
开发者ID:sopyer,项目名称:Shadowgrounds,代码行数:67,代码来源:physics_lib.cpp


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