Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,606 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Draws a correct 3D boundingBox #431424
10/16/13 00:26
10/16/13 00:26
Joined: Nov 2007
Posts: 318
Brasil, Paraná
NeoNeper Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
I have a problem when trying to Draws a correct 3D bounding box on 3D Entity with Roll, tilt and pan.

See picture for sample?
PIC 1 - Here I managed to correctly simulate the boundBox

http://uploaddeimagens.com.br/imagens/pic1-jpg--2

PIC 2 - In this second image, you can see that my function does not work when the object using Roll, Tilt and PAN
http://uploaddeimagens.com.br/imagens/pic2-jpg

My Script

Code:
VECTOR modelMin,modelMax;
while(1)
{
vec_set(modelMin,modelSelect.min_x);    
vec_rotate(modelMin,modelSelect.pan);			
vec_add(modelMin,modelSelect.x);		
			
vec_set(modelMax,modelSelect.max_x);
vec_rotate(modelMax,modelSelect.pan);
vec_add(modelMax,modelSelect.x);		
			
draw_box3d(modelMin,modelMax,vector(0,255,180),100);
wait(1);
}


Last edited by NeoNeper; 10/16/13 16:57.

Please! Use easy words to be translated. because my English is not very good! Grateful.
_______________________________________________________
Re: Draws a correct 3D bounding with draw_box3d() [Re: NeoNeper] #431425
10/16/13 01:32
10/16/13 01:32
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
You can't express a rotated box with just two points, you need to defined all four. Basically, use the draw line method to draw a line from all anchor points to their neighbours.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Draws a correct 3D bounding with draw_box3d() [Re: WretchedSid] #431469
10/16/13 14:27
10/16/13 14:27
Joined: Nov 2007
Posts: 318
Brasil, Paraná
NeoNeper Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
Thank JustSid i understand (^.~).
I used the same script to get the position of two corners of the object.

Code:
//corner 1
vec_set(corner1,modelSelect.min_x);			
vec_rotate(corner1,modelSelect.pan);
vec_add(corner1,modelSelect.x);
draw_point3d(corner1,COLOR_RED,100,2);	
	
//Corner2		
vec_set(corner2,modelSelect.max_x);			
vec_rotate(corner2,modelSelect.pan);
vec_add(corner2,modelSelect.x);
draw_point3d(corner2,COLOR_RED,100,2);





But I am with great difficulty in the other two corners. Could you send me an example?


Please! Use easy words to be translated. because my English is not very good! Grateful.
_______________________________________________________
Re: Draws a correct 3D bounding with draw_box3d() [Re: NeoNeper] #431473
10/16/13 15:56
10/16/13 15:56
Joined: Aug 2002
Posts: 3,258
Mainz
oliver2s Offline
Expert
oliver2s  Offline
Expert

Joined: Aug 2002
Posts: 3,258
Mainz
Here you go:

Code:
void draw_rotated_bbox(ENTITY* ent)
{
	VECTOR c1,c2,c3,c4,c5,c6,c7,c8;  
		
	vec_set(c1,vector(ent.min_x,ent.min_y,ent.min_z));    
	vec_rotate(c1,ent.pan);
	vec_add(c1,ent.x);
		
	vec_set(c2,vector(ent.max_x,ent.min_y,ent.min_z));    
	vec_rotate(c2,ent.pan);
	vec_add(c2,ent.x);
		
	vec_set(c3,vector(ent.max_x,ent.max_y,ent.min_z));    
	vec_rotate(c3,ent.pan);
	vec_add(c3,ent.x);
		
	vec_set(c4,vector(ent.min_x,ent.max_y,ent.min_z));    
	vec_rotate(c4,ent.pan);
	vec_add(c4,ent.x);
		
	vec_set(c5,vector(ent.min_x,ent.min_y,ent.max_z));    
	vec_rotate(c5,ent.pan);
	vec_add(c5,ent.x);
		
	vec_set(c6,vector(ent.max_x,ent.min_y,ent.max_z));    
	vec_rotate(c6,ent.pan);
	vec_add(c6,ent.x);
		
	vec_set(c7,vector(ent.max_x,ent.max_y,ent.max_z));    
	vec_rotate(c7,ent.pan);
	vec_add(c7,ent.x);
		
	vec_set(c8,vector(ent.min_x,ent.max_y,ent.max_z));    
	vec_rotate(c8,ent.pan);
	vec_add(c8,ent.x);	
		
	draw_line3d(c1,NULL,100); 
	draw_line3d(c2,vector(0,255,0),100);
	draw_line3d(c3,vector(0,255,0),100);
	draw_line3d(c4,vector(0,255,0),100);
	draw_line3d(c1,vector(0,255,0),100);
		
	draw_line3d(c5,NULL,100);
	draw_line3d(c6,vector(0,255,0),100);
	draw_line3d(c7,vector(0,255,0),100);
	draw_line3d(c8,vector(0,255,0),100);
	draw_line3d(c5,vector(0,255,0),100);

	draw_line3d(c1,NULL,100);
	draw_line3d(c5,vector(0,255,0),100);
		
	draw_line3d(c2,NULL,100);
	draw_line3d(c6,vector(0,255,0),100);
		
	draw_line3d(c3,NULL,100);
	draw_line3d(c7,vector(0,255,0),100);
		
	draw_line3d(c4,NULL,100);
	draw_line3d(c8,vector(0,255,0),100);
}


Re: Draws a correct 3D bounding with draw_box3d() [Re: oliver2s] #431477
10/16/13 17:09
10/16/13 17:09
Joined: Nov 2007
Posts: 318
Brasil, Paraná
NeoNeper Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
Wonderful. It worked perfectly and was also very enlightening for me.
Now I can solve many other problems in my project.
I appreciate the attention. thank you


Please! Use easy words to be translated. because my English is not very good! Grateful.
_______________________________________________________

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1