# ID3DXLine::DrawTransform() anyone ever gotten it to work?

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

## Recommended Posts

I just spent all day with this beast. It sure dosnt draw lines the way you think it would. I imagined it to be like this: Draw() draws in screenspace, great. And with DrawTransform you can draw in "3d". But nooo! DrawTransform dosnt want to do much drawing at all infact. I cant for my life figure out what matrix'es it want. What i want to do is to draw the bounding box around a mesh. So i calc min and max vectors. And then calculate the other points and try to draw lines between them. (in this code just for testing i just try to draw from min to max) It draws nothing at all, infact only if i send it a ident matrix i can get some result out of it, and that apperas to be in screenspace. If you are thinking about this line: D3DXMATRIX temp_matrix = world_matrix*view_matrix*proj_matrix; Aha! Wrong order. Wrong. Iv tried all possible combinations of adding em together, and not, and adding just two, or one. etc. Soo.. Anyone know what you are supposed to do to get this to work?
void mesh_d3d_t::render_bounding_box()
{
IDirect3DDevice9* d3d_device = m_graphics_manager->get_d3d_device();
ID3DXLine* d3dx_line = m_graphics_manager->get_d3dx_line();

d3dx_line->Begin();
D3DXVECTOR3 point_list[2];
point_list[0].x = m_bb_min.x;
point_list[0].y = m_bb_min.y;
point_list[0].z = m_bb_min.z;
point_list[1].x = m_bb_max.x;
point_list[1].y = m_bb_max.y;
point_list[1].z = m_bb_max.z;

D3DXMATRIX world_matrix;
d3d_device->GetTransform(D3DTS_WORLD, &world_matrix);
D3DXMATRIX proj_matrix;
d3d_device->GetTransform(D3DTS_PROJECTION, &proj_matrix);
D3DXMATRIX view_matrix;
d3d_device->GetTransform(D3DTS_VIEW, &view_matrix);

// draw
D3DXMATRIX temp_matrix = world_matrix*view_matrix*proj_matrix;
d3dx_line->DrawTransform(point_list, 2, &temp_matrix, D3DCOLOR_XRGB(255,255,255));
d3dx_line->End();
}



##### Share on other sites
ID3DXLine::DrawTransform performs the transformation with the input vertices expected in *screen space.* Essentially ID3DXLine is meant for 2D lines.

You can always do the transformations from world space to screen space yourself...

##### Share on other sites
ID3DXLine is in a messed up state at the moment. At this point I don't remember how or why, but DrawTransform() never worked, and other functions like SetAntialias(), SetPattern(), and SetWidth() didn't work either. I would suggest just making your own wrapper thing to draw lines.

##### Share on other sites
how about using linestrips or linelist with the DrawPrimitive() function?
Should do what you want, I guess... though I don´t know nothing about ID3DXLines

1. 1
2. 2
Rutin
15
3. 3
4. 4
5. 5

• 9
• 9
• 14
• 12
• 10
• ### Forum Statistics

• Total Topics
633268
• Total Posts
3011143
• ### Who's Online (See full list)

There are no registered users currently online

×