Exemple #1
0
    void DynamicLines::fillHardwareBuffers()
    {
        unsigned int size = (unsigned int)mPoints.size();

        prepareHardwareBuffers(size, 0);

        if(!size)
        {
            mBox.setExtents(Ogre::Vector3::ZERO, Ogre::Vector3::ZERO);
            mDirty = false;
            return;
        }

        Ogre::Vector3 vaabMin = mPoints[0];
        Ogre::Vector3 vaabMax = mPoints[0];

        Ogre::HardwareVertexBufferSharedPtr vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);

        Ogre::Real *prPos = static_cast<Ogre::Real *>(vbuf->lock(Ogre::HardwareBuffer::HBL_DISCARD));
        {
            for(unsigned int i = 0; i < size; i++)
            {
                *prPos++ = mPoints[i].x;
                *prPos++ = mPoints[i].y;
                *prPos++ = mPoints[i].z;

                if(!mUse2D)
                {
                    if(mPoints[i].x < vaabMin.x)
                        vaabMin.x = mPoints[i].x;

                    if(mPoints[i].y < vaabMin.y)
                        vaabMin.y = mPoints[i].y;

                    if(mPoints[i].z < vaabMin.z)
                        vaabMin.z = mPoints[i].z;

                    if(mPoints[i].x > vaabMax.x)
                        vaabMax.x = mPoints[i].x;

                    if(mPoints[i].y > vaabMax.y)
                        vaabMax.y = mPoints[i].y;

                    if(mPoints[i].z > vaabMax.z)
                        vaabMax.z = mPoints[i].z;
                }
            }
        }

        vbuf->unlock();

        if(mUse2D)
            mBox.setInfinite();
        else
            mBox.setExtents(vaabMin, vaabMax);

        mDirty = false;
    }
void NxLine::fillHardwareBuffers()
{
	int size = mPoints.size();
	prepareHardwareBuffers(size,0, mUseVertexColour);
 
	if (!size) 
	{ 
		mBox.setExtents(Vector3::ZERO,Vector3::ZERO);
		mDirty=false;
		return;
	}

	Nx::Vector3 vaabMin = mPoints[0];
	Nx::Vector3 vaabMax = mPoints[0];

	HardwareVertexBufferSharedPtr vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);

	Real *prPos = static_cast<Real*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));
	{
		for(int i = 0; i < size; i++)
		{
			*prPos++ = mPoints[i].x;
			*prPos++ = mPoints[i].y;
			*prPos++ = mPoints[i].z;

			if(mPoints[i].x < vaabMin.x)
				vaabMin.x = mPoints[i].x;
			if(mPoints[i].y < vaabMin.y)
				vaabMin.y = mPoints[i].y;
			if(mPoints[i].z < vaabMin.z)
				vaabMin.z = mPoints[i].z;

			if(mPoints[i].x > vaabMax.x)
				vaabMax.x = mPoints[i].x;
			if(mPoints[i].y > vaabMax.y)
				vaabMax.y = mPoints[i].y;
			if(mPoints[i].z > vaabMax.z)
				vaabMax.z = mPoints[i].z;
		}
	}

	vbuf->unlock();


	if( mUseVertexColour ) {
		HardwareVertexBufferSharedPtr cbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(1);
		cbuf->writeData(0, size * sizeof(unsigned int), &mPointsColor[0], true );
	}


	mBox.setExtents( NxVec3ToOgre( vaabMin ), NxVec3ToOgre(  vaabMax ) );
	mDirty = false;

}
//------------------------------------------------------------------------------------------------
void DynamicLines::fillHardwareBuffers()
{
	int size = m_Points.size();

	prepareHardwareBuffers(size,0);

	if (!size) {
		mBox.setExtents(Vec3::ZERO,Vec3::ZERO);
		m_bDirty=false;
		return;
	}

	Vec3 vaabMin = m_Points[0];
	Vec3 vaabMax = m_Points[0];

	Ogre::HardwareVertexBufferSharedPtr vbuf =
		mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);

	real *prPos = static_cast<real*>(vbuf->lock(Ogre::HardwareBuffer::HBL_DISCARD));
	{
		for(int i = 0; i < size; i++)
		{
			*prPos++ = m_Points[i].x;
			*prPos++ = m_Points[i].y;
			*prPos++ = m_Points[i].z;

			if(m_Points[i].x < vaabMin.x)
				vaabMin.x = m_Points[i].x;
			if(m_Points[i].y < vaabMin.y)
				vaabMin.y = m_Points[i].y;
			if(m_Points[i].z < vaabMin.z)
				vaabMin.z = m_Points[i].z;

			if(m_Points[i].x > vaabMax.x)
				vaabMax.x = m_Points[i].x;
			if(m_Points[i].y > vaabMax.y)
				vaabMax.y = m_Points[i].y;
			if(m_Points[i].z > vaabMax.z)
				vaabMax.z = m_Points[i].z;
		}
	}
	vbuf->unlock();

	mBox.setExtents(vaabMin, vaabMax);

	m_bDirty = false;
}