Exemple #1
0
void FPSCamera::KeyPressed(int key, bool repeat) {
	if (repeat) {
		const float keySens = inputHandler->GetKeySensitivity();
		const bool mouseLook = AUX->GetMouseLook();

		switch (key) {
			case SDLK_LALT:  { VStrafe( 1, keySens); } break;
			case SDLK_LCTRL: { VStrafe(-1, keySens); } break;

			case SDLK_w: { Move(    1, keySens); } break;
			case SDLK_s: { Move(   -1, keySens); } break;
			case SDLK_a: { HStrafe(-1, keySens); } break;
			case SDLK_d: { HStrafe( 1, keySens); } break;
			case SDLK_q: { Roll(   -1, keySens * DEG2RAD(0.5f)); } break;
			case SDLK_e: { Roll(    1, keySens * DEG2RAD(0.5f)); } break;

			case SDLK_UP:    { if (!mouseLook) { Pitch(-1, keySens * DEG2RAD(0.5f)); } } break;
			case SDLK_DOWN:  { if (!mouseLook) { Pitch( 1, keySens * DEG2RAD(0.5f)); } } break;
			case SDLK_LEFT:  { if (!mouseLook) { Yaw(  -1, keySens * DEG2RAD(0.5f)); } } break;
			case SDLK_RIGHT: { if (!mouseLook) { Yaw(   1, keySens * DEG2RAD(0.5f)); } } break;

			default: {} break;
		}
	}
}
Vector2D GoalKeeper::GetRearInterposeTarget()const
{
  double xPosTarget = Team()->HomeGoal()->Center().x;

  double yPosTarget = Pitch()->PlayingArea()->Center().y - 
                     Prm.GoalWidth*0.5 + (Ball()->Pos().y*Prm.GoalWidth) /
                     Pitch()->PlayingArea()->Height();

  return Vector2D(xPosTarget, yPosTarget); 
}
void Camera::Update(float deltaTime, SDL_Event e)
{
	if (e.type == SDL_KEYDOWN)
	{
		switch (e.key.keysym.sym)
		{
		case SDLK_a:
			Yaw(-kAngleToTurn);
			break;

		case SDLK_d:
			Yaw(kAngleToTurn);
			break;

		case SDLK_s:
			Pitch(-kAngleToTurn);
			break;

		case SDLK_w:
			Pitch(kAngleToTurn);
			break;

		case SDLK_q:
			Roll(kAngleToTurn);
			break;

		case SDLK_e:
			Roll(-kAngleToTurn);
			break;

		case SDLK_DOWN:
			MoveForward(-kMoveDistance);
			break;

		case SDLK_UP:
			MoveForward(kMoveDistance);
			break;

		case SDLK_LEFT:
			Strafe(kMoveDistance);
			break;

		case SDLK_RIGHT:
			Strafe(-kMoveDistance);
			break;
		}
	}
}
clsObject::clsObject(
		float pX, 
		float pY, 
		float pZ, 
		float p,
		float y,
		float r, 
		CLASS_ID clsID)
	: ClassID(clsID), ID(Counter++), Name(NULL)
{
	Name	= new TCHAR[MAX_OBJECT_NAME_LEN];
	Name[0]	= '\0';

	//UCS		= NULL;
	pos		= VECTOR3D(pX, pY, pZ);

	fWd		= VECTOR3D(1.0f, .0f, .0f);
	rWd		= VECTOR3D(.0f, 1.0f, .0f);
	uWd		= VECTOR3D(.0f, .0f, 1.0f);
	world	= VECTOR3D();

	worldScale	= VECTOR3D(1.0f, 1.0f, 1.0f);
	localScale	= worldScale;

	Pitch(p);
	Yaw(y);
	Roll(r);
}
Exemple #5
0
Dvoid Camera::UpdateCamera(Dint x, Dint y, Dint clickState, MoveKey moveKey, Matrix44& viewMatrix, Matrix44& perspectiveMatrix)
{
    UpdateTimeDelta();
    m_bMove = false;

    //───────────────────────────────────────────────────────────────────────────────────
    //키 입력 처리
    InputHandle(x, y, clickState, moveKey);
    //───────────────────────────────────────────────────────────────────────────────────

    m_vPos += m_vMoveDir;
    m_vLook += m_vMoveDir;

    Pitch();
    Yaw();

    if (m_bMove)
    {
        ViewMatrixCalculate();
    }

    viewMatrix = m_matCam[CM_VIEW];
    perspectiveMatrix = m_matCam[CM_PROJ];

    m_MouseMoveInterval = { 0, 0 };
}
	void MidiInputDeviceMidiShare::KeyOffTask(long date, short ref, long a1, long a2, long a3)
	{
		MidiInputDeviceMidiShare* driver = (MidiInputDeviceMidiShare*)MidiGetInfo(ref);
		MidiEvPtr ev =(MidiEvPtr)a1;
		driver->DispatchNoteOn(Pitch(ev),Vel(ev),Chan(ev));
		MidiFreeEv(ev);
	}
