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


C++ KX_GameObject类代码示例

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


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

示例1: NeedRayCast

/* this function is used to pre-filter the object before casting the ray on them.
 * This is useful for "X-Ray" option when we want to see "through" unwanted object.
 */
bool KX_MouseFocusSensor::NeedRayCast(KX_ClientObjectInfo* client)
{
	KX_GameObject *hitKXObj = client->m_gameobject;

	if (client->m_type > KX_ClientObjectInfo::ACTOR)
	{
		// Unknown type of object, skip it.
		// Should not occur as the sensor objects are filtered in RayTest()
		printf("Invalid client type %d found ray casting\n", client->m_type);
		return false;
	}
	if (m_bXRay && m_propertyname.Length() != 0)
	{
		if (m_bFindMaterial)
		{
			bool found = false;
			for (unsigned int i = 0; i < hitKXObj->GetMeshCount(); ++i) {
				RAS_MeshObject *meshObj = hitKXObj->GetMesh(i);
				for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) {
					found = strcmp(m_propertyname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0;
					if (found)
						break;
				}
			}
			if (!found)
				return false;
		}
		else
		{
			if (hitKXObj->GetProperty(m_propertyname) == NULL)
				return false;
		}
	}
	return true;
}
开发者ID:JasonWilkins,项目名称:blender-viewport_fx,代码行数:38,代码来源:KX_MouseFocusSensor.cpp

示例2: assert

// this function is called at broad phase stage to check if the two controller
// need to interact at all. It is used for Near/Radar sensor that don't need to
// check collision with object not included in filter
bool	KX_NearSensor::BroadPhaseFilterCollision(void*obj1,void*obj2)
{
	KX_GameObject* parent = static_cast<KX_GameObject*>(GetParent());
	
	// need the mapping from PHY_IPhysicsController to gameobjects now
	assert(obj1==m_physCtrl && obj2);
	KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>((static_cast<PHY_IPhysicsController*>(obj2))->GetNewClientInfo());

	KX_GameObject* gameobj = ( client_info ? 
			client_info->m_gameobject :
			NULL);
	
	if (gameobj && (gameobj != parent))
	{
		// only take valid colliders
		if (client_info->m_type == KX_ClientObjectInfo::ACTOR)
		{
			if ((m_touchedpropname.size() == 0) || 
				(gameobj->GetProperty(m_touchedpropname)))
			{
				return true;
			}
		}
	}

	return false;
}
开发者ID:UPBGE,项目名称:blender,代码行数:30,代码来源:KX_NearSensor.cpp

示例3: strcmp

