Ejemplo n.º 1
0
/* ARGSUSED2 */
enum muiReturnValue  pdhandler(muiObject *obj, int event, int value, int x, int y)
{
    int i;
    Pulldown *pd = (Pulldown *)obj->object;
 
    if( !muiGetEnable(obj) || !muiGetVisible(obj) ) return MUI_NO_ACTION;
    
    if (event == MUI_DEVICE_UP) {
	for (i = 0; i < pd->count; i++)
	    if (pd->menus[i].xoffset-8 < x && x < pd->menus[i+1].xoffset-8) {
		if (activemenu != pd->menus[i].menu && !menuinuse) {
		    glutSetMenu(activemenu = pd->menus[i].menu);
		    glutAttachMenu(GLUT_LEFT_BUTTON);
		}
		return MUI_NO_ACTION;
	    }
	if (pd->ishelp && (x > pd->helpmenu.xoffset-8)) {
	    if ((activemenu != pd->helpmenu.menu) && !menuinuse) {
		glutSetMenu(activemenu = pd->helpmenu.menu);
		glutAttachMenu(GLUT_LEFT_BUTTON);
	    }
	    return MUI_NO_ACTION;
	}
	if (activemenu && !menuinuse) {
	    glutDetachMenu(GLUT_LEFT_BUTTON);
	    activemenu = -1;
	}
    }
    return MUI_NO_ACTION;
}
int     GLUI_Listbox::mouse_over( int state, int x, int y )
{
  GLUI_Listbox_Item *item;

  /*  printf( "x/y:   %d/%d\n", x, y );              */

  if ( state AND enabled AND x > x_abs + text_x_offset) {
    /****  Build a GLUT menu for this listbox   ***/
    
    /*	printf( "%d %d\n", x, y );              */

    glut_menu_id = glutCreateMenu(listbox_callback);

    item = (GLUI_Listbox_Item *) items_list.first_child();
    while( item ) {
      glutAddMenuEntry( item->text.c_str(), item->id );
      item = (GLUI_Listbox_Item *) item->next();
    }

    glutAttachMenu( GLUT_LEFT_BUTTON);
    
    GLUI_Master.set_left_button_glut_menu_control( this );
  }
  else if ( glut_menu_id != -1 ) {
    /*    printf( "OUT\n" );              */
    glutDetachMenu( GLUT_LEFT_BUTTON );
    glutDestroyMenu( glut_menu_id );
    glut_menu_id = -1;
  }

  return true;
}
Ejemplo n.º 3
0
void 
GlutMenu::detach()
{
	if (_menuID!=-1)
	{
		glutSetMenu(_menuID);
		glutDetachMenu(_button);
	}
}
Ejemplo n.º 4
0
void
time2(int value)
{
  if (value != 2) {
    printf("FAIL: time2 expected 2\n");
    exit(1);
  }
  glutMouseFunc(mouse);

  /* By attaching and detaching a menu to each button, make
     sure button usage for menus does not mess up normal button 

     callback. */
  glutCreateMenu(menu);
  glutAttachMenu(GLUT_RIGHT_BUTTON);
  glutAttachMenu(GLUT_MIDDLE_BUTTON);
  glutAttachMenu(GLUT_LEFT_BUTTON);
  glutDetachMenu(GLUT_RIGHT_BUTTON);
  glutDetachMenu(GLUT_MIDDLE_BUTTON);
  glutDetachMenu(GLUT_LEFT_BUTTON);
  glutDestroyMenu(glutGetMenu());

  switch (mouseButtons) {
  case 3:
    printf("In the black window, please click: left, then middle, then right buttons (in that order)\n");
    break;
  case 2:
    printf("In the black window, please click: left, then right buttons (in that order)\n");
    break;
  case 1:
    printf("In the black window, please click: left button\n");
    break;
  case 0:
    /* No mouse buttons??  Skip all subsequent tests since they 
       involve the mouse. */
    glutTimerFunc(1000, time7, 7);
    glutMouseFunc(NULL);
    break;
  }
}
Ejemplo n.º 5
0
void onMouseCb(int button, int state, int x, int y)
{
   theButtonState = button;
   theModifierState = glutGetModifiers();
   lastX = x;
   lastY = y;

   glutSetMenu(theMenu);
   if (theModifierState & GLUT_ACTIVE_ALT)
   {
      glutDetachMenu(GLUT_RIGHT_BUTTON);
   }
   else
   {
      glutAttachMenu(GLUT_RIGHT_BUTTON);
   }

   onMouseMotionCb(x, y);
}
Ejemplo n.º 6
0
void keydownfunc(unsigned char key, int x, int y)
{
    keys[key] = true;

    if (key == 27) // Escape Key Pressed
    {
        glutDestroyWindow(window_id);
        exit(0);
    }
    else if (key == 'm' && bound)
    {
        bound = false;
        glutSetCursor(GLUT_CURSOR_INHERIT);
        glutAttachMenu(GLUT_RIGHT_BUTTON);
    }
    else if (key == 'm' && !bound)
    {
        bound = true;
        glutSetCursor(GLUT_CURSOR_NONE);
        glutDetachMenu(GLUT_RIGHT_BUTTON);
        mousex = x;
        mousey = y;
    }
}
Ejemplo n.º 7
0
void muiHandleEvent(int event, int value, int x, int y)
{
    muiObject *obj;
    static int lastactive = 0;
    enum muiReturnValue retval;

    if (ActiveUIList == 0) {
        muiError("muiHandleEvent: no active UI list");
    }
    if (lastactive != ActiveUIList) {
        muiInitInteraction(lastactive = ActiveUIList);
    }
    if ((event == MUI_KEYSTROKE)) {
        if (obj = muiGetActiveTB()) {
            retval = (obj->handler)(obj, event, value, x, y);
            if (retval && obj->callback)
                (obj->callback)(obj, retval);
            return;
        }
        /* may have to add text editors, et cetera */
        return;
    }
    if (event == MUI_DEVICE_RELEASE && ActiveSlider) {
        retval = (ActiveSlider->handler)(ActiveSlider, event, value, x, y);
        if (retval && ActiveSlider->callback)
            (ActiveSlider->callback)(ActiveSlider, retval);
        ActiveSlider = 0;
        return;
    }
    ActiveCons = muiGetListCons(ActiveUIList);
    obj = muiFastHitInList(ActiveCons, x, y);
    if (obj == 0 && event == MUI_DEVICE_PRESS) {
        nonmuicallback(x, y);
        return;
    }
    if (event == MUI_DEVICE_UP && (!menuinuse) && (activemenu != -1) && (obj == 0 || obj->type != MUI_PULLDOWN)) {
        activemenu = -1;
        glutDetachMenu(GLUT_LEFT_BUTTON);
    }
    if (obj && (obj->type == MUI_VSLIDER || obj->type == MUI_HSLIDER)
            && event == MUI_DEVICE_PRESS)
        ActiveSlider = obj;
    if (obj == 0) {
        if (ActiveSlider) {
            retval = (ActiveSlider->handler)(ActiveSlider, event, value, x, y);
            if (retval && ActiveSlider->callback)
                (ActiveSlider->callback)(ActiveSlider, retval);
            return;
        }
        if (LocatedObj) {
            muiSetLocate(LocatedObj, 0);
            muiDrawObject(LocatedObj);
            LocatedObj = 0;
        }
        if ((event == MUI_DEVICE_RELEASE) && SelectedObj) {
            muiSetSelect(SelectedObj, 0);
            muiSetLocate(SelectedObj, 0);
            muiDrawObject(SelectedObj);
            LocatedObj = SelectedObj = 0;
        }
        return;
    }
    retval = (obj->handler)(obj, event, value, x, y);
    if (retval && obj->callback)
        (obj->callback)(obj, retval);
    return;
}
Ejemplo n.º 8
0
/**	Keyboard interaction function
@param unsigned char key
@param int x
@param int y
@return void
*/
void Cyb3DWorld::keyboard(unsigned char key, int x, int y)
{
    CybParameters *cybCore = CybParameters::getInstance();
    CybVector4D<float> color;
    switch (key)
    {
    case 'p':
        cybCore->initParameters();
        cybCore->transforChange = true;
        break;

    case 't':
        cybCore->xScale = cybCore->xScale / 1.1;
        cybCore->transforChange = true;
        break;
    case 'g':
        cybCore->xScale = cybCore->xScale * 1.1;
        cybCore->transforChange = true;
        break;
    case 'y':
        cybCore->yScale = cybCore->yScale / 1.1;
        cybCore->transforChange = true;
        break;
    case 'h':
        cybCore->yScale = cybCore->yScale * 1.1;
        cybCore->transforChange = true;
        break;
    case 'u':
        cybCore->zScale = cybCore->zScale / 1.1;
        cybCore->transforChange = true;
        break;
    case 'j':
        cybCore->zScale = cybCore->zScale * 1.1;
        cybCore->transforChange = true;
        break;

    case 'n':
        cybCore->setParalaxe(cybCore->getParalaxe() - 0.005);
        cybCore->modified = 1;
        break;
    case 'm':
        cybCore->setParalaxe(cybCore->getParalaxe() + 0.005);
        cybCore->modified = 1;
        break;
    case 'v':
        cybCore->setStereoMagnitude(cybCore->getStereoMagnitude() - 0.01);
        cybCore->modified = 1;
        break;
    case 'b':
        cybCore->setStereoMagnitude(cybCore->getStereoMagnitude() + 0.01);
        cybCore->modified = 1;
        break;

    case '0':
        cybCore->objChosen = 0;
        break;
    case '1':
        cybCore->objChosen = 1;
        break;
    case '2':
        cybCore->objChosen = 2;
        break;
    case '3':
        cybCore->objChosen = 3;
        break;
    case '4':
        cybCore->objChosen = 4;
        break;
    case '5':
        cybCore->objChosen = 5;
        break;
    case '6':
        cybCore->objChosen = 6;
        break;
    case '7':
        cybCore->objChosen = 7;
        break;
    case '8':
        cybCore->objChosen = 8;
        break;
    case '9':
        cybCore->objChosen = 9;
        break;

    case 'a':
        cybCore->habLayer[cybCore->objChosen] = 1;
        break;
    case 'd':
        cybCore->habLayer[cybCore->objChosen] = 0;
        break;

        // Active mouse interaction
    case 'i':
        if(cybCore->isInteractionEnable())
        {
            cybCore->mouseOn = true;
            CybMouseInteraction* mouseInteraction = CybMouseInteraction::getInstance();
            CybInterator* mouseInterator = mouseInteraction->getMouseInterator();
            if (mouseInterator != NULL)
            {
                mouseInterator->setEnabled(true);
            }


            glutDetachMenu(GLUT_RIGHT_BUTTON);

            glutSetCursor(GLUT_CURSOR_NONE);
            CybParameters::setCollisionStatus(true);
        }
        break;

        // Deactive mouse interaction
    case 'k':
        if(cybCore->isInteractionEnable())
        {
            cybCore->mouseOn = false;
            CybMouseInteraction* mouseInteraction = CybMouseInteraction::getInstance();
            CybInterator* mouseInterator = mouseInteraction->getMouseInterator();
            if (mouseInterator != NULL)
            {
                mouseInterator->setEnabled(false);
            }
            glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
            CybParameters::setCollisionStatus(false);
        }
        break;

        // alpha
    case '-':
        color = cybCore->getColor(cybCore->objChosen);
        if(color[3] > 0.1)
        {
            color[3] -= 0.1;
            cybCore->setColor(cybCore->objChosen, color);
        }
        break;
    case '+':
        color = cybCore->getColor(cybCore->objChosen);
        if(color[3] < 1)
        {
            color[3] += 0.1;
            cybCore->setColor(cybCore->objChosen, color);
        }
        break;

        // exit
    case 27:
        exit(0);
        break;
    }

    glutPostRedisplay();
}
Ejemplo n.º 9
0
bool SBOnKeyEvent( int key, unsigned short state )
{
	dbg_msg("SBOnKeyEvent(): key:%d  %d \n", key, state);

	if (state == KEY_UP)
	switch ( Scene_State )
	{
	case SCENE_TITLE:
		if ( key == ' ' || key == 62 )
		{
			Sub_State++;
			return true;
		}
		break;

#ifdef SB_DEBUG
	case SCENE_PLAY:
		if ( sIsDebugStartScene(key) )
		{
			Draw_Engine.init();
			return true;
		}
		if ( sIsDebugNextScene(key) )
		{
			Scene_State++;
			Sub_State = SUB_STATE0;
			Is_GameOver = TRUE;
			Is_GameCleared = FALSE;
			return true;
		}
		break;

	case SCENE_END:
		if ( sIsDebugStartScene(key) )
		{
			Draw_Engine.init();
			return true;
		}
		if ( sIsDebugNextScene(key) )
		{
			Is_GameOver = FALSE;
			Is_GameCleared = TRUE;
		}
		break;
#endif
	}

	//----// Dream's action
#ifdef SB_ANDROID

	//WSAD
	switch (key)
	{
	_CASE_ON_KEY(51,UP);		// android.view.KeyEvent.KEYCODE_W
	_CASE_ON_KEY(33,UP);		// KEYCODE_E
	_CASE_ON_KEY(47,DOWN);
	_CASE_ON_KEY(52,DOWN);
	_CASE_ON_KEY(54,DOWN);
	_CASE_ON_KEY(29,LEFT);
	_CASE_ON_KEY(32,RIGHT);
	_CASE_ON_KEY(38,SPUP);
	_CASE_ON_KEY(41,SPDOWN);
	_CASE_ON_KEY(42,LTURN);
	_CASE_ON_KEY(105,RTURN);
	_CASE_ON_KEY(66,FIRE);		// KEYCODE_ENTER
	}
#endif

	//
	if (state == KEY_UP)
	if ( key == 'p' || key == 44 )
	{
		SBOnTogglePause();
#ifdef SB_WIN
		if ( !game_paused )
		{
			glutTimerFunc(frame_rate, vGlutTimer, TIMER0);
			last_redraw_time = glutGet(GLUT_ELAPSED_TIME);
			glutAttachMenu(GLUT_RIGHT_BUTTON);
		}
		else
			glutDetachMenu(GLUT_RIGHT_BUTTON);
	}
#ifdef SB_DEBUG
	else if ( key == 'q' )
		exit(0);
#endif
#else
		return true;
	}
