Add API to change texture with object id and link index.

This commit is contained in:
yunfeibai
2016-10-21 11:55:27 -07:00
parent 4911b14271
commit 3d79961725
6 changed files with 63 additions and 11 deletions

View File

@@ -832,6 +832,7 @@ void TinyRendererVisualShapeConverter::resetAll()
void TinyRendererVisualShapeConverter::activateShapeTexture(int shapeUniqueId, int textureUniqueId)
{
btAssert(textureUniqueId < m_data->m_textures.size());
TinyRendererObjectArray** ptrptr = m_data->m_swRenderInstances.getAtIndex(shapeUniqueId);
if (ptrptr && *ptrptr)
{
@@ -840,6 +841,29 @@ void TinyRendererVisualShapeConverter::activateShapeTexture(int shapeUniqueId, i
}
}
void TinyRendererVisualShapeConverter::activateShapeTexture(int objectUniqueId, int jointIndex, int shapeIndex, int textureUniqueId)
{
int start = -1;
//find first one, then count how many
for (int i = 0; i < m_data->m_visualShapes.size(); i++)
{
printf("object id: %d\n", m_data->m_visualShapes[i].m_objectUniqueId);
if (m_data->m_visualShapes[i].m_objectUniqueId == objectUniqueId && m_data->m_visualShapes[i].m_linkIndex == jointIndex)
{
start = i;
break;
}
}
if (start >= 0)
{
if (start + shapeIndex < m_data->m_visualShapes.size())
{
activateShapeTexture(start + shapeIndex, textureUniqueId);
}
}
}
int TinyRendererVisualShapeConverter::registerTexture(unsigned char* texels, int width, int height)
{
MyTexture2 texData;