示例#1
0
static void initialize(void)
{
    int attr;

    attr = doublebuffer ? RGBA_DB_attributes : RGBA_SB_attributes;
    glutInitDisplayMode(attr);
    glutInitWindowSize(300, 240);
    glutCreateWindow("Ideas");

    if (multisample) glEnable(GL_POLYGON_SMOOTH); 
    
    init_lights();
    init_materials();

    build_table();

    view_from_spline = calc_spline_params(view_from_ctl, TIME);
    view_to_spline = calc_spline_params(view_to_ctl, TIME);
    light_pos_spline = calc_spline_params(light_pos_ctl, TIME);
    logo_pos_spline = calc_spline_params(logo_pos_ctl, TIME);
    logo_rot_spline = calc_spline_params(logo_rot_ctl, TIME);

    glutReshapeFunc(resize_window);
    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutKeyboardFunc(keyboard);
    glutVisibilityFunc(vis);

    glMatrixMode(GL_MODELVIEW);
}
示例#2
0
文件: main.cpp 项目: daid/Rogue
/*
 * main:
 *        The main program, of course
 */
int main(int argc, char **argv)
{
    md_init();
    initJedi();

    /*
     * get home and options from environment
     */

#ifdef __linux__
    strcpy(file_name, "/var/lib/griffin/rogue.save");
#else
    strcpy(file_name, "rogue.save");
#endif

    open_score();

    /*
     * check for print-score option
     */

    if (argc == 2)
    {
        if (strcmp(argv[1], "-s") == 0)
        {
            score(0, -1, 0);
            exit(0);
        }
    }

    init_check();                        /* check for legal startup */
    restore("-r");

    init_probs();                        /* Set up prob tables for objects */
    init_player();                        /* Set up initial player stats */
    init_names();                        /* Set up names of scrolls */
    init_colors();                        /* Set up colors of potions */
    init_stones();                        /* Set up stone settings of rings */
    init_materials();                        /* Set up materials of wands */
    setup();

    displayMessage("WELCOME TO THE DUNGEONS OF DOOM");
    new_level();                        /* Draw current level */
    /*
     * Start up daemons and fuses
     */
    start_daemon(runners, 0, AFTER);
    start_daemon(doctor, 0, AFTER);
    fuse(swander, 0, WANDERTIME, AFTER);
    start_daemon(stomach, 0, AFTER);
    playit();
    return(0);
}
示例#3
0
void AD_Scene3D::init (void)
{
  int k;

  init_materials();
  init_lights();
  init_camere();
  init_objects();

  for (k=0; k<num_materials+2; k++)
  {
	if (materials[k].trasparencytype==OFF)
	{
	  materials[k].my_tria_list=(void **) new AD_Tria3DPtr[materials[k].my_num_tria];
	  materials[k].my_tria_list_copy=materials[k].my_tria_list;
	}
  }
  counter_for_resetting_vertex=0;
  zclear=-1;
  return;
}
示例#4
0
/* INITMODEL: this guy initializes much of the model structure.
 */
