add internal set matrix function

This commit is contained in:
Jasmine Hsu 2016-06-10 15:14:00 -07:00
parent ecc192df94
commit 9c5a7925f0

View File

@ -390,6 +390,45 @@ pybullet_setJointPositions(PyObject* self, PyObject* args)
// const unsigned char* m_rgbColorData;//3*m_pixelWidth*m_pixelHeight bytes // const unsigned char* m_rgbColorData;//3*m_pixelWidth*m_pixelHeight bytes
// const float* m_depthValues;//m_pixelWidth*m_pixelHeight floats // const float* m_depthValues;//m_pixelWidth*m_pixelHeight floats
// internal function to set a float matrix[16]
// used to initialize camera position with
// a view and projection matrix in renderImage()
static int pybullet_internalSetMatrix(PyObject* objMat, float matrix[16])
{
int i, len;
PyObject* item;
PyObject* seq;
seq = PySequence_Fast(objMat, "expected a sequence");
len = PySequence_Size(objMat);
if (len==16)
{
if (PyList_Check(seq))
{
for (i = 0; i < len; i++)
{
item = PyList_GET_ITEM(seq, i);
matrix[i] = PyFloat_AsDouble(item);
}
}
else
{
for (i = 0; i < len; i++)
{
item = PyTuple_GET_ITEM(seq,i);
matrix[i] = PyFloat_AsDouble(item);
}
}
Py_DECREF(seq);
return 1;
} else
{
Py_DECREF(seq);
return 0;
}
}
// Render an image from the current timestep of the simulation // Render an image from the current timestep of the simulation
// //