Mouse in 3D

Posted By: Liamissimo

Mouse in 3D - 06/08/10 17:20

Hey,

it is very simple but I cant figure it out. I already did it and it worked but when i use the same code it isnt working. The block is coming from a special point to me. it isnt using the mouse pos.

if(mouse_left == 1)
{
vec_set(to, mouse_dir3d);
vec_scale(to, 1000);
c_trace(camera.x, to, 0);
vec_set(to,target);
ent_create("block.mdl",to,NULL);
}

yes, simple as hell. But the point is when I start at nullvector, it is in the upper left corner of the screen.
Posted By: Pappenheimer

Re: Mouse in 3D - 06/08/10 17:34

Do you have a plane within the range of 1000, that the trace can hit?
Posted By: Liamissimo

Re: Mouse in 3D - 06/08/10 17:37

no, the distance was 1400, now i changed it into scale 2000. Still downst work
Posted By: DJBMASTER

Re: Mouse in 3D - 06/08/10 18:11

Have you locked the mouse position to the cursor? Do this in the main function/while loop.
Code:
while (1)
  {  
    mouse_pos.x = mouse_cursor.x;    
    mouse_pos.y = mouse_cursor.y;
    wait(1);
  }


Posted By: Liamissimo

Re: Mouse in 3D - 06/08/10 20:33

doesnt work... sorry laugh

Code:
var schalten = 0;
function setzen()
{
	VECTOR to;
	while(1)
	{
		if(mouse_left == 1)
		{
		 	vec_set(to,mouse_dir3d);
 			vec_scale(to,2000); 
 			vec_add(to,mouse_pos3d);
 			c_trace(mouse_pos3d,to,USE_BOX | IGNORE_MODELS | IGNORE_SPRITES);
 			vec_set(to,target.x);
			if(schalten == 0)
			{
				ent_create("block.mdl",mouse_pos3d.x,NULL);
			}
		}
  	   wait(1);
	}
}
function scroller()
{
	var lastkey = 0;
	while(1)
	{
		if(mouse_right == 1 && schalten < 6)
		{
			schalten += 1*time_step/2;
		}	
		if(schalten >=6)
		{
			schalten = 0;
		}
		wait(1);
	}
}
PANEL* schalte_pan =
{
	pos_x = 0; pos_y = 0;
	layer = 1;
	digits(0,0,2,Arial#20b,1,schalten);
	flags |= (SHOW);
}
function main()
{
	mouse_mode = 4;
	video_set(1024,768,0,0);
	level_load("leer.wmb");
	wait(1);
	scroller();
	setzen();
	while (1)
 	{  
   	mouse_pos.x = mouse_cursor.x;    
   	mouse_pos.y = mouse_cursor.y;
   	wait(1);
  	}
}


Posted By: keilyn3d

Re: Mouse in 3D - 06/08/10 22:41

if what you want is create the block in the position of the wall or floor that you clicked change the ent_create line to this:
ent_create("block.mdl",hit.x,NULL);
Posted By: Liamissimo

Re: Mouse in 3D - 06/09/10 13:12

OK genius, it works grin
© 2024 lite-C Forums