mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-14 05:40:05 +00:00
Merge branch 'master' of https://github.com/erwincoumans/bullet3
This commit is contained in:
commit
97a62b33c0
@ -64,6 +64,20 @@ SimpleCamera::~SimpleCamera()
|
||||
void SimpleCamera::setVRCamera(const float viewMat[16], const float projectionMatrix[16])
|
||||
{
|
||||
m_data->m_enableVR = true;
|
||||
|
||||
b3Matrix3x3 vm;
|
||||
vm.setValue(viewMat[0],viewMat[4],viewMat[8],
|
||||
viewMat[1],viewMat[5],viewMat[9],
|
||||
viewMat[2],viewMat[6],viewMat[10]);
|
||||
|
||||
b3Vector3 vp = b3MakeVector3(viewMat[12],viewMat[13],viewMat[14]);
|
||||
b3Transform tr;
|
||||
tr.setBasis(vm);
|
||||
tr.setOrigin(vp);
|
||||
b3Transform cp = tr.inverse();
|
||||
m_data->m_cameraPosition = cp.getOrigin();
|
||||
|
||||
|
||||
for (int i=0;i<16;i++)
|
||||
{
|
||||
m_data->m_viewMatrixVR[i] = viewMat[i];
|
||||
|
@ -3509,17 +3509,50 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
||||
int* segmentationMaskBuffer = (int*)(bufferServerToClient+numRequestedPixels*8);
|
||||
|
||||
serverStatusOut.m_numDataStreamBytes = numRequestedPixels * totalBytesPerPixel;
|
||||
float viewMat[16];
|
||||
float projMat[16];
|
||||
for (int i=0;i<16;i++)
|
||||
{
|
||||
viewMat[i] = clientCmd.m_requestPixelDataArguments.m_viewMatrix[i];
|
||||
projMat[i] = clientCmd.m_requestPixelDataArguments.m_projectionMatrix[i];
|
||||
}
|
||||
if ((clientCmd.m_updateFlags & REQUEST_PIXEL_ARGS_HAS_CAMERA_MATRICES)==0)
|
||||
{
|
||||
b3OpenGLVisualizerCameraInfo tmpCamResult;
|
||||
bool result = this->m_data->m_guiHelper->getCameraInfo(
|
||||
&tmpCamResult.m_width,
|
||||
&tmpCamResult.m_height,
|
||||
tmpCamResult.m_viewMatrix,
|
||||
tmpCamResult.m_projectionMatrix,
|
||||
tmpCamResult.m_camUp,
|
||||
tmpCamResult.m_camForward,
|
||||
tmpCamResult.m_horizontal,
|
||||
tmpCamResult.m_vertical,
|
||||
&tmpCamResult.m_yaw,
|
||||
&tmpCamResult.m_pitch,
|
||||
&tmpCamResult.m_dist,
|
||||
tmpCamResult.m_target);
|
||||
if (result)
|
||||
{
|
||||
for (int i=0;i<16;i++)
|
||||
{
|
||||
viewMat[i] = tmpCamResult.m_viewMatrix[i];
|
||||
projMat[i] = tmpCamResult.m_projectionMatrix[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((clientCmd.m_updateFlags & ER_BULLET_HARDWARE_OPENGL)!=0)
|
||||
{
|
||||
m_data->m_guiHelper->copyCameraImageData(clientCmd.m_requestPixelDataArguments.m_viewMatrix,
|
||||
clientCmd.m_requestPixelDataArguments.m_projectionMatrix,pixelRGBA,numRequestedPixels,
|
||||
|
||||
m_data->m_guiHelper->copyCameraImageData(viewMat,
|
||||
projMat,pixelRGBA,numRequestedPixels,
|
||||
depthBuffer,numRequestedPixels,
|
||||
segmentationMaskBuffer, numRequestedPixels,
|
||||
startPixelIndex,width,height,&numPixelsCopied);
|
||||
|
||||
m_data->m_guiHelper->debugDisplayCameraImageData(clientCmd.m_requestPixelDataArguments.m_viewMatrix,
|
||||
clientCmd.m_requestPixelDataArguments.m_projectionMatrix,pixelRGBA,numRequestedPixels,
|
||||
m_data->m_guiHelper->debugDisplayCameraImageData(viewMat,
|
||||
projMat,pixelRGBA,numRequestedPixels,
|
||||
depthBuffer,numRequestedPixels,
|
||||
0, numRequestedPixels,
|
||||
startPixelIndex,width,height,&numPixelsCopied);
|
||||
|
@ -46,6 +46,8 @@ struct MyTexture2
|
||||
struct TinyRendererObjectArray
|
||||
{
|
||||
btAlignedObjectArray< TinyRenderObjectData*> m_renderObjects;
|
||||
int m_objectUniqueId;
|
||||
int m_linkIndex;
|
||||
};
|
||||
|
||||
#define START_WIDTH 640
|
||||
@ -596,8 +598,11 @@ void TinyRendererVisualShapeConverter::convertVisualShapes(
|
||||
m_data->m_swRenderInstances.insert(colObj,new TinyRendererObjectArray);
|
||||
}
|
||||
visualsPtr = m_data->m_swRenderInstances[colObj];
|
||||
|
||||
btAssert(visualsPtr);
|
||||
TinyRendererObjectArray* visuals = *visualsPtr;
|
||||
visuals->m_objectUniqueId = bodyUniqueId;
|
||||
visuals->m_linkIndex = linkIndex;
|
||||
|
||||
b3VisualShapeData visualShape;
|
||||
visualShape.m_objectUniqueId = bodyUniqueId;
|
||||
@ -699,37 +704,41 @@ int TinyRendererVisualShapeConverter::getVisualShapesData(int bodyUniqueId, int
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TinyRendererVisualShapeConverter::changeRGBAColor(int bodyUniqueId, int linkIndex, const double rgbaColor[4])
|
||||
{
|
||||
int start = -1;
|
||||
for (int i = 0; i < m_data->m_visualShapes.size(); i++)
|
||||
{
|
||||
if (m_data->m_visualShapes[i].m_objectUniqueId == bodyUniqueId && m_data->m_visualShapes[i].m_linkIndex == linkIndex)
|
||||
{
|
||||
start = i;
|
||||
int start = -1;
|
||||
for (int i = 0; i < m_data->m_visualShapes.size(); i++)
|
||||
{
|
||||
if (m_data->m_visualShapes[i].m_objectUniqueId == bodyUniqueId && m_data->m_visualShapes[i].m_linkIndex == linkIndex)
|
||||
{
|
||||
m_data->m_visualShapes[i].m_rgbaColor[0] = rgbaColor[0];
|
||||
m_data->m_visualShapes[i].m_rgbaColor[1] = rgbaColor[1];
|
||||
m_data->m_visualShapes[i].m_rgbaColor[2] = rgbaColor[2];
|
||||
m_data->m_visualShapes[i].m_rgbaColor[3] = rgbaColor[3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start>=0)
|
||||
}
|
||||
|
||||
for (int i=0;i<m_data->m_swRenderInstances.size();i++)
|
||||
{
|
||||
TinyRendererObjectArray** visualArrayPtr = m_data->m_swRenderInstances.getAtIndex(start);
|
||||
TinyRendererObjectArray* visualArray = *visualArrayPtr;
|
||||
|
||||
btHashPtr colObjHash = m_data->m_swRenderInstances.getKeyAtIndex(start);
|
||||
const btCollisionObject* colObj = (btCollisionObject*) colObjHash.getPointer();
|
||||
|
||||
float rgba[4] = {rgbaColor[0], rgbaColor[1], rgbaColor[2], rgbaColor[3]};
|
||||
for (int v=0;v<visualArray->m_renderObjects.size();v++)
|
||||
TinyRendererObjectArray** ptrptr = m_data->m_swRenderInstances.getAtIndex(i);
|
||||
if (ptrptr && *ptrptr)
|
||||
{
|
||||
visualArray->m_renderObjects[v]->m_model->setColorRGBA(rgba);
|
||||
float rgba[4] = {rgbaColor[0], rgbaColor[1], rgbaColor[2], rgbaColor[3]};
|
||||
TinyRendererObjectArray* visuals = *ptrptr;
|
||||
if ((bodyUniqueId == visuals->m_objectUniqueId) && (linkIndex == visuals->m_linkIndex))
|
||||
{
|
||||
for (int q=0;q<visuals->m_renderObjects.size();q++)
|
||||
{
|
||||
visuals->m_renderObjects[q]->m_model->setColorRGBA(rgba);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TinyRendererVisualShapeConverter::setUpAxis(int axis)
|
||||
{
|
||||
m_data->m_upAxis = axis;
|
||||
|
Loading…
Reference in New Issue
Block a user