bool SFXProfile::_preloadBuffer() { AssertFatal( !mDescription->mIsStreaming, "SFXProfile::_preloadBuffer() - must not be called for streaming profiles" ); mBuffer = _createBuffer(); return ( !mBuffer.isNull() ); }
void EffectBillboardChain::setNbChainElements(unsigned int nbChainElements) { mCurrentNbChainElements = nbChainElements; _createBuffer(); mChainElementList.resize(mCurrentNbChainElements); }
void Sprite::create(graphics::Texture texture) { material_->setTexture(texture); float width = static_cast<u32>(texture->width()); float height = static_cast<u32>(texture->height()); _createBuffer(width, height); }
EffectBillboardChain::EffectBillboardChain(int maxNbChainElements) { mInitData= false; mRadius = 0.0f; mCurrentNbChainElements = maxNbChainElements; _createBuffer(); // set basic white material this->setMaterial("BaseWhiteNoLighting"); }
IntersectGrid::IntersectGrid() { // 缓冲区初始大小为54个顶点(9个格子) mCurrentVertexCount = 6*9; mRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST; mRenderOp.useIndexes = false; _createBuffer(); this->setMaterial(_createIntersectGridMaterial()->getName()); this->setPolygonModeOverrideable(false); }
void IntersectGrid::fillPosition( const PositionArray &posArray ) { size_t posCount = posArray.size(); if ( posCount <= 0 ) return; // if ( posCount > mCurrentVertexCount ) // { // 如果缓冲区不够用了,就扩容一倍 // mCurrentVertexCount = posCount<<1; // 如果不每帧创建缓冲区的话,由于lock时用的是discard,所以上次缓冲区中的内容还是会被显示 mCurrentVertexCount = posCount; _createBuffer(); // } Ogre::Vector3 vmax = posArray[posCount-1]; Ogre::Vector3 vmin = posArray[0]; vmin.y -= 100.0f; vmax.y += 100.0f; Real sqLen = std::max(vmax.squaredLength(), vmin.squaredLength()); mRadius = Ogre::Math::Sqrt(sqLen);// mBox.setExtents(vmin,vmax);// getParentNode()->needUpdate();// float *vertexPos = static_cast<float*>(vbuf->lock(Ogre::HardwareBuffer::HBL_DISCARD)); for (size_t i = 0; i < posCount; ++i) { *vertexPos++ = posArray[i].x; *vertexPos++ = posArray[i].y+1; *vertexPos++ = posArray[i].z; Ogre::RGBA *pCol; pCol = static_cast<Ogre::RGBA*>(static_cast<void*>(vertexPos)); // 用diffuse来做为alpha来源 Ogre::Root::getSingleton().convertColourValue(mGridsColour, pCol++ ) ; vertexPos = static_cast<float*>(static_cast<void*>(pCol)); } vbuf->unlock(); }
SFXBuffer* SFXProfile::getBuffer() { if ( mDescription->mIsStreaming ) { // Streaming requires unique buffers per // source, so this creates a new buffer. if ( SFX ) return _createBuffer(); return NULL; } if ( mBuffer.isNull() ) _preloadBuffer(); return mBuffer; }
void Sprite::create(const char* filePath) { destroy(); material_->setTextureName(filePath); Texture texture_ = material_->texture(); float width = static_cast<u32>(texture_->width()); float height = static_cast<u32>(texture_->height()); texture_->bind(); texture_->setWrapModeS(WRAP_CLAMP); texture_->setWrapModeT(WRAP_CLAMP); texture_->setMagFilterMode(MIPMAP_LINEAR); texture_->setMinFilterMode(MIPMAP_LINEAR); texture_->unbind(); _createBuffer(width, height); }
void Sprite::create(u32 width, u32 height) { destroy(); _createBuffer(width, height); }