void btDiscreteDynamicsWorld::debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color) { // Draw a small simplex at the center of the object { btVector3 start = worldTransform.getOrigin(); getDebugDrawer()->drawLine(start, start+worldTransform.getBasis() * btVector3(1,0,0), btVector3(1,0,0)); getDebugDrawer()->drawLine(start, start+worldTransform.getBasis() * btVector3(0,1,0), btVector3(0,1,0)); getDebugDrawer()->drawLine(start, start+worldTransform.getBasis() * btVector3(0,0,1), btVector3(0,0,1)); } if (shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE) { const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shape); for (int i=compoundShape->getNumChildShapes()-1;i>=0;i--) { btTransform childTrans = compoundShape->getChildTransform(i); const btCollisionShape* colShape = compoundShape->getChildShape(i); debugDrawObject(worldTransform*childTrans,colShape,color); } } else { switch (shape->getShapeType()) { case SPHERE_SHAPE_PROXYTYPE: { const btSphereShape* sphereShape = static_cast<const btSphereShape*>(shape); btScalar radius = sphereShape->getMargin();//radius doesn't include the margin, so draw with margin debugDrawSphere(radius, worldTransform, color); break; } case MULTI_SPHERE_SHAPE_PROXYTYPE: { const btMultiSphereShape* multiSphereShape = static_cast<const btMultiSphereShape*>(shape); for (int i = multiSphereShape->getSphereCount()-1; i>=0;i--) { btTransform childTransform = worldTransform; childTransform.getOrigin() += multiSphereShape->getSpherePosition(i); debugDrawSphere(multiSphereShape->getSphereRadius(i), childTransform, color); } break; } case CAPSULE_SHAPE_PROXYTYPE: { const btCapsuleShape* capsuleShape = static_cast<const btCapsuleShape*>(shape); btScalar radius = capsuleShape->getRadius(); btScalar halfHeight = capsuleShape->getHalfHeight(); int upAxis = capsuleShape->getUpAxis(); btVector3 capStart(0.f,0.f,0.f); capStart[upAxis] = -halfHeight; btVector3 capEnd(0.f,0.f,0.f); capEnd[upAxis] = halfHeight; // Draw the ends { btTransform childTransform = worldTransform; childTransform.getOrigin() = worldTransform * capStart; debugDrawSphere(radius, childTransform, color); } { btTransform childTransform = worldTransform; childTransform.getOrigin() = worldTransform * capEnd; debugDrawSphere(radius, childTransform, color); } // Draw some additional lines btVector3 start = worldTransform.getOrigin(); capStart[(upAxis+1)%3] = radius; capEnd[(upAxis+1)%3] = radius; getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); capStart[(upAxis+1)%3] = -radius; capEnd[(upAxis+1)%3] = -radius; getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); capStart[(upAxis+1)%3] = 0.f; capEnd[(upAxis+1)%3] = 0.f; capStart[(upAxis+2)%3] = radius; capEnd[(upAxis+2)%3] = radius; getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); capStart[(upAxis+2)%3] = -radius; capEnd[(upAxis+2)%3] = -radius; getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); break; } case CONE_SHAPE_PROXYTYPE: { const btConeShape* coneShape = static_cast<const btConeShape*>(shape); btScalar radius = coneShape->getRadius();//+coneShape->getMargin(); btScalar height = coneShape->getHeight();//+coneShape->getMargin(); btVector3 start = worldTransform.getOrigin(); int upAxis= coneShape->getConeUpIndex(); btVector3 offsetHeight(0,0,0); offsetHeight[upAxis] = height * btScalar(0.5); btVector3 offsetRadius(0,0,0); offsetRadius[(upAxis+1)%3] = radius; btVector3 offset2Radius(0,0,0); offset2Radius[(upAxis+2)%3] = radius; getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color); getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color); getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offset2Radius),color); getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offset2Radius),color); break; } case CYLINDER_SHAPE_PROXYTYPE: { const btCylinderShape* cylinder = static_cast<const btCylinderShape*>(shape); int upAxis = cylinder->getUpAxis(); btScalar radius = cylinder->getRadius(); btScalar halfHeight = cylinder->getHalfExtentsWithMargin()[upAxis]; btVector3 start = worldTransform.getOrigin(); btVector3 offsetHeight(0,0,0); offsetHeight[upAxis] = halfHeight; btVector3 offsetRadius(0,0,0); offsetRadius[(upAxis+1)%3] = radius; getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight+offsetRadius),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color); getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight-offsetRadius),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color); break; } case STATIC_PLANE_PROXYTYPE: { const btStaticPlaneShape* staticPlaneShape = static_cast<const btStaticPlaneShape*>(shape); btScalar planeConst = staticPlaneShape->getPlaneConstant(); const btVector3& planeNormal = staticPlaneShape->getPlaneNormal(); btVector3 planeOrigin = planeNormal * planeConst; btVector3 vec0,vec1; btPlaneSpace1(planeNormal,vec0,vec1); btScalar vecLen = 100.f; btVector3 pt0 = planeOrigin + vec0*vecLen; btVector3 pt1 = planeOrigin - vec0*vecLen; btVector3 pt2 = planeOrigin + vec1*vecLen; btVector3 pt3 = planeOrigin - vec1*vecLen; getDebugDrawer()->drawLine(worldTransform*pt0,worldTransform*pt1,color); getDebugDrawer()->drawLine(worldTransform*pt2,worldTransform*pt3,color); break; } default: { if (shape->isConcave()) { btConcaveShape* concaveMesh = (btConcaveShape*) shape; ///@todo pass camera, for some culling? no -> we are not a graphics lib btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30)); btVector3 aabbMin(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30)); DebugDrawcallback drawCallback(getDebugDrawer(),worldTransform,color); concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax); } if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE) { btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape; //todo: pass camera for some culling btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30)); btVector3 aabbMin(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30)); //DebugDrawcallback drawCallback; DebugDrawcallback drawCallback(getDebugDrawer(),worldTransform,color); convexMesh->getMeshInterface()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax); } /// for polyhedral shapes if (shape->isPolyhedral()) { btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape; int i; for (i=0;i<polyshape->getNumEdges();i++) { btVector3 a,b; polyshape->getEdge(i,a,b); btVector3 wa = worldTransform * a; btVector3 wb = worldTransform * b; getDebugDrawer()->drawLine(wa,wb,color); } } } } } }
void CControlArrowStyleSelector::Draw(CDC* pDC) { CRect rc(m_rcControl); int nCount = sizeof(arrowStyles) / sizeof(arrowStyles[0]); for (int i = 0; i < nCount; i++) { CRect rcButton = GetRect(i); if (i == m_nSelected || arrowStyles[i].iArrowStyle == m_iArrowStyle) { BOOL bPressed = GetPressed() && i == m_nSelected; //GetPaintManager()->DrawControlEntry(pDC, &rcButton, m_bEnabled, i == m_nSelected, bPressed, arrowStyles[i].iArrowStyle == m_iArrowStyle, FALSE, GetParent()->GetPosition()); GetPaintManager()->DrawRectangle(pDC, &rcButton, i == m_nSelected, bPressed, m_bEnabled, arrowStyles[i].iArrowStyle == m_iArrowStyle, FALSE, GetParent()->GetType(), GetParent()->GetPosition()); } Gdiplus::Graphics gdipGraphics(pDC->m_hDC); Gdiplus::Pen pen(Gdiplus::Color(255, 0, 0, 0), 1); Gdiplus::SolidBrush brush(Gdiplus::Color(255, 0, 0, 0)); /* if (arrowStyles[i].iArrowStyle == msoLineRoundDot) pen.SetDashCap(Gdiplus::DashCapTriangle); else pen.SetDashCap(Gdiplus::DashCapFlat); pen.SetDashPattern(arrowStyles[i].dashValues, arrowStyles[i].iDashValueCount); pen.SetDashStyle(Gdiplus::DashStyleCustom);*/ // Gdiplus::Point points[3] = {Gdiplus::Point(0, 0), Gdiplus::Point(0, 0), Gdiplus::Point(0, 0)}; Gdiplus::GraphicsPath startCapPath; Gdiplus::GraphicsPath endCapPath; // Create a CustomLineCap object with capPath as the stroke path. int yPos = rcButton.top + XTP_AS_SELECTOR_HEIGHT / 2; switch(arrowStyles[i].startCap) { case Gdiplus::LineCapArrowAnchor: { Gdiplus::AdjustableArrowCap capStart(9, 9, false); pen.SetCustomStartCap(&capStart); break; } case Gdiplus::LineCapTriangle: { Gdiplus::AdjustableArrowCap capStart(6, 5, true); pen.SetCustomStartCap(&capStart); break; } case Gdiplus::LineCapDiamondAnchor: { Gdiplus::Point points[4] = {Gdiplus::Point(rcButton.left , yPos ), Gdiplus::Point(rcButton.left + 5, yPos + 5), Gdiplus::Point(rcButton.left + 10, yPos), Gdiplus::Point(rcButton.left + 5, yPos - 5)}; startCapPath.AddPolygon(points, 4); break; } case Gdiplus::LineCapRoundAnchor: { Gdiplus::Rect rect(rcButton.left, yPos - 5, 10, 10); startCapPath.AddEllipse(rect); break; } default: break; } switch(arrowStyles[i].endCap) { case Gdiplus::LineCapArrowAnchor: { Gdiplus::AdjustableArrowCap capEnd(9, 9, false); pen.SetCustomEndCap(&capEnd); break; } case Gdiplus::LineCapTriangle: { Gdiplus::AdjustableArrowCap capEnd(6, 5, true); pen.SetCustomEndCap(&capEnd); break; } case Gdiplus::LineCapDiamondAnchor: { Gdiplus::Point points[4] = {Gdiplus::Point(rcButton.right - 10 , yPos ), Gdiplus::Point(rcButton.right - 5, yPos + 5), Gdiplus::Point(rcButton.right, yPos), Gdiplus::Point(rcButton.right - 5, yPos - 5)}; endCapPath.AddPolygon(points, 4); break; } case Gdiplus::LineCapRoundAnchor: { Gdiplus::Rect rect(rcButton.right - 10, yPos - 5, 10, 10); endCapPath.AddEllipse(rect); break; } default: break; } if (!m_bEnabled) { pen.SetColor(Gdiplus::Color(255, 128, 128, 128)); brush.SetColor(Gdiplus::Color(255, 128, 128, 128)); } gdipGraphics.DrawLine(&pen, Gdiplus::Point(rcButton.left + 2, yPos), Gdiplus::Point(rcButton.right-2, yPos)); gdipGraphics.FillPath(&brush,&startCapPath); gdipGraphics.FillPath(&brush,&endCapPath); } }