Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 1,258 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 2 of 2 1 2
Re: accurate mouse3d function [Re: mpdeveloper_B] #166954
11/30/07 05:22
11/30/07 05:22
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline
User
MrCode  Offline
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
Anyone know how I could use this code (or code like this) to pick up a physics entity with the mouse? I've been having difficulty with this (I even started a thread that never got answered ), and this is an integral part of my biggest project right now.

Please answer this


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: accurate mouse3d function [Re: MrCode] #166955
02/27/08 08:08
02/27/08 08:08
Joined: Dec 2004
Posts: 237
H
Hani Offline
Member
Hani  Offline
Member
H

Joined: Dec 2004
Posts: 237
hi,
i'm testing this code with A7.07 , but i'm not getting the same results ,
insted i'm having bad results , the object is sometime created to the left or right of my mouse curcer .

any idea ?


The deference between madness and geniuses is success
Re: accurate mouse3d function [Re: Hani] #166956
03/26/08 22:45
03/26/08 22:45
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline OP
Expert
Joozey  Offline OP
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Probably because you have no mouse function.
Mouse_dir3d depends on mouse_pos, but when you do not assign the cursor.x to mouse_pos, it remains 0,0. Making a trace scan from camera to (0,0) instead of your real mouse position could cause some trouble.

*just found out myself the hard way*


Click and join the 3dgs irc community!
Room: #3dgs
Re: accurate mouse3d function [Re: Joozey] #215921
07/14/08 02:13
07/14/08 02:13
Joined: Jun 2008
Posts: 19
H
halfpint Offline
Newbie
halfpint  Offline
Newbie
H

Joined: Jun 2008
Posts: 19
Edit: Fixed my first problem but i don't want you to be able to load entities on top of each other, so i tried to use scan texture for the warlock model but i cant get it too work so if anyone could help me out that would be very helpful. I have the general idea i am probably just missing one thing.

So this is my attempt after all the vector stuff:

c_trace (camera.x,mouse_click,IGNORE_PASSABLE | SCAN_TEXTURE | IGNORE_MODELS);
string model_name = "warlock.mdl";
if ((str_cmpi (model_name,tex_name)) ==0 )
{
ent_create ("warlock.mdl" , target.x,NULL);
}

this all works for creating the entity but it will still make it even if im on top of another one which is what im trying to make it not do. Also im using c-script. Thanks.

Last edited by halfpint; 07/14/08 08:55.
Re: accurate mouse3d function [Re: halfpint] #222929
08/21/08 17:07
08/21/08 17:07
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
use
Code:
if(!mouse_ent){
//do your sexy thang
}


then if you click on a model it'll be ignore laugh
though if you want something more than that you'll need to set up a basic node storage and work with tiles

Re: accurate mouse3d function [Re: MrGuest] #299743
11/26/09 15:54
11/26/09 15:54
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline OP
Expert
Joozey  Offline OP
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Here is a working code for isometric view:

Code:
VECTOR mouse_click;

void mouseTo3D() {
	while (1) {
		if (mouse_left) {
			
			vec_set (mouse_click, mouse_dir3d); //get direction vector from mouse to world
			vec_normalize(mouse_click, 4000); //give it a large distance for tracing
			vec_add (mouse_click, mouse_pos3d); //calculate from camera mouse in 3d position
		
			c_trace (mouse_pos3d, mouse_click, IGNORE_MODELS); //trace from isometric 3d mouse position to clicked position (= mouse position + 4000 in depth)
			
			vec_set( mouse_click, target );
			ent_create ("warlock.mdl", mouse_click, NULL); //accurate warlock placement!
			
		}
	wait(1);
	}
}




Click and join the 3dgs irc community!
Room: #3dgs
Page 2 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | 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