Beispiel #1
0
void GlobalTimer::Freeze()
{
	unsigned long thisTime;
	unsigned long advance;

	UpdateAnimations(true);

	thisTime = GetTickCount();
	advance = thisTime - startTime;
	if ( advance < interval) {
		return;
	}
	startTime = thisTime;
	Game* game = core->GetGame();
	if (!game) {
		return;
	}
	game->RealTime++;

	ieDword count = advance/interval;
	// pst/bg2 do this, if you fix it for another game, wrap it in a check
	DoFadeStep(count);

	// show scrolling cursor while paused
	GameControl* gc = core->GetGameControl();
	if (gc)
		gc->UpdateScrolling();
}
Beispiel #2
0
void AnimatorBar::AddAnimation()
{
	HTREEITEM Item = curHTreeItem;
	HTREEITEM Parent = 0;

	if (Item) 
	{
		if (Item == TVI_ROOT)
			Parent = 0;
		else
			Parent = animations.GetParentItem(Item);
	}

	CAnimation* pAnimation;
	
	if(Parent)
		pAnimation = AddAnimation((CAnimation*)animations.GetItemData(Parent));
	else
		pAnimation = AddAnimation(m_pAnimation);	

	UpdateAnimations(NULL, NULL, NULL, -2);

	// Select animation
	animations.SelectItem(pAnimation->m_Tree);
}
void CAnimationEditorDlg::OnBnClickedAdddirection()
{
	HTREEITEM item = m_AnimationTree.GetSelectedItem();

	if(((CAnimation*)m_AnimationTree.GetItemData(item))->IsAngle())
		item = m_AnimationTree.GetParentItem(item);

	if(item)
	{
		CAngleDlg dlg;
		dlg.DoModal();

		CAnimation* anim = (CAnimation*)m_AnimationTree.GetItemData(item);
		map<float,int> CurrentAngles;
		for(list<CAnimation>::iterator a = anim->m_SubAnimations.begin(); a!= anim->m_SubAnimations.end();a ++)
		{
			if(a->IsAngle())
				CurrentAngles[a->m_Angle] = 1;
		}
		for(vector<float>::iterator i = dlg.m_Angles.begin(); i!= dlg.m_Angles.end(); i++)
		{
			if(CurrentAngles.find(*i) == CurrentAngles.end() )
			{
				anim->m_SubAnimations.push_back( CAnimation());
				CAnimation& angle = anim->m_SubAnimations.back();
				angle.m_IsAngle = true;
				angle.m_Angle = *i;
				angle.m_FixedID = m_pApplication->m_AnimationFixID++;
				CurrentAngles[*i] = 1;
				angle.m_pApp = anim->m_pApp;
			}
		}
	}
	UpdateAnimations();
}
Beispiel #4
0
void Model::Load(Serializer::Reader &rd)
{
	LoadVisitor lv(&rd);
	m_root->Accept(lv);

	for (AnimationContainer::const_iterator i = m_animations.begin(); i != m_animations.end(); ++i)
		(*i)->SetProgress(rd.Double());
	UpdateAnimations();
}
bool GlobalTimer::Update()
{
	Map *map;
	Game *game;
	GameControl* gc;
	unsigned long thisTime;
	unsigned long advance;

	gc = core->GetGameControl();
	if (gc)
		gc->UpdateScrolling();

	UpdateAnimations();

	thisTime = GetTickCount();

	if (!startTime) {
		startTime = thisTime;
		return false;
	}

	advance = thisTime - startTime;
	if ( advance < interval) {
		return false;
	}
	ieDword count = advance/interval;
	DoStep(count);
	DoFadeStep(count);
	if (!gc) {
		goto end;
	}
	game = core->GetGame();
	if (!game) {
		goto end;
	}
	map = game->GetCurrentArea();
	if (!map) {
		goto end;
	}
	//do spell effects expire in dialogs?
	//if yes, then we should remove this condition
	if (!(gc->GetDialogueFlags()&DF_IN_DIALOG) ) {
		map->UpdateFog();
		map->UpdateEffects();
		if (thisTime) {
			//this measures in-world time (affected by effects, actions, etc)
			game->AdvanceTime(1);
		}
	}
	//this measures time spent in the game (including pauses)
	if (thisTime) {
		game->RealTime++;
	}
end:
	startTime = thisTime;
	return true;
}
void CAnimationEditorDlg::OnBnClickedSubanimation()
{
	HTREEITEM item = m_AnimationTree.GetSelectedItem();

	if(((CAnimation*)m_AnimationTree.GetItemData(item))->IsAngle())
		item = m_AnimationTree.GetParentItem(item);
	if(item) 
		AddAnimation((CAnimation*)m_AnimationTree.GetItemData(item));
	else
		OnBnClickedAddanimation();
	
	UpdateAnimations();
}
void CAnimationEditorDlg::OnBnClickedAddanimation()
{
	HTREEITEM item = m_AnimationTree.GetSelectedItem();
	HTREEITEM parent = 0;
	if(item) 
		parent = m_AnimationTree.GetParentItem(item);
	if(parent)
		AddAnimation((CAnimation*)m_AnimationTree.GetItemData(parent));
	else
		AddAnimation(m_Animation);	
	
	UpdateAnimations();
}
Beispiel #8
0
void AnimatorBar::AddSubAnimation()
{
	HTREEITEM Item = curHTreeItem;

	if(((CAnimation*)animations.GetItemData(Item))->IsAngle())
		Item = animations.GetParentItem(Item);

	CAnimation* pAnimation;

	if(Item) 
		pAnimation = AddAnimation((CAnimation*)animations.GetItemData(Item));
	else
		pAnimation = AddAnimation(m_pAnimation);

	UpdateAnimations(NULL, NULL,NULL, -2);

	// Select animation
	animations.SelectItem(pAnimation->m_Tree);
}
// CAnimationEditorDlg message handlers
BOOL CAnimationEditorDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	m_iFrame = 0;
	
	m_AnimSpeedSlider.SetRange(0, 100);
	m_AnimSpeedSlider.SetPos(m_Animation->m_Speed);

	m_AddFrame.SetWindowTextA(PROPERTIES_ADD);
	m_RemoveFrame.SetWindowText(PROPERTIES_REMOVE);

	dlgMan.Load(this->m_hWnd, "Software\\Construct\\AnimationEditorDlg");
    dlgAnchor.Init(this->m_hWnd);

	dlgAnchor.Add(IDOK, ANCHOR_RIGHT | ANCHOR_BOTTOM);
	dlgAnchor.Add(IDCANCEL, ANCHOR_RIGHT | ANCHOR_BOTTOM);
	dlgAnchor.Add(IDC_PLAY, ANCHOR_BOTTOM | ANCHOR_RIGHT);
	dlgAnchor.Add(IDC_FILMSTRIP, ANCHOR_TOPLEFT | ANCHOR_RIGHT | ANCHOR_BOTTOM);

	dlgAnchor.Add(IDC_FRAMETIMELABEL, ANCHOR_RIGHT | ANCHOR_TOP);
	dlgAnchor.Add(IDC_TIME, ANCHOR_RIGHT | ANCHOR_TOP);

	dlgAnchor.Add(ID_COPY, ANCHOR_LEFT | ANCHOR_BOTTOM);
	dlgAnchor.Add(ID_PASTE, ANCHOR_LEFT | ANCHOR_BOTTOM);

	/////////////////////////////////////////////
	//// Set up initial variables
	m_bDragging = false;
	m_nDragIndex = -1;
	m_nDropIndex = -1;
	m_pDragImage = NULL;

	m_pDDMgr.AddFormat("Construct Frames");
	m_pDDMgr.AddFormat("Construct Animations");

	FirstRun = true;
	UpdateAnimations();
	if(m_AnimationTree.GetCount() == 0)
		m_CurrentAnimation = m_Animation;
	UpdateList();
	
	return TRUE;
}
Beispiel #10
0
/**
* Main update method.
* Updates position and attitude of object
* Fix this so that the track-only mode does not require a game object to be 
* present.
*/
void ObjectUpdater::operator()(Node* node, NodeVisitor* nv)
{
    tcGameObject* gameObject = model->GetGameObj();
	tcSensorMapTrack* sensorTrack = model->GetSensorTrack();

	bool use3Dcheat = tcOptions::Get()->mn3DCheatMode == 3;
    bool isServer = simState->IsMultiplayerServer();


    if (gameObject)
    {        
		if (use3Dcheat || isServer || simState->mpUserInfo->IsOwnAlliance(gameObject->GetAlliance()))
		{
			UpdateTrue(node);
		}
		else
		{
			wxASSERT(false);
		}

		UpdateAnimations();

		// must call any nested node callbacks and continue subgraph traversal.
		NodeCallback::traverse(node,nv);
	}
	else if (sensorTrack)
	{
		UpdateTrack(node);
		UpdateTrackAnimations();

		// must call any nested node callbacks and continue subgraph traversal.
		NodeCallback::traverse(node,nv);
	}
	else // no game object available
	{
		fprintf(stderr, "Error - ObjectUpdater::operator() - called with null game obj\n");
	}

}
void CAnimationEditorDlg::OnBnClickedAnimationremove()
{
	HTREEITEM item = m_AnimationTree.GetSelectedItem();
	if(!item) 
		return;

	HTREEITEM parent = m_AnimationTree.GetParentItem(item);


	{
		CAnimation* child_anim = (CAnimation*)m_AnimationTree.GetItemData(item);
		

		CAnimation* parent_anim;
		if(parent)
			parent_anim = (CAnimation*)m_AnimationTree.GetItemData(parent);
		else
			parent_anim = m_Animation;
			

		for(list<CAnimation>::iterator i = parent_anim->m_SubAnimations.begin();
			i != parent_anim->m_SubAnimations.end();
			i ++)
		{
			if(&(*i) == child_anim)
			{
				parent_anim->m_SubAnimations.erase(i);
				i = parent_anim->m_SubAnimations.end();
			}
		}



	}

	UpdateAnimations();
	UpdateList();
	// TODO: Add your control notification handler code here
}
Beispiel #12
0
// Updating
void Player::Update(float dt)
{
	// Update grid position
	UpdateGridPosition();

	// Update the voxel model
	float animationSpeeds[AnimationSections_NUMSECTIONS] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
	m_pVoxelCharacter->Update(dt, animationSpeeds);
	m_pVoxelCharacter->SetWeaponTrailsOriginMatrix(dt, m_worldMatrix);

	// Update animations
	UpdateAnimations(dt);

	// Update / Create weapon lights and particle effects
	UpdateWeaponLights(dt);
	UpdateWeaponParticleEffects(dt);

	// Update timers
	UpdateTimers(dt);

	// Physics update
	UpdatePhysics(dt);
}
Beispiel #13
0
static BOOLEAN
DoTalkSegue (TALKING_STATE *pTS)
{
	bool left = false;
	bool right = false;
	COUNT curTrack;

	if (GLOBAL (CurrentActivity) & CHECK_ABORT)
	{
		pTS->ended = true;
		return FALSE;
	}
	
	if (PulsedInputState.menu[KEY_MENU_CANCEL])
	{
		JumpTrack ();
		pTS->ended = true;
		return FALSE;
	}

	if (optSmoothScroll == OPT_PC)
	{
		left = PulsedInputState.menu[KEY_MENU_LEFT] != 0;
		right = PulsedInputState.menu[KEY_MENU_RIGHT] != 0;
	}
	else if (optSmoothScroll == OPT_3DO)
	{
		left = CurrentInputState.menu[KEY_MENU_LEFT] != 0;
		right = CurrentInputState.menu[KEY_MENU_RIGHT] != 0;
	}

#if DEMO_MODE || CREATE_JOURNAL
	left = false;
	right = false;
#endif

	if (right)
	{
		SetSliderImage (SetAbsFrameIndex (ActivityFrame, 3));
		if (optSmoothScroll == OPT_PC)
			FastForward_Page ();
		else if (optSmoothScroll == OPT_3DO)
			FastForward_Smooth ();
		pTS->seeking = true;
	}
	else if (left || pTS->rewind)
	{
		pTS->rewind = false;
		SetSliderImage (SetAbsFrameIndex (ActivityFrame, 4));
		if (optSmoothScroll == OPT_PC)
			FastReverse_Page ();
		else if (optSmoothScroll == OPT_3DO)
			FastReverse_Smooth ();
		pTS->seeking = true;
	}
	else if (pTS->seeking)
	{
		// This is only done once the seeking is over (in the smooth
		// scroll case, once the user releases the seek button)
		pTS->seeking = false;
		SetSliderImage (SetAbsFrameIndex (ActivityFrame, 2));
	}
	else
	{
		// This used to have a buggy guard condition, which
		// would cause the animations to remain paused in a couple cases
		// after seeking back to the beginning.
		// Broken cases were: Syreen "several hours later" and Starbase
		// VUX Beast analysis by the scientist.
		CheckSubtitles ();
	}

	// XXX: When seeking, all animations (talking and ambient) stop
	// progressing. This is an original 3DO behavior, and I see no
	// reason why the animations cannot continue while seeking.
	UpdateAnimations (pTS->seeking);
	UpdateSpeechGraphics ();

	curTrack = PlayingTrack ();
	pTS->ended = !pTS->seeking && !curTrack;

	SleepThreadUntil (pTS->NextTime);
	// Need a high enough framerate for 3DO smooth seeking
	pTS->NextTime = GetTimeCounter () + ONE_SECOND / 60;

	return pTS->seeking || (curTrack && curTrack <= pTS->waitTrack);
}
Beispiel #14
0
static void
UpdateCommGraphics (void)
{
	UpdateAnimations (false);
	UpdateSpeechGraphics ();
}
Beispiel #15
0
LRESULT AnimatorBar::OnEndDrag(WPARAM wParam, LPARAM lParam)
{
	XHTMLTREEMSGDATA *pMsg = (XHTMLTREEMSGDATA *) wParam;
	ASSERT(pMsg);

	XHTMLTREEDRAGMSGDATA *pData = (XHTMLTREEDRAGMSGDATA *) lParam;

	LRESULT lResult = 0;

	bool isCopying = (GetKeyState(VK_CONTROL) >> 4);

	if (pMsg)
	{
		if (pData)
		{
			// Get the animation to be dropped
			CAnimation* pAnimation = (CAnimation*)animations.GetItemData(pData->hItem);
			CAnimation New = *pAnimation;
			
			// Now find a parent
			HTREEITEM Parent = pData->hNewParent;
			CAnimation* pParent = m_pAnimation;

			if(!Parent)
				pParent = m_pAnimation;//return 1;

			else if (Parent != TVI_ROOT)
				pParent = (CAnimation*)animations.GetItemData(Parent);

			// Find it and remove it from wherever it is
			if(isCopying)
			{
				New.DuplicateAllTheImages();
				New.m_FixedID = application->m_AnimationFixID++;
			}
			else
				application->resources.DeleteAnimationFromNumber(pAnimation->m_FixedID);

			// Now find where under this parent we need to insert
			if (pData->hAfter == TVI_FIRST)
				pParent->m_SubAnimations.push_front(New);
				
			else if (pData->hAfter == TVI_LAST)
				pParent->m_SubAnimations.push_back(New);

			else
			{
				// Custom location somewhere
				CAnimation* pAfter = (CAnimation*)animations.GetItemData(pData->hAfter);

				if (find(pParent->m_SubAnimations.begin(), pParent->m_SubAnimations.end(), *pAfter) != pParent->m_SubAnimations.end())
					pParent->m_SubAnimations.insert(++find(pParent->m_SubAnimations.begin(), pParent->m_SubAnimations.end(), *pAfter), New);
				else
					pParent->m_SubAnimations.push_back(New);
			}

			if (Parent != TVI_ROOT)
				animations.Expand(Parent, TVE_EXPAND);
			AnimationHasChanged();
			if(isCopying)
			{
				UpdateAnimations(NULL, NULL, NULL, -2);
				lResult = 1;
			}

			
		}
	}

	return lResult;	// return 0 to allow drop
}
Beispiel #16
0
void AnimatorBar::RemoveAnimation()
{
	HTREEITEM Item = animations.GetSelectedItem();
	if(!Item) 
		return;

	HTREEITEM Parent = animations.GetParentItem(Item);

	CAnimation* pChildAnim = (CAnimation*)animations.GetItemData(Item);
	CAnimation* pParentAnim;

	if(Parent)
		pParentAnim = (CAnimation*)animations.GetItemData(Parent);
	else
	{
		pParentAnim = m_pAnimation;

		if (pParentAnim->m_SubAnimations.size() == 1)
		{
			message_bar.Attach(this);
			message_bar.SetHighlightOnMouseOver();
			message_bar.SetWrapText();
			message_bar.SetText(AB_CANNOTDELETEANIMATIONDESC);

			return;
		}
	}

	if (pChildAnim->IsAngle())
	{
		// Do a quick check for other angles
		bool bFound = false;

		for(list<CAnimation>::iterator i = pParentAnim->m_SubAnimations.begin(); i != pParentAnim->m_SubAnimations.end(); i ++)
			if(i->IsAngle() && i->m_FixedID != pChildAnim->m_FixedID)
				bFound = true;

		if (!bFound)
		{
			message_bar.Attach(this);
			message_bar.SetHighlightOnMouseOver();
			message_bar.SetWrapText();
			message_bar.SetText(AB_CANNOTDELETEANGLEDESC);

			return;
		}
	}

	for(list<CAnimation>::iterator i = pParentAnim->m_SubAnimations.begin();
		i != pParentAnim->m_SubAnimations.end();
		i ++)
	{
		if(&(*i) == pChildAnim)
		{
			pParentAnim->m_SubAnimations.erase(i);
			i = pParentAnim->m_SubAnimations.end();
		}
	}

	AnimationHasChanged();
	UpdateFilmStrip();
	UpdateAnimations(NULL, NULL, NULL, -2);
}
Beispiel #17
0
void AnimatorBar::AddAngle()
{
	HTREEITEM Item = curHTreeItem;

	if(((CAnimation*)animations.GetItemData(Item))->IsAngle())
		Item = animations.GetParentItem(Item);

	CAnimation* pAngle;

	bool changed = false;

	if(Item)
	{
		CAngleDlg AddAngle;
		if (AddAngle.DoModal() != IDOK)
			return;

		CAnimation* pAnimation = (CAnimation*)animations.GetItemData(Item);

		map<float,int> CurrentAngles;

		for(list<CAnimation>::iterator a = pAnimation->m_SubAnimations.begin(); a!= pAnimation->m_SubAnimations.end(); a++)
			if(a->IsAngle())
				CurrentAngles[a->m_Angle] = 1;

		for(vector<float>::iterator i = AddAngle.m_Angles.begin(); i!= AddAngle.m_Angles.end(); i++)
		{
			if(CurrentAngles.find(*i) == CurrentAngles.end())
			{
				pAnimation->m_SubAnimations.push_back(CAnimation());

				CAnimation& Angle = pAnimation->m_SubAnimations.back();

				Angle.m_IsAngle = true;
				Angle.m_Angle = *i;
				Angle.m_FixedID = application->m_AnimationFixID++;
				CurrentAngles[*i] = 1;
				Angle.application = pAnimation->application;

				// Add a frame
				int ID = 0;
				ID = layout->AddImage(32, 32);

				Angle.m_Images.push_back(ID);
				Angle.m_FrameTimes.push_back(1.0);

				pAngle = &Angle;

				changed = true;
			}
		}
	}

	if (changed)
	{
		AnimationHasChanged();
		UpdateAnimations(NULL, NULL, NULL, -2);

		// Select animation
		animations.SelectItem(pAngle->m_Tree);
	}
}
Beispiel #18
0
void ObjectUpdater::Update(tcGameObject* obj)
{
    distanceFromCamera = 99999.0f;

    if (obj == 0)
    {
        wxASSERT(false);
        return;
    }

    tc3DModel* model = obj->GetModel();

    if (viewer->GetDatabaseViewState())
    {
        model->Enable(false);
        return;
    }


    LocationParams p;
	GetLocationParams(obj, p);
    
	float& x = p.x;
	float& y = p.y;
	float& z = p.z;
	float& yaw = p.yaw;
	float& pitch = p.pitch;
	float& roll = p.roll;
	bool& isVisible = p.isVisible;

	model->SetGenericMode(tc3DModel::USE_TRUE_MODEL);

    //pitch = 0;
    //roll = 0.5*sin(obj->mfStatusTime);
    //yaw = 0; //0.5*sin(obj->mfStatusTime);


	// not correct for child objects
	Vec3 cameraDelta = Vec3(x,y,z) - viewer->GetCameraPosition();
    distanceFromCamera = cameraDelta.Length();
	model->SetDistanceFromCamera(distanceFromCamera);

    if (isVisible && (distanceFromCamera < 10000.0f))
    {
        model->Enable(true);

        tcMatrix3 R;
        R.SetYawPitchRoll(yaw, -pitch, -roll);

        if (obj->parent != 0)
        {
            tcMatrix3 Rp;
            Rp.SetYawPitchRoll(obj->parent->mcKin.mfHeading_rad, -obj->parent->mcKin.mfPitch_rad,
                -obj->parent->mcKin.mfRoll_rad);

            Rp.PreMultiply(R);
            R = Rp;
        }

        model->SetPosition(x, y, z);
        model->SetRotationMatrix(R);
    }
    else
    {
        model->Enable(false);
        return;
    }

    UpdateAnimations(obj);


}