コード例 #1
0
ISound* MySound::startSound3D(ISound* sound, const char* sndLocation, vec3 position) {
  if (sound->isFinished()) {
    sound = engine->play3D(sndLocation, vec3df(position.x, position.y, position.z), false, false, true);
  }
  else if (sound->getIsPaused()) {
    sound = engine->play3D("../dependencies/irrKlang/media/killing_to_me.wav", vec3df(position.x, position.y, position.z), false, true, true);
    sound->setIsPaused(false);
  }
  return sound;
}
コード例 #2
0
void SoundSystem::Play3D(Sound3D* media){
	if(Instance().CheckSoundPlaying(media)){//if playing
		ISound* temp = Instance().currPlayingLoopedSounds[media];
		if(!temp->getIsPaused()){
			temp->setPlayPosition(0.0f);//set back to beginning
		}
		temp->setIsLooped(false);
		temp->setSoundStopEventReceiver (Instance().sndEndReceiver,media);
		temp->setVolume(media->volume);
		temp->setMinDistance(media->minSoundDist);
		temp->setMaxDistance(FLT_MAX); // max attenuation distance
		temp->setIsPaused(false);
	}else{
		//creates a new sound instance
         ISound* temp = Instance().soundEngine->play3D(media->mySoundSource,vec3df(media->GetSoundPosition()[x],media->GetSoundPosition()[y],media->GetSoundPosition()[z]),false,false,true);
		
		//ISound* temp = Instance().soundEngine->play3D(media->mySoundSource,media->GetPosition(),false,true);
		Instance().currPlayingLoopedSounds.insert(std::pair<Sound*,ISound*>(media,temp));
		temp->setSoundStopEventReceiver(Instance().sndEndReceiver,media);
		temp->setVolume(media->volume);
		temp->setMinDistance(media->minSoundDist);
		temp->setMaxDistance(FLT_MAX); // max attenuation distance
		temp->setIsPaused(false);
		
	}
}
コード例 #3
0
ファイル: CClientSound.cpp プロジェクト: 50p/multitheftauto
void CClientSound::SetPosition ( const CVector& vecPosition )
{
    m_vecPosition = vecPosition;
    if ( m_pSound )
    {
        m_pSound->setPosition ( vec3df ( vecPosition.fX, vecPosition.fY, vecPosition.fZ ) );
    }
}
コード例 #4
0
void SoundSystem::SetSoundPosition(Sound* media, Vect& newPos ){
	map<Sound*,ISound*>::iterator it;
	it = Instance().currPlayingLoopedSounds.find(media);
	if(it!=Instance().currPlayingLoopedSounds.end()){//if found
		DebugVisualizer::ShowPoint(Vect(newPos[x], newPos[y],-newPos[z]));
		Instance().currPlayingLoopedSounds[media]->setPosition( vec3df(newPos[x], newPos[y],-newPos[z]) ); //Azul (right hand) to irrklang (left hand)
	
	}
}
コード例 #5
0
ファイル: R2D2Audio.cpp プロジェクト: kamilkazmierczak/Doom
void R2D2Audio::play3DAudio(vec3 position)
{

	if(_lastPlayTime + _delay < glfwGetTime())
	{
		_lastPlayTime = glfwGetTime();
		GLfloat random = rand() % 3 + 1;

		if (random == 0)
			_music = _engine->play3D(findPatch("r2d2a"), vec3df(0, 0, 0), false, false, true);
		if (random == 1)
			_music = _engine->play3D(findPatch("r2d2b"), vec3df(0, 0, 0), false, false, true);
		else 
			_music = _engine->play3D(findPatch("r2d2c"), vec3df(0, 0, 0), false, false, true);

		_music->setMinDistance(2.0f);
		_music->setPosition(vec3df(position.x, position.y, position.z));
	
	}

}
コード例 #6
0
BoundingSphere::BoundingSphere(vert_ls verts)
{
    static int count;
    count++;
    
    vert_ls* partitions;
    
    switch (verts.size()) {
        case 0:
            cout << "error: shouldn't be empty\n";
            exit(EXIT_FAILURE);
            break;
            
        case 1:
            center = *verts.front();
            center.color = vec3df(0.0, 1.0, 0.0);
            center.leaf = true;
            break;
            
        default:
            partitions = partitionMesh(verts);
            
            //printf("node: %i, left: %lu, right %lu\n", count, partitions[0].size(), partitions[1].size() );
            
            if (partitions[0].empty() || partitions[1].empty() )
            {
                printf("error: A partition of node %i was empty!\n", count);
                exit(EXIT_SUCCESS);
            }
            
            leftSubTree = new BoundingSphere(partitions[0]);
            rightSubTree = new BoundingSphere(partitions[1]);
            
            center.normal = (leftSubTree->center.normal + rightSubTree->center.normal).normalize();
            center.color = vec3df(0.9, 0.9, 0.9);
            center.leaf = false;
            break;
    }
}
コード例 #7
0
void SceneBase::UpdateSoundStatus(const unsigned char key)
{
	static bool shootsound = true;
	static bool reload = true;
	static bool pickup = true;
	static bool attacked = true;

	engine->setListenerPosition(vec3df(player.camera.getPosition().x, player.camera.getPosition().y, player.camera.getPosition().z),vec3df(player.camera.getView().x, player.camera.getView().y, player.camera.getView().z));

	switch(player.bagpack.currentWeapon->getWeaponType())
	{
	case WEAP_PISTOL:
		{
			if (key == '1' && shootsound)
			{
				snd[FIREPISTOL] = engine->play2D("Wav//pistol.wav");
				shootsound = false;
			}

			else if (key != '1')
			{
				shootsound = true;
			}

			if (key == '2' && reload)
			{
				snd[FIREPISTOL] = engine->play2D("Wav//pistolreload.wav");
				reload = false;
			}

			else if (key != '2')
			{
				reload = true;
			}

			break;
		}
	case WEAP_RIFLE:
		{
			if (key == '1' && shootsound)
			{
				snd[FIRERIFLE] = engine->play2D("Wav//rifle.wav");
				shootsound = false;
			}

			else if (key != '1')
			{
				shootsound = true;
			}

			if (key == '2' && reload)
			{
				snd[FIREPISTOL] = engine->play2D("Wav//riflereload.wav");
				reload = false;
			}

			else if (key != '2')
			{
				reload = true;
			}
			break;
		}
	}

	if(key == 'p' && pickup)
	{
		snd[FIREPISTOL] = engine->play2D("Wav//bonus.ogg");
		pickup = false;
	}

	else if (key != 'p')
	{
		pickup = true;
	}

	//if (key == '0' && attacked)
	//{	
	//	snd[ATTACKED] = engine->play2D("Wav//attacked.wav");
	//	attacked = false;
	//}

	//else if (key != '0')
	//{
	//	attacked = true;
	//}
}
コード例 #8
0
ファイル: VRSim.cpp プロジェクト: nburfield/VirtualReality
void VRSim::DSGeometryPass(){
  m_gbuffer.BindForGeomPass();
  //geomProgram.enable();

  // Only the geometry pass updates the depth buffer

  glDepthMask(GL_TRUE);
  glDepthFunc(GL_LEQUAL);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glEnable(GL_DEPTH_TEST);

  //render the pointer

  cursor.render(cam->getView());

  //render each ball of the color palette
  /*
  for(int i = 0; i < colorPalette.size(); i++){
    colorPalette[i].render(cam->getView());
  }
  */

  // Rui's fake gravity
  float deltaTime = cavr::input::InputManager::dt()*1000;
  //std::cout<<deltaTime<<std::endl;



  // update listener's pos
  auto listenerPos = cavr::input::getSixDOF("head")->getPosition();

  engine->setListenerPosition(vec3df(listenerPos.x,listenerPos.y,listenerPos.z), // Listener's position
  vec3df(0,0,1)); // What direction is the listener's facing directiion -- in this case we are always stareing forward..


  //enable the terrains program and render it
  terrain->enable();
  terrain->model = cavr::math::mat4f::translate(cavr::math::vec3f(0 , -100 , 0));
  terrain->render(terrain->time);

  //enable geom program for those objects that require it
  geomProgram.enable();

  //load regular models

  //render the painting itself
  for(int i = 0; i < painting.size(); i++){
    // update music position
    cavr::math::vec3f tempPos = painting[i].getPos();
    music[i]->setPosition(vec3df(tempPos.x,tempPos.y,tempPos.z));
    timeFromPaint[i] = timeFromPaint[i] + deltaTime;
    
    // need to change this line a little bit to make it fall down using g=9.8
    //if(terrain->fallOnGround(tempPos,sphereRadius)==false)
    // std::cout<<"y: "<<tempPos.y<<std::endl;
    // std::cout<<"terrain height: "<<terrainHeight[i]<<std::endl;
    // std::cout<<tempPos.y-terrainHeight[i]<<std::endl;
    if(terrain->fallOnGround(tempPos.y-terrainHeight[i],sphereRadius)==false)
    {
      painting[i].setPos(cavr::math::vec3f(tempPos.x,tempPos.y-timeFromPaint[i],tempPos.z));  
    }
    

    //painting[i].renderPainting(wand_sixdof->getPosition() + cavr::math::vec3f(0, 0, -2), cam->getView(), wand_sixdof->getForward());

    // Render the sphere
    textpaint.model = cavr::math::mat4f::translate(painting[i].getPos()) * cavr::math::mat4f::scale(0.2);
    //pen.model = cavr::math::mat4f::translate(cavr::math::vec3f(0,0,0)) * cavr::math::mat4f::scale(0.1) ;
    auto mvp4 = (cavr::gfx::getProjection() * (cavr::gfx::getView() * cam->getView()) * textpaint.model );
    geomProgram.set("gWVP", mvp4);
    geomProgram.set("gWorld", textpaint.model);
    geomProgram.set("gColorMap", 0);
    // textpaint.renderModel(textures[0]);
    textpaint.renderModel(textures[painting[i].GetIndex()].id, textures[painting[i].GetIndex()].image);
  }

  /////loads one model/////
  wand_sixdof = cavr::input::getSixDOF("wand");
  pen.model = wand_sixdof->getMatrix()* cavr::math::mat4f::translate(cavr::math::vec3f(0,0,-1)) * cavr::math::mat4f::scale(0.1);
  //pen.model = cavr::math::mat4f::translate(cavr::math::vec3f(0,0,0)) * cavr::math::mat4f::scale(0.1) ;
  auto mvp4 = (cavr::gfx::getProjection() * (cavr::gfx::getView()) * pen.model );
  geomProgram.set("gWVP", mvp4);
  geomProgram.set("gWorld", pen.model);
  geomProgram.set("gColorMap", 0);
  pen.renderModel();
  /////////////////////////

  /////loads one model/////
  textpaint.model = wand_sixdof->getMatrix()* cavr::math::mat4f::translate(cavr::math::vec3f(0,1,0)) * cavr::math::mat4f::scale(0.1);
  //pen.model = cavr::math::mat4f::translate(cavr::math::vec3f(0,0,0)) * cavr::math::mat4f::scale(0.1) ;
  mvp4 = (cavr::gfx::getProjection() * (cavr::gfx::getView()) * textpaint.model );
  geomProgram.set("gWVP", mvp4);
  geomProgram.set("gWorld", textpaint.model);
  geomProgram.set("gColorMap", 0);
  textpaint.renderModel(textures[textureindex].id, textures[textureindex].image);
  /////////////////////////

  glDepthMask(GL_FALSE);
}
コード例 #9
0
ファイル: VRSim.cpp プロジェクト: nburfield/VirtualReality
void VRSim::processInput(){
  // handle analog stick movement
  auto xAnalog = cavr::input::getAnalog("x");
  auto xVal = xAnalog->getValue();
  auto yAnalog = cavr::input::getAnalog("y");
  auto yVal = yAnalog->getValue();

  // cout << xVal << " | " << yVal << "\n";
  if (cavr::input::getButton("boost")->delta() != cavr::input::Button::Held) {
      speedMod = 5.0f;
  }
  else{
    speedMod = 2.0f;
  }

  if(abs(xVal) > 0.05 || abs(yVal) > 0.05) {
    if (cavr::input::getButton("rotation")->delta() == cavr::input::Button::Held) {
        Engine::getEngine()->graphics->camera->rotate(xVal, yVal);
    }
    else{
      //auto head = cavr::input::getSixDOF("head");
      cavr::math::vec3f look_dir = cam->ViewDir;
      cavr::math::vec3f move_dir = (cavr::math::vec3f(-xVal, 0, yVal));
      cam->Move(look_dir * (yVal/speedMod));
      cam->Move(cam->RightVector * (xVal/speedMod));
      //cam->StrafeRight(xVal);
      //cam->Move(move_dir);

      //Engine::getEngine()->graphics->camera->Move(move_dir);
    }
  }

  //do this for each color palette ball
  for(int i = 0; i < colorPalette.size(); i++){
    if(cavr::input::getButton("color")->delta() != cavr::input::Button::Open){
      cavr::gfx::Ray ray(wand_sixdof->getPosition(), wand_sixdof->getForward());
       if(solveRaycast(ray, colorPalette[i].getPos(), 0.075)) {
         currentColor = colorPalette[i].getColor();
       }
    }
  }

  if(cavr::input::getButton("clear")->delta() != cavr::input::Button::Open){
    painting.clear();
    engine->removeAllSoundSources();
    nodeMusicName.clear();
    music.clear();
  }

  if(cavr::input::getButton("replay")->delta() != cavr::input::Button::Open){
    engine->removeAllSoundSources();
    music.clear();
    for(int i=0; i<nodeMusicName.size(); i++)
    {
       // get the position of the current 
       cavr::math::vec3f paintBallPos = painting[i].getPos();
       music.push_back(engine->play3D(nodeMusicName[i],
                    vec3df(paintBallPos.x,paintBallPos.y,paintBallPos.z), // Music source position
                    false, // play looped
                    false, //  start paused
                    true) 
                  );
       // delay and play next one
       // this is the easiest way to do it
       // for irrklang lib there is no delay playing function
       // based on my search
       usleep(100000);
    }

  }

  // Switch the texture to be painted
  if(cavr::input::getButton("switchTexture")->delta() == cavr::input::Button::Held)
  {
    if(buttonPress)
    {
      std::cout << "Switching Texture" << std::endl;
      textureindex++;
      if(textureindex == textures.size())
      {
        textureindex = 0;
      }
      usleep(100000);
    }
    buttonPress = !buttonPress;
  }

  //if(cavr::input::getButton("paint")->delta() != cavr::input::Button::Open){
  if(cavr::input::getButton("placeBall")->delta() != cavr::input::Button::Open){
     Paintball temp(textureindex);

     //newView[2][0] = -newView[2][0];
     //newView[2][2] = -newView[2][2];
     cavr::math::vec3f forward = wand_sixdof->getForward();
     cavr::math::mat4f tempMat = (/*cam->getView()**/ wand_sixdof->getMatrix() * cavr::math::mat4f::translate(cavr::math::vec3f(0,0,-2)));
     cavr::math::vec3f wf = cavr::math::vec3f(tempMat[2][0], tempMat[2][1], tempMat[2][2]);
     cavr::math::vec3f wp = cavr::math::vec3f(tempMat[3][0], tempMat[3][1], tempMat[3][2]);
     cavr::math::vec3f better  =  cam->getPos() + cam->ViewDir + cavr::math::vec3f(wf.x, wf.y, wf.z) +cavr::math::vec3f(-wp.x, wp.y, -wp.z) ;
     temp.setPos(cavr::math::vec3f(-tempMat[3][0]+playerPos.x, tempMat[3][1]+playerPos.y, -tempMat[3][2]+playerPos.z));
     //temp.setPos(better);

     painting.push_back(temp);
     int musicNameIndex;
     //std::cout<<(cavr::math::vec3f(1,0,0)==cavr::math::vec3f(1,0,0))<<std::endl; 
     // for(int i = 0; i < colorPalette.size(); i++)
     // {
     //  // find the index of current color
     //  if(currentColor == colorPalette[i].getColor())
     //  {
     //    musicNameIndex = i % musicName.size();
     //  }
     // }
     musicNameIndex = textureindex % musicName.size();
     // Rui sound
     cavr::math::vec3f paintBallPos = temp.getPos();
     music.push_back(engine->play3D(musicName[musicNameIndex],
                      vec3df(paintBallPos.x,paintBallPos.y,paintBallPos.z), // Music source position
                      false, // play looped
                      false, //  start paused
                      true)
                    );
     nodeMusicName.push_back(musicName[musicNameIndex]);

     // init the start time
     timeFromPaint.push_back(0);

     // Rui fake gravity
     terrainHeight.push_back(terrain->findCurrentY(paintBallPos));
  }

  wand_sixdof = cavr::input::getSixDOF("wand");
  cursor.wandModel = (wand_sixdof->getMatrix() * cavr::math::mat4f::translate(0, 0, -2.5) * cavr::math::mat4f::scale(0.1));

  cursor.setColor(currentColor);
  playerPos = Engine::getEngine()->graphics->camera->getPos();
}
コード例 #10
0
void MySound::setListenerPos(vec3 position, vec3 direction) {
  engine->setListenerPosition(vec3df(position.x, position.y, position.z),
    vec3df(direction.x, direction.y, direction.z));
}
コード例 #11
0
MySound::MySound() {

  this->engine = createIrrKlangDevice();
  if (!engine) {
    std::cerr << "Oh dear the sound engine did not start up" << std::endl; // error starting up the engine
  }
  //engine->play2D("../dependencies/irrKlang/media/Sinner Monologues.wav", false, false, true);
  // Play something on loop for background music
  //this->openBckGrnd = engine->play2D("../dependencies/irrKlang/media/ope.wav", false, true, true);
  //this->openBckGrnd->setVolume(.05);
  //this->openBckGrnd->setSoundStopEventReceiver(myReceiver, 0);
  //this->openBckGrnd->setIsPaused(false);
  this->backGroundSnd = engine->play2D("../dependencies/irrKlang/media/red_sky_at_night.wav", true, true, true);
  this->backGroundSnd->setVolume(.05);

  this->noseSnd = engine->play2D("../dependencies/irrKlang/media/ow_my_nose.wav", false, true, true);
  this->noseSnd->setVolume(.7);
  this->footSndPlayr = engine->play2D("../dependencies/irrKlang/media/footstepsWalk2.wav", false, true, true);

  this->guardTalk = engine->play3D("../dependencies/irrKlang/media/killing_to_me.wav", vec3df(0, 0, 0), false, true, true);
  this->guardTalk->setMinDistance(1.0f);

  this->loseSnd = engine->play2D("../dependencies/irrKlang/media/endNoise1.wav", false, true, true);
  this->loseSnd->setVolume(0.5);
  this->winSnd = engine->play2D("../dependencies/irrKlang/media/end.wav", false, true, true);
  this->winSnd->setVolume(0.5);
  this->collectableSnd = engine->play2D("../dependencies/irrKlang/media/collect0.wav", false, true, true);
  this->collectableSnd->setVolume(0.5);

  this->openingSnd = engine->play2D("../dependencies/irrKlang/media/intro.wav", false, true, true);
  this->openingSnd->setVolume(.5);

  this->leanOut = engine->play2D("../dependencies/irrKlang/media/leanOut.wav", false, true, true);
  this->leanOut->setVolume(.05);
  this->leanIn = engine->play2D("../dependencies/irrKlang/media/leanIn.wav", false, true, true);
  this->leanIn->setVolume(.05);

  this->reactSnd = engine->play2D("../dependencies/irrKlang/media/guard1_Reac.wav", false, true, true);
  this->reactSnd->setVolume(0.3);

  this->dismissSnd = engine->play2D("../dependencies/irrKlang/media/guard1_Dismiss.wav", false, true, true);
  this->dismissSnd->setVolume(0.3);
}