• Advertisement

DirectxTK and basic concept of drawing models

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Advertisement