Raydium 3D Game Engine

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

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: new proposal: triviewer
PostPosted: Sun Jul 22, 2007 4:16 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
I'm been working in a simple (or not so) application with just one big objective:
show the tri files wherever they are.

With this application you could do:

Code:
triviewer

this will show a usage message. It's almost done, there is still a bit of garbage.

Code:
triviewer /path/to/local/file.tri

To shown a tri file located in a certain path. Works, or i think so

Code:
triviewer filename.tri

To show a local folder tri file OR A FILE LOCATED IN THE REPOSITORY. It's failing. The problem is realted to php and paths.

When all be solved i'll ask for help to make a deb(and ubuntu) package to install it and to add a new trifile mime type. Currently tri files are text plain files.

Here you can see the current code. Note that this DO NOT RUN using ./ocomp.sh.
However you have to do the ./ocomp.sh then a copy "test" to a folder in the path (ie, sudo cp test /usr/bin/triviewer) and then you can call it from terminal.

Code:
/*
    Raydium - CQFD Corp.
    http://raydium.org/
    License: GPL - GNU General Public License, see "gpl.txt" file.
*/

// This file is a default skeleton. Replace all [ ... ] sections with yours.
// Have fun !

#include "raydium/index.c"
char TRIVIEWERVERSION[255]="1.0";
GLfloat cam_angle_x = 0;
GLfloat cam_angle_y = 90;

GLfloat cam_pos_x = 0;
GLfloat cam_pos_y = 0;
GLfloat cam_pos_z = 0;
GLfloat speed = 0.05;
GLint sensibilite = 2;


void display(void)
{
    int delta_x, delta_y;
    raydium_joy_key_emul();

    cam_pos_z += (raydium_trigo_sin(cam_angle_x+90)*raydium_joy_y*speed*raydium_trigo_sin(90-cam_angle_y));
    cam_pos_x += (raydium_trigo_cos(cam_angle_x+90)*raydium_joy_y*speed*raydium_trigo_sin(90-cam_angle_y));
    cam_pos_y += (raydium_trigo_cos(90-cam_angle_y)*speed*raydium_joy_y);
   
    cam_pos_x -= (raydium_trigo_cos(cam_angle_x)*raydium_joy_x*speed);
    cam_pos_z -= (raydium_trigo_sin(cam_angle_x)*raydium_joy_x*speed);
    raydium_joy_key_emul();

    delta_x = raydium_mouse_x - (raydium_window_tx/2);
    cam_angle_x += (delta_x*sensibilite*0.1f);

    delta_y = raydium_mouse_y - (raydium_window_ty/2);
    cam_angle_y += (delta_y*sensibilite*0.1f);

    raydium_mouse_move(raydium_window_tx/2, raydium_window_ty/2);
if(raydium_key_last==1027)
    exit(0);

raydium_clear_frame();
/* [ place your camera here ] */ raydium_camera_place(cam_pos_x,cam_pos_y,cam_pos_z,cam_angle_x,cam_angle_y,0);
raydium_camera_replace();
/* [ draw here ] */ raydium_ode_draw_all(0);
raydium_rendering_finish();
}


int main(int argc, char **argv)
{
char *dest;
char *name;

dest=(char*)calloc(2048,sizeof(char));
name=(char*)calloc(2048,sizeof(char));

raydium_init_args(argc,argv);
if(argc!=2)
{
    raydium_log("*--------------------------------------*");
    raydium_log("triviewer version %s",TRIVIEWERVERSION);
    raydium_log("usage: triview [FILE.tri]");   
    raydium_log("No file specified, aborting application.");
    exit (0);
}

raydium_window_create(640,480,RAYDIUM_RENDERING_WINDOW,"Triviewer 1.0");   

raydium_texture_filter_change(RAYDIUM_TEXTURE_FILTER_TRILINEAR);
raydium_window_view_perspective(60,0.01,2500); /* fov 60 + near and far planes */

raydium_fog_disable();   
raydium_light_enable();
raydium_light_on(0);

raydium_light_conf_7f(0,50,150,200,1000000,1,0.9,0.7); /* id, pos, intensity and color (RGB) */
raydium_background_color_change(1,0.9,0.7,1);

/*/here we should fix the repository issue*/
raydium_file_dirname(dest,argv[1]);
raydium_rayphp_repository_defaults("http://fastrepo.raydium.org/\nhttp://repository.raydium.org/");
raydium_path_add(dest);
raydium_sky_box_cache();


raydium_file_basename(name,argv[1]);
raydium_log("Adding folder \"%s\" as extra repository.",dest);
raydium_log("Preparing to load file: %s",name);
/* [ place base scene here ] */ raydium_ode_ground_set_name(name);

free(dest);
free(name);
raydium_callback(&display);
return(0);
}

