34 FlexMeshWheel::FlexMeshWheel(
35 Ogre::Entity* rim_prop_entity,
36 Ogre::SceneNode* rim_scene_node,
38 int axis_node_1_index,
39 int axis_node_2_index,
42 std::string
const& tire_mesh_name,
43 std::string
const& tire_mesh_rg,
44 std::string
const& tire_material_name,
45 std::string
const& tire_material_rg,
49 m_axis_node0_idx(axis_node_1_index)
50 , m_axis_node1_idx(axis_node_2_index)
51 , m_start_node_idx(nstart)
52 , m_num_rays(static_cast<size_t>(nrays))
53 , m_gfx_actor(gfx_actor)
54 , m_is_rim_reverse(rimreverse)
55 , m_rim_radius(rimradius)
62 m_mesh = MeshManager::getSingleton().createManual(tire_mesh_name, tire_mesh_rg);
68 m_submesh->setMaterialName(tire_material_name, tire_material_rg);
76 for (i=0; i<nrays+1; i++)
78 m_vertices[i*6 ].texcoord=Vector2((
float)i/(
float)nrays, 0.00f);
79 m_vertices[i*6+1 ].texcoord=Vector2((
float)i/(
float)nrays, 0.23f);
80 m_vertices[i*6+2 ].texcoord=Vector2((
float)i/(
float)nrays, 0.27f);
81 m_vertices[i*6+3 ].texcoord=Vector2((
float)i/(
float)nrays, 0.73f);
82 m_vertices[i*6+4 ].texcoord=Vector2((
float)i/(
float)nrays, 0.77f);
83 m_vertices[i*6+5 ].texcoord=Vector2((
float)i/(
float)nrays, 1.00f);
90 for (i=0; i<nrays; i++)
117 m_mesh->sharedVertexData =
new VertexData();
124 offset += VertexElement::getTypeSize(VET_FLOAT3);
126 offset += VertexElement::getTypeSize(VET_FLOAT3);
127 m_vertex_format->addElement(0, offset, VET_FLOAT2, VES_TEXTURE_COORDINATES, 0);
128 offset += VertexElement::getTypeSize(VET_FLOAT2);
133 HardwareBufferManager::getSingleton().createVertexBuffer(
134 offset,
m_mesh->sharedVertexData->vertexCount, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
140 VertexBufferBinding* bind =
m_mesh->sharedVertexData->vertexBufferBinding;
145 HardwareIndexBufferSharedPtr ibuf = HardwareBufferManager::getSingleton().
147 HardwareIndexBuffer::IT_16BIT,
149 HardwareBuffer::HBU_STATIC_WRITE_ONLY);
152 ibuf->writeData(0, ibuf->getSizeInBytes(),
m_indices.data(),
true);
157 m_submesh->indexData->indexBuffer = ibuf;
163 m_mesh->_setBounds(AxisAlignedBox(-1,-1,0,1,1,0),
true);
183 Ogre::MeshManager::getSingleton().remove(
m_mesh->getHandle());
200 ray=pl.projectVector(ray);
211 ray=pl.projectVector(ray);
223 for (
int i=0; i<6; i++)
248 Vector3 onormal = axis.crossProduct(ray);
250 ray = axis.crossProduct(onormal);