void *get_pthread(void *arg){ char buf[100]; listptr=lookdir("/opt"); _7seg_info_t segment; while(1){ printf("thread1\n"); printf("please input your cmd:"); fflush(stdout); printf("\nlistptr->songname=%s\n",listptr->song_name); printf("listptr->nextPtr->songname=%s\n",listptr->nextPtr->song_name); fgets(buf,sizeof(buf),stdin); if(strlen(buf)==6) { printf("\n13456789\n"); ioctl(fd1, 1, NULL); }else if(strlen(buf)>=8) { ioctl(fd1, 2, NULL); } printf("after fgets.............listptr->songname=%s\n",listptr->song_name); buf[strlen(buf)] = '\0'; printf("*%s*\n", buf); if(write(fd_fifo, buf, strlen(buf)) != strlen(buf)) perror("write"); } }
bool EditorFrameHandler::MouseMoved( const OIS::MouseEvent &arg ) { if( arg.state.buttonDown( OIS::MB_Right ) ) { mRotX = Ogre::Degree(-arg.state.X.rel * 0.13); mRotY = Ogre::Degree(-arg.state.Y.rel * 0.13); // //EditorCamera->pitch(Ogre::Degree(mRotY)); //EditorCamera->yaw(Ogre::Degree(mRotX)); // Ogre::Quaternion q, orientation; q.FromAngleAxis(mRotY, Ogre::Vector3::UNIT_X); orientation.FromAngleAxis(mRotX, Ogre::Vector3::UNIT_Y); orientation = orientation*q; Ogre::Vector3 lookdir(orientation*Ogre::Vector3::NEGATIVE_UNIT_Z); Ogre::Vector3 xVec = Ogre::Vector3::UNIT_Y.crossProduct(lookdir); xVec.normalise(); Ogre::Vector3 yVec = lookdir.crossProduct(xVec); yVec.normalise(); Ogre::Quaternion unitZToTarget = Ogre::Quaternion(xVec, yVec, lookdir); orientation = Ogre::Quaternion(-unitZToTarget.y, -unitZToTarget.z, unitZToTarget.w, unitZToTarget.x); EditorCamera->setOrientation(EditorCamera->getOrientation()*orientation); } return true; }
void EnPlayerNameDisplay::updateName() { EnPlayer* p_player = dynamic_cast< EnPlayer* >( vrc::gameutils::PlayerUtils::get()->getLocalPlayer() ); if ( !p_player ) return; // names are only displayed in Ego camera mode if ( p_player->getPlayerImplementation()->getCameraMode() != BasePlayerImplementation::Ego ) { _nameBox->setText( "" ); return; } EnCamera* p_playercamera = p_player->getPlayerImplementation()->getPlayerCamera(); const osg::Vec3f& campos = p_playercamera->getCameraPosition() + p_playercamera->getCameraOffsetPosition(); const osg::Quat& camrotlocal = p_playercamera->getLocalRotation(); const osg::Quat& camrot = p_playercamera->getCameraRotation(); // calculate the player look direction osg::Vec3f lookdir( 0.0f, 1.0f, 0.0f ); lookdir = camrotlocal * camrot * lookdir; // a line between a remote client and camera osg::Vec3f line; osg::Vec3f maxdist( 1000000.0f, 0.0f, 0.0f ); //! find nearest player in front of local player yaf3d::BaseEntity* p_playerinfront = NULL; std::vector< yaf3d::BaseEntity* >& remoteplayers = vrc::gameutils::PlayerUtils::get()->getRemotePlayers(); std::vector< yaf3d::BaseEntity* >::iterator p_beg = remoteplayers.begin(), p_end = remoteplayers.end(); for ( ; p_beg != p_end; ++p_beg ) { line = ( *p_beg )->getPosition() - campos; osg::Vec3f dir( line ); dir.normalize(); // check if the player is in our view if ( ( dir * lookdir ) > _viewAngle ) { // store the nearest distance ( sorting ) if ( maxdist.length2() > line.length2() ) { maxdist = line; p_playerinfront = *p_beg; } } } if ( p_playerinfront ) { EnPlayer* p_playerentity = dynamic_cast< EnPlayer* >( p_playerinfront ); assert( p_playerentity && "wrong object type: EnPlayer expected!" ); std::string playername = p_playerentity->getPlayerName(); _nameBox->setText( playername ); } else { _nameBox->setText( "" ); } }