예제 #1
0
/*
================
sdScriptedEntityHelper_Aimer::Update
================
*/
void sdScriptedEntityHelper_Aimer::Update( bool force ) {
	if ( gunJoints[ AIMER_JOINT_YAW ] == gunJoints[ AIMER_JOINT_PITCH ] ) {
		bool changed = false;
		changed |= UpdateAngles( yawInfo, force );
		changed |= UpdateAngles( pitchInfo, force );
		if ( changed ) {
			idMat3 yawAxes, pitchAxes;
			idAngles::YawToMat3( yawInfo.current, yawAxes );
			idAngles::PitchToMat3( pitchInfo.current, pitchAxes );

			yawAxes *= pitchAxes;
			yawAxes = baseAxes[ AIMER_JOINT_YAW ] * yawAxes * yawTranspose;

			_owner->GetAnimator()->SetJointAxis( gunJoints[ AIMER_JOINT_YAW ], JOINTMOD_LOCAL, yawAxes );
		}
	} else {
		if ( UpdateAngles( yawInfo, force ) ) {
			idMat3 yawAxes;
			idAngles::YawToMat3( yawInfo.current, yawAxes );

			yawAxes = baseAxes[ AIMER_JOINT_YAW ] * yawAxes  * yawTranspose;

			_owner->GetAnimator()->SetJointAxis( gunJoints[ AIMER_JOINT_YAW ], JOINTMOD_LOCAL, yawAxes );
		}

		if ( UpdateAngles( pitchInfo, force ) ) {
			idMat3 pitchAxes;
			idAngles::PitchToMat3( pitchInfo.current, pitchAxes );

			pitchAxes = baseAxes[ AIMER_JOINT_PITCH ] * pitchAxes * pitchTranspose;

			_owner->GetAnimator()->SetJointAxis( gunJoints[ AIMER_JOINT_PITCH ], JOINTMOD_LOCAL, pitchAxes );		
		}
	}
}
예제 #2
0
void CDofEditing::OnBnClickedDofreset()
{
	m_Yaw=m_Pitch=m_Roll=0.0f;
	m_Dof->dof.translation.x=m_Dof->dof.translation.y=m_Dof->dof.translation.z=0.0f;
	m_Dof->dof.scale.x=m_Dof->dof.scale.y=m_Dof->dof.scale.z=0.0f;
	UpdateAngles();
}
예제 #3
0
void CDofEditing::OnBnClickedDofdegrees()
{
	m_Dof->dof.flags|=(m_DofDegrees.GetCheck())?XDOF_ISDOF:0;
	m_Dof->dof.flags&=(!m_DofDegrees.GetCheck())?~XDOF_ISDOF:0xffffffff;
	UpdateAngles();

}
예제 #4
0
//----------------------------
bool CEmitter::Update()
{
	// Game pausing can cause dumb time things to happen, so kill the effect in this instance
	if ( mTimeStart > theFxHelper.mTime )
	{
		return false;
	}
		
	// Use this to track if we've stopped moving
	VectorCopy( mOrigin1, mOldOrigin );
	VectorCopy( mVel, mOldVelocity );

	if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false )
	{
		// we are marked for death
		return false;
	}

	// If the thing is no longer moving, kill the angle delta, but don't do it too quickly or it will
	//	look very artificial.  Don't do it too slowly or it will look like there is no friction.
	if ( VectorCompare( mOldOrigin, mOrigin1 ))
	{
		VectorScale( mAngleDelta, 0.7f, mAngleDelta );
	}

	UpdateAngles();
	UpdateSize();