// EOF


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

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
The question is more complex than it seems :)

Here is the result of my tests: (my "model" is your "argv[1]")
Code:
    raydium_php_rayphp_path_change("/home/xfennec/opengl/rayphp"); // path to RayPHP files
raydium_file_dirname(dest,model);
raydium_path_add(dest);
raydium_path_write_local_deny(1); // always write to the "raydium_path_write"


It work with data in the current directory, called from another directory or not, and with a filename of the repository. The binary is "standalone" (except libraydium if not static, obviously).
When needed, all is downloaded in user home directory, the best place for this IMHO (I don't like programs who writes everywhere in my filesystem, for example).

I've added the last function in the commit 552.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 15, 2007 1:59 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Still problems. Perhaps i have included your code in a bad way.

The new code is:

Code:
/*
    Raydium - CQFD Corp.
    http://raydium.org/
    License: GPL - GNU General Public License, see "gpl.txt" file.
*/

// This file is a default skeleton. Replace all [ ... ] sections with yours.
// Have fun !

#include "raydium/index.c"
char TRIVIEWERVERSION[255]="1.0";
GLfloat cam_angle_x = 0;
GLfloat cam_angle_y = 90;

GLfloat cam_pos_x = 0;
GLfloat cam_pos_y = 0;
GLfloat cam_pos_z = 0;
GLfloat speed = 0.05;
GLint sensibilite = 2;


void display(void)
{
    int delta_x, delta_y;
    raydium_joy_key_emul();

    cam_pos_z += (raydium_trigo_sin(cam_angle_x+90)*raydium_joy_y*speed*raydium_trigo_sin(90-cam_angle_y));
    cam_pos_x += (raydium_trigo_cos(cam_angle_x+90)*raydium_joy_y*speed*raydium_trigo_sin(90-cam_angle_y));
    cam_pos_y += (raydium_trigo_cos(90-cam_angle_y)*speed*raydium_joy_y);
   
    cam_pos_x -= (raydium_trigo_cos(cam_angle_x)*raydium_joy_x*speed);
    cam_pos_z -= (raydium_trigo_sin(cam_angle_x)*raydium_joy_x*speed);
    raydium_joy_key_emul();

    delta_x = raydium_mouse_x - (raydium_window_tx/2);
    cam_angle_x += (delta_x*sensibilite*0.1f);

    delta_y = raydium_mouse_y - (raydium_window_ty/2);
    cam_angle_y += (delta_y*sensibilite*0.1f);

    raydium_mouse_move(raydium_window_tx/2, raydium_window_ty/2);
if(raydium_key_last==1027)
    exit(0);

raydium_clear_frame();
/* [ place your camera here ] */ raydium_camera_place(cam_pos_x,cam_pos_y,cam_pos_z,cam_angle_x,cam_angle_y,0);
raydium_camera_replace();
/* [ draw here ] */ raydium_ode_draw_all(0);
raydium_rendering_finish();
}


int main(int argc, char **argv)
{
char *dest;
char *name;

dest=(char*)calloc(2048,sizeof(char));
name=(char*)calloc(2048,sizeof(char));

raydium_init_args(argc,argv);
if(argc!=2)
{
    raydium_log("*--------------------------------------*");
    raydium_log("triviewer version %s",TRIVIEWERVERSION);
    raydium_log("usage: triview [FILE.tri]");   
    raydium_log("No file specified, aborting application.");
    exit (0);
}

raydium_window_create(640,480,RAYDIUM_RENDERING_WINDOW,"Triviewer 1.0");   

raydium_texture_filter_change(RAYDIUM_TEXTURE_FILTER_ANISO);
raydium_window_view_perspective(60,0.01,2500); /* fov 60 + near and far planes */

raydium_fog_disable();   
raydium_light_enable();
raydium_light_on(0);

raydium_light_conf_7f(0,50,150,200,1000000,1,0.9,0.7); /* id, pos, intensity and color (RGB) */
raydium_background_color_change(1,0.9,0.7,1);

/*/here we should fix the repository issue*/
raydium_rayphp_repository_defaults("http://fastrepo.raydium.org/\nhttp://repository.raydium.org/");
raydium_php_rayphp_path_change("~/.raydium"); // path to RayPHP files
raydium_file_dirname(dest,argv[1]);
raydium_path_add(dest);
raydium_path_write_local_deny(1); // always write to the "raydium_path_write"

//raydium_file_dirname(dest,argv[1]);
//raydium_rayphp_repository_defaults("http://fastrepo.raydium.org/\nhttp://repository.raydium.org/");
//raydium_path_add(dest);

raydium_sky_box_cache();


raydium_file_basename(name,argv[1]);
raydium_log("Adding folder \"%s\" as extra repository.",dest);
raydium_log("Preparing to load file: %s",name);
/* [ place base scene here ] */ raydium_ode_ground_set_name(name);

free(dest);
free(name);
raydium_callback(&display);
return(0);
}

// EOF


And the output is:
Code:
 ./triviewer ak47
Raydium: Raydium 3D Game Engine
Raydium: version 0.706
Raydium: command line args: OK
Raydium: chdir to './': OK
Raydium: using '/home/vicente/.raydium' as home dir
Raydium: Requesting 640x480:32 mode
Raydium: Xinerama detected with 1 screens:
Raydium: *** screen 0 : 1440x900 at (0,0)
Raydium: using Xinerama screen 0
Raydium: Found 640x480 with 24 bpp color and 24 bits zbuffer (stencil is 1)
Raydium: using GeForce Go 7400/PCI/SSE2, from NVIDIA Corporation (version 2.1.1 NVIDIA 100.14.11)
Raydium: Signal Handlers: OK
Raydium: OpenGL extensions: OK
Raydium: Platform "4xfloat" vector size is: 16 byte(s) long
Raydium: OpenGL implementation maximum texture size: 4096x4096
Raydium: OpenGL hardware providing 4 texture unit(s), Raydium deals with 4
Raydium: OpenGL anisotropy max level is 16.00
Raydium: OpenGL texture compression available
Raydium: vertex arrays memory: OK
Raydium: path: OK
Raydium: keyboard: OK
Raydium: mouse: OK
Raydium: /dev/input/event0: cannot open (rw), no Force Feedback.
Raydium: joy: FAILED (cannot open /dev/js0 and /dev/input/js0)
Raydium: sound: Buffer creation successfull
Raydium: sound: OK, using 'default device'
Raydium: PHP support: OK
Raydium: atexit functions: OK
Raydium: lights: OK
Raydium: fog: OK
Raydium: objects: OK
Raydium: network: OK
Raydium: timer: detection: 1 iterations: diff: 2 steps (1000000/sec)
Raydium: timecall: method accuracy = 0.002 ms (499999.97 Hz)
Raydium: timecall: Using basic gettimeofday() method
Raydium: timecall: OK (499999 Hz)
Raydium: timecall: softcall 0: 1 Hz (1000000 clocks interval)
Raydium: particle: OK
Raydium: gui: OK
Raydium: video (live): OK
Raydium: shadow: OK
Raydium: HDR: OK
Raydium: shaders: OK (version 1.20 NVIDIA via Cg compiler)
Raydium: webserver: OK
Raydium: Raydium engine reseted to original state
Raydium: timecall: callback 1: 400 Hz (2500 clocks interval)
Raydium: physics: ODE Net: 10 element(s)/packet
Raydium: physics: OK
Raydium: RegAPI: OK
Raydium: Engine is now ready.
         -----------------------------------------------------------
Raydium: php: ERROR: cannot post-open '~/.raydium/getfile.php' file
Raydium: Cannot open BOXfront.tga texture
Raydium: texture: faking 'BOXfront.tga' with pink color
Raydium: Texture num 1, rgb(1.000000,0.000000,1.000000) is RGB Color
Raydium: php: ERROR: cannot post-open '~/.raydium/getfile.php' file
Raydium: Cannot open BOXback.tga texture
Raydium: texture: faking 'BOXback.tga' with pink color
Raydium: Texture num 2, rgb(1.000000,0.000000,1.000000) is RGB Color
Raydium: php: ERROR: cannot post-open '~/.raydium/getfile.php' file
Raydium: Cannot open BOXleft.tga texture
Raydium: texture: faking 'BOXleft.tga' with pink color
Raydium: Texture num 3, rgb(1.000000,0.000000,1.000000) is RGB Color
Raydium: php: ERROR: cannot post-open '~/.raydium/getfile.php' file
Raydium: Cannot open BOXright.tga texture
Raydium: texture: faking 'BOXright.tga' with pink color
Raydium: Texture num 4, rgb(1.000000,0.000000,1.000000) is RGB Color
Raydium: php: ERROR: cannot post-open '~/.raydium/getfile.php' file
Raydium: Cannot open BOXbottom.tga texture
Raydium: texture: faking 'BOXbottom.tga' with pink color
Raydium: Texture num 5, rgb(1.000000,0.000000,1.000000) is RGB Color
Raydium: php: ERROR: cannot post-open '~/.raydium/getfile.php' file
Raydium: Cannot open BOXtop.tga texture
Raydium: texture: faking 'BOXtop.tga' with pink color
Raydium: Texture num 6, rgb(1.000000,0.000000,1.000000) is RGB Color
Raydium: Adding folder "./" as extra repository.
Raydium: Preparing to load file: ak47
Raydium: php: ERROR: cannot post-open '~/.raydium/getfile.php' file
cannot read from file "ak47", fopen() failed
Raydium: shadow: ground (0) modelsize is 0.00, center factors : NAN/NAN
Raydium: Object: creating display list for object ak47
Raydium: Internal buffers:
Raydium: -----------------
Raydium: Total of 0 vertex(s) loaded:
Raydium: Texture num 0: 0 vertex(s) - loaded as "dummy.null"
Raydium: Texture num 1: 0 vertex(s) - loaded as "BOXfront.tga"
Raydium: Texture num 2: 0 vertex(s) - loaded as "BOXback.tga"
Raydium: Texture num 3: 0 vertex(s) - loaded as "BOXleft.tga"
Raydium: Texture num 4: 0 vertex(s) - loaded as "BOXright.tga"
Raydium: Texture num 5: 0 vertex(s) - loaded as "BOXbottom.tga"
Raydium: Texture num 6: 0 vertex(s) - loaded as "BOXtop.tga"
Raydium: Estimated total: 0.00 MB used for textures.
Raydium: Using 1 object(s):
Raydium: Object num 0: 0 vertex(s) - loaded as "ak47"
Raydium: sound: Deleting sources
Raydium: sound: Deleting buffers
Raydium: sound: Releasing OpenAL
Raydium: path: read: "/home/vicente/.raydium/data:."
Raydium: path: write: "/home/vicente/.raydium/data"


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 17, 2007 4:05 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Quote:
raydium_php_rayphp_path_change("~/.raydium"); // path to RayPHP files

Probably wrong. This function is used to gives Raydium the path of RayPHP files (the files in the rayphp/ directory of the svn trunk, for example). Dunno how you want to install your app, but if the binary goes in "/usr/bin", you can imagine something like "/usr/share/raydium/rayphp/" for these files.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 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