Jump to content
  • Advertisement
Sign in to follow this  
savail

How to use third parameter in D3DXVECTOR3 ?

This topic is 2783 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey
I was trying to render 3 images on my sreen and put some of them behind each other:
My render function:
void Input::DrawSprite(int pos_x, int pos_y, int z, int left, int top, int right, int bottom, bool mirror, int tex_nr)
{
RECT rct;
SetRect(&rct, left, top, right, bottom);

D3DXVECTOR3 pos(pos_x, pos_y, z);
D3DXVECTOR3 pos2(-80, 0, z);

if(mirror == true)
{
D3DXVECTOR2 position( pos_x, pos_y );
D3DXVECTOR2 spriteCentre=D3DXVECTOR2(pos_x,pos_y);
float rotation=0.0f;
D3DXVECTOR2 scaling(-1.0f,1.0f);
D3DXMATRIX mat;
D3DXMatrixTransformation2D(&mat, NULL, 0.0,&scaling,&spriteCentre,rotation,&position);
Sprite->SetTransform(&mat);

Sprite->Draw(Texture[tex_nr], &rct, NULL, &pos2, 0xFFFFFFFC);

D3DXMatrixIdentity(&mat);
Sprite->SetTransform(&mat);

}
else
Sprite->Draw(Texture[tex_nr], &rct, NULL, &pos, 0xFFFFFFFC);
}

Here are images I want to draw in correct order:
Image1 - background - behind all other images, I give it "z" = 0
image2 - small sprite - on the background, I give it "z" = 2
image3 - small sprite - behind image2, I give it "z" = 1
However only background (image1) is drawn, image2 and image3 are drawn behind it... How to put these images correctly as I wanted? I tried putting "z" = 3 for image1 but then only image3 was drawn

Share this post


Link to post
Share on other sites
Advertisement
z has to be in range 0.0 < z < 1.0. Depending on your viewport eigther lower valzes or higher ones will be drawn on top.

Share this post


Link to post
Share on other sites
hmm so I've changed the values to the range of 0 - 1 but the effect is still the same. I haven't set any Viewport function yet. Might that be the problem?
edit: My mistake, I've been putting wrong values. I thought that higher the value is the closer image is written

Share this post


Link to post
Share on other sites
Assuming a left handed system, the Z axis points into the screen, so objects with a larger Z are further from the camera.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!