Ejemplo n.º 10
0
void GLUTCALLBACK Key(unsigned char key,int x,int y)
{
   char buf[30];
   glutSetMenu(controlMID);
   switch(key) {
      case '1':
         axis=X_AXIS;
         break;
      case '2':
         axis=Y_AXIS;
         break;
      case '3':
         axis=Z_AXIS;
         break;
      case '<':
      case ',':
         angle-=ROTATE_DELTA;
         sprintf(buf,"Angle: %+.1f",angle);
         glutChangeToMenuEntry(3,buf,3);
         break;
      case '>':
      case '.':
         angle+=ROTATE_DELTA;
         sprintf(buf,"Angle: %+.1f",angle);
         glutChangeToMenuEntry(3,buf,3);
         break;
      case '+':
      case '=':
         if(eesrSpeed<0.9)
            eesrSpeed+=0.08;
         sprintf(buf,"Speed: %+.2f",eesrSpeed);
         glutChangeToMenuEntry(5,buf,5);
         break;
      case '_':
      case '-':
         if(eesrSpeed>-0.9)
            eesrSpeed-=0.08;
         sprintf(buf,"Speed: %+.2f",eesrSpeed);
         glutChangeToMenuEntry(5,buf,5);
         break;
      case 'T':
         eesrSetTime(eesrGetTime()-1.0);
         break;
      case 't':
         eesrSetTime(eesrGetTime()+1.0);
         break;
      case 'm':
         if(menusActive) {
            glutDetachMenu(GLUT_LEFT_BUTTON);
            glutDetachMenu(GLUT_RIGHT_BUTTON);
            menusActive=FALSE;
         } else {
            glutSetMenu(controlMID);
            glutAttachMenu(GLUT_LEFT_BUTTON);
            glutSetMenu(optionMID);
            glutAttachMenu(GLUT_RIGHT_BUTTON);
            menusActive=TRUE;
         }
         break;
      case 27: /* escape */
      case 'q':
      case 'Q':
	 exit(0);
   }
#ifdef HAVE_GLUTCAVE
   GLUTCAVE_REDISPLAY();
#else
   glutPostRedisplay();
#endif
}
Ejemplo n.º 11
0
void pmotionfunc(int x, int y)
{
    if (bound)
    {
        glutSetMenu(canvas_menu_id);

        int deltax = x - mousex;
        int deltay = y - mousey;

        mousex = x;
        mousey = y;

        bool warp = false;
        if (mousex > 3*canvas.get_width()/4 || mousex < canvas.get_width()/4)
        {
            mousex = canvas.get_width()/2;
            warp = true;
        }

        if (mousey > 3*canvas.get_height()/4 || mousey < canvas.get_height()/4)
        {
            mousey = canvas.get_height()/2;
            warp = true;
        }

        if (warp)
            glutWarpPointer(mousex, mousey);

        if (scene.active_camera_valid())
        {
            scene.cameras[scene.active_camera]->orientation[1] -= (float)deltax/500.0;
            scene.cameras[scene.active_camera]->orientation[0] -= (float)deltay/500.0;
        }

        glutPostRedisplay();
    }
    else if (scene.active_camera_valid())
    {
        vec3f direction;
        vec3f position;

        if (scene.active_camera_valid())
        {
            if (scene.cameras[scene.active_camera]->type == "ortho")
            {
                position = canvas.unproject(canvas.to_window(vec2i(x, y)));
                direction = ror3(vec3f(0.0f, 0.0f, 1.0f), scene.cameras[scene.active_camera]->orientation);
            }
            else
            {
                position = scene.cameras[scene.active_camera]->position;
                direction = norm(canvas.unproject(canvas.to_window(vec2i(x, y))));
            }
        }

        int old_active_object = scene.active_object;
        scene.active_object = -1;
        for (int i = 0; i < scene.objects.size(); i++)
        {
            if (scene.objects[i] != NULL && scene.cameras[scene.active_camera]->model != scene.objects[i])
            {
                bool is_light = false;
                bool is_camera = false;

                // TODO Assignment 3: uncomment this
                //for (int j = 0; j < scene.lights.size() && !is_light; j++)
                //	if (scene.lights[j] != NULL && scene.lights[j]->model == scene.objects[i])
                //		is_light = true;

                for (int j = 0; j < scene.cameras.size() && !is_camera; j++)
                    if (scene.cameras[j] != NULL && scene.cameras[j]->model == scene.objects[i])
                        is_camera = true;

                if ((!is_light && !is_camera) || (is_light && scene.render_lights) || (is_camera && scene.render_cameras))
                {
                    vec3f invdir = 1.0f/direction;
                    vec3i sign((int)(invdir[0] < 0), (int)(invdir[1] < 0), (int)(invdir[2] < 0));
                    vec3f origin = position - scene.objects[i]->position;
                    float tmin, tmax, tymin, tymax, tzmin, tzmax;
                    tmin = (scene.objects[i]->bound[0 + sign[0]]*scene.objects[i]->scale - origin[0])*invdir[0];
                    tmax = (scene.objects[i]->bound[0 + 1-sign[0]]*scene.objects[i]->scale - origin[0])*invdir[0];
                    tymin = (scene.objects[i]->bound[2 + sign[1]]*scene.objects[i]->scale - origin[1])*invdir[1];
                    tymax = (scene.objects[i]->bound[2 + 1-sign[1]]*scene.objects[i]->scale - origin[1])*invdir[1];
                    if ((tmin <= tymax) && (tymin <= tmax))
                    {
                        if (tymin > tmin)
                            tmin = tymin;
                        if (tymax < tmax)
                            tmax = tymax;

                        tzmin = (scene.objects[i]->bound[4 + sign[2]]*scene.objects[i]->scale - origin[2])*invdir[2];
                        tzmax = (scene.objects[i]->bound[4 + 1-sign[2]]*scene.objects[i]->scale - origin[2])*invdir[2];

                        if ((tmin <= tzmax) && (tzmin <= tmax))
                        {
                            scene.active_object = i;
                            i = scene.objects.size();
                        }
                    }
                }
            }
        }

        if (scene.active_object != old_active_object)
        {
            bool is_light = false;
            bool is_camera = false;

            // TODO Assignment 3: uncomment this
            //for (int i = 0; i < scene.lights.size() && !is_light; i++)
            //	if (scene.lights[i] != NULL && scene.active_object_valid() && scene.lights[i]->model == scene.objects[scene.active_object])
            //		is_light = true;

            for (int i = 0; i < scene.cameras.size() && !is_camera; i++)
                if (scene.cameras[i] != NULL && scene.active_object_valid() && scene.cameras[i]->model == scene.objects[scene.active_object])
                    is_camera = true;

            glutDetachMenu(GLUT_RIGHT_BUTTON);
            if (scene.active_object == -1)
                glutSetMenu(canvas_menu_id);
            else if (is_light)
                glutSetMenu(light_menu_id);
            else if (is_camera)
                glutSetMenu(camera_menu_id);
            else
                glutSetMenu(object_menu_id);
            glutAttachMenu(GLUT_RIGHT_BUTTON);
            glutPostRedisplay();
        }
    }
}
Ejemplo n.º 12
0
/*
 * Class:     gruenewa_opengl_GLUT__
 * Method:    glutDetachMenu
 * Signature: (I)V
 */