ReturnCode init_model(ModelStruct* ms)
{
    int i;
    const char *p;
    // ms->modelnum is preset; store it here so you can restore it after memset().
    int model_number = ms->modelnum;

    memset(ms, 0, sizeof(ModelStruct));

    ms->modelnum = model_number;
    ms->is_demo_model = no;
    ms->useIK = yes;
    ms->defaultGCApproved = yes;
    ms->defaultLoopsOK = yes;
    ms->defaultConstraintsOK = yes;
    ms->constraintsOK = yes;
    ms->loopsOK = yes;
    ms->muscle_array_size = MUSCLE_ARRAY_INCREMENT;
    ms->ligament_array_size = MUSCLE_ARRAY_INCREMENT;
    ms->muscgroup_array_size = MUSCGROUP_ARRAY_INCREMENT;
    ms->world_array_size = INIT_WORLD_ARRAY_SIZE;
    ms->genc_array_size = GENC_ARRAY_INCREMENT;
    ms->segment_array_size = SEGMENT_ARRAY_INCREMENT;
    ms->joint_array_size = JOINT_ARRAY_INCREMENT;
    ms->func_array_size = FUNC_ARRAY_INCREMENT;
    ms->specified_min_thickness = yes;
    ms->specified_max_thickness = yes;
    ms->dynamics_ready = no;
    ms->max_diagonal_needs_recalc = yes;
    ms->GEFuncOK = no;
    ms->marker_visibility = yes;
    ms->marker_radius = DEFAULT_MARKER_RADIUS;
    ms->loop_tolerance = DEFAULT_LOOP_TOLERANCE;
    ms->loop_weight = DEFAULT_LOOP_WEIGHT;
    ms->solver.accuracy = DEFAULT_SOLVER_ACCURACY;
    ms->solver.method = smLevenbergMarquart;
    ms->solver.max_iterations = 100;
    ms->solver.joint_limits = smYes;
    ms->solver.orient_body = smNo;
    ms->solver.fg_contact = smNo;
    ms->global_show_masscenter = no;
    ms->global_show_inertia = no;

    ms->gravity = smNegY;

    ms->functionMenu = 0;

    ms->motion_array_size = MOTION_ARRAY_INCREMENT;
    ms->motion = (MotionSequence**)simm_malloc(ms->motion_array_size * sizeof(MotionSequence*));
    if (ms->motion == NULL)
    {
        error(none,"Not enough memory to add another model.");
        return code_bad;
    }
    else
    {
        for (i = 0; i < ms->motion_array_size; i++)
            ms->motion[i] = NULL;
    }


    for (i=0; i<100; i++)
        ms->motionfilename[i] = NULL;
    ms->num_motion_files = 0;

    ms->joint = (JointStruct*)simm_malloc(ms->joint_array_size*sizeof(JointStruct));
    ms->segment = (SegmentStruct*)simm_malloc(ms->segment_array_size*sizeof(SegmentStruct));
    ms->muscgroup = (MuscleGroup*)simm_malloc(ms->muscgroup_array_size*sizeof(MuscleGroup));
    ms->seggroup = NULL;
    ms->gencgroup = NULL;
    ms->gencoord = (GeneralizedCoord**)simm_calloc(ms->genc_array_size, sizeof(GeneralizedCoord*));

    ms->muscle = (dpMuscleStruct**)simm_calloc(ms->muscle_array_size, sizeof(dpMuscleStruct*));

    ms->ligament = (LigamentStruct*)simm_malloc(ms->ligament_array_size*sizeof(LigamentStruct));

    ms->function = (dpFunction**)simm_calloc(ms->func_array_size, sizeof(dpFunction*));

    ms->save.function = (dpFunction**)simm_calloc(ms->func_array_size, sizeof(dpFunction*));

    ms->worldobj = (WorldObject*)simm_malloc(ms->world_array_size*sizeof(WorldObject));

    if (ms->joint == NULL || ms->segment == NULL || ms->muscgroup == NULL ||
            ms->gencoord == NULL || ms->function == NULL ||
            ms->save.function == NULL || ms->worldobj == NULL)
    {
        error(none,"Not enough memory to add another model.");
        return code_bad;
    }

    ms->num_wrap_objects = 0;
    ms->wrap_object_array_size = WRAP_OBJECT_ARRAY_INCREMENT;
    ms->wrapobj = (dpWrapObject**)simm_malloc(ms->wrap_object_array_size*sizeof(dpWrapObject*));
    if (ms->wrapobj == NULL)
    {
        error(none,"Not enough memory to add another wrap object.");
        return code_bad;
    }

//   ms->constraint_tolerance = DEFAULT_CONSTRAINT_TOLERANCE;
    ms->num_constraint_objects = 0;
    ms->constraint_object_array_size = CONSTRAINT_OBJECT_ARRAY_INCREMENT;
    ms->constraintobj = (ConstraintObject*)simm_malloc(ms->constraint_object_array_size*sizeof(ConstraintObject));
    if (ms->constraintobj == NULL)
    {
        error(none,"Not enough memory to add another constraint.");
        return code_bad;
    }

    ms->num_deformities = 0;
    ms->deformity_array_size = DEFORMITY_ARRAY_INCREMENT;
    ms->deformity = (Deformity*) simm_malloc(ms->deformity_array_size * sizeof(Deformity));
    if (ms->deformity == NULL)
    {
        error(none,"Not enough memory to add another deformity object.");
        return code_bad;
    }

    init_materials(ms);

    ms->num_motion_objects = 0;
    ms->motion_objects = NULL;

#if ! ENGINE || OPENSMAC
    add_default_motion_objects(ms);
#endif

    /* This part of the display structure must be initialized here because
     * it can be changed when reading in the joints file, which happens before
     * the display structure is initialized.
     */
    ms->dis.num_file_views = 0;
//   ms->dis.muscle_array_size = 0;//dkb = MUSCLE_ARRAY_INCREMENT;
    ms->dis.muscle_array_size = MUSCLE_ARRAY_INCREMENT;

    ms->dis.fast_muscle_drawing = no;

#if ! ENGINE
    ms->dis.fast_muscle_drawing = is_preference_on(get_preference("FASTER_MUSCLE_DRAWING"));

#if INCLUDE_MSL_LENGTH_COLOR
    ms->dis.muscle_color_factor = 0.0;
#endif

    for (i=0; i<MAXSAVEDVIEWS; i++)
    {
        ms->dis.view_used[i] = no;
        ms->dis.view_name[i] = NULL;
    }

    for (i=0; i<3; i++)
    {
        ms->dis.background_color[i] = 0.2f;
        ms->dis.vertex_label_color[i] = 0.0f;
        ms->dis.rotation_axes_color[i] = 1.0f;
        ms->dis.crosshairs_color[i] = 1.0f;
    }
    ms->dis.rotation_axes_color[2] = 0.0f;
    ms->dis.vertex_label_color[0] = 1.0f;

    ms->dis.background_color_spec = no;
    ms->dis.vertex_label_color_spec = no;
    ms->dis.rotation_axes_color_spec = no;
    ms->dis.crosshairs_color_spec = no;

    ms->modelLock = glutNewMutex();
    ms->realtimeState = rtNotConnected;

#endif /* ENGINE */

    ms->gencoordmenu = -1;
    ms->gencoordmenu2 = -1;
    ms->gencoord_group_menu = -1;
    ms->xvarmenu = -1;
    ms->momentgencmenu = -1;
    ms->momentarmgencmenu = -1;
    ms->momentarmnumgencmenu = -1;
    ms->maxmomentgencmenu = -1;

    return code_fine;
}
/*
 * main:
 *	The main program, of course
 */
