Get Developer > Avatar > Show Collision Bounding Shapes working again

Note: Currently doesn't display well because alpha isn't working.
This commit is contained in:
David Rowe 2015-07-22 16:15:17 -07:00
parent 3362358dcd
commit 11078d0d02

View file

@ -13,6 +13,7 @@
#include <QMultiMap> #include <QMultiMap>
#include <CapsuleShape.h> #include <CapsuleShape.h>
#include <DeferredLightingEffect.h>
#include <SphereShape.h> #include <SphereShape.h>
#include "Application.h" #include "Application.h"
@ -785,31 +786,34 @@ void SkeletonModel::resetShapePositionsToDefaultPose() {
void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha) { void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha) {
const int BALL_SUBDIVISIONS = 10; const int BALL_SUBDIVISIONS = 10;
if (_shapes.isEmpty()) { if (_shapes.isEmpty()) {
// the bounding shape has not been propery computed // the bounding shape has not been properly computed
// so no need to render it // so no need to render it
return; return;
} }
// draw a blue sphere at the capsule endpoint auto geometryCache = DependencyManager::get<GeometryCache>();
auto deferredLighting = DependencyManager::get<DeferredLightingEffect>();
Transform transform; // = Transform();
// draw a blue sphere at the capsule end point
glm::vec3 endPoint; glm::vec3 endPoint;
_boundingShape.getEndPoint(endPoint); _boundingShape.getEndPoint(endPoint);
endPoint = endPoint + _translation; endPoint = endPoint + _translation;
Transform transform = Transform();
transform.setTranslation(endPoint); transform.setTranslation(endPoint);
batch.setModelTransform(transform); batch.setModelTransform(transform);
auto geometryCache = DependencyManager::get<GeometryCache>(); deferredLighting->bindSimpleProgram(batch);
geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS,
glm::vec4(0.6f, 0.6f, 0.8f, alpha)); glm::vec4(0.6f, 0.6f, 0.8f, alpha));
// draw a yellow sphere at the capsule startpoint // draw a yellow sphere at the capsule start point
glm::vec3 startPoint; glm::vec3 startPoint;
_boundingShape.getStartPoint(startPoint); _boundingShape.getStartPoint(startPoint);
startPoint = startPoint + _translation; startPoint = startPoint + _translation;
glm::vec3 axis = endPoint - startPoint; glm::vec3 axis = endPoint - startPoint;
Transform axisTransform = Transform(); transform.setTranslation(startPoint);
axisTransform.setTranslation(-axis); batch.setModelTransform(transform);
batch.setModelTransform(axisTransform); deferredLighting->bindSimpleProgram(batch);
geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS,
glm::vec4(0.8f, 0.8f, 0.6f, alpha)); glm::vec4(0.8f, 0.8f, 0.6f, alpha));
// draw a green cylinder between the two points // draw a green cylinder between the two points