bool	KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_CollData* colldata)
{
//	KX_TouchEventManager* toucheventmgr = (KX_TouchEventManager*)m_eventmgr;
	KX_GameObject* parent = (KX_GameObject*)GetParent();

	// need the mapping from PHY_IPhysicsController to gameobjects now

	KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*> (object1 == m_physCtrl?
					((PHY_IPhysicsController*)object2)->GetNewClientInfo():
					((PHY_IPhysicsController*)object1)->GetNewClientInfo());

	KX_GameObject* gameobj = ( client_info ?
			client_info->m_gameobject :
			NULL);

	// add the same check as in SCA_ISensor::Activate(),
	// we don't want to record collision when the sensor is not active.
	if (m_links && !m_suspended &&
		gameobj && (gameobj != parent) && client_info->isActor())
	{

		bool found = m_touchedpropname.IsEmpty();
		bool hitMaterial = false;
		if (!found)
		{
			if (m_bFindMaterial) {
				for (unsigned int i = 0; i < gameobj->GetMeshCount(); ++i) {
					RAS_MeshObject *meshObj = gameobj->GetMesh(i);
					for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) {
						found = strcmp(m_touchedpropname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0;
						if (found) {
							hitMaterial = true;
							break;
						}
					}
				}
			}
			else {
				found = (gameobj->GetProperty(m_touchedpropname) != NULL);
			}
		}
		if (found)
		{
			if (!m_colliders->SearchValue(gameobj)) {
				m_colliders->Add(gameobj->AddRef());

				if (m_bTouchPulse)
					m_bColliderHash += (uint_ptr)(static_cast<void *>(&gameobj));
			}
			m_bTriggered = true;
			m_hitObject = gameobj;
			m_hitMaterial = hitMaterial;
			//printf("KX_TouchSensor::HandleCollision\n");
		}

	}
	return false; // was DT_CONTINUE but this was defined in sumo as false.
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:58,代码来源:KX_TouchSensor.cpp

示例4:

PyObject *BL_ArmatureActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
{
    BL_ArmatureActuator* actuator = static_cast<BL_ArmatureActuator*>(self);
    KX_GameObject *target = (attrdef->m_name == "target") ? actuator->m_gametarget : actuator->m_gamesubtarget;
    if (!target)
        Py_RETURN_NONE;
    else
        return target->GetProxy();
}
开发者ID:UPBGE,项目名称:blender,代码行数:9,代码来源:BL_ArmatureActuator.cpp

示例5: getName

const char* KX_BulletPhysicsController::getName()
{
	if (m_pObject)
	{
		KX_GameObject* gameobj = (KX_GameObject*)	m_pObject->GetSGClientObject();
		return gameobj->GetName();
	}
	return 0;
}
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:9,代码来源:KX_BulletPhysicsController.cpp

示例6: ResetPhysicsObjectsAnimationIpo

void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
{
	//TODO this entire function is deprecated, written for 2.4x
	//the functionality should be rewritten, currently it does nothing

	KX_SceneList *scenes = m_ketsjiEngine->CurrentScenes();
	int numScenes = scenes->size();
	int i;
	for (i = 0; i < numScenes; i++) {
		KX_Scene *scene = scenes->at(i);
		CListValue *parentList = scene->GetRootParentList();
		int numObjects = parentList->GetCount();
		int g;
		for (g = 0; g < numObjects; g++) {
			KX_GameObject *gameObj = (KX_GameObject *)parentList->GetValue(g);
			if (gameObj->IsRecordAnimation()) {
				Object *blenderObject = gameObj->GetBlenderObject();
				if (blenderObject) {
#if 0
					//erase existing ipo's
					Ipo* ipo = blenderObject->ipo;//findIpoForName(blenderObject->id.name+2);
					if (ipo) { 	//clear the curve data
						if (clearIpo) {//rcruiz
							IpoCurve *icu1;

							int numCurves = 0;
							for ( icu1 = (IpoCurve*)ipo->curve.first; icu1;  ) {

								IpoCurve* tmpicu = icu1;

								/*int i;
								BezTriple *bezt;
								for ( bezt = tmpicu->bezt, i = 0;	i < tmpicu->totvert; i++, bezt++) {
									printf("(%f,%f,%f),(%f,%f,%f),(%f,%f,%f)\n",bezt->vec[0][0],bezt->vec[0][1],bezt->vec[0][2],bezt->vec[1][0],bezt->vec[1][1],bezt->vec[1][2],bezt->vec[2][0],bezt->vec[2][1],bezt->vec[2][2]);
								}*/

								icu1 = icu1->next;
								numCurves++;

								BLI_remlink( &( blenderObject->ipo->curve ), tmpicu );
								if ( tmpicu->bezt )
									MEM_freeN( tmpicu->bezt );
								MEM_freeN( tmpicu );
								localDel_ipoCurve( tmpicu );
							}
						}
					} 
					else {
						ipo = NULL; // XXX add_ipo(blenderObject->id.name+2, ID_OB);
						blenderObject->ipo = ipo;
					}
#endif
				}
			}
		}
	}
}
开发者ID:sadmansk,项目名称:blender,代码行数:57,代码来源:KX_BlenderSceneConverter.cpp

示例7: DecLink

void BL_ActionActuator::DecLink()
{
	SCA_IActuator::DecLink();
	/* In this case no controllers use this action actuator,
	   and it should stop its action. */
	if (m_links == 0) {
		KX_GameObject *obj = (KX_GameObject *)GetParent();
		obj->StopAction(m_layer);
	}
}
开发者ID:DrangPo,项目名称:blender,代码行数:10,代码来源:BL_ActionActuator.cpp

示例8: KX_ObjectActuator

KX_ObjectActuator::
KX_ObjectActuator(
	SCA_IObject* gameobj,
	KX_GameObject* refobj,
	const MT_Vector3& force,
	const MT_Vector3& torque,
	const MT_Vector3& dloc,
	const MT_Vector3& drot,
	const MT_Vector3& linV,
	const MT_Vector3& angV,
	const short damping,
	const KX_LocalFlags& flag
) : 
	SCA_IActuator(gameobj, KX_ACT_OBJECT),
	m_force(force),
	m_torque(torque),
	m_dloc(dloc),
	m_drot(drot),
	m_linear_velocity(linV),
	m_angular_velocity(angV),
	m_linear_length2(0.0f),
	m_current_linear_factor(0.0f),
	m_current_angular_factor(0.0f),
	m_damping(damping),
	m_previous_error(0.0f,0.0f,0.0f),
	m_error_accumulator(0.0f,0.0f,0.0f),
	m_bitLocalFlag (flag),
	m_reference(refobj),
	m_active_combined_velocity (false),
	m_linear_damping_active(false),
	m_angular_damping_active(false),
	m_jumping(false)
{
	if (m_bitLocalFlag.ServoControl)
	{
		// in servo motion, the force is local if the target velocity is local
		m_bitLocalFlag.Force = m_bitLocalFlag.LinearVelocity;

		m_pid = m_torque;
	}
	if (m_bitLocalFlag.CharacterMotion)
	{
		KX_GameObject *parent = static_cast<KX_GameObject *>(GetParent());
		PHY_ICharacter *character = parent->GetScene()->GetPhysicsEnvironment()->GetCharacterController(parent);

		if (!character)
		{
			printf("Character motion enabled on non-character object (%s), falling back to simple motion.\n", parent->GetName().Ptr());
			m_bitLocalFlag.CharacterMotion = false;
		}
	}
	if (m_reference)
		m_reference->RegisterActuator(this);
	UpdateFuzzyFlags();
}
开发者ID:Brachi,项目名称:blender,代码行数:55,代码来源:KX_ObjectActuator.cpp

示例9: pyattr_get_object

PyObject* KX_PythonComponent::pyattr_get_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
	KX_PythonComponent *self = static_cast<KX_PythonComponent *>(self_v);
	KX_GameObject *gameobj = self->GetGameObject();

	if (gameobj) {
		return gameobj->GetProxy();
	}
	else {
		Py_RETURN_NONE;
	}
}
开发者ID:UPBGE,项目名称:blender,代码行数:12,代码来源:KX_PythonComponent.cpp

