I tried to draw a simple aline in 3D but it never gets a perspective in the scene, even If I supplied the shader with the correct projection view matrix of the camera.
Here is my setup:
Code: Select all
BulletDebugDrawer::BulletDebugDrawer(cGraphics *graphics)
{
if (graphics != nullptr)
{
m_pGraphics = graphics;
}
line = std::unique_ptr<PrimitiveBatch<VertexPositionColor>>(new PrimitiveBatch<VertexPositionColor>(m_pGraphics->getContext()));
basicEffect = std::unique_ptr<BasicEffect>(new BasicEffect(m_pGraphics->getDevice()));
basicEffect->SetProjection(m_pGraphics->getViewProjectionMatrix());
basicEffect->SetVertexColorEnabled(true);
void const* shaderByteCode;
size_t byteCodeLength;
basicEffect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength);
m_pGraphics->getDevice()->CreateInputLayout(VertexPositionColor::InputElements,
VertexPositionColor::InputElementCount,
shaderByteCode, byteCodeLength,
inputLayout.GetAddressOf());
}
void BulletDebugDrawer::drawLine(const btVector3& from, const btVector3& to, const btVector3& lineColor)
{
CommonStates states( device );
m_pGraphics->getContext()->OMSetBlendState( states.Opaque(), nullptr, 0xFFFFFFFF );
m_pGraphics->getContext()->OMSetDepthStencilState( states.DepthNone(), 0 );
m_pGraphics->getContext()->RSSetState( states.CullCounterClockwise() );
basicEffect->Apply(m_pGraphics->getContext());
m_pGraphics->getContext()->IASetInputLayout(inputLayout.Get());
line->Begin();
line->DrawLine(VertexPositionColor(XMFLOAT3(from.x(), from.y(), from.z()), XMFLOAT4(1, 0, 1, 1)),
VertexPositionColor(XMFLOAT3(to.x(), to.y(), to.z()), XMFLOAT4(1, 0, 1, 1)));
line->End();
}