|
1 registered members (AndrewAMD),
6,385
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Silly question about players PAN
[Re: 3run]
#348993
12/02/10 17:52
12/02/10 17:52
|
Joined: Feb 2010
Posts: 886
Random
User
|
User
Joined: Feb 2010
Posts: 886
|
3run I think you already made that. Look at the codes in youre webside. But do you meen it like this?; action move_pan_with_mouse_guy() { player = my; set (my, INVISIBLE);
vec_set (camera.x, player.x); camera.z += 35; camera.pan -= 6 * mouse_force.x * time_step; player.pan = camera.pan; wait (1); } }Red is the colure youre looking for  Random
|
|
|
Re: Silly question about players PAN
[Re: Random]
#348995
12/02/10 18:04
12/02/10 18:04
|
Joined: May 2009
Posts: 5,377 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,377
Caucasus
|
Dude  That way, players PAN will change only when you move mouse to the left and right ^^ And I need to be able to turn it by 'mouse_force.x' together with 'mouse_force.y' (up and down). So as I said when I move mouse in circle player will turn around for 360 digress. I use ISOMETRIC flag on camera (so it's TOP VIEW). Camera has it's own non turning PAN. Only pan that need to be changed is PLAYERS PAN. And with only 'mouse_force.x' it will be really uncomfortable. Any ideas how to make player turn around with mouse? I though about making it look at the cursor (with using of 'mouse_mode'), that way it will be a bit better I guess, but I don't need to have a cursor on screen...
|
|
|
Re: Silly question about players PAN
[Re: 3run]
#349022
12/03/10 08:06
12/03/10 08:06
|
Joined: Feb 2010
Posts: 320 TANA/Madagascar
3dgs_snake
Senior Member
|
Senior Member
Joined: Feb 2010
Posts: 320
TANA/Madagascar
|
Hi! I know that it is not what you really want  , but I think it does what you want to do (here, I use mouse_pos, not mouse_force  , If you want to use mouse_force, you need to do more calculations, perhaps you need to store the last mouse pos and do the calculations with the curent mouse pos, add or substract angles depending on mouse pos - I think you get the Idea ). Bellow is the code
#include <acknex.h>
#include <default.c>
#include <camera.c>
FONT *fnt_arial = "Arial#14" ;
var force_x = 0 ;
var force_y = 0 ;
PANEL *pan_mouseForce =
{
digits ( 0, 0, "mouse_force.x = %0.2f", fnt_arial, 1, force_x ) ;
digits ( 0, 10, "mouse_force.y = %0.2f", fnt_arial, 1, force_y ) ;
flags = SHOW ;
}
void main()
{
video_mode = 4 ;
mouse_mode = 4 ;
mouse_pointer = 0 ;
// Load level
level_load ( "" ) ;
ENTITY *ent_player = ent_create ( "cube.mdl", nullvector, NULL ) ;
camera.tilt = -90 ;
camera.flags |= ISOMETRIC ;
vec_set (camera.x, ent_player.x) ;
camera.z += 20 ;
camera.arc = 10 ;
VECTOR vec_mouse ;
while(1)
{
// Transform mouse coordinates to screeen coordinates
vec_set ( &vec_mouse, mouse_pos ) ;
vec_for_screen ( &vec_mouse, camera ) ;
// Transform coordinates to entity coordinates
vec_sub ( &vec_mouse, ent_player.x ) ;
// Calculate rotation angle from mouse position, centered to the player
ent_player.pan = atan2v(vec_mouse.y, vec_mouse.x);
// Debug
force_x = mouse_pos.x ;
force_y = mouse_pos.y ;
wait(1);
}
}
Best regards.
Last edited by 3dgs_snake; 12/03/10 08:14. Reason: Added mouse_pointer = 0 to hide the mouse cursor
|
|
|
Re: Silly question about players PAN
[Re: 3run]
#349040
12/03/10 12:17
12/03/10 12:17
|
Joined: Feb 2010
Posts: 320 TANA/Madagascar
3dgs_snake
Senior Member
|
Senior Member
Joined: Feb 2010
Posts: 320
TANA/Madagascar
|
I tried to normalize the transformed coordinates bya a radius amount
vec_sub ( &vec_mouse, ent_player.x ) ;
vec_normalize( &vec_mouse, radius ) ;
but  that doesn't seem to work.
|
|
|
Re: Silly question about players PAN
[Re: 3run]
#349043
12/03/10 13:18
12/03/10 13:18
|
Joined: Feb 2010
Posts: 320 TANA/Madagascar
3dgs_snake
Senior Member
|
Senior Member
Joined: Feb 2010
Posts: 320
TANA/Madagascar
|
 I think you found it! At least, it is better than my previous code. Perhaps smoothing the rotation will make it look beter.
#include <acknex.h>
#include <default.c>
#include <camera.c>
// Ray radius
var ray_radius = 20 ;
FONT *fnt_arial = "Arial#14" ;
var force_x = 0 ;
var force_y = 0 ;
PANEL *pan_mouseForce =
{
digits ( 0, 0, "mouse_force.x = %0.2f", fnt_arial, 1, force_x ) ;
digits ( 0, 10, "mouse_force.y = %0.2f", fnt_arial, 1, force_y ) ;
flags = SHOW ;
}
VECTOR vec_mouse;
VECTOR temp;
void main()
{
video_mode = 4;
mouse_mode = 4;
mouse_pointer = 0;
level_load("");
ENTITY *ent_player = ent_create("cube.mdl",nullvector,NULL);
camera.tilt = -90 ;
set(camera,ISOMETRIC);
vec_set(camera.x,ent_player.x);
camera.z += 20;
camera.arc = 10 ;
while(1)
{
vec_set(&vec_mouse,mouse_pos);
vec_for_screen(&vec_mouse,camera);
vec_diff(temp,vec_mouse.x,ent_player.x);
vec_normalize(temp,100);
vec_add(temp,ent_player.x);
vec_sub(&vec_mouse,ent_player.x) ;
ent_player.pan = atan2v(vec_mouse.y,vec_mouse.x);
wait(1);
}
}
|
|
|
|