本文整理汇总了C++中KX_GameObject::GetMeshCount方法的典型用法代码示例。如果您正苦于以下问题:C++ KX_GameObject::GetMeshCount方法的具体用法?C++ KX_GameObject::GetMeshCount怎么用?C++ KX_GameObject::GetMeshCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KX_GameObject
的用法示例。
在下文中一共展示了KX_GameObject::GetMeshCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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.
}
示例3: RayHit
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
}
示例4: getMaterial
// get pointer to material
RAS_IPolyMaterial * getMaterial (PyObject *obj, short matID)
{
// if object is available
if (obj != NULL)
{
// get pointer to texture image
KX_GameObject * gameObj = gameObjectType.checkType(obj);
if (gameObj != NULL && gameObj->GetMeshCount() > 0)
{
// get material from mesh
RAS_MeshObject * mesh = gameObj->GetMesh(0);
RAS_MeshMaterial *meshMat = mesh->GetMeshMaterial(matID);
if (meshMat != NULL && meshMat->m_bucket != NULL)
// return pointer to polygon or blender material
return meshMat->m_bucket->GetPolyMaterial();
}
}
// otherwise material was not found
return NULL;
}
示例5: BroadPhaseSensorFilterCollision
// this function is called only for sensor objects
// return true if the controller can collide with the object
bool KX_CollisionSensor::BroadPhaseSensorFilterCollision(void *obj1, void *obj2)
{
BLI_assert(obj1 == m_physCtrl && obj2);
KX_GameObject *myobj = (KX_GameObject *)GetParent();
KX_GameObject *myparent = myobj->GetParent();
KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo *>(((PHY_IPhysicsController *)obj2)->GetNewClientInfo());
KX_ClientObjectInfo *my_client_info = static_cast<KX_ClientObjectInfo *>(m_physCtrl->GetNewClientInfo());
KX_GameObject *otherobj = (client_info ? client_info->m_gameobject : NULL);
// we can only check on persistent characteristic: m_link and m_suspended are not
// good candidate because they are transient. That must be handled at another level
if (!otherobj ||
otherobj == myparent || // don't interact with our parent
(my_client_info->m_type == KX_ClientObjectInfo::OBACTORSENSOR &&
client_info->m_type != KX_ClientObjectInfo::ACTOR)) // only with actor objects
{
return false;
}
bool found = m_touchedpropname.empty();
if (!found) {
if (m_bFindMaterial) {
for (unsigned int i = 0; i < otherobj->GetMeshCount(); ++i) {
RAS_MeshObject *meshObj = otherobj->GetMesh(i);
for (unsigned int j = 0; j < meshObj->NumMaterials(); ++j) {
found = (m_touchedpropname == std::string(meshObj->GetMaterialName(j), 2));
if (found) {
break;
}
}
}
}
else {
found = (otherobj->GetProperty(m_touchedpropname) != NULL);
}
}
return found;
}
示例6: FreeBlendFile
//.........这里部分代码省略.........
mapStringToActions.remove(an);
i--;
}
}
}
//scene->FreeTagged(); /* removed tagged objects and meshes*/
CListValue *obj_lists[] = {scene->GetObjectList(), scene->GetInactiveList(), NULL};
for (int ob_ls_idx=0; obj_lists[ob_ls_idx]; ob_ls_idx++)
{
CListValue *obs= obj_lists[ob_ls_idx];
RAS_MeshObject* mesh;
for (int ob_idx = 0; ob_idx < obs->GetCount(); ob_idx++)
{
KX_GameObject* gameobj = (KX_GameObject*)obs->GetValue(ob_idx);
if (IS_TAGGED(gameobj->GetBlenderObject())) {
int size_before = obs->GetCount();
/* Eventually calls RemoveNodeDestructObject
* frees m_map_gameobject_to_blender from UnregisterGameObject */
scene->RemoveObject(gameobj);
if (size_before != obs->GetCount())
ob_idx--;
else {
printf("ERROR COULD NOT REMOVE \"%s\"\n", gameobj->GetName().ReadPtr());
}
}
else {
/* free the mesh, we could be referecing a linked one! */
int mesh_index= gameobj->GetMeshCount();
while(mesh_index--) {
mesh= gameobj->GetMesh(mesh_index);
if (IS_TAGGED(mesh->GetMesh())) {
gameobj->RemoveMeshes(); /* XXX - slack, should only remove meshes that are library items but mostly objects only have 1 mesh */
break;
}
}
/* make sure action actuators are not referencing tagged actions */
for (unsigned int act_idx=0; act_idx<gameobj->GetActuators().size(); act_idx++)
{
if (gameobj->GetActuators()[act_idx]->IsType(SCA_IActuator::KX_ACT_ACTION))
{
BL_ActionActuator *act = (BL_ActionActuator*)gameobj->GetActuators()[act_idx];
if (IS_TAGGED(act->GetAction()))
act->SetAction(NULL);
}
}
}
}
}
}
}
int size;
// delete the entities of this scene
/* TODO - */
#if 0
vector<pair<KX_Scene*,KX_WorldInfo*> >::iterator worldit;
size = m_worldinfos.size();
示例7: FreeBlendFile
//.........这里部分代码省略.........
STR_HashedString an = action->name + 2;
mapStringToActions.remove(an);
m_map_blender_to_gameAdtList.remove(CHashedPtr(action));
i--;
}
}
}
//scene->FreeTagged(); /* removed tagged objects and meshes*/
CListValue *obj_lists[] = {scene->GetObjectList(), scene->GetInactiveList(), NULL};
for (int ob_ls_idx = 0; obj_lists[ob_ls_idx]; ob_ls_idx++) {
CListValue *obs = obj_lists[ob_ls_idx];
RAS_MeshObject *mesh;
for (int ob_idx = 0; ob_idx < obs->GetCount(); ob_idx++) {
KX_GameObject *gameobj = (KX_GameObject*)obs->GetValue(ob_idx);
if (IS_TAGGED(gameobj->GetBlenderObject())) {
int size_before = obs->GetCount();
/* Eventually calls RemoveNodeDestructObject
* frees m_map_gameobject_to_blender from UnregisterGameObject */
scene->RemoveObject(gameobj);
if (size_before != obs->GetCount())
ob_idx--;
else {
printf("ERROR COULD NOT REMOVE \"%s\"\n", gameobj->GetName().ReadPtr());
}
}
else {
gameobj->RemoveTaggedActions();
/* free the mesh, we could be referecing a linked one! */
int mesh_index = gameobj->GetMeshCount();
while (mesh_index--) {
mesh = gameobj->GetMesh(mesh_index);
if (IS_TAGGED(mesh->GetMesh())) {
gameobj->RemoveMeshes(); /* XXX - slack, should only remove meshes that are library items but mostly objects only have 1 mesh */
break;
}
else {
/* also free the mesh if it's using a tagged material */
int mat_index = mesh->NumMaterials();
while (mat_index--) {
if (IS_TAGGED(mesh->GetMeshMaterial(mat_index)->m_bucket->GetPolyMaterial()->GetBlenderMaterial())) {
gameobj->RemoveMeshes(); /* XXX - slack, same as above */
break;
}
}
}
}
/* make sure action actuators are not referencing tagged actions */
for (unsigned int act_idx = 0; act_idx < gameobj->GetActuators().size(); act_idx++) {
if (gameobj->GetActuators()[act_idx]->IsType(SCA_IActuator::KX_ACT_ACTION)) {
BL_ActionActuator *act = (BL_ActionActuator *)gameobj->GetActuators()[act_idx];
if (IS_TAGGED(act->GetAction()))
act->SetAction(NULL);
}
}
}
}
}
}
}