JNIEXPORT void JNICALL Java_gruenewa_opengl_GLUT_00024_glutDetachMenu
  (JNIEnv * jenv, jobject jobj, jint arg1) {
   glutDetachMenu(arg1); 
}
Ejemplo n.º 13
0
void pmotionfunc(int x, int y)
{
	if (bound)
	{
		glutSetMenu(canvas_menu_id);

		int deltax = x - mousex;
		int deltay = y - mousey;

		mousex = x;
		mousey = y;

		bool set_warp = false;
		if (mousex > 3*width/4 || mousex < width/4)
		{
			mousex = width/2;
			set_warp = true;
		}

		if (mousey > 3*height/4 || mousey < height/4)
		{
			mousey = height/2;
			set_warp = true;
		}

		if (!set_warp)
			warp = false;

		if (scene.active_camera_valid() && !warp)
		{
			scene.cameras[scene.active_camera]->orientation[1] -= (float)deltax/500.0;
			scene.cameras[scene.active_camera]->orientation[0] -= (float)deltay/500.0;
		}

		if (set_warp)
		{
			glutWarpPointer(mousex, mousey);
			warp = true;
		}

		glutPostRedisplay();
	}
	else if (scene.active_camera_valid())
	{
		vec3f direction;
		vec3f position;

		if (scene.cameras[scene.active_camera]->type == "ortho")
		{
			GLdouble model[16];
			GLdouble proj[16];
			GLint view[4];
			glGetDoublev(GL_MODELVIEW_MATRIX, model);
			glGetDoublev(GL_PROJECTION_MATRIX, proj);
			glGetIntegerv(GL_VIEWPORT, view);
			vec<double, 3> p;
			gluUnProject(x, height-y, 0.0f, model, proj, view, &p[0], &p[1], &p[2]);
			position = p;
			direction = ror3(vec3f(0.0f, 0.0f, 1.0f), scene.cameras[scene.active_camera]->orientation);
		}
		else
		{
			GLdouble model[16];
			GLdouble proj[16];
			GLint view[4];
			glGetDoublev(GL_MODELVIEW_MATRIX, model);
			glGetDoublev(GL_PROJECTION_MATRIX, proj);
			glGetIntegerv(GL_VIEWPORT, view);
			vec<double, 3> p;
			gluUnProject(x, height-y, 0.0f, model, proj, view, &p[0], &p[1], &p[2]);
			position = scene.cameras[scene.active_camera]->position;
			direction = norm(p - position);
		}

		int old_active_object = scene.active_object;
		scene.active_object = -1;
		for (int i = 0; i < scene.objects.size(); i++)
		{
			if (scene.objects[i] != NULL && scene.cameras[scene.active_camera]->model != scene.objects[i])
			{
				bool is_light = false;
				bool is_camera = false;

				for (int j = 0; j < scene.lights.size() && !is_light; j++)
					if (scene.lights[j] != NULL && scene.lights[j]->model == scene.objects[i])
						is_light = true;

				for (int j = 0; j < scene.cameras.size() && !is_camera; j++)
					if (scene.cameras[j] != NULL && scene.cameras[j]->model == scene.objects[i])
						is_camera = true;

				if ((!is_light && !is_camera) || (is_light && scene.render_lights) || (is_camera && scene.render_cameras))
				{
					vec3f invdir = 1.0f/direction;
					vec3i sign((int)(invdir[0] < 0), (int)(invdir[1] < 0), (int)(invdir[2] < 0));
					vec3f origin = position - scene.objects[i]->position;
					float tmin, tmax, tymin, tymax, tzmin, tzmax;
					tmin = (scene.objects[i]->bound[0 + sign[0]]*scene.objects[i]->scale - origin[0])*invdir[0];
					tmax = (scene.objects[i]->bound[0 + 1-sign[0]]*scene.objects[i]->scale - origin[0])*invdir[0];
					tymin = (scene.objects[i]->bound[2 + sign[1]]*scene.objects[i]->scale - origin[1])*invdir[1];
					tymax = (scene.objects[i]->bound[2 + 1-sign[1]]*scene.objects[i]->scale - origin[1])*invdir[1];
					if ((tmin <= tymax) && (tymin <= tmax))
					{
						if (tymin > tmin)
							tmin = tymin;
						if (tymax < tmax)
							tmax = tymax;

						tzmin = (scene.objects[i]->bound[4 + sign[2]]*scene.objects[i]->scale - origin[2])*invdir[2];
						tzmax = (scene.objects[i]->bound[4 + 1-sign[2]]*scene.objects[i]->scale - origin[2])*invdir[2];

						if ((tmin <= tzmax) && (tzmin <= tmax))
						{
							scene.active_object = i;
							i = scene.objects.size();
						}
					}
				}
			}
		}

		if (scene.active_object != old_active_object)
		{
			bool is_light = false;
			bool is_camera = false;

			for (int i = 0; i < scene.lights.size() && !is_light; i++)
				if (scene.lights[i] != NULL && scene.active_object_valid() && scene.lights[i]->model == scene.objects[scene.active_object])
					is_light = true;

			for (int i = 0; i < scene.cameras.size() && !is_camera; i++)
				if (scene.cameras[i] != NULL && scene.active_object_valid() && scene.cameras[i]->model == scene.objects[scene.active_object])
					is_camera = true;

			glutDetachMenu(GLUT_RIGHT_BUTTON);
			if (scene.active_object == -1)
				glutSetMenu(canvas_menu_id);
			else if (is_light)
				glutSetMenu(light_menu_id);
			else if (is_camera)
				glutSetMenu(camera_menu_id);
			else
				glutSetMenu(object_menu_id);
			glutAttachMenu(GLUT_RIGHT_BUTTON);
			glutPostRedisplay();
		}
	}
}
Ejemplo n.º 14
0
void update_Display(void){

  if(update_have_gvec == 1){
    update_have_gvec = 0;
    update_gvec_down(1);
  }
  if(update_smokecolorbar == 1){
    update_smokecolorbar = 0;
    SmokeColorBarMenu(fire_colorbar_index);
  }
  if(update_colorbartype == 1){
    colorbardata *cb;

    cb = getcolorbar(colorbarname);
    if(cb != NULL){
      colorbartype = cb - colorbarinfo;
      current_colorbar = cb;
      if(colorbartype != colorbartype_default){
        colorbartype_ini = colorbartype;
      }
    }
    update_colorbartype = 0;
  }
  if(update_fire_line == 1){
    WUI_CB(TERRAIN_FIRE_LINE_UPDATE);
    update_fire_line = 0;
  }
  if(updatezoommenu == 1 || first_display > 0){
    if(first_display > 0)first_display--;
    updatezoommenu = 0;
    ZoomMenu(zoomindex);
  }
  if(update_makeiblank_smoke3d == 1){
    makeiblank_smoke3d();
  }
#ifdef pp_CULL
  if(update_initcull == 1)initcull(cullsmoke);
#endif
  if(update_streaks == 1 && ReadPartFile == 1){
    ParticleStreakShowMenu(streak_index);
    update_streaks = 0;
  }
  if(update_screensize == 1){
    update_screensize = 0;
    update_windowsizelist();
    ResizeWindow(screenWidthINI, screenHeightINI);
  }
  if(updatemenu == 1 && usemenu == 1 && menustatus == GLUT_MENU_NOT_IN_USE){
    glutDetachMenu(GLUT_RIGHT_BUTTON);
    InitMenus(LOAD);
    glutAttachMenu(GLUT_RIGHT_BUTTON);
    updatemenu = 0;
  }
  if(update_fire_colorbar_index == 1){
    SmokeColorBarMenu(fire_colorbar_index_ini);
    update_fire_colorbar_index = 0;
  }
  if(showtime == 0 && ntotal_smooth_blockages > 0){
    update_smoothblockage_info();
  }
  if(update_colorbar_select_index == 1 && colorbar_select_index >= 0 && colorbar_select_index <= 255){
    update_colorbar_select_index = 0;
    UpdateRGBColors(colorbar_select_index);
  }
}
Ejemplo n.º 15
0
int setup_case(int argc, char **argv){
  int return_code;
  char *input_file;

  /* 
  warning: the following line was commented out!! (perhaps it broke something)
     this line is necessary in order to define smv_filename and trainer_filename
  */
 // parse_commandlines(argc, argv); 
  return_code=-1;
  if(strcmp(input_filename_ext,".svd")==0||demo_option==1){
    trainer_mode=1;
    trainer_active=1;
    if(strcmp(input_filename_ext,".svd")==0){
      input_file=trainer_filename;
    }
    else if(strcmp(input_filename_ext,".smt")==0){
      input_file=test_filename;
    }
    else{
      input_file=smv_filename;
    }
    return_code=readsmv(input_file,iso_filename);
    if(return_code==0){
      show_glui_trainer();
      show_glui_alert();
    }
  }
  else{
    input_file=smv_filename;
    return_code=readsmv(input_file,iso_filename);
  }
  switch(return_code){
    case 1:
      fprintf(stderr,"*** Error: Smokeview file, %s, not found\n",input_file);
      return 1;
    case 2:
      fprintf(stderr,"*** Error: problem reading Smokeview file, %s\n",input_file);
      return 2;
    case 0:
      readsmv_dynamic(input_file);
      break;
    default:
      ASSERT(FFALSE);
  }

  /* initialize units */

  InitUnits();
  init_unit_defs();
  set_unit_vis();

  CheckMemory;
  readini(NULL);
  readboundini();
  if(use_graphics==0)return 0;
#ifdef pp_LANG
  init_lang();
#endif

  if(sb_atstart==1)smooth_blockages();

  if(ntours==0)setup_tour();
  glui_colorbar_setup(mainwindow_id);
  glui_motion_setup(mainwindow_id);
  glui_bounds_setup(mainwindow_id);
  glui_shooter_setup(mainwindow_id);
  glui_geometry_setup(mainwindow_id);
  glui_clip_setup(mainwindow_id);
  glui_wui_setup(mainwindow_id);
  glui_labels_setup(mainwindow_id);
  glui_device_setup(mainwindow_id);
  glui_tour_setup(mainwindow_id);
  glui_alert_setup(mainwindow_id);
  glui_stereo_setup(mainwindow_id);
  glui_3dsmoke_setup(mainwindow_id);

  if(UpdateLIGHTS==1)updateLights(NULL,NULL);

  glutReshapeWindow(screenWidth,screenHeight);

  glutSetWindow(mainwindow_id);
  glutShowWindow();
  glutSetWindowTitle(fdsprefix);
  Init();
  glui_trainer_setup(mainwindow_id);
  glutDetachMenu(GLUT_RIGHT_BUTTON);
  InitMenus(LOAD);
  glutAttachMenu(GLUT_RIGHT_BUTTON);
  if(trainer_mode==1){
    show_glui_trainer();
    show_glui_alert();
  }
  return 0;
}