mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-02 03:15:35 +00:00
Fix some subentity assumptions
This commit is contained in:
parent
7f2d71554e
commit
e8ac3976b5
1 changed files with 40 additions and 34 deletions
|
@ -205,44 +205,48 @@ unsigned int Moon::getPhaseInt() const
|
|||
|
||||
void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
|
||||
{
|
||||
// Get the vertex colour buffer of this mesh
|
||||
const Ogre::VertexElement* ves_diffuse = ent->getMesh()->getSubMesh(0)->vertexData->vertexDeclaration->findElementBySemantic( Ogre::VES_DIFFUSE );
|
||||
HardwareVertexBufferSharedPtr colourBuffer = ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource());
|
||||
|
||||
// Lock
|
||||
void* pData = colourBuffer->lock(HardwareBuffer::HBL_NORMAL);
|
||||
|
||||
// Iterate over all vertices
|
||||
int vertex_size = colourBuffer->getVertexSize();
|
||||
float * currentVertex = NULL;
|
||||
for (unsigned int i=0; i<colourBuffer->getNumVertices(); ++i)
|
||||
for(unsigned int idx = 0;idx < ent->getNumSubEntities();idx++)
|
||||
{
|
||||
// Get a pointer to the vertex colour
|
||||
ves_diffuse->baseVertexPointerToElement( pData, ¤tVertex );
|
||||
Ogre::SubMesh *submesh = ent->getSubEntity(idx)->getSubMesh();
|
||||
// Get the vertex colour buffer of this mesh
|
||||
const Ogre::VertexElement* ves_diffuse = submesh->vertexData->vertexDeclaration->findElementBySemantic( Ogre::VES_DIFFUSE );
|
||||
HardwareVertexBufferSharedPtr colourBuffer = submesh->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource());
|
||||
|
||||
unsigned char alpha=0;
|
||||
if (meshType == 0) alpha = i%2 ? 0 : 255; // this is a cylinder, so every second vertex belongs to the bottom-most row
|
||||
else if (meshType == 1)
|
||||
// Lock
|
||||
void* pData = colourBuffer->lock(HardwareBuffer::HBL_NORMAL);
|
||||
|
||||
// Iterate over all vertices
|
||||
int vertex_size = colourBuffer->getVertexSize();
|
||||
for (unsigned int i=0; i<colourBuffer->getNumVertices(); ++i)
|
||||
{
|
||||
if (i>= 49 && i <= 64) alpha = 0; // bottom-most row
|
||||
else if (i>= 33 && i <= 48) alpha = 64; // second bottom-most row
|
||||
else alpha = 255;
|
||||
// Get a pointer to the vertex colour
|
||||
float *currentVertex = NULL;
|
||||
ves_diffuse->baseVertexPointerToElement( pData, ¤tVertex );
|
||||
|
||||
unsigned char alpha=0;
|
||||
if (meshType == 0) alpha = i%2 ? 0 : 255; // this is a cylinder, so every second vertex belongs to the bottom-most row
|
||||
else if (meshType == 1)
|
||||
{
|
||||
if (i>= 49 && i <= 64) alpha = 0; // bottom-most row
|
||||
else if (i>= 33 && i <= 48) alpha = 64; // second bottom-most row
|
||||
else alpha = 255;
|
||||
}
|
||||
// NB we would have to swap R and B depending on rendersystem specific VertexElementType, but doesn't matter since they are both 1
|
||||
uint8 tmpR = static_cast<uint8>(255);
|
||||
uint8 tmpG = static_cast<uint8>(255);
|
||||
uint8 tmpB = static_cast<uint8>(255);
|
||||
uint8 tmpA = static_cast<uint8>(alpha);
|
||||
|
||||
// Modify
|
||||
*((uint32*)currentVertex) = tmpR | (tmpG << 8) | (tmpB << 16) | (tmpA << 24);
|
||||
|
||||
// Move to the next vertex
|
||||
pData = static_cast<unsigned char *> (pData) + vertex_size;
|
||||
}
|
||||
// NB we would have to swap R and B depending on rendersystem specific VertexElementType, but doesn't matter since they are both 1
|
||||
uint8 tmpR = static_cast<uint8>(255);
|
||||
uint8 tmpG = static_cast<uint8>(255);
|
||||
uint8 tmpB = static_cast<uint8>(255);
|
||||
uint8 tmpA = static_cast<uint8>(alpha);
|
||||
|
||||
// Modify
|
||||
*((uint32*)currentVertex) = tmpR | (tmpG << 8) | (tmpB << 16) | (tmpA << 24);
|
||||
|
||||
// Move to the next vertex
|
||||
pData = static_cast<unsigned char *> (pData) + vertex_size;
|
||||
// Unlock
|
||||
colourBuffer->unlock();
|
||||
}
|
||||
|
||||
// Unlock
|
||||
ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock();
|
||||
}
|
||||
|
||||
SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
|
||||
|
@ -356,7 +360,8 @@ void SkyManager::create()
|
|||
atmosphere_ent->setCastShadows(false);
|
||||
atmosphere_ent->setRenderQueueGroup(RQG_SkiesEarly);
|
||||
atmosphere_ent->setVisibilityFlags(RV_Sky);
|
||||
atmosphere_ent->getSubEntity (0)->setMaterialName ("openmw_atmosphere");
|
||||
for(unsigned int j = 0;j < atmosphere_ent->getNumSubEntities();j++)
|
||||
atmosphere_ent->getSubEntity (j)->setMaterialName("openmw_atmosphere");
|
||||
ModVertexAlpha(atmosphere_ent, 0);
|
||||
}
|
||||
|
||||
|
@ -369,7 +374,8 @@ void SkyManager::create()
|
|||
Entity* clouds_ent = entities.mEntities[i];
|
||||
clouds_ent->setVisibilityFlags(RV_Sky);
|
||||
clouds_ent->setRenderQueueGroup(RQG_SkiesEarly+5);
|
||||
clouds_ent->getSubEntity(0)->setMaterialName ("openmw_clouds");
|
||||
for(unsigned int j = 0;j < clouds_ent->getNumSubEntities();j++)
|
||||
clouds_ent->getSubEntity(j)->setMaterialName("openmw_clouds");
|
||||
clouds_ent->setCastShadows(false);
|
||||
|
||||
ModVertexAlpha(clouds_ent, 1);
|
||||
|
|
Loading…
Reference in a new issue