Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Tue Mar 19, 2024 3:21 am

All times are UTC




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sat Jul 21, 2007 11:36 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
I have created a new function that maybe could be usefull.

Here an example of use into the display function in the skel.c:
Code:
void display(void)
{
raydium_camera_first_person_free_allinone();
if(raydium_key_last==1027)
    exit(0);
/* [ draw here ] */ raydium_ode_draw_all(0);
raydium_rendering_finish();
}


The variables and declarations could be placed in camera.c:
Code:
//Free FP camera
GLfloat rffp_cam_angle_x = 0;
GLfloat rffp_cam_angle_y = 90;
GLfloat rffp_cam_pos_x = 0;
GLfloat rffp_cam_pos_y = 0;
GLfloat rffp_cam_pos_z = 0;
GLfloat rffp_speed = 0.1;
GLint   rffp_sensibilite = 1;
int rffp_delta_x, rffp_delta_y;
dReal   *rffp_pos;

void raydium_camera_first_person_free_allinone()
{
    raydium_joy_key_emul();
    rffp_cam_pos_z += (raydium_trigo_sin(rffp_cam_angle_x+90)*raydium_joy_y*rffp_speed*raydium_trigo_sin(90-rffp_cam_angle_y));
    rffp_cam_pos_x += (raydium_trigo_cos(rffp_cam_angle_x+90)*raydium_joy_y*rffp_speed*raydium_trigo_sin(90-rffp_cam_angle_y));
    rffp_cam_pos_y += (raydium_trigo_cos(90-rffp_cam_angle_y)*rffp_speed*raydium_joy_y);
   
    rffp_cam_pos_x -= (raydium_trigo_cos(rffp_cam_angle_x)*raydium_joy_x*rffp_speed);
    rffp_cam_pos_z -= (raydium_trigo_sin(rffp_cam_angle_x)*raydium_joy_x*rffp_speed);
    raydium_joy_key_emul();

    rffp_delta_x = raydium_mouse_x - (raydium_window_tx/2);
    rffp_cam_angle_x += (rffp_delta_x*rffp_sensibilite*0.1f);

    rffp_delta_y = raydium_mouse_y - (raydium_window_ty/2);
    rffp_cam_angle_y += (rffp_delta_y*rffp_sensibilite*0.1f);

    raydium_mouse_move(raydium_window_tx/2, raydium_window_ty/2);
    raydium_clear_frame();
    raydium_camera_place(rffp_cam_pos_x,rffp_cam_pos_y,rffp_cam_pos_z,rffp_cam_angle_x,rffp_cam_angle_y,0);
    raydium_camera_replace();
}


Usefull? Should it be added to raydium?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 08, 2007 10:58 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
OK with the idea, but there's a few problems I see now:

- variable names should follow the usual raydium naming style (__global in common.h and raydium_camera_.... names) or (better I think) declared in the function as static.
- the function should use directly keyboard, not joystick emulation (raydium_key[GLUT_KEY_UP] and so on ...)
- a camera function is not supposed to clear the framebuffer

... then the function name should be something like void raydium_camera_mouselook(void) I think.

Ok for you ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 1:27 pm 
Offline

Joined: Sun Oct 09, 2005 10:46 pm
Posts: 759
Hello,

I think this kind of function is missing to raydium.

Often, display function incorpore the same camera orbit move code.

So i vote Yes !

Bye
Ouille


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 4:01 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Xfennec wrote:
variable names should follow the usual raydium naming style (__global in common.h and raydium_camera_.... names) or (better I think) declared in the function as static.

Of course, this is just an idea. It has to be cleaned.

Quote:
the function should use directly keyboard, not joystick emulation (raydium_key[GLUT_KEY_UP] and so on ...)
Why? ...I only wanted to allow joystick users to move also with it. Using direct keys will remove the ability to use joystick? And i think this function is focus to developers testing, it won't be used in the 99% of the final applications, so it doesn't matter, i think, if it has a few "extras". right?

Quote:
a camera function is not supposed to clear the framebuffer
Not sure... again, why? Anyway i think putting in the main code a clear function is not so bad, so ok. But i'm not sure which is the reason.

Quote:
then the function name should be something like void raydium_camera_mouselook(void) I think.
Mmm, that name don't show the possibility of move, just of look around with the mouse.
Maybe raydium_camera_auto() or raydium_camera_fps() or raydium_camera_... i'm not too imaginative right now... more ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 6:01 pm 
Offline

