is it possible to draw the ray D3DXIntersect creates? , DrawLine only draws x , y cordinates and not z ,
is it possible to draw the ray D3DXIntersect creates? , DrawLine only draws x , y cordinates and not z ,
You would have to create a primitive using the ray. Using the parametric form you should be able to cast a ray using the info from D3DXIntersect and a set distance.
but no primitive would be able to be drawn on the z axis
Sure it can. Given a 3D vector and a distance:
Code:#ifndef VERTEX_H #define VERTEX_H struct Vertex { float x,y,z; float u,v; Vertex():x(0.0f),y(0.0f),z(0.0f),u(0.0f),v(0.0f) { } Vertex(float x,float y,float z,float u, float v):x(x),y(y),z(z),u(u),v(v) { } static const DWORD FVF; }; #endifWhat do you mean you cannot draw a primitive on the z axis?Code:#include "Vertex.h" const DWORD Vertex::FVF = D3DFVF_XYZ | D3DFVF_TEX1; Vertex Vertices[4]; void CreateVerticesFromRay(D3DXVECTOR3 vecRay, float dist) { D3DXVec3Normalize(&vecRay,&vecRay); Vertices[0] = Vertex(0.0f,0.0f,0.0f,0.0f,0.0f); Vertices[1] = Vertex(vecRay.x * dist,0.0f,0.0f,1.0f,0.0f); Vertices[2] = Vertex(0.0f,0.0f,vecRay.z * dist,0.0f,1.0f); Vertices[3] = Vertex(vecRay.x * dist,0.0f, vecRay.z * dist,1.0f,1.0f); }
i cant seem to make the line transformed so if the ray moves , so does the line to show where the ray is , it seems like the line is just stuck on front of the screen with no z direction etc...here is a screen shot
http://img86.imageshack.us/my.php?image=d3dlinest6.jpg
That's not much help. Post some code and I can help fix it. Incorrect rendering can be caused by incorrect projection matrices, incorrect translation/rotation/scaling/shearing, etc, etc matrices and so on. There are an inumerable about issues that could be happening. Guessing won't help you any so post the code that's drawing the line and setting the system up.
DXCreateCylinder(d3dDevice, 0.5, 0.5, 4000, 8, 8, &m_RayMesh, NULL);
D3DXMatrixInverse(&matRayWorld, NULL, &matView);
bitmatRayWorld._42 -= 1.0f;
meshd3dDevice->SetTransform(D3DTS_WORLD, matRayWorld);
m_RayMesh->DrawSubset(0);
this should draw the ray now right ? , RayPos ,
Last edited by Anddos; 02-10-2008 at 05:09 AM.