sorry maybe its me bein an idiot or bein lazy but wat is the problem, do u get a error message that u need help with or wat is the bug u r talkin about (ie wat happens that u dont want it to)
The bug is because the ray is incorret position, i want shot and make the ray go to front of player, but it go to a fixed position how you can see on game when you shot (left mouse click or control key).
Im trying make the shot going to front, but it go to a diferent position, and i dont know what i make incorrect.
I see others examples but all is based on the camera and use 1st camera position, but on my game i have to do all based on player position...
i downloaded ur game and i can see the problem now, well i can see the start position of the ray is correct but the direction the ray points to and ends is incorrect, no matter where u go on the map it always wants to point and end in the same direction
sorry but im nt the best at using line3d but i would suggest lookin the line ray.end..., the only way i can explain wat i think u could do is:
wen the ray is started get the position AND rotation of the node, then wen settin the end create it so it goes 1000.0f, nt sure if this will work but worth a try
Thx, but im already see it, and it is make from the camera... i want start from node...its different..i dont understand how to do it from de node and not from de camera.
From the camera has too much examples...but not frm the node.
jogadores[0] => my player class that have a node object in it
start => start position of line
end => end position of line
500 => length of line (distance)
When I think about it now, there might be problem with my code. If your node is scaled, endpoint will be scaled too. Instead of m.transformVect(rayend); you may want to use this code:
jogadores[0]->getNode()->updateAbsolutePosition();
vector3df start= jogadores[0]->getNode()->getPosition();
matrix4 m = jogadores[0]->getNode()->getAbsoluteTransformation();
vector3df end(500,0,0);
m.rotateVect(end);
end += start;
driver->draw3DLine(start, end);
Transformation matrix consist of position, rotation and scale. its only first two you need.
Also updating absolute position might or might not be necessary. Try to remove it to see whats happen. If not sure, let it be, it won't hurt.
Easiest is via node bounding box: bool irr::core::aabbox3d< T >::intersectsWithLine()
Its fast but not too precize. It is ofthen sufficient but if not you whould use some kind of triangle selector on tested node then use bool irr::core::triangle3d< T >::getIntersectionWithLimitedLine().