Hi, I am completely newbie. I've been reading about DirectX for 2, 3 months now and the only thing I am able to do is to draw a simple model on a scene (with lighting).
I started to do things using DirectXTK. But I think I don't understand some basic concepts, so maybe someone would be so kind and will explain them for me.
So I tried to create basic scene with anchor and some models. By anchor I mean just x, y, z axes.
So I did something like that (I am using basic examples from here: https://github.com/Microsoft/DirectXTK/wiki/Getting-Started
Vector3 originVector(0.f, 0.f, 0.f);
m_batch->Begin();
m_batch->DrawLine(VertexPositionColor(originVector, Colors::Red), VertexPositionColor(Vector3::UnitX, Colors::Red));
m_batch->DrawLine(VertexPositionColor(originVector, Colors::Yellow), VertexPositionColor(Vector3::UnitY, Colors::Yellow));
m_batch->DrawLine(VertexPositionColor(originVector, Colors::Green), VertexPositionColor(Vector3::UnitZ, Colors::Green));
m_batch->End();
Batch is just primitive batch(with VertexPositionColor) that I use to drawing axes.
This code gives me beautiful colorful axes.
But now I wanted to add a model. Simple sphere. So I did (before drawing axes):
m_shape->Draw(m_world, m_view, m_proj, Colors::Red);
(m_world is identity matrix)
And then first problem arouse. My axes now all have red color. Actually they get the color that my sphere has. Why is that?
Next, I wanted to move the sphere somewhere else, so I did:
Matrix m1 = Matrix::CreateTranslation(Vector3(-5.f, -2.f, -5.f));
m_shape->Draw(m1, m_view, m_proj, Colors::Red);
And what happened? My axes moved with the sphere. Now they are not drawn in place that I wanted, but they "come from inside" the sphere. Why is that?