Exemple #7
0
void Camera3::Update(double dt, bool* myKeys)
{/*
	Vector3 view = (target - position).Normalized();
	Vector3 right = view.Cross(up);
	right.y = 0;
	Inertia: instant dir change

	* strafe */
	if(myKeys[KEY_A] && !myKeys[KEY_D])
		Strafe(-dt);
	else if(straftMovingLeft)
		DecelerateLeft(-dt);

	if(myKeys[KEY_D] && !myKeys[KEY_A])
		Strafe(dt);
	else if(straftMovingRight)
		DecelerateRight(dt);

	/* walk */
	if(myKeys[KEY_W] && !myKeys[KEY_S])
		Walk(dt);
	else if(walkMovingForward)
		DecelerateForward(dt);

	if(myKeys[KEY_S] && !myKeys[KEY_W])
		Walk(-dt);
	else if(walkMovingBackward)
		DecelerateBackward(-dt);

	if(myKeys[KEY_C] && !croutching)
		croutching = true;

	croutch(dt);


	/* fly */
	if(myKeys[KEY_K])
		Fly(dt);
	if(myKeys[KEY_L])
		Fly(-dt);

	if(myKeys[KEY_SPACE] && !jump)	//com runs too fast, spacebar 2 times
		setJump(dt);

	if(myKeys[KEY_T])	//reset
	{
		Reset();
	}
	

	/** update jump **/
	if(jump)
		Jump(dt);
	

	/** mouse **/
	Yaw(dt);
	Pitch(dt);
}
/* --------------------------------------------------------
Real time echo management task
-------------------------------------------------------- */
void MSALARMAPI EchoTask( long d,short ref,long el,long a2, long a3)
{
    MidiEvPtr e;
    short v,p;

    e= (MidiEvPtr)el;
    v = Vel(e)+MSParam[kVel];
    p = Pitch(e)+MSParam[kPitch];
    if ( ((v>0)&&(v<128)) && ((p>=0)&&(p<128)) ) {
        Vel(e) = v;
        Pitch(e) = p;
        MidiSendAt(ref, MidiCopyEv(e), d);
        if( !MidiTask(EchoTask, d+MSParam[kDelay], ref, el, 0, 0))
            MidiFreeEv(e);
    }
    else MidiFreeEv(e);
}
Exemple #9
0
 /*
 Generates a view matrix for the camera's viewpoint. This matrix can be sent
 straight to the shader...it's already an 'inverse camera' matrix.
 */
 glm::mat4 Camera::BuildViewMatrix()
 {
     //Why do a complicated matrix inversion, when we can just generate the matrix
     //using the negative values ;). The matrix multiplication order is important!
     return glm::rotate(-Pitch(), glm::vec3(1.f, 0.f, 0.f))
          * glm::rotate(-Yaw(), glm::vec3(0.f, 1.f, 0.f))
          * glm::translate(-transform.GetPosition());
 }
