/*
* browser3d.h (Visit http://browser3d.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (file COPYRIGHT); if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef __WIN32
#include <GL/openglut.h>
#else
#include <GL/glut.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <expat.h>
#include <string.h>
#include <math.h>
#ifndef _BROWSER3D_H_INCLUDED
#define _BROWSER3D_H_INCLUDED
#ifdef __WIN32
#define usleep(time) Sleep(time/1000)
#else
#define __glutSolidCylinder
#endif
/* const char* version="0.2a"; */
#define BROWSER3D_VERSION "0.2a"
#define BROWSER3D_NAME "Browser3D"
#define BROWSER3D_USERAGENT "Browser3D 0.2a"
#define MAX_LINE_LENGTH 1024
//#include "browser3d_network.h"
enum object3d_type {CUBE, SPHERE, CONE, TORUS, DODECAHEDRON, OCTAHEDRON, TETRAHEDRON, ICOSAHEDRON, TEAPOT, RHOMBICDODECAHEDRON, SIERPINSKISPONGE, CYLINDER, PLANE, A3D, LABEL3D};
typedef enum object3d_type object_type;
struct object3d
{
object_type type;
GLfloat x,y,z;
GLfloat scalex,scaley,scalez;
GLfloat rotatex,rotatey,rotatez;
GLfloat red,green,blue;
char* data;
unsigned char collision;
} static object[255];
struct s_vector
{
float x,y,z;
};
typedef struct s_vector vector;
static int num_objects=0;
//// TEXTURES
// Storage for one texture
static GLuint texture[1];
// Image type - contains height, width, and data
struct Image
{
unsigned long sizeX;
unsigned long sizeY;
char *data;
};
typedef struct Image Image;
//// END TEXTURES
/* planes for texture coordinate generation */
static GLfloat xequalzero[] = {1.0, 0.0, 0.0, 0.0};
static GLfloat slanted[] = {1.0, 1.0, 1.0, 0.0};
static GLfloat *currentCoeff;
static GLenum currentPlane;
static GLint currentGenMode;
static GLuint texName;
//values for lighting
static GLfloat AmbientLight[] = { 0.3f, 0.3f, 0.3f, 1.0f };
static GLfloat DiffuseLight[] = { 0.8f, 0.8f, 0.8f, 1.0f };
static GLfloat SpecularLight[] = { 1.0f, 1.0f, 1.0f, 1.0f };
static GLfloat SpecRef[] = { 0.7f, 0.7f, 0.7f, 1.0f };
static GLfloat LightPos[] = {-50.0f,50.0f,100.0f,1.0f};
static GLubyte Shine = 128;
//camera position
#define XCAM_INI 0.0
#define YCAM_INI 0.0
#define ZCAM_INI 0.0
#define SXCAM_INI 0.0
#define SYCAM_INI 0.0
#define SZCAM_INI 1.0
#define UPXCAM_INI 0.0
#define UPYCAM_INI 1.0
#define UPZCAM_INI 0.0
static GLfloat xCam = XCAM_INI,yCam=YCAM_INI,zCam = ZCAM_INI,sxCam=SXCAM_INI,syCam=SYCAM_INI,szCam=SZCAM_INI,upxCam=UPXCAM_INI,upyCam=UPYCAM_INI,upzCam=UPZCAM_INI;
//mouse position
static int xMouse = 0, yMouse = 0;
void rotateCamera(GLfloat xRotate,GLfloat yRotate,GLfloat zrotate);
int ImageLoad(char *, Image *);
void LoadGLTextures(void);
void initialize3DObject(GLfloat x,GLfloat y,GLfloat z, GLfloat width, GLfloat height, GLfloat depth,GLfloat xRotate,GLfloat yRotate,GLfloat zRotate,GLfloat red,GLfloat green,GLfloat blue);
void draw_object(int num);
void initialize3DObject(GLfloat x,GLfloat y,GLfloat z, GLfloat width, GLfloat height, GLfloat depth,GLfloat xRotate,GLfloat yRotate,GLfloat zRotate,GLfloat red,GLfloat green,GLfloat blue);
void draw_object(int num);
void cube(GLfloat x,GLfloat y,GLfloat z, GLfloat width, GLfloat height, GLfloat depth,GLfloat xRotate,GLfloat yRotate,GLfloat zRotate,GLfloat red,GLfloat green,GLfloat blue);
void sphere(GLfloat x,GLfloat y,GLfloat z, GLfloat width, GLfloat height, GLfloat depth,GLfloat xRotate,GLfloat yRotate,GLfloat zRotate,GLfloat red,GLfloat green,GLfloat blue);
void draw_object_type(struct object3d* o3d);
void initialize_3D_object(struct object3d* o3d);
void init(void);
void display(void);
void reshape (int w, int h);
void keyboard (unsigned char key, int x, int y);
void idle();
void menu1(int id);
void menu2(int id);
void draw_object(int num);
void parse_attributes(const char **attr);
void create_primitive(object_type type,const char **atts);
static void startElement(void *userdata, const char *name, const char **atts);
static void endElement(void *userData, const char *name);
int main(int argc, char** argv);
void initialize_world();
void load_url(char* url);
int collision(vector* v);
void move_forward();
void move_backward();
void change_move_mode();
int winIdMain, winIdSub;
#define WINDOW_WIDTH 500
#define WINDOW_HEIGHT 500
void subDisplay(void);
void subReshape(int w, int h);
void drawString (char *s);
void drawStringBig (char *s);
static char label[100] = "";
static char label2[100] = "";
char *new_url;
char n_url[255];
char current_url[255];
#define MOVE_3D 0
#define MOVE_2D 1
static unsigned int move_mode = MOVE_3D;
#endif