Joined: Sun Oct 09, 2005 10:46 pm
Posts: 759
Hello,

Perhaps splitting in
Code:
raydium_camera_orbit()


and

Code:
raydium_camera_move


can also give parameter for orbit and mov, those parameter can be mouse / keyboard / joystick as user want.

last all of this included in a

Code:
 raydium_camera_fps


Bye Ouille


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 6:05 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
I think we don't see the same function. For me, this code is supposed to be just one more camera function, like the others, so the user is still responsible for clearing frame buffer (if he want) and emulating joystick (and he may not want that). An regular (not "debuging") application may want to this function too.

IMHO, removing these two simple calls (it's void(void) functions) from the display() don't make things simplier, it's only masking important possibilities to the user. And it can be confusing too, since other camera functions don't do this.

About the name, raydium_camera_fps() is quiet OK but can be confused with FPS abilities of RayODE and "frame per second", that's why mouselook seems better for me (mouselook is a quiet common word and implies, for me, the ability to move) but I see your point.
Perhaps "freemove" then ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 3:53 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
freemove is Ok for me.

I'm cleaing the code. Almost all the variables are nor static into the function but the next 2 are global(common.h):
__global GLfloat raydium_camera_freemove_sensibility;
__global GLfloat raydium_camera_freemove_speed;

Where could i initilize them?
Just before the freemove function(in camera.c)? in the common.h file? where?
Currently I bet for "Just before the freemove function".

autoresponse:
in init.c file, done.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 5:25 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Commit done.
Added the function and one silly demo.
Sadly, the second commit(the demo) has the same comment than the first... rapidsvn is a bad guy.

Clearframe is out, but joyemu is in (in my laptop doesn't work else)

Patches?updates?comments?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 6:22 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Nice !

but:
Quote:
+ //Xfennec don't like this :)
+ raydium_joy_key_emul();


For sure ! :)
What's the trouble when you remove this call and use raydium_keys[] with your laptop ?

Others points:
- For me this code is "serious", why so much warnings about that ?
- More than adding freemove.c example, it could be a good idea to "rewrite" willou.c and other demos using freemove style. Don't you think ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 17, 2007 9:02 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Xfennec wrote:
Nice !
What's the trouble when you remove this call and use raydium_keys[] with your laptop ?

Simply, it doesn't move... But really i'm not sure why. I have to investigate.

Quote:
Others points:
- For me this code is "serious", why so much warnings about that ?

With serious i'm talking about a complex code with a personal handling of input data por example. Since this function take data directly, we can not manage the input data by ourselves... But yes, maybe i have insist too much with the "serious code" idea :)

Quote:
More than adding freemove.c example, it could be a good idea to "rewrite" willou.c and other demos using freemove style. Don't you think ?
Hmm, ok for me. Who make the conversions?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 17, 2007 12:58 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Quote:
Simply, it doesn't move... But really i'm not sure why. I have to investigate.

OK. I'll try to have a look on my side too.

Quote:
But yes, maybe i have insist too much with the "serious code" idea Smile

Yep :)

Quote:
Hmm, ok for me. Who make the conversions?

Whatever. It's just a matter of removing a few lines and make a call to your function. I can do it if you want.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 17, 2007 4:03 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Xfennec wrote:
I can do it if you want.

Ok, so i can continue with the config load function. Maybe i can commit that today.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 17, 2007 6:50 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Commits 557, 558 and 559 should have closed this thread ;)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 06, 2007 8:30 pm 
Offline

Joined: Sun Oct 09, 2005 10:46 pm
Posts: 759
hello,

camera pos : orientation is static in freemove().

Added a parameter for just place camera with move orbit.

Is it ok ?

See svn.

Bye
Ouille


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 08, 2007 1:04 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
The idea is OK for me, but the commit is a bit "heavy" :)

- Changes in server applications about Sleep() call not related to this commit
- You've changed the API. Another function like freemove_internal(int) could have been a better idea, with freemove calling it with "1" and a new freemove camere (freemove_fixed() for example) with "0", so the API was the same for users.
- The use of an integer for the function should have been replaced with constants like RAYDIUM_CAMERA_FREEMOVE_NORMAL and RAYDIUM_CAMERA_FREEMOVE_FIXED for example.
- What about placing the camera ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group