Exemple #10
0
void Camera::MouseMoved(int xdelta, int ydelta)
{
	if (xdelta != 0)
		Yaw(Units::Radians, -xdelta * 0.2 * DEG_TO_RAD);

	if (ydelta != 0)
		Pitch(Units::Radians, -ydelta * 0.2 * DEG_TO_RAD);
}
static void SongSelLinearizeMth (MidiEvPtr e, Ev2StreamPtr f)
{
	f->count = 2;
	f->data[2] = SongSel;
	f->data[1] = Pitch(e);
	f->runStat = 0;
	MidiFreeCell (e);	
}
Exemple #12
0
void CAMERA::Update(MOUSE &mouse, float timeDelta)
{
	//Restrict focus movment to the xz-plane
	m_right.y = m_look.y = 0.0f;
	D3DXVec3Normalize(&m_look, &m_look);
	D3DXVec3Normalize(&m_right, &m_right);

	//Move Focus (i.e. Scroll)
	if(mouse.x < mouse.m_viewport.left + 10)	Scroll(-m_right * timeDelta * 30.0f);
	if(mouse.x > mouse.m_viewport.right - 10)	Scroll(m_right * timeDelta * 30.0f);
	if(mouse.y < mouse.m_viewport.top + 10)		Scroll(m_look * timeDelta * 30.0f);
	if(mouse.y > mouse.m_viewport.bottom - 10)	Scroll(-m_look * timeDelta * 30.0f);

	//Move Camera (i.e. Change Angle)
	if(KEYDOWN(VK_LEFT))Yaw(-timeDelta);
	if(KEYDOWN(VK_RIGHT))Yaw(timeDelta);
	if(KEYDOWN(VK_UP))Pitch(timeDelta);
	if(KEYDOWN(VK_DOWN))Pitch(-timeDelta);
	
	//Zoom (i.e. change fov)
	if(KEYDOWN(VK_ADD))Zoom(-timeDelta);
	if(KEYDOWN(VK_SUBTRACT))Zoom(timeDelta);

	//Change m_radius
	if(mouse.WheelUp())  ChangeRadius(-1.0f);
	if(mouse.WheelDown())ChangeRadius(1.0f);

	//Calculate Eye Position
	float sideRadius = m_radius * cos(m_beta);
	float height = m_radius * sin(m_beta);

	m_eye = D3DXVECTOR3(m_focus.x + sideRadius * cos(m_alpha),
					  m_focus.y + height, 
					  m_focus.z + sideRadius * sin(m_alpha));

	if(m_pDevice != NULL)
	{
		D3DXMATRIX view = GetViewMatrix();
		D3DXMATRIX projection = GetProjectionMatrix();

		m_pDevice->SetTransform(D3DTS_VIEW, &view);
		m_pDevice->SetTransform(D3DTS_PROJECTION, &projection);

		CalculateFrustum(view, projection);
	}	
}
Exemple #13
0
void XM_CALLCONV Camera::Update( float deltaTime ) {

	if( GetAsyncKeyState( VK_HOME ) ) {
		SetCamType();
	}
	
	if( GetCamType()==1 ) {

		if( GetAsyncKeyState( VK_LEFT ) ) {
			RotateY( 5.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_RIGHT ) ) {
			RotateY( -5.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_UP ) ) {
			Walk( -15.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_DOWN ) ) {
			Walk( 15.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_PRIOR ) ) {
			Pitch( 1.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_NEXT ) ) {
			Pitch( -1.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_OEM_COMMA ) ) {
			Strafe( -15.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_OEM_PERIOD ) ) {
			Strafe( 15.0f * deltaTime );
		}
	} else {

		// default camera
		
		//XMStoreFloat3( &target1, goblin1Pos);
		//XMVECTOR posV = XMLoadFloat3( &pos );
		//XMVECTOR targetV = goblin1Pos;
		//XMVECTOR upV = GetUpXM();
		//LookAt( posV, targetV, upV );
	}

	UpdateViewMatrix();
}
static void SongPosLinearizeMth (MidiEvPtr e, Ev2StreamPtr f)
{
	f->count = 3;
	f->data[3] = SongPos;
	f->data[2] = Pitch(e);
	f->data[1] = Vel(e);
	f->runStat = 0;
	MidiFreeCell (e);	
}
	void MidiInputDeviceMidiShare::ReceiveEvents(short ref)
	{
		MidiInputDeviceMidiShare* driver = (MidiInputDeviceMidiShare*)MidiGetInfo(ref);
		MidiEvPtr ev;
		
		while ((ev = MidiGetEv(ref)))
		
			switch(EvType(ev)) { 
			
				case typeCtrlChange:
					if (MidiGetField(ev,0) == 0)
						driver->DispatchBankSelectMsb(MidiGetField(ev,0),Chan(ev));
					else if (MidiGetField(ev,0) == 32)
						driver->DispatchBankSelectLsb(MidiGetField(ev,0),Chan(ev));
					else
						driver->DispatchControlChange(MidiGetField(ev,0),MidiGetField(ev,0),Chan(ev));
					MidiFreeEv(ev);
					break;
					
				case typePitchWheel:
					driver->DispatchPitchbend(((MidiGetField(ev,0)+(MidiGetField(ev,1) << 7)) - 8192),Chan(ev));
					MidiFreeEv(ev);
					break;
					
				case typeNote:
					driver->DispatchNoteOn(Pitch(ev),Vel(ev),Chan(ev));
					MidiTask(KeyOffTask,Date(ev)+Dur(ev),ref,(long)ev,0,0);
					break;

				case typeKeyOn:
					if (Vel(ev) > 0)
						driver->DispatchNoteOn(Pitch(ev),Vel(ev),Chan(ev));
					else
						driver->DispatchNoteOff(Pitch(ev),Vel(ev),Chan(ev));
					MidiFreeEv(ev);
					break;
				
				case typeKeyOff:
					driver->DispatchNoteOff(Pitch(ev),Vel(ev),Chan(ev));
					MidiFreeEv(ev);
					break;
			}
		}