int
main(int argc, char **argv)
{
    char *env;
    time_t lowtime;

    md_init();

#ifdef MASTER
    /*
     * Check to see if he is a wizard
     */
    if (argc >= 2 && argv[1][0] == '\0')
	if (strcmp(PASSWD, md_crypt(md_getpass("wizard's password: "******"mT")) == 0)
	{
	    wizard = TRUE;
	    player.t_flags |= SEEMONST;
	    argv++;
	    argc--;
	}

#endif

    /*
     * get home and options from environment
     */

    strcpy(home, md_gethomedir());

	if (strlen(home) > MAXSTR - strlen("rogue.save") - 1)
		*home = 0;

    strcpy(file_name, home);
    strcat(file_name, "rogue.save");

    if ((env = getenv("ROGUEOPTS")) != NULL)
	parse_opts(env);
    if (env == NULL || whoami[0] == '\0')
        strucpy(whoami, md_getusername(), strlen(md_getusername()));
    lowtime = time(NULL);
    if (getenv("SEED") != NULL)
    {
	dnum = atoi(getenv("SEED"));
	noscore = 1;
    }
    else
	dnum = (unsigned int) lowtime + md_getpid();
    seed = dnum;

    open_score();

	/* 
     * Drop setuid/setgid after opening the scoreboard file. 
     */ 

    md_normaluser();

    /*
     * check for print-score option
     */

	md_normaluser(); /* we drop any setgid/setuid priveldges here */

    if (argc == 2)
    {
	if (strcmp(argv[1], "-s") == 0)
	{
	    noscore = TRUE;
	    score(0, -1, 0);
	    exit(0);
	}
	else if (strcmp(argv[1], "-d") == 0)
	{
	    dnum = rnd(100);	/* throw away some rnd()s to break patterns */
	    while (--dnum)
		rnd(100);
	    purse = rnd(100) + 1;
	    level = rnd(100) + 1;
	    initscr();
	    getltchars();
	    death(death_monst());
	    exit(0);
	}
    }

    init_check();			/* check for legal startup */
    if (argc == 2)
	if (!restore(argv[1]))	/* Note: restore will never return */
	    my_exit(1);
#ifdef MASTER
    if (wizard)
	printf("Hello %s, welcome to dungeon #%d", whoami, dnum);
    else
#endif
	printf("Hello %s, just a moment while I dig the dungeon...", whoami);
    fflush(stdout);

    initscr();				/* Start up cursor package */
    init_probs();			/* Set up prob tables for objects */
    init_player();			/* Set up initial player stats */
    init_names();			/* Set up names of scrolls */
    init_colors();			/* Set up colors of potions */
    init_stones();			/* Set up stone settings of rings */
    init_materials();			/* Set up materials of wands */
    setup();

    /*
     * The screen must be at least NUMLINES x NUMCOLS
     */
    if (LINES < NUMLINES || COLS < NUMCOLS)
    {
	printf("\nSorry, the screen must be at least %dx%d\n", NUMLINES, NUMCOLS);
	endwin();
	my_exit(1);
    }

    /*
     * Set up windows
     */
    hw = newwin(LINES, COLS, 0, 0);
    idlok(stdscr, TRUE);
    idlok(hw, TRUE);
#ifdef MASTER
    noscore = wizard;
#endif
    new_level();			/* Draw current level */
    /*
     * Start up daemons and fuses
     */
    start_daemon(runners, 0, AFTER);
    start_daemon(doctor, 0, AFTER);
    fuse(swander, 0, WANDERTIME, AFTER);
    start_daemon(stomach, 0, AFTER);
    playit();
    return(0);
}