本文整理汇总了C++中SubEntity类的典型用法代码示例。如果您正苦于以下问题:C++ SubEntity类的具体用法?C++ SubEntity怎么用?C++ SubEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SubEntity类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void Entity::decode(const std::string& fileName)
{
//
tinyxml2::XMLDocument doc;
if (tinyxml2::XML_SUCCESS != doc.LoadFile(fileName.c_str()))
{
return;
}
tinyxml2::XMLElement* r = doc.RootElement();
tinyxml2::XMLElement* tex= r->FirstChildElement("subEntity");
std::string parentPath = Buddha::FileSystem::getInstancePtr()->standardFilePath(fileName);
parentPath = Buddha::FileSystem::getInstancePtr()->getParent(parentPath);
parentPath = Buddha::FileSystem::getInstancePtr()->getParent(parentPath);
parentPath += "/";
while (tex)
{
std::string subEntityFileName = tex->Attribute("file");
SubEntity* sub = new SubEntity;
sub->decode(parentPath + subEntityFileName);
mSubEntities.push_back(sub);
tex = tex->NextSiblingElement("subEntity");
}
}
示例2:
void OgreSample13App::setupInstancedMaterialToEntity(Ogre::Entity *ent)
{
for (Ogre::uint i=0;i<ent->getNumSubEntities();++i)
{
SubEntity * se = ent->getSubEntity(i);
String materialName = se->getMaterialName();
se->setMaterialName(buildInstancedMaterial(materialName));
}
}
示例3: addBspEntityToRenderQueue
//-----------------------------------------------------------------------------
void VisibleBspLeavesSearch::addBspEntityToRenderQueue()
{
for(size_t i = 0; i != mNumMaterials; ++i)
{
SubEntity* subEntity = mEntity->getSubEntity(i);
if(subEntity->isVisible() && mIndexDatas[i] && mIndexDatas[i]->indexCount != 0)
{
mRenderQueue->addRenderable(subEntity);
}
}
}
示例4: assert
//-----------------------------------------------------------------------
void
MeshInformer::getEntityStatistics(const Entity* entity, size_t& numVertices, size_t& numIndices)
{
size_t numSubEntities = entity->getNumSubEntities();
bool added_shared_vertex = false;
for (size_t i = 0; i < numSubEntities; ++i)
{
SubEntity* subEntity = entity->getSubEntity(i);
if (!subEntity->isVisible())
{
// Skip non-visible sub-entity
continue;
}
SubMesh* subMesh = subEntity->getSubMesh();
if (subMesh->operationType == RenderOperation::OT_TRIANGLE_LIST ||
subMesh->operationType == RenderOperation::OT_TRIANGLE_STRIP ||
subMesh->operationType == RenderOperation::OT_TRIANGLE_FAN)
{
if (subMesh->useSharedVertices)
{
if (!added_shared_vertex)
{
added_shared_vertex = true;
numVertices += subMesh->parent->sharedVertexData->vertexCount;
}
}
else
{
numVertices += subMesh->vertexData->vertexCount;
}
assert(subMesh->indexData->indexCount >= 3);
switch (subMesh->operationType)
{
case RenderOperation::OT_TRIANGLE_LIST:
assert(subMesh->indexData->indexCount % 3 == 0);
numIndices += subMesh->indexData->indexCount;
break;
case RenderOperation::OT_TRIANGLE_STRIP:
case RenderOperation::OT_TRIANGLE_FAN:
numIndices += (subMesh->indexData->indexCount - 2) * 3;
break;
}
}
}
}
示例5: _applyBaseKeyFrame
//---------------------------------------------------------------------
void Animation::apply(Entity* entity, Real timePos, Real weight,
bool software, bool hardware)
{
_applyBaseKeyFrame();
// Calculate time index for fast keyframe search
TimeIndex timeIndex = _getTimeIndex(timePos);
VertexTrackList::iterator i;
for (i = mVertexTrackList.begin(); i != mVertexTrackList.end(); ++i)
{
unsigned short handle = i->first;
VertexAnimationTrack* track = i->second;
VertexData* swVertexData;
VertexData* hwVertexData;
if (handle == 0)
{
// shared vertex data
swVertexData = entity->_getSoftwareVertexAnimVertexData();
hwVertexData = entity->_getHardwareVertexAnimVertexData();
entity->_markBuffersUsedForAnimation();
}
else
{
// sub entity vertex data (-1)
SubEntity* s = entity->getSubEntity(handle - 1);
// Skip this track if subentity is not visible
if (!s->isVisible())
continue;
swVertexData = s->_getSoftwareVertexAnimVertexData();
hwVertexData = s->_getHardwareVertexAnimVertexData();
s->_markBuffersUsedForAnimation();
}
// Apply to both hardware and software, if requested
if (software)
{
track->setTargetMode(VertexAnimationTrack::TM_SOFTWARE);
track->applyToVertexData(swVertexData, timeIndex, weight,
&(entity->getMesh()->getPoseList()));
}
if (hardware)
{
track->setTargetMode(VertexAnimationTrack::TM_HARDWARE);
track->applyToVertexData(hwVertexData, timeIndex, weight,
&(entity->getMesh()->getPoseList()));
}
}
}
示例6: getEntity
void MeshObject::setHighlighted( bool highlight )
{
String nameExtension = "_HighLight";
Entity* ent = getEntity();
int numEnts = ent->getNumSubEntities();
for( int i = 0; i < numEnts; i++ )
{
SubEntity* subent = ent->getSubEntity(i);
if( subent == NULL )
continue;
// TODO - optimieren, nur wenn der Typ verändert wird
//if(StringUtil::endsWith(subent->getMaterialName(),nameExtension)
// == highlight )
// continue;
MaterialPtr oldMaterial = subent->getMaterial();
// Highlight setzen
if( highlight )
{
MaterialPtr material = MaterialManager::getSingleton().getByName( oldMaterial->getName()+nameExtension );
if( material.isNull() )
{
material = oldMaterial->clone( oldMaterial->getName()+nameExtension );
material->setAmbient(1.0, 1.0, 1.0);
material->setDiffuse(1.0, 1.0, 1.0, 1.0);
material->setSelfIllumination(0.4, 0.4, 0.4);
}
subent->setMaterialName(material->getName());
}
// Highlight entfernen
else
{
String matName = oldMaterial->getName();
matName = matName.erase(matName.length() - nameExtension.length(), nameExtension.length() );
subent->setMaterialName( matName );
}
}
}
示例7: OnMouseMove
int MultiPlayChapter::OnMouseMove(int x, int y)
{
if( m_pkThirdCube->IsWait() )
return 0;
if( g_nMouseState & 1 )
{
//Ray mouseRay = m_pkCamera->getCameraToViewportRay((float)x/m_pkWindow->getWidth(), (float)y/m_pkWindow->getHeight());
Ray mouseRay = m_pkCamera->getCameraToViewportRay((float)(x-(m_pkWindow->getWidth()*0.25f))/m_pkViewport->getActualWidth(), (float)y/m_pkViewport->getActualHeight());
Entity *target;
float dis;
int subIndex = -1;
Vector3 result;
if( m_pkCollisionTools->raycastFromPoint(mouseRay.getOrigin(), mouseRay.getDirection(), result, target, dis, subIndex) )
{
if( m_currentEntity == target )
return 0;
if( m_currentEntity )
{
m_pkMIManager->SetTransparency(m_currentEntity, 0.4f, m_nCurrentSubIndex);
m_currentEntity = 0;
}
SubEntity *subEntity = target->getSubEntity(subIndex);
if( subEntity->getMaterialName().substr(0,10) == "07-Default" )
return 0;
for(int i=0; i<4; ++i)
{
if( target == m_pkMaterialChange[i] && subIndex == m_nMaterialChangeIndex[i] )
{
m_currentEntity = target;
m_nCurrentSubIndex = subIndex;
m_nCurrentMOC = result;
}
}
if( m_currentEntity == 0 )
return 0;
m_pkMIManager->ChangeOriginalMaterial(m_currentEntity, subIndex);
}
}
return 0;
}
示例8: SubEntity
//-----------------------------------------------------------------------
void Entity::buildSubEntityList(Mesh* mesh, SubEntityList* sublist) {
// Create SubEntities
int i, numSubMeshes;
SubMesh* subMesh;
SubEntity* subEnt;
numSubMeshes = mesh->getNumSubMeshes();
for (i = 0; i < numSubMeshes; ++i) {
subMesh = mesh->getSubMesh(i);
subEnt = new SubEntity();
subEnt->mParentEntity = this;
subEnt->mSubMesh = subMesh;
if (subMesh->isMatInitialised())
subEnt->setMaterialName(subMesh->getMaterialName());
sublist->push_back(subEnt);
}
}
示例9: extractSkeletonData
//-----------------------------------------------------------------------
void HardwareSkinningFactory::prepareEntityForSkinning(const Entity* pEntity, SkinningType skinningType,
bool correctAntidpodalityHandling, bool shearScale)
{
if (pEntity != NULL)
{
size_t lodLevels = pEntity->getNumManualLodLevels() + 1;
for(size_t indexLod = 0 ; indexLod < lodLevels ; ++indexLod)
{
const Entity* pCurEntity = pEntity;
if (indexLod > 0) pCurEntity = pEntity->getManualLodLevel(indexLod - 1);
ushort boneCount = 0,weightCount = 0;
bool isValid = extractSkeletonData(pCurEntity,boneCount,weightCount);
unsigned int numSubEntities = pCurEntity->getNumSubEntities();
for(unsigned int indexSub = 0 ; indexSub < numSubEntities ; ++indexSub)
{
SubEntity* pSubEntity = pCurEntity->getSubEntity(indexSub);
const MaterialPtr& pMat = pSubEntity->getMaterial();
imprintSkeletonData(pMat, isValid, boneCount, weightCount, skinningType, correctAntidpodalityHandling, shearScale);
}
}
}
}
示例10: _getTimeIndex
//---------------------------------------------------------------------
void Animation::apply(Entity* entity, Real timePos, Real weight,
bool software, bool hardware)
{
// Calculate time index for fast keyframe search
TimeIndex timeIndex = _getTimeIndex(timePos);
VertexTrackList::iterator i;
for (i = mVertexTrackList.begin(); i != mVertexTrackList.end(); ++i)
{
unsigned short handle = i->first;
VertexAnimationTrack* track = i->second;
VertexData* swVertexData;
VertexData* hwVertexData;
VertexData* origVertexData;
bool firstAnim = false;
if (handle == 0)
{
// shared vertex data
firstAnim = !entity->_getBuffersMarkedForAnimation();
swVertexData = entity->_getSoftwareVertexAnimVertexData();
hwVertexData = entity->_getHardwareVertexAnimVertexData();
origVertexData = entity->getMesh()->sharedVertexData;
entity->_markBuffersUsedForAnimation();
}
else
{
// sub entity vertex data (-1)
SubEntity* s = entity->getSubEntity(handle - 1);
// Skip this track if subentity is not visible
if (!s->isVisible())
continue;
firstAnim = !s->_getBuffersMarkedForAnimation();
swVertexData = s->_getSoftwareVertexAnimVertexData();
hwVertexData = s->_getHardwareVertexAnimVertexData();
origVertexData = s->getSubMesh()->vertexData;
s->_markBuffersUsedForAnimation();
}
// Apply to both hardware and software, if requested
if (software)
{
if (firstAnim && track->getAnimationType() == VAT_POSE)
{
// First time through for a piece of pose animated vertex data
// We need to copy the original position values to the temp accumulator
const VertexElement* origelem =
origVertexData->vertexDeclaration->findElementBySemantic(VES_POSITION);
const VertexElement* destelem =
swVertexData->vertexDeclaration->findElementBySemantic(VES_POSITION);
HardwareVertexBufferSharedPtr origBuffer =
origVertexData->vertexBufferBinding->getBuffer(origelem->getSource());
HardwareVertexBufferSharedPtr destBuffer =
swVertexData->vertexBufferBinding->getBuffer(destelem->getSource());
destBuffer->copyData(*origBuffer.get(), 0, 0, destBuffer->getSizeInBytes(), true);
}
track->setTargetMode(VertexAnimationTrack::TM_SOFTWARE);
track->applyToVertexData(swVertexData, timeIndex, weight,
&(entity->getMesh()->getPoseList()));
}
if (hardware)
{
track->setTargetMode(VertexAnimationTrack::TM_HARDWARE);
track->applyToVertexData(hwVertexData, timeIndex, weight,
&(entity->getMesh()->getPoseList()));
}
}
}
示例11: getEntityStatistics
//-----------------------------------------------------------------------
void
MeshInformer::getEntityTriangles(const Entity* entity,
std::vector<Vector3>& vertices,
std::vector<size_t>& indices,
std::vector<size_t>* indexOffsets)
{
size_t numVertices = 0, numIndices = 0;
getEntityStatistics(entity, numVertices, numIndices);
size_t vertex_offset = vertices.size();
size_t index_offset = indices.size();
vertices.resize(vertex_offset + numVertices);
indices.resize(index_offset + numIndices);
// Software blended vertex data available only if animation enabled, and software animation are
// used by internally engine, or user requested software animation.
bool useBlended = entity->_isAnimated() &&
(!entity->isHardwareAnimationEnabled() || entity->getSoftwareAnimationRequests() > 0);
// Use skinned vertex data only if blended data available and skeleton animation enabled.
bool useSkinned = useBlended && entity->_isSkeletonAnimated();
Vector3* pVertices = &vertices[0];
size_t* pIndices = &indices[0];
size_t shared_vertex_offset = vertex_offset;
bool added_shared_vertex = false;
size_t numSubEntities = entity->getNumSubEntities();
for (size_t i = 0; i < numSubEntities; ++i)
{
SubEntity* subEntity = entity->getSubEntity(i);
if (!subEntity->isVisible())
{
// Skip non-visible sub-entity
continue;
}
SubMesh* subMesh = subEntity->getSubMesh();
if (indexOffsets)
{
indexOffsets->push_back(index_offset);
}
if (subMesh->operationType == RenderOperation::OT_TRIANGLE_LIST ||
subMesh->operationType == RenderOperation::OT_TRIANGLE_STRIP ||
subMesh->operationType == RenderOperation::OT_TRIANGLE_FAN)
{
size_t current_vertex_offset;
if (subMesh->useSharedVertices)
{
if (!added_shared_vertex)
{
size_t vertexCount = getVertices(pVertices + vertex_offset,
useSkinned ? entity->_getSkelAnimVertexData()
:
useBlended && subMesh->parent->getSharedVertexDataAnimationType() != VAT_NONE ? entity->_getSoftwareVertexAnimVertexData()
:
subMesh->parent->sharedVertexData);
shared_vertex_offset = vertex_offset;
vertex_offset += vertexCount;
added_shared_vertex = true;
}
current_vertex_offset = shared_vertex_offset;
}
else
{
size_t vertexCount = getVertices(pVertices + vertex_offset,
useSkinned ? subEntity->_getSkelAnimVertexData()
:
useBlended && subMesh->getVertexAnimationType() != VAT_NONE ? subEntity->_getSoftwareVertexAnimVertexData()
:
subMesh->vertexData);
current_vertex_offset = vertex_offset;
vertex_offset += vertexCount;
}
size_t index_count = getTriangles(pIndices + index_offset, subMesh->indexData, current_vertex_offset, subMesh->operationType);
index_offset += index_count;
}
}
}
示例12: createScene
// Just override the mandatory create scene method
void createScene(void)
{
// Check capabilities
const RenderSystemCapabilities* caps = Root::getSingleton().getRenderSystem()->getCapabilities();
if (!caps->hasCapability(RSC_VERTEX_PROGRAM) || !(caps->hasCapability(RSC_FRAGMENT_PROGRAM)))
{
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "Your card does not support vertex and fragment programs, so cannot "
"run this demo. Sorry!",
"CelShading::createScene");
}
// Create a point light
Light* l = mSceneMgr->createLight("MainLight");
// Accept default settings: point light, white diffuse, just set position
// Add light to the scene node
rotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
rotNode->createChildSceneNode(Vector3(20,40,50))->attachObject(l);
Entity *ent = mSceneMgr->createEntity("head", "ogrehead.mesh");
mCamera->setPosition(20, 0, 100);
mCamera->lookAt(0,0,0);
// Set common material, but define custom parameters to change colours
// See Example-Advanced.material for how these are finally bound to GPU parameters
SubEntity* sub;
// eyes
sub = ent->getSubEntity(0);
sub->setMaterialName("Examples/CelShading");
sub->setCustomParameter(CUSTOM_SHININESS, Vector4(35.0f, 0.0f, 0.0f, 0.0f));
sub->setCustomParameter(CUSTOM_DIFFUSE, Vector4(1.0f, 0.3f, 0.3f, 1.0f));
sub->setCustomParameter(CUSTOM_SPECULAR, Vector4(1.0f, 0.6f, 0.6f, 1.0f));
// skin
sub = ent->getSubEntity(1);
sub->setMaterialName("Examples/CelShading");
sub->setCustomParameter(CUSTOM_SHININESS, Vector4(10.0f, 0.0f, 0.0f, 0.0f));
sub->setCustomParameter(CUSTOM_DIFFUSE, Vector4(0.0f, 0.5f, 0.0f, 1.0f));
sub->setCustomParameter(CUSTOM_SPECULAR, Vector4(0.3f, 0.5f, 0.3f, 1.0f));
// earring
sub = ent->getSubEntity(2);
sub->setMaterialName("Examples/CelShading");
sub->setCustomParameter(CUSTOM_SHININESS, Vector4(25.0f, 0.0f, 0.0f, 0.0f));
sub->setCustomParameter(CUSTOM_DIFFUSE, Vector4(1.0f, 1.0f, 0.0f, 1.0f));
sub->setCustomParameter(CUSTOM_SPECULAR, Vector4(1.0f, 1.0f, 0.7f, 1.0f));
// teeth
sub = ent->getSubEntity(3);
sub->setMaterialName("Examples/CelShading");
sub->setCustomParameter(CUSTOM_SHININESS, Vector4(20.0f, 0.0f, 0.0f, 0.0f));
sub->setCustomParameter(CUSTOM_DIFFUSE, Vector4(1.0f, 1.0f, 0.7f, 1.0f));
sub->setCustomParameter(CUSTOM_SPECULAR, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
// Add entity to the root scene node
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
mWindow->getViewport(0)->setBackgroundColour(ColourValue::White);
}
示例13: switch
int MultiPlayChapter::OnMouseClick(int x, int y, unsigned short nButton, unsigned short nModifier)
{
if( m_pkThirdCube->IsWait() )
return 0;
switch( nButton )
{
case 0:
{
ShowCursor(true);
if( m_pkThirdCube->IsShuffle() )
break;
Ray mouseRay = m_pkCamera->getCameraToViewportRay((float)(x-(m_pkWindow->getWidth()*0.25f))/m_pkViewport->getActualWidth(), (float)y/m_pkViewport->getActualHeight());
Entity *target;
float dis;
int subIndex = 0;
Vector3 result;
if( m_pkCollisionTools->raycastFromPoint(mouseRay.getOrigin(), mouseRay.getDirection(), result, target, dis, subIndex) )
{
SubEntity *subEntity = target->getSubEntity(subIndex);
if( subEntity->getMaterialName() == "07-Default" )
break;
String tmp = target->getParentNode()->getName();
int dumiIndex = Ogre::StringConverter::parseInt(tmp.substr(5,2));
m_pkThirdCube->InputFirstSelect(dumiIndex-1, result);
Vector3 dumi(m_pkThirdCube->GetDumiPos(dumiIndex-1));
int axis=0;
float x, y, z;
x = result.x<0?result.x*-1: result.x;
y = result.y<0?result.y*-1: result.y;
z = result.z<0?result.z*-1: result.z;
for(int i=0; i<27; ++i)
{
Entity *entity = m_pkThirdCube->GetBoxEntity(i);
m_pkMIManager->AddData(new MIManagerData(entity, new EntityMaterialInstance(entity)));
}
Vector3 Ray1[2] = { Vector3(dumi), Vector3(dumi) };
Vector3 Ray2[2] = { Vector3(dumi), Vector3(dumi) };
Vector3 dir(Vector3::ZERO);
if( x > 15.4f )
axis = 1;
else if( y > 15.4f )
axis = 2;
else if( z > 15.4f )
axis = 3;
switch( axis )
{
case 1:
{
dir.x = result.x<0?1.0f:-1.0f;
Ray1[0].x = dumi.x<0?dumi.x-10.0f: dumi.x+10.0f;
Ray1[1].x = Ray1[0].x;
Ray2[0].x = Ray1[0].x;
Ray2[1].x = Ray1[0].x;
if( dumi.y == 0 )
{
Ray1[0].y = dumi.y+10.5f;
Ray1[1].y = dumi.y-10.5f;
}
else if( dumi.y > 0 )
{
Ray1[0].y = dumi.y-10.5f;
Ray1[1].y = dumi.y-21.0f;
}
else if( dumi.y < 0 )
{
Ray1[0].y = dumi.y+10.5f;
Ray1[1].y = dumi.y+21.0f;
}
if( dumi.z == 0 )
{
Ray2[0].z = dumi.z+10.5f;
Ray2[1].z = dumi.z-10.5f;
}
else if( dumi.z > 0 )
{
Ray2[0].z = dumi.z-10.5f;
Ray2[1].z = dumi.z-21.0f;
}
else if( dumi.z < 0 )
{
Ray2[0].z = dumi.z+10.5f;
Ray2[1].z = dumi.z+21.0f;
}
}
break;
case 2:
{
dir.y = result.y<0?1.0f:-1.0f;
Ray1[0].y = dumi.y<0?dumi.y-10.0f: dumi.y+10.0f;
Ray1[1].y = Ray1[0].y;
Ray2[0].y = Ray1[0].y;
Ray2[1].y = Ray1[0].y;
if( dumi.x == 0 )
{
//.........这里部分代码省略.........
示例14: log
//.........这里部分代码省略.........
sscanf(line, "%f, %f, %f",&sc.x, &sc.y, &sc.z);
String entityName = "object" + TOSTRING(objcounter) + "(" + name + ")";
objcounter++;
SceneNode *tenode = gEnv->sceneManager->getRootSceneNode()->createChildSceneNode();
bool background_loading = BSETTING("Background Loading", false);
MeshObject *mo = NULL;
if (String(mesh) != "none")
{
mo = new MeshObject(mesh, entityName, tenode, NULL, background_loading);
}
//mo->setQueryFlags(OBJECTS_MASK);
//tenode->attachObject(te);
tenode->setScale(sc);
tenode->setPosition(pos);
tenode->rotate(rotation);
tenode->pitch(Degree(-90));
tenode->setVisible(true);
// register in map
loadedObject_t *obj = &loadedObjects[instancename];
obj->instanceName = instancename;
obj->loadType = 0;
obj->enabled = true;
obj->sceneNode = tenode;
obj->collTris.clear();
if (mo && uniquifyMaterial && !instancename.empty())
{
for (unsigned int i = 0; i < mo->getEntity()->getNumSubEntities(); i++)
{
SubEntity *se = mo->getEntity()->getSubEntity(i);
String matname = se->getMaterialName();
String newmatname = matname + "/" + instancename;
//LOG("subentity " + TOSTRING(i) + ": "+ matname + " -> " + newmatname);
se->getMaterial()->clone(newmatname);
se->setMaterialName(newmatname);
}
}
//String meshGroup = ResourceGroupManager::getSingleton().findGroupContainingResource(mesh);
//MeshPtr mainMesh = mo->getMesh();
//collision box(es)
bool virt=false;
bool rotating=false;
bool classic_ref=true;
// everything is of concrete by default
ground_model_t *gm = gEnv->collisions->getGroundModelByString("concrete");
char eventname[256] = {};
while (!ds->eof())
{
size_t ll=ds->readLine(line, 1023);
// little workaround to trim it
String lineStr = String(line);
Ogre::StringUtil::trim(lineStr);
const char* ptline = lineStr.c_str();
if (ll==0 || line[0]=='/' || line[0]==';') continue;
if (!strcmp("end",ptline)) break;
if (!strcmp("movable", ptline)) {ismovable=true;continue;};
if (!strcmp("localizer-h", ptline))