Exemple #16
0
void FPSCamera::MouseMoved(int, int, int dx, int dy) {
	if (AUX->GetMouseLook()) {
		const int xsign =  (dx > 0)?  1: -1;
		const int ysign =  (dy > 0)? -1:  1;
		const float rdx = ((dx > 0)? dx: -dx) / hFOVdeg;
		const float rdy = ((dy > 0)? dy: -dy) / vFOVdeg;

		if (dx != 0) { Yaw(  xsign, rdx); }
		if (dy != 0) { Pitch(ysign, rdy); }
	}
}
static void NoteLinearizeMth (MidiEvPtr e, Ev2StreamPtr f)
{
	Byte status = NoteOn + Chan(e);
	if( f->runStat== status)
		f->count= 2;
	else {
		f->runStat= f->data[3] = status;
		f->count = 3;
	}
	f->data[2] = Pitch(e);
	f->data[1] = Vel(e);
}
/*---------------------------------------------------------------------------------*/
void CameraHandler::RotateThirdPerson(const OIS::MouseEvent &arg)
{
	//In the future: Implement raycast, so the cameras bound spehere always can see the Player and not get stuck between stuff.

	//Yaw the camera. Rotate around the Y axis
	mvpCamOrginNode->yaw(Ogre::Degree(-(*mvpRotate) * arg.state.X.rel), Ogre::Node::TS_LOCAL);
	//Pitch the camera. Rotate around X axis
	Pitch(arg,mvpCamHelperNode,mvPitchTrackerThirdPerson);

	//Update GUI cursor position
	GameFramework::getSingletonPtr()->mpGui->updateCursorPos(arg.state.X.abs,arg.state.Y.abs);
}
static void ChanPressLinearizeMth (MidiEvPtr e, Ev2StreamPtr f)
{
	Byte status = AfterTouch + Chan(e);
	if( f->runStat== status)
		f->count= 1;
	else {
		f->runStat= f->data[2] = status;
		f->count = 2;
	}
	f->data[1] = Pitch(e);
	MidiFreeCell (e);	
}
static void ProgChangeLinearizeMth (MidiEvPtr e, Ev2StreamPtr f)
{
	Byte status = ProgramChg + Chan(e);
	if( f->runStat== status)
		f->count= 1;
	else {
		f->runStat= f->data[2] = status;
		f->count = 2;
	}
	f->data[1] = Pitch(e);
	MidiFreeCell (e);	
}
Exemple #21
0
void
Camera::LookAt(const Point& target)
{
    // No navel gazing:
    if (target == Pos())
    return;

    Point tgt, tmp = target - Pos();

    // Rotate into the view orientation:
    tgt.x = (tmp * vrt());
    tgt.y = (tmp * vup());
    tgt.z = (tmp * vpn());

    if (tgt.z == 0) {
        Pitch(0.5);
        Yaw(0.5);
        LookAt(target);
        return;
    }

    double az = atan(tgt.x/tgt.z);
    double el = atan(tgt.y/tgt.z);

    // if target is behind, offset by 180 degrees:
    if (tgt.z < 0)
    az -= PI;

    Pitch(-el);
    Yaw(az);

    // roll to upright position:
    double deflection = vrt().y;
    while  (fabs(deflection) > 0.001) {
        double theta = asin(deflection/vrt().length());
        Roll(-theta);

        deflection = vrt().y;
    }
}
static void PitchWheelLinearizeMth (MidiEvPtr e, Ev2StreamPtr f)
{
	Byte status = PitchBend + Chan(e);
	if( f->runStat== status)
		f->count= 2;
	else {
		f->runStat= f->data[3] = status;
		f->count = 3;
	}
	f->data[2] = Pitch(e);
	f->data[1] = Vel(e);
	MidiFreeCell (e);	
}
static void CtrlChangeLinearizeMth (MidiEvPtr e, Ev2StreamPtr f)
{
	Byte status = ControlChg + Chan(e);
	if( f->runStat== status)
		f->count= 2;
	else {
		f->runStat= f->data[3] = status;
		f->count = 3;
	}
	f->data[2] = Pitch(e);
	f->data[1] = Vel(e);
	MidiFreeCell (e);	
}
void ChapterAWriter::notifyCommand ( MidiEvPtr command )
{

  /* KeyPress */
  if ( EvType ( command ) == typeKeyPress ) {

    for ( list<TNotePressInfo>::iterator i = _history.begin ( ) ; i != _history.end ( ) ; i++ ) {
      if ( ( * i ).pitch == Pitch ( command ) ) {
	_history.erase ( i );
	break;
      }
    }

    TNotePressInfo newNotePress;
    newNotePress.pitch = Pitch ( command );
    newNotePress.press = Vel ( command );
    newNotePress.x = 0;
    newNotePress.payload = currentPayloadNumber ( );
    _history.push_back ( newNotePress );

  }

}
void CFreeCameraController::MouseView()
{
	// if there's no velocity changed, skip the process
	glm::vec3 vel = Global::InputManager().CursorVelocity();
	if (glm::length2(vel) < glm::epsilon<float>() * glm::epsilon<float>())
		return;

	// find angular increment
	float angleYaw = vel.x * ANG_SPEED_SCALER;
	float anglePitch = vel.y * ANG_SPEED_SCALER;

	Yaw(-angleYaw);
	Pitch(-anglePitch);
}
Exemple #26
0
void SymbolBehavior::setOptions(const SymbolOptions &options)
{
    // Unset all data
    setData(QVariant(), LP::SymbolPitch);
    setData(QVariant(), LP::SymbolLength);

    m_options = options;

    if (options.testFlag(HasPitch)) {
        setData(QVariant::fromValue<Pitch>(Pitch()), LP::SymbolPitch);
    }
    if (options.testFlag(HasLength)) {
        setData(QVariant::fromValue<Length::Value>(Length::_8), LP::SymbolLength);
    }
}
/*---------------------------------------------------------------------------------*/
void CameraHandler::RotateFirstPerson(const OIS::MouseEvent &arg)
{
	//Yaw and pitch FirstPerson Nodes
	mvpCamOrginNode->yaw(Ogre::Degree(-(*mvpRotate) * arg.state.X.rel), Ogre::Node::TS_LOCAL);
	Pitch(arg,mvpCamFirstPersonNode,mvPitchTrackerFirstPerson);

	//So the camera always looks at the Gun Tracker Node.
	Ogre::Vector3 charPosition = mvpCharNode->_getDerivedPosition();
	charPosition.y += *mvpCamCharYAdjust;
	Ogre::Vector3 directionToGunTracker =  mvpFirstPersonGunTrackerNode->_getDerivedPosition() - charPosition  ;
	mvpCam->setDirection(directionToGunTracker);

	//Tells the player class that the bones needs an update in the game loop (Maybe not needed if only single player and no multiplayer).
	mvpPlayer->setNeedUpdateBones();
}
Exemple #28
0
static pascal void AccProcess(long d, short refNum, long a1, long a2, long a3)
{
  short i;
  for (i = 0; i <= 15; i++) {
    MidiEvPtr e = MidiNewEv(typeNote);
    if (e) {
      Pitch(e) = 60;
      Vel(e) = 80;
      Dur(e) = 16;
      Chan(e) = i;
    }
    MidiSend (refNum, e);
  }
  MidiTask (AccProcess, d + 32, refNum, a1, a2, a3);
}
Exemple #29
0
/* -----------------------------------------------------------------------------*/
static pascal void GenProcess(long d, short ref, long start, long num, long freq)
{
  short i, adv = 5;

  for (i = 0; i <= 15; i++) {
    MidiEvPtr e = MidiNewEv (typeKeyPress);
    if (e) {
      Pitch(e) = 60;
      Vel(e) = 80;
      Chan(e) = i;
      MidiSendAt (ref, e, start + adv + num * 1000 / freq);
      num++;
    }
  }
  genTask = MidiTask (GenProcess, start + num * 1000 / freq, ref, start, num, freq);
}
Exemple #30
0
inline
typename
std::enable_if<
	Pitch::static_size == 1,
	Pitch
>::type
flipped_pitch(
	Pitch const &,
	typename Pitch::value_type _last_value
)
{
	return
		Pitch(
			_last_value
		);
}