//	UpdateRGB();	// had wanted to do something slick whereby an emitted effect could somehow inherit these
//	UpdateAlpha();	// values, but it's not a priority right now.

	Draw();

	return true;
}
예제 #5
0
void CDofEditing::OnBnClickedDofinvcheck()
{
	// TODO: Add your control notification handler code here
	m_Dof->dof.flags|=(m_DofInvCheck.GetCheck())?XDOF_NEGATE:0;
	m_Dof->dof.flags&=(!m_DofInvCheck.GetCheck())?~XDOF_NEGATE:0xffffffff;
	UpdateAngles();
}
예제 #6
0
void CDofEditing::OnDeltaposPitchspin(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
	// TODO: Add your control notification handler code here
	*pResult = 0;
	signed int Cx=(signed short)(m_PitchSpin.GetPos()&0xffff);
	m_PitchSpin.SetPos(0);
	m_Pitch+=(D3DXToRadian((float)Cx)/100);
	UpdateAngles();
}
예제 #7
0
void CDofEditing::OnToolsPastedof()
{
	// TODO: Add your command handler code here
	if(m_DofCopy.dofNumber!=-1){
		DWORD	DofNr=m_Dof->dof.dofNumber;
		m_Dof->dof=m_DofCopy;
		m_Dof->dof.dofNumber=DofNr;
	}
	UpdateAngles();
}
예제 #8
0
void CDofEditing::OnDeltaposCxspin(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
	// TODO: Add your control notification handler code here
	*pResult = 0;
	signed int Cx=(signed short)(m_CxSpin.GetPos()&0xffff);
	m_CxSpin.SetPos(0);
	m_Dof->dof.multiplier+=((float)Cx)/1000;
	UpdateAngles();
}
예제 #9
0
void CDofEditing::OnToolsChangedofnumber()
{
	// TODO: Add your command handler code here
	CString	NewDof;
	CString Mex="Input the new DOF Number";
	CInputBox	*Box;
	Box=new CInputBox(this, &NewDof, &Mex );
	int Result=Box->DoModal();
	delete Box;
	if(Result==IDOK){
		m_Dof->dof.dofNumber=atoi(NewDof);
		TheTreeViews->UpdateItemLabel(m_Dof->TreeItem);
	}
	UpdateAngles();

}
예제 #10
0
void CDofEditing::EditDof(E_Object *Object, DXDof *Dof)
{
	m_Dof=Dof;
	m_OriginalDof=Dof->dof;
	m_Object=Object;
	if(!m_Object) {
		ShowWindow(SW_HIDE);
		return;
	}
	m_DofList.SetCurSel(2);
	m_DofSlider.SetPos((int)D3DXToDegree((float)m_Object->Obj->DOFValues[m_Dof->dof.dofNumber].rotation));
	ShowWindow(SW_SHOW);

	GetOriginalAngles();
	UpdateAngles();
}
예제 #11
0
void CDofEditing::OnToolsApplychanges()
{
	m_Dof->dof.flags=m_DofRef.flags;
	m_Dof->dof.translation.x+=m_DofRef.translation.x;
	m_Dof->dof.translation.y+=m_DofRef.translation.y;
	m_Dof->dof.translation.z+=m_DofRef.translation.z;
	m_Dof->dof.scale.x+=m_DofRef.scale.x;
	m_Dof->dof.scale.y+=m_DofRef.scale.y;
	m_Dof->dof.scale.z+=m_DofRef.scale.z;
	for(DWORD a=0; a<4; a++){
		for(DWORD b=0; b<4; b++){
			m_Dof->dof.rotation.m[a][b]+=m_DofRef.rotation.m[a][b];
		}
	}
	m_Dof->dof.max+=m_DofRef.max;
	m_Dof->dof.min+=m_DofRef.min;
	m_Dof->dof.multiplier+=m_DofRef.multiplier;
	m_Dof->dof.max+=m_DofRef.max;
	UpdateAngles();
}
예제 #12
0
void CDofEditing::DofMoveFunction(D3DXVECTOR3 Transform, D3DXVECTOR3 Move, bool Remove)
{
	if(Remove){
		m_bDofMove=false;
		m_DofMoveButton.SetCheck(m_bDofMove);
		MoveFunction=NULL;
		return;
	}
	
	m_Dof->dof.translation.x+=Move.x;
	m_Dof->dof.translation.y+=Move.y;
	m_Dof->dof.translation.z+=Move.z;

	m_Yaw+=Transform.x;
	m_Pitch+=Transform.y;
	m_Roll+=Transform.z;

	UpdateAngles();

}
예제 #13
0
WizualizacjaWahadla::WizualizacjaWahadla( QWidget *wRodzic ): QWidget( wRodzic ){

  param.q[0] = -90; param.q[1] = -90; param.q[2] = 0; param.q[3] = 0;
  param.l[0] = 6; param.l[1] = 3;
  param.m[0] = 5; param.m[1] = 4;

  S = new Wahadlo( this );

  B = new QPushButton( this );
  B->resize( 100, 30 );
  B->move( 500, 300 );
  B->setText("Apply Force");

  connect(S, SIGNAL(UpdateAngles(PendulumParameters)), this, SLOT(fresh(PendulumParameters)));
  connect(B, SIGNAL(pressed()), S, SLOT(ApplyForce()));
  connect(B, SIGNAL(released()), S, SLOT(ReleaseForce()));

  setPalette( QPalette(Qt::white) );
  setAutoFillBackground( true );
  update();

}
예제 #14
0
void CDofEditing::OnBnClickedDofrestore()
{
	m_Dof->dof=m_OriginalDof;
	UpdateAngles();
}
예제 #15
0
void CDofEditing::OnBnClickedDoflimits()
{
	m_Dof->dof.flags|=(m_DofLimits.GetCheck())?XDOF_MINMAX:0;
	m_Dof->dof.flags&=(!m_DofLimits.GetCheck())?~XDOF_MINMAX:0xffffffff;
	UpdateAngles();
}
예제 #16
0
void CDofEditing::OnBnClickedRoll5p()
{
	m_Roll+=D3DXToRadian(5);
	UpdateAngles();
}
예제 #17
0
void CDofEditing::OnBnClickedPitch5p()
{
	m_Pitch+=D3DXToRadian(5);
	UpdateAngles();
}
예제 #18
0
void CDofEditing::OnBnClickedYaw5p()
{
	m_Yaw+=D3DXToRadian(5);
	UpdateAngles();
}
예제 #19
0
bool IK_QJacobianSolver::Solve(
    IK_QSegment *root,
    std::list<IK_QTask *> tasks,
    const MT_Scalar,
    const int max_iterations
    )
{
	float scale = ComputeScale();
	bool solved = false;
	//double dt = analyze_time();

	Scale(scale, tasks);

	ConstrainPoleVector(root, tasks);

	root->UpdateTransform(m_rootmatrix);

	// iterate
	for (int iterations = 0; iterations < max_iterations; iterations++) {
		// update transform
		root->UpdateTransform(m_rootmatrix);

		std::list<IK_QTask *>::iterator task;

		// compute jacobian
		for (task = tasks.begin(); task != tasks.end(); task++) {
			if ((*task)->Primary())
				(*task)->ComputeJacobian(m_jacobian);
			else
				(*task)->ComputeJacobian(m_jacobian_sub);
		}

		MT_Scalar norm = 0.0;

		do {
			// invert jacobian
			try {
				m_jacobian.Invert();
				if (m_secondary_enabled)
					m_jacobian.SubTask(m_jacobian_sub);
			}
			catch (...) {
				fprintf(stderr, "IK Exception\n");
				return false;
			}

			// update angles and check limits
		} while (UpdateAngles(norm));

		// unlock segments again after locking in clamping loop
		std::vector<IK_QSegment *>::iterator seg;
		for (seg = m_segments.begin(); seg != m_segments.end(); seg++)
			(*seg)->UnLock();

		// compute angle update norm
		MT_Scalar maxnorm = m_jacobian.AngleUpdateNorm();
		if (maxnorm > norm)
			norm = maxnorm;

		// check for convergence
		if (norm < 1e-3 && iterations > 10) {
			solved = true;
			break;
		}
	}

	if (m_poleconstraint)
		root->PrependBasis(m_rootmatrix.getBasis());

	Scale(1.0f / scale, tasks);

	//analyze_add_run(max_iterations, analyze_time()-dt);

	return solved;
}
예제 #20
0
void CDofEditing::OnBnClickedDofscale()
{
	m_Dof->dof.flags|=(m_DofScale.GetCheck())?XDOF_SUBRANGE:0;
	m_Dof->dof.flags&=(!m_DofScale.GetCheck())?~XDOF_SUBRANGE:0xffffffff;
	UpdateAngles();
}