32 FlexObj::FlexObj(
RoR::GfxActor* gfx_actor,
node_t* all_nodes, std::vector<CabTexcoord>& texcoords,
int numtriangles,
33 int* triangles, std::vector<CabSubmesh>& submesh_defs,
34 char* texname,
const char* name,
char* backtexname,
char* transtexname):
35 m_gfx_actor(gfx_actor)
44 for (
size_t j=0; j<submesh_defs.size(); j++)
46 Ogre::SubMesh* submesh =
m_mesh->createSubMesh();
47 switch (submesh_defs[j].backmesh_type)
51 default: submesh->setMaterialName(texname);
76 m_s_ref=(
float*)malloc(numtriangles*
sizeof(
float));
78 for (
size_t i=0; i<(
unsigned int)numtriangles;i++)
83 m_s_ref[i]=v1.crossProduct(v2).length()*2.0;
89 m_mesh->sharedVertexData =
new VertexData();
96 offset += VertexElement::getTypeSize(VET_FLOAT3);
98 offset += VertexElement::getTypeSize(VET_FLOAT3);
99 m_vertex_format->addElement(0, offset, VET_FLOAT2, VES_TEXTURE_COORDINATES, 0);
100 offset += VertexElement::getTypeSize(VET_FLOAT2);
104 m_hw_vbuf = HardwareBufferManager::getSingleton().createVertexBuffer(
105 offset,
m_mesh->sharedVertexData->vertexCount, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
111 VertexBufferBinding* bind =
m_mesh->sharedVertexData->vertexBufferBinding;
119 index_count = 3*submesh_defs[j].cabs_pos;
121 index_count = 3*(submesh_defs[j].cabs_pos-submesh_defs[j-1].cabs_pos);
124 HardwareIndexBufferSharedPtr ibuf = HardwareBufferManager::getSingleton().createIndexBuffer(
125 HardwareIndexBuffer::IT_16BIT,
127 HardwareBuffer::HBU_STATIC_WRITE_ONLY);
130 unsigned short* faces_ptr;
134 faces_ptr = &
m_indices[submesh_defs[j-1].cabs_pos * 3];
136 ibuf->writeData(0, ibuf->getSizeInBytes(), faces_ptr,
true);
138 m_submeshes[j]->indexData->indexCount = index_count;
143 m_mesh->_setBounds(AxisAlignedBox(-100,-100,-100,100,100,100),
true);
164 int num_submeshes =
static_cast<int>(submeshes.size());
165 for (context = 0; context < num_submeshes; ++context)
167 if (tidx < submeshes[context].cabs_pos)
175 int i_min = (context < 0) ? 0 : static_cast<int>(submeshes[context].texcoords_pos);
176 int i_max =
static_cast<int>(submeshes[context + 1].texcoords_pos);
177 for (
int i = i_min; i < i_max; ++i)
203 v1=v1.crossProduct(v2);
241 Ogre::MeshManager::getSingleton().remove(
m_mesh->getHandle());