|
Highlighting bounding box
#255636
03/11/09 16:19
03/11/09 16:19
|
Joined: Aug 2004
Posts: 1,345 Kyiv, Ukraine
VeT
OP

Serious User
|
OP

Serious User
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
|
After model creation and rotation, i set c_setminmax(me); Then, i use standard function
function draw_bbox(ENTITY* ent)
{
VECTOR vMin, vMax;
while(1)
{
vec_set(vMin,ent.x);
vec_add(vMin,ent.min_x);
vec_set(vMax,ent.x);
vec_add(vMax,ent.max_x);
draw_box3d(vMin,vMax,vector(0,0,255),100);
wait(1);
}
}
i use it in
void InitMouseEvent()
{
while(1) {
if(mouse_ent) {
if(mouse_left == 1) {
ent_morph(mouse_ent,sHandleModelName);
draw_bbox(mouse_ent);
}
 Why its so different? debugging bounding boxes are more correct than draw_bbox(), but last one also use ent.min_x... so why this trouble can come?
Last edited by VeT; 03/11/09 16:44.
|
|
|
Re: Highlighting bounding box
[Re: VeT]
#255648
03/11/09 18:05
03/11/09 18:05
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
I think things are getting messy if your entity world co-ord goes negative. Then that happens I think you need to swap placement of vMin and vMax.
Because draw_box3d expects the "from" parameter to be smaller than the "to" ?? Thats the way i read it..
[EDIT] My bad, complete lie. After testing the order of draw_box3d 1st & 2nd params doesnt matter. BUT it doesnt take into account any rotation of the entity. I have no idea how to get around that...
Last edited by EvilSOB; 03/11/09 18:38. Reason: Completely wrong!
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Highlighting bounding box
[Re: EvilSOB]
#255659
03/11/09 19:22
03/11/09 19:22
|
Joined: Mar 2009
Posts: 112 Germany
KDuke
Member
|
Member
Joined: Mar 2009
Posts: 112
Germany
|
Hi VeT, if draw_box3d doesn't take rotation into account, like EvilSOB said, you have to translate the vectors you give to draw_box3d yourself before calling the function. There are two practical ways of doing this. The first one I can think of would be a rotation matrix which you multiply with the vectors. The other would be quaternions. I won't go into detail of these two methods now as this would be too much as well as other resources in the internet will explain it much better than I am able to. Just try to throw "rotation matrix" and "quaternion" into google. Though I gotta warn you! These mathematics are anything but trivial! Most probably there is a better solution for this problem though that's the only idea I got now. greetings KDuke EDIT: There just comes a resource into my mind which might be very worthy at this approach. Game Physics Engine Development
Last edited by KDuke; 03/11/09 19:26.
Using A7 Free Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Highlighting bounding box
[Re: MokyjeBrute]
#255666
03/11/09 19:46
03/11/09 19:46
|
Joined: Mar 2009
Posts: 112 Germany
KDuke
Member
|
Member
Joined: Mar 2009
Posts: 112
Germany
|
Darn it!
I'm not really familiar with Lite-C (yet) so I didn't know of vec_rotate. This makes things easy. You simply have to use vec_rotate on both vectors before calling draw_box3d.
By the way, thanks for advising me of vec_rotate MokyjeBrute.
greetings KDuke
Last edited by KDuke; 03/11/09 19:47.
Using A7 Free Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Highlighting bounding box
[Re: KDuke]
#255673
03/11/09 20:19
03/11/09 20:19
|
Joined: Aug 2004
Posts: 1,345 Kyiv, Ukraine
VeT
OP

Serious User
|
OP

Serious User
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
|
Wow, thank you, guys, for answers
I dont understand, why i need to rotate bb(bounding box). I have an entity, then i rotate it and set new BB. So, logically, its looking like minimum and maximum points of BB may also be rotated(like on debug view)... i thought that blue box(box from debug panel) and my red box are build on the same points, max_x and min_x
|
|
|
|