1 registered members (TipmyPip),
18,619
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Mouse entity.
[Re: flits]
#209665
06/04/08 20:00
06/04/08 20:00
|
Joined: May 2008
Posts: 73 Richmond, VA (USA)
coma_dose
OP
Junior Member
|
OP
Junior Member
Joined: May 2008
Posts: 73
Richmond, VA (USA)
|
This isn't what I need. This code converts 2d screen coordinates into 3d world coordinates and places an object at that location.
What I need is help with code that places a view entity at the mouse location in the view, not the 3d world; the thing that gets me is that the x/y/z locations for a view entity are different than the x/y/z locations in the 3d world.
X is the depth, how close the view entity is to the screen.
Y is the horizontal placement, setting it to 0 puts the view entity in the middle of the screen on the Y axis instead of at the left side.
Z is the vertical placement, setting it to 0 puts the view entity in the middle of the screen on the Z instead of the top.
So what I need help with is converting the regular screen coordinates (mouse_pos.x, mouse_pos.y) to a number that can place the view entity at the mouse position.
What I tried to do is set the view entity to mouse_pos.x and mouse_pos.y, needless to say that lead to a messed up result. I then subtracted half of the screen width and height which worked, but the vector was inverted: pushing the mouse left moved the view entity right, moving the mouse up moved the view entity down, etc... I tried to invert the vector again to make negatives positive and positives negative, but the result was the view entity being really messed up.
|
|
|
Re: Mouse entity.
[Re: coma_dose]
#209672
06/04/08 20:54
06/04/08 20:54
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
i tried to do it myself many time but all tryes wher a bit wrong but came close
i gues you are searching for this
vec_for_screen ( VECTOR*, VIEW*);
"empty"
|
|
|
Re: Mouse entity.
[Re: flits]
#209690
06/05/08 03:17
06/05/08 03:17
|
Joined: May 2008
Posts: 73 Richmond, VA (USA)
coma_dose
OP
Junior Member
|
OP
Junior Member
Joined: May 2008
Posts: 73
Richmond, VA (USA)
|
I actually HAVE done it before! It was great, the cursor worked wonderfully and had effects like it spun around and always pointed away from the center of the screen. I cannot for the life of me remember. Heck, I even found the old cursor model that I used, just can't find the code.
vec_for_screen doesn't really do what I need, it would work for using the mouse map or a panel. Using a view entity means that coordinates 0,0 would be in the exact center of the screen; with my screen size (1280x1024), it would mean that I would need screen coordinates of -640 to +640 for the horizontal placement and -512 to +512 for the verticle placement;if I was using a panel, then 0,0 would be in the upper left. I'm sure that you know what I mean now.
I will take a good look at this again tonight, I'll see what memories I can jog. I am also compiling my cool achievements into a wdl file to distribute. I have altered a lot of code for personal use and have come up with some really nice functions. Like I have a rotational function for a 3rd person space ship shooter that boils down to one function and will roll with the pan angles and correct itself when the ship isn't turning so hard, etc.
EDIT: CRAP! I think I remembered! LOL I'll post later.
Last edited by coma_dose; 06/05/08 03:18.
|
|
|
Re: Mouse entity.
[Re: coma_dose]
#209723
06/05/08 09:02
06/05/08 09:02
|
Joined: Apr 2006
Posts: 159 Latvija
Arrovs
Member
|
Member
Joined: Apr 2006
Posts: 159
Latvija
|
That is so easy! Of course when i first time try get models in view that was quit difficulty, but now peace of cake!
Then code here:
ENTITY peksi ////////this is model in view - that mean when it //never will make trobles in game world! { type = "earth.mdl"; layer = 11; view = camera; }
//this write into your mouse function behind pos and cursor //sinhronyzing! temp.x = mouse_pos.x;//we now give three vectors for model temp.y = mouse_pos.y; temp.z=500; vec_for_screen(temp,camera);//convert them in view peksi.x = temp.x;//give new coordinates to model in view peksi.y = temp.y; peksi.z = temp.z; //and vuala - model moves together with mouse positions
if you want that model rolling and doing all kind effects then i hope how to done it!
Arrovs once will publish game
|
|
|
Re: Mouse entity.
[Re: Arrovs]
#209776
06/05/08 17:23
06/05/08 17:23
|
Joined: May 2008
Posts: 73 Richmond, VA (USA)
coma_dose
OP
Junior Member
|
OP
Junior Member
Joined: May 2008
Posts: 73
Richmond, VA (USA)
|
I had to change it to rel_for_screen to get it to work properly. I'll work on the rotational effects and re-post.
Last edited by coma_dose; 06/05/08 17:25.
|
|
|
|