예제 #1
0
KartUpdateMessage::KartUpdateMessage()
                 : Message(Message::MT_KART_INFO)
{
    World *world = World::getWorld();
    unsigned int num_karts = world->getNumKarts();

    // Send the number of karts and for each kart the compressed 
    // control structure (3 ints) and xyz,hpr (4 floats: quaternion:
    allocate(getCharLength()+
             num_karts*(KartControl::getLength() + getVec3Length()
                         +getQuaternionLength()) );
    addChar(num_karts);
    for(unsigned int i=0; i<num_karts; i++)
    {
        const Kart* kart = world->getKart(i);
        const KartControl& kc=kart->getControls();
        kc.serialise(this);
        addVec3(kart->getXYZ());
        addQuaternion(kart->getRotation());
    }   // for i
}   // KartUpdateMessage
	void cNoAlphaShaderAccumulate::updateDebugInfo()
	{
		iter_shadercol it_shader = m_list.begin();
		for (; it_shader != m_list.end(); ++it_shader)
		{
			/*
			*	material
			*/
			map_mtlcol& mtlList = it_shader->second->m_mtlColList;
			iter_mtlcol it_mtl = mtlList.begin();
			for (; it_mtl != mtlList.end(); ++it_mtl)
			{
				/*
				*	mesh
				*/
				vec_meshcol& meshList = it_mtl->second->m_meshColList;
				iter_meshcol it_mesh = meshList.begin();
				for (; it_mesh != meshList.end(); ++it_mesh)
				{
					cEntityModel* entity = (*it_mesh)->m_entity;
					cMesh* mesh = (*it_mesh)->m_mesh;
					sVBInfo* vbInfo = _getVBMgr()->get(mesh->m_vbBuid);
					if (!vbInfo)
						continue;

					void* vbList;
					if (!vbInfo->m_vb.lock(0, vbInfo->m_vbSize, (void**)&vbList, vbInfo->m_lock))
						continue;

					uint offset = 0;
					sVector3 temp, p;
					for (uint vn = 0; vn < vbInfo->m_vertexNum; ++vn)
					{
						sVector3* position = vbInfo->getVBOffset<sVector3*>(vbList, offset, sFVFInfo::FVF_XYZ);
						addVec3(*position, entity->getPosition(), p);
						
						if (_getIsRender(RENDER_NORMAL))
						{
							sVector3* normal = vbInfo->getVBOffset<sVector3*>(vbList, offset, sFVFInfo::FVF_NORMAL);
							entity->getMatRot().transformCoord(*normal, temp);
							_getBatchRenderMgr()->pushAtNormal(&p, &temp, 10.0f, COLOR_GREEN);
						}
						if (_getIsRender(RENDER_TANGENT))
						{
							sVector3* tangent = vbInfo->getVBOffset<sVector3*>(vbList, offset, sFVFInfo::FVF_TANGENT);
							entity->getMatRot().transformCoord(*tangent, temp);
							_getBatchRenderMgr()->pushAtNormal(&p, &temp, 10.0f, COLOR_RED);
						}
						if (_getIsRender(RENDER_BINORMAL))
						{
							sVector3* binormal = vbInfo->getVBOffset<sVector3*>(vbList, offset, sFVFInfo::FVF_BINORMAL);
							entity->getMatRot().transformCoord(*binormal, temp);
							_getBatchRenderMgr()->pushAtNormal(&p, &temp, 10.0f, COLOR_BLUE);
						}

						offset += vbInfo->m_stride;
					}

					vbInfo->m_vb.unlock();
				}			
			}
		}
	}