示例10:

PyObject *KX_VehicleWrapper::PyAddWheel(PyObject *args)
{
	
	PyObject *pylistPos,*pylistDir,*pylistAxleDir;
	PyObject *wheelGameObject;
	float suspensionRestLength,wheelRadius;
	int hasSteering;

	
	if (PyArg_ParseTuple(args,"OOOOffi:addWheel",&wheelGameObject,&pylistPos,&pylistDir,&pylistAxleDir,&suspensionRestLength,&wheelRadius,&hasSteering))
	{
		KX_GameObject *gameOb;
		if (!ConvertPythonToGameObject(wheelGameObject, &gameOb, false, "vehicle.addWheel(...): KX_VehicleWrapper (first argument)"))
			return NULL;

		if (gameOb->GetSGNode())
		{
			MT_Vector3 attachPos,attachDir,attachAxle;
			if(!PyVecTo(pylistPos,attachPos)) {
				PyErr_SetString(PyExc_AttributeError,
				                "addWheel(...) Unable to add wheel. attachPos must be a vector with 3 elements.");
				return NULL;
			}
			if(!PyVecTo(pylistDir,attachDir))  {
				PyErr_SetString(PyExc_AttributeError,
				                "addWheel(...) Unable to add wheel. downDir must be a vector with 3 elements.");
				return NULL;
			}
			if(!PyVecTo(pylistAxleDir,attachAxle)) {
				PyErr_SetString(PyExc_AttributeError,
				                "addWheel(...) Unable to add wheel. axleDir must be a vector with 3 elements.");
				return NULL;
			}

			//someone reverse some conventions inside Bullet (axle winding)
			attachAxle = -attachAxle;
			
			if(wheelRadius<=0) {
				PyErr_SetString(PyExc_AttributeError,
				                "addWheel(...) Unable to add wheel. wheelRadius must be positive.");
				return NULL;
			}

			PHY_IMotionState *motionState = new KX_MotionState(gameOb->GetSGNode());
			m_vehicle->AddWheel(motionState,attachPos,attachDir,attachAxle,suspensionRestLength,wheelRadius,hasSteering);
		}
		
	} else {
		return NULL;
	}
	Py_RETURN_NONE;
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:52,代码来源:KX_VehicleWrapper.cpp

示例11: SCA_IActuator

KX_SteeringActuator::KX_SteeringActuator(SCA_IObject *gameobj,
                                         int mode,
                                         KX_GameObject *target,
                                         KX_GameObject *navmesh,
                                         float distance,
                                         float velocity,
                                         float acceleration,
                                         float turnspeed,
                                         bool  isSelfTerminated,
                                         int pathUpdatePeriod,
                                         KX_ObstacleSimulation* simulation,
                                         short facingmode,
                                         bool normalup,
                                         bool enableVisualization,
                                         bool lockzvel)
    : SCA_IActuator(gameobj, KX_ACT_STEERING),
      m_target(target),
      m_mode(mode),
      m_distance(distance),
      m_velocity(velocity),
      m_acceleration(acceleration),
      m_turnspeed(turnspeed),
      m_simulation(simulation),
      m_updateTime(0),
      m_obstacle(NULL),
      m_isActive(false),
      m_isSelfTerminated(isSelfTerminated),
      m_enableVisualization(enableVisualization),
      m_facingMode(facingmode),
      m_normalUp(normalup),
      m_pathLen(0),
      m_pathUpdatePeriod(pathUpdatePeriod),
      m_lockzvel(lockzvel),
      m_wayPointIdx(-1),
      m_steerVec(MT_Vector3(0, 0, 0))
{
	m_navmesh = static_cast<KX_NavMeshObject*>(navmesh);
	if (m_navmesh)
		m_navmesh->RegisterActuator(this);
	if (m_target)
		m_target->RegisterActuator(this);
	
	if (m_simulation)
		m_obstacle = m_simulation->GetObstacle((KX_GameObject*)gameobj);
	KX_GameObject* parent = ((KX_GameObject*)gameobj)->GetParent();
	if (m_facingMode>0 && parent)
	{
		m_parentlocalmat = parent->GetSGNode()->GetLocalOrientation();
	}
	else
		m_parentlocalmat.setIdentity();
} 
开发者ID:UPBGE,项目名称:blender,代码行数:52,代码来源:KX_SteeringActuator.cpp

示例12: ReParent

void KX_CollisionSensor::ReParent(SCA_IObject *parent)
{
	KX_GameObject *gameobj = static_cast<KX_GameObject *>(parent);
	PHY_IPhysicsController *sphy = ((KX_GameObject *)parent)->GetPhysicsController();
	if (sphy) {
		m_physCtrl = sphy;
	}

	KX_ClientObjectInfo *client_info = gameobj->getClientInfo();

	client_info->m_sensors.push_back(this);
	SCA_ISensor::ReParent(parent);
}
开发者ID:UPBGE,项目名称:blender,代码行数:13,代码来源:KX_CollisionSensor.cpp

示例13: GetParent

bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo *client_info, KX_RayCast *result, void * const data)
{
	KX_GameObject* hitKXObj = client_info->m_gameobject;
	
	/* Is this me? In the ray test, there are a lot of extra checks
	 * for aliasing artifacts from self-hits. That doesn't happen
	 * here, so a simple test suffices. Or does the camera also get
	 * self-hits? (No, and the raysensor shouldn't do it either, since
	 * self-hits are excluded by setting the correct ignore-object.)
	 * Hitspots now become valid. */
	KX_GameObject* thisObj = (KX_GameObject*) GetParent();

	bool bFound = false;

	if ((m_focusmode == 2) || hitKXObj == thisObj)
	{
		if (m_propertyname.Length() == 0)
		{
			bFound = true;
		}
		else
		{
			if (m_bFindMaterial) {
				for (unsigned int i = 0; i < hitKXObj->GetMeshCount(); ++i) {
					RAS_MeshObject *meshObj = hitKXObj->GetMesh(i);
					for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) {
						bFound = strcmp(m_propertyname.ReadPtr(), meshObj->GetMaterialName(j).ReadPtr() + 2) == 0;
						if (bFound)
							break;
					}
				}
			}
			else {
				bFound = hitKXObj->GetProperty(m_propertyname) != NULL;
			}
		}

		if (bFound)
		{
			m_hitObject = hitKXObj;
			m_hitPosition = result->m_hitPoint;
			m_hitNormal = result->m_hitNormal;
			m_hitUV = result->m_hitUV;
			return true;
		}		
	}
	
	return true;     // object must be visible to trigger
	//return false;  // occluded objects can trigger
}
开发者ID:JasonWilkins,项目名称:blender-viewport_fx,代码行数:50,代码来源:KX_MouseFocusSensor.cpp

示例14:

void	KX_TouchSensor::ReParent(SCA_IObject* parent)
{
	KX_GameObject *gameobj = static_cast<KX_GameObject *>(parent);
	PHY_IPhysicsController *sphy = ((KX_GameObject*)parent)->GetPhysicsController();
	if (sphy)
		m_physCtrl = sphy;

//	m_solidHandle = m_sumoObj->getObjectHandle();
	KX_ClientObjectInfo *client_info = gameobj->getClientInfo();
	//client_info->m_gameobject = gameobj;
	//client_info->m_auxilary_info = NULL;

	client_info->m_sensors.push_back(this);
	SCA_ISensor::ReParent(parent);
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:15,代码来源:KX_TouchSensor.cpp

示例15:

KX_BulletPhysicsController::~KX_BulletPhysicsController ()
{
	// The game object has a direct link to 
	if (m_pObject)
	{
		// If we cheat in SetObject, we must also cheat here otherwise the 
		// object will still things it has a physical controller
		// Note that it requires that m_pObject is reset in case the object is deleted
		// before the controller (usual case, see KX_Scene::RemoveNodeDestructObjec)
		// The non usual case is when the object is not deleted because its reference is hanging
		// in a AddObject actuator but the node is deleted. This case is covered here.
		KX_GameObject* gameobj = (KX_GameObject*)	m_pObject->GetSGClientObject();
		gameobj->SetPhysicsController(NULL,false);
	}
}
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:15,代码来源:KX_BulletPhysicsController.cpp


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