Beispiel #1
0
void CListSaveFilesTask::CreateFileEntry (CGameFile &GameFile, const CTimeDate &ModifiedTime, int yStart, IAnimatron **retpEntry, int *retcyHeight)

//	CreateFileEntry
//
//	Creates a display entry for the save file

	{
	const CVisualPalette &VI = m_HI.GetVisuals();
	const CG16bitFont &MediumFont = VI.GetFont(fontMedium);
	const CG16bitFont &SubTitleFont = VI.GetFont(fontSubTitle);

	int x = 0;
	int y = 0;
	int xText = x + ADVENTURE_ICON_WIDTH + ICON_SPACING_HORZ;
	int cxText = m_cxWidth - (ADVENTURE_ICON_WIDTH + 2 * ICON_SPACING_HORZ + SHIP_IMAGE_WIDTH);

	//	Start with a sequencer

	CAniSequencer *pRoot = new CAniSequencer;
	pRoot->SetPropertyVector(PROP_POSITION, CVector(0, yStart));

	//	Add the character name and current star system

	CString sHeading = strPatternSubst(CONSTLIT("%s — %s"), GameFile.GetPlayerName(), GameFile.GetSystemName());

	IAnimatron *pName = new CAniText;
	pName->SetPropertyVector(PROP_POSITION, CVector(xText, y));
	pName->SetPropertyVector(PROP_SCALE, CVector(10000, 1000));
	pName->SetPropertyColor(PROP_COLOR, VI.GetColor(colorTextDialogInput));
	pName->SetPropertyFont(PROP_FONT, &SubTitleFont);
	pName->SetPropertyString(PROP_TEXT, sHeading);

	pRoot->AddTrack(pName, 0);
	y += SubTitleFont.GetHeight();

	//	Now add some additional information

	CShipClass *pClass = g_pUniverse->FindShipClass(GameFile.GetPlayerShip());
	CString sShipClass = (pClass ? pClass->GetName() : NULL_STR);
	CString sGenome = strCapitalize(GetGenomeName(GameFile.GetPlayerGenome()));

	CString sState;
	if (GameFile.IsGameResurrect())
		sState = strPatternSubst(CONSTLIT("Resurrect in the %s System"), GameFile.GetSystemName());
	else
		sState = strPatternSubst(CONSTLIT("Continue in the %s System"), GameFile.GetSystemName());

	CString sDesc;
	if (!sGenome.IsBlank() && !sShipClass.IsBlank())
		sDesc = strPatternSubst(CONSTLIT("%s — %s — %s"), sGenome, sShipClass, sState);
	else
		sDesc = sState;

	IAnimatron *pDesc = new CAniText;
	pDesc->SetPropertyVector(PROP_POSITION, CVector(xText, y));
	pDesc->SetPropertyVector(PROP_SCALE, CVector(cxText, 1000));
	pDesc->SetPropertyColor(PROP_COLOR, VI.GetColor(colorTextDialogInput));
	pDesc->SetPropertyFont(PROP_FONT, &MediumFont);
	pDesc->SetPropertyString(PROP_TEXT, sDesc);

	RECT rcLine;
	pDesc->GetSpacingRect(&rcLine);

	pRoot->AddTrack(pDesc, 0);
	y += RectHeight(rcLine);

	//	Adventure info

	CExtension *pAdventure = NULL;
	bool bHasAdventureIcon = false;

	if (g_pUniverse->FindExtension(GameFile.GetAdventure(), 0, &pAdventure))
		{
		//	Adventure icon

		CG16bitImage *pIcon;
		pAdventure->CreateIcon(ADVENTURE_ICON_WIDTH, ADVENTURE_ICON_HEIGHT, &pIcon);

		if (pIcon)
			{
			int xOffset = (ADVENTURE_ICON_WIDTH - pIcon->GetWidth()) / 2;
			IAnimatron *pIconAni = new CAniRect;
			pIconAni->SetPropertyVector(PROP_POSITION, CVector(x + xOffset, 0));
			pIconAni->SetPropertyVector(PROP_SCALE, CVector(pIcon->GetWidth(), pIcon->GetHeight()));
			pIconAni->SetFillMethod(new CAniImageFill(pIcon, true));

			pRoot->AddTrack(pIconAni, 0);

			bHasAdventureIcon = true;
			}

		//	Adventure name

		pName = new CAniText;
		pName->SetPropertyVector(PROP_POSITION, CVector(xText, y));
		pName->SetPropertyVector(PROP_SCALE, CVector(10000, 1000));
		pName->SetPropertyColor(PROP_COLOR, VI.GetColor(colorTextDialogLabel));
		pName->SetPropertyFont(PROP_FONT, &MediumFont);
		pName->SetPropertyString(PROP_TEXT, pAdventure->GetName());

		pRoot->AddTrack(pName, 0);
		y += MediumFont.GetHeight();
		}

	//	Create an image of the ship class

	if (pClass)
		{
		const CObjectImageArray &ObjImage = pClass->GetImage();
		if (ObjImage.IsLoaded())
			{
			RECT rcRect = ObjImage.GetImageRect();
			CG16bitImage &Image = ObjImage.GetImage(NULL_STR);
			int cxImage = RectWidth(rcRect);
			int cyImage = RectHeight(rcRect);

			int cxNewWidth = Min(SHIP_IMAGE_WIDTH, cxImage);
			int cyNewHeight = cxNewWidth;

			CG16bitImage *pNewImage = new CG16bitImage;
			pNewImage->CreateFromImageTransformed(Image, 
					rcRect.left, 
					rcRect.top, 
					cxImage,
					cyImage,
					(Metric)cxNewWidth / cxImage,
					(Metric)cyNewHeight / cyImage,
					0.0);

			//	Position

			int xImage = x + m_cxWidth - SHIP_IMAGE_WIDTH + (SHIP_IMAGE_WIDTH - cxNewWidth) / 2;
			int yImage = (SHIP_IMAGE_HEIGHT - cyNewHeight) / 2;

			//	New image frame

			IAnimatron *pImageFrame = new CAniRect;
			pImageFrame->SetPropertyVector(PROP_POSITION, CVector(xImage, yImage));
			pImageFrame->SetPropertyVector(PROP_SCALE, CVector(cxNewWidth, cyNewHeight));
			pImageFrame->SetFillMethod(new CAniImageFill(pNewImage, true));

			pRoot->AddTrack(pImageFrame, 0);
			}
		}

	//	Extra information

	CString sEpitaph = GameFile.GetEpitaph();
	int iScore = GameFile.GetScore();
	CTimeDate LocalTime = ModifiedTime.ToLocalTime();
	CString sModifiedTime = LocalTime.Format("%d %B %Y %I:%M %p");
	CString sFilename = pathGetFilename(GameFile.GetFilespec());

	CString sGameType;
	if (GameFile.IsRegistered())
		sGameType = CONSTLIT("Registered");
	else if (GameFile.IsDebug())
		sGameType = CONSTLIT("Debug");
	else
		sGameType = CONSTLIT("Unregistered");

	CString sExtra;
	if (!sEpitaph.IsBlank())
		sExtra = strPatternSubst(CONSTLIT("Score %d — %s\n%s — %s — %s"), iScore, sEpitaph, sGameType, sModifiedTime, sFilename);
	else if (iScore > 0)
		sExtra = strPatternSubst(CONSTLIT("Score %d\n%s — %s — %s"), iScore, sGameType, sModifiedTime, sFilename);
	else
		sExtra = strPatternSubst(CONSTLIT("%s — %s — %s"), sGameType, sModifiedTime, sFilename);

	pDesc = new CAniText;
	pDesc->SetPropertyVector(PROP_POSITION, CVector(xText, y));
	pDesc->SetPropertyVector(PROP_SCALE, CVector(cxText, 1000));
	pDesc->SetPropertyColor(PROP_COLOR, VI.GetColor(colorTextDialogLabel));
	pDesc->SetPropertyFont(PROP_FONT, &MediumFont);
	pDesc->SetPropertyString(PROP_TEXT, sExtra);

	pDesc->GetSpacingRect(&rcLine);

	pRoot->AddTrack(pDesc, 0);
	y += RectHeight(rcLine);

	//	Done

	*retpEntry = pRoot;

	if (retcyHeight)
		*retcyHeight = (bHasAdventureIcon ? Max(ADVENTURE_ICON_HEIGHT, y) : y);
	}
BOOL CRVTrackerNodeMove::OnStart()
{
	// Only start if we're in brush or objectmode
	if ((m_pView->GetEditMode() != BRUSH_EDITMODE) && 
		(m_pView->GetEditMode() != OBJECT_EDITMODE))
		return FALSE;

	// Make sure something is selected
	if (!m_pView->GetRegion()->m_Selections.GetSize())
		return FALSE;

	// If in handle mode, make sure we're clicking on a move handle
	if (m_bHandle)
	{
		// Any handle at all?
		int iCurHandle = m_pView->GetCurrentMouseOverHandle();
		if (iCurHandle == -1)
			return FALSE;

		// A movement handle?
		CVector vDummy;
		if (m_pView->GetHandleInfo(iCurHandle, NULL, vDummy, vDummy))
			return FALSE;
	}

	// Make a clone if needed  
	if (m_bClone)
	{
		m_pView->GetRegionDoc()->Clone();
	}

	// Default to successful start...
	BOOL bStart = TRUE;
	
	CVector vClosest;

	if(m_bSnap && m_pView->GetClosestPoint(m_cCurPt, vClosest, TRUE ))
	{
		// Make the closest point our starting position...
		m_vStartVec = vClosest;

		// Snap to grid...
		CEditGrid *pGrid = &m_pView->EditGrid();
		m_vStartVec -= pGrid->Forward() * (pGrid->Forward().Dot(m_vStartVec - pGrid->Pos()));
	}
	else
	{
		if (!m_bSnap)
		{
			// Reset the move offset
			m_vTotalMoveOffset = CVector(0.0f, 0.0f, 0.0f);
			m_vMoveSnapAxis = CVector(1.0f, 1.0f, 1.0f);
		}

		// Find another point...
		bStart = m_pView->GetVertexFromPoint(m_cCurPt, m_vStartVec);
	}

	if( bStart )
		m_pView->GetRegionDoc()->SetupUndoForSelections();
	
	return bStart;
}
/////////////////////////////////////////////////////////////
//
// CVertexStreamBoundingBoxManager::ComputeVertexStreamBoundingBox
//
// Measure used vertices
//
/////////////////////////////////////////////////////////////
bool CVertexStreamBoundingBoxManager::ComputeVertexStreamBoundingBox ( SCurrentStateInfo2& state, uint ReadOffsetStart, uint ReadSize, CBox& outBoundingBox )
{
    IDirect3DVertexBuffer9* pStreamDataPT = state.stream.pStreamData;

    const uint StridePT = state.stream.Stride;

    uint NumVerts = ReadSize / StridePT;

    // Adjust for the offset in the stream
    ReadOffsetStart += state.stream.elementOffset;
    ReadSize -= state.stream.elementOffset;
    if ( ReadSize < 1 )
        return false;

    // Get the source vertex bytes
    std::vector < uchar > sourceArray;
    sourceArray.resize ( ReadSize );
    uchar* pSourceArrayBytes = &sourceArray[0];
    {
        void* pVertexBytesPT = NULL;
        if ( FAILED( pStreamDataPT->Lock ( ReadOffsetStart, ReadSize, &pVertexBytesPT, D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY ) ) )
            return false;
        memcpy ( pSourceArrayBytes, pVertexBytesPT, ReadSize );
        pStreamDataPT->Unlock ();
    }

    // Compute bounds
    {
        // Get index data
        if ( FAILED( m_pDevice->GetIndices( &state.pIndexData ) ) )
            return false;

        // Get index buffer desc
        D3DINDEXBUFFER_DESC IndexBufferDesc;
        state.pIndexData->GetDesc ( &IndexBufferDesc );

        uint numIndices = state.args.primCount + 2;
        uint step = 1;
        if ( state.args.PrimitiveType == D3DPT_TRIANGLELIST )
        {
            numIndices = state.args.primCount * 3;
            step = 3;
        }
        assert ( IndexBufferDesc.Size >= ( numIndices + state.args.startIndex ) * 2 );

        // Get index buffer data
        std::vector < uchar > indexArray;
        indexArray.resize ( numIndices*2 );
        uchar* pIndexArrayBytes = &indexArray[0];
        {
            void* pIndexBytes = NULL;
            if ( FAILED( state.pIndexData->Lock ( state.args.startIndex*2, numIndices*2, &pIndexBytes, D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY ) ) )
                return false;
            memcpy ( pIndexArrayBytes, pIndexBytes, numIndices*2 );
            state.pIndexData->Unlock ();
        }

        CVector& vecMin = outBoundingBox.vecMin;
        CVector& vecMax = outBoundingBox.vecMax;
        vecMin = CVector ( 9999, 9999, 9999 );
        vecMax = CVector ( -9999, -9999, -9999 );

        // For each triangle
        for ( uint i = 0 ; i < numIndices - 2 ; i += step )
        {
            // Get triangle vertex indici
            WORD v0 = ((WORD*)pIndexArrayBytes)[ i ];
            WORD v1 = ((WORD*)pIndexArrayBytes)[ i + 1 ];
            WORD v2 = ((WORD*)pIndexArrayBytes)[ i + 2 ];

            if ( v0 >= NumVerts || v1 >= NumVerts || v2 >= NumVerts )
                continue;   // vert index out of range

            if ( v0 == v1 || v0 == v2 || v1 == v2 )
                continue;   // degenerate tri

            // Get vertex positions from original stream
            CVector* pPos0 = (CVector*)( pSourceArrayBytes + v0 * StridePT );
            CVector* pPos1 = (CVector*)( pSourceArrayBytes + v1 * StridePT );
            CVector* pPos2 = (CVector*)( pSourceArrayBytes + v2 * StridePT );

            // Update min/max
            vecMin.fX = Min ( vecMin.fX, pPos0->fX );
            vecMin.fY = Min ( vecMin.fY, pPos0->fY );
            vecMin.fZ = Min ( vecMin.fZ, pPos0->fZ );
            vecMax.fX = Max ( vecMax.fX, pPos0->fX );
            vecMax.fY = Max ( vecMax.fY, pPos0->fY );
            vecMax.fZ = Max ( vecMax.fZ, pPos0->fZ );

            vecMin.fX = Min ( vecMin.fX, pPos1->fX );
            vecMin.fY = Min ( vecMin.fY, pPos1->fY );
            vecMin.fZ = Min ( vecMin.fZ, pPos1->fZ );
            vecMax.fX = Max ( vecMax.fX, pPos1->fX );
            vecMax.fY = Max ( vecMax.fY, pPos1->fY );
            vecMax.fZ = Max ( vecMax.fZ, pPos1->fZ );

            vecMin.fX = Min ( vecMin.fX, pPos2->fX );
            vecMin.fY = Min ( vecMin.fY, pPos2->fY );
            vecMin.fZ = Min ( vecMin.fZ, pPos2->fZ );
            vecMax.fX = Max ( vecMax.fX, pPos2->fX );
            vecMax.fY = Max ( vecMax.fY, pPos2->fY );
            vecMax.fZ = Max ( vecMax.fZ, pPos2->fZ );
        }
    }

    return true;
}
void CTestScenarioOffsetPursue::Initialize(CIATestMainWindow *pWindow)
{
	CIAEntityBase *pTarget=new CIAEntityBase;
	pTarget->SetPosition(CVector(dBaseSize*0.3,dBaseSize*0.6,0));
	pTarget->SetColor(CVector(0.5,0.5,0.5));
	pTarget->SetSize(30);
	pWindow->AddEntity("Target",pTarget,true);

	CIAEntityBase *pLeader=new CIAEntityBase;
	pLeader->SetPosition(CVector(dBaseSize*0.3,dBaseSize*0.6,0));
	pLeader->SetColor(CVector(0,0,0.5));
	pLeader->SetSize(30);
	//pLeader->Wander(true,200,100,5000);
	pLeader->ArriveTarget(pTarget,eSBArriveSpeed_Normal);
    pWindow->AddEntity("Leader",pLeader,true);

	CVector pVectors[]={CVector(-30,-50,0),CVector(-30,50,0),CVector(-60,0,0),CVector(0,0,0)};
	int nFollowers=0;
	while(pVectors[nFollowers]!=CVector(0,0,0))
	{
		char sName[1024];
		CIAEntityBase *pFollower=new CIAEntityBase;
		pFollower->SetPosition(CVector(dBaseSize*(0.2+((double)nFollowers)*0.1),dBaseSize*(0.2+((double)nFollowers)*0.1),0));
		pFollower->SetColor(CVector(0.5,0,0));
		pFollower->SetSize(20);
		pFollower->SetMaxVelocity(pLeader->GetMaxVelocity()*0.7);
		pFollower->SetMaxForce(pLeader->GetMaxForce());
		pFollower->OffsetPursue(pLeader,pVectors[nFollowers]);
		pFollower->SetRenderFlags(RENDER_FLAGS_NONE);
		sprintf(sName,"Follower-%d",nFollowers+1);
		pWindow->AddEntity(sName,pFollower,true);
		nFollowers++;
	}
}
void CCoronas::RegisterCorona(unsigned int nID, CEntity* pAttachTo, unsigned char R, unsigned char G, unsigned char B, unsigned char A, const CVector& Position, float Size, float Range, RwTexture* pTex, unsigned char flareType, unsigned char reflectionType, unsigned char LOSCheck, unsigned char unused, float normalAngle, bool bNeonFade, float PullTowardsCam, bool bFadeIntensity, float FadeSpeed, bool bOnlyFromBelow, bool bWhiteCore)
{
    UNREFERENCED_PARAMETER(unused);

    CVector		vecPosToCheck;
    if (pAttachTo)
    {
        // TODO: AllocateMatrix
        vecPosToCheck = *pAttachTo->GetMatrix() * Position;
    }
    else
        vecPosToCheck = Position;

    CVector*	pCamPos = TheCamera.GetCoords();
    if (Range * Range >= (pCamPos->x - vecPosToCheck.x)*(pCamPos->x - vecPosToCheck.x) + (pCamPos->y - vecPosToCheck.y)*(pCamPos->y - vecPosToCheck.y))
    {
        if (bNeonFade)
        {
            float		fDistFromCam = CVector(*pCamPos - vecPosToCheck).Magnitude();

            if (fDistFromCam < 35.0f)
                return;
            if (fDistFromCam < 50.0f)
                A *= static_cast<unsigned char>((fDistFromCam - 35.0f) * (2.0f / 3.0f));
        }

        // Is corona already present?
        CRegisteredCorona*		pSuitableSlot;
        auto it = UsedMap.find(nID);

        if (it != UsedMap.end())
        {
            pSuitableSlot = it->second->GetFrom();

            if (pSuitableSlot->FadedIntensity == 0 && A == 0)
            {
                // Mark as free
                it->second->GetFrom()->Identifier = 0;
                it->second->Add(&FreeList);
                UsedMap.erase(nID);
                return;
            }
        }
        else
        {
            if (!A)
                return;

            // Adding a new element
            auto	pNewEntry = FreeList.First();
            if (!pNewEntry)
            {
                MessageBoxA(0, "ERROR: Not enough space for coronas!", "ERROR: Not enough space for coronas!", 0);
                return;
            }

            pSuitableSlot = pNewEntry->GetFrom();

            // Add to used list and push this index to the map
            pNewEntry->Add(&UsedList);
            UsedMap[nID] = pNewEntry;

            pSuitableSlot->FadedIntensity = bFadeIntensity ? 255 : 0;
            pSuitableSlot->OffScreen = true;
            pSuitableSlot->JustCreated = true;
            pSuitableSlot->Identifier = nID;
        }

        pSuitableSlot->Red = R;
        pSuitableSlot->Green = G;
        pSuitableSlot->Blue = B;
        pSuitableSlot->Intensity = A;
        pSuitableSlot->Coordinates = Position;
        pSuitableSlot->Size = Size;
        pSuitableSlot->NormalAngle = normalAngle;
        pSuitableSlot->Range = Range;
        pSuitableSlot->pTex = pTex;
        pSuitableSlot->FlareType = flareType;
        pSuitableSlot->ReflectionType = reflectionType;
        pSuitableSlot->LOSCheck = LOSCheck;
        pSuitableSlot->RegisteredThisFrame = true;
        pSuitableSlot->PullTowardsCam = PullTowardsCam;
        pSuitableSlot->FadeSpeed = FadeSpeed;

        pSuitableSlot->NeonFade = bNeonFade;
        pSuitableSlot->OnlyFromBelow = bOnlyFromBelow;
        pSuitableSlot->WhiteCore = bWhiteCore;

        if (pAttachTo)
        {
            pSuitableSlot->bIsAttachedToEntity = true;
            pSuitableSlot->pEntityAttachedTo = pAttachTo;

            pAttachTo->RegisterReference(&pSuitableSlot->pEntityAttachedTo);
        }
        else
        {
            pSuitableSlot->bIsAttachedToEntity = false;
            pSuitableSlot->pEntityAttachedTo = nullptr;
        }
    }
}
void CEntity::Tick(CMap* pMap)
{
	if(Mov != CVector(0,0) && CanMove(pMap, Mov))
		Pos += Mov;
	Mov = CVector(0,0);
}
Beispiel #7
0
void CUIHelper::CreateSessionTitle (IHISession *pSession, 
									CCloudService &Service, 
									const CString &sTitle, 
									const TArray<SMenuEntry> *pMenu,
									DWORD dwOptions, 
									IAnimatron **retpControl) const

//	CreateSessionTitle
//
//	Creates a session title bar, including:
//
//	User icon
//	User name
//	Session title
//	Close button

	{
	int i;
	const CVisualPalette &VI = m_HI.GetVisuals();
	const CG16bitFont &SubTitleFont = VI.GetFont(fontSubTitle);

	RECT rcRect;
	VI.GetWidescreenRect(m_HI.GetScreen(), &rcRect);

	//	Create a sequencer to hold all the controls

	CAniSequencer *pRoot;
	CAniSequencer::Create(CVector(rcRect.left, rcRect.top - TITLE_BAR_HEIGHT), &pRoot);

	//	Add the header, unless excluded

	if (!(dwOptions & OPTION_SESSION_NO_HEADER))
		{
		//	The user icon is centered

		CAniRoundedRect *pIcon = new CAniRoundedRect;
		pIcon->SetPropertyVector(PROP_POSITION, CVector(0, (TITLE_BAR_HEIGHT - ICON_HEIGHT) / 2));
		pIcon->SetPropertyVector(PROP_SCALE, CVector(ICON_HEIGHT, ICON_WIDTH));
		pIcon->SetPropertyColor(PROP_COLOR, CG16bitImage::RGBValue(128, 128, 128));
		pIcon->SetPropertyOpacity(PROP_OPACITY, 255);
		pIcon->SetPropertyInteger(PROP_UL_RADIUS, ICON_CORNER_RADIUS);
		pIcon->SetPropertyInteger(PROP_UR_RADIUS, ICON_CORNER_RADIUS);
		pIcon->SetPropertyInteger(PROP_LL_RADIUS, ICON_CORNER_RADIUS);
		pIcon->SetPropertyInteger(PROP_LR_RADIUS, ICON_CORNER_RADIUS);

		pRoot->AddTrack(pIcon, 0);

		//	The user name baseline is centered.

		CString sUsername;
		WORD wUsernameColor;
		if (Service.HasCapability(ICIService::canGetUserProfile))
			{
			sUsername = Service.GetUsername();
			wUsernameColor = VI.GetColor(colorTextDialogInput);
			}
		else
			{
			sUsername = CONSTLIT("Offline");
			wUsernameColor = VI.GetColor(colorTextDialogLabel);
			}

		int y = (TITLE_BAR_HEIGHT / 2) - SubTitleFont.GetAscent();

		IAnimatron *pName = new CAniText;
		pName->SetPropertyVector(PROP_POSITION, CVector(ICON_WIDTH + PADDING_LEFT, y));
		pName->SetPropertyVector(PROP_SCALE, CVector(RectWidth(rcRect), RectHeight(rcRect)));
		pName->SetPropertyColor(PROP_COLOR, wUsernameColor);
		pName->SetPropertyFont(PROP_FONT, &SubTitleFont);
		pName->SetPropertyString(PROP_TEXT, sUsername);

		pRoot->AddTrack(pName, 0);
		y += SubTitleFont.GetHeight();

		//	Add the session title

		IAnimatron *pTitle = new CAniText;
		pTitle->SetPropertyVector(PROP_POSITION, CVector(ICON_WIDTH + PADDING_LEFT, y));
		pTitle->SetPropertyVector(PROP_SCALE, CVector(RectWidth(rcRect), RectHeight(rcRect)));
		pTitle->SetPropertyColor(PROP_COLOR, VI.GetColor(colorTextDialogTitle));
		pTitle->SetPropertyFont(PROP_FONT, &SubTitleFont);
		pTitle->SetPropertyString(PROP_TEXT, sTitle);

		pRoot->AddTrack(pTitle, 0);
		}

	//	Add command buttons at the bottom

	int yBottomBar = TITLE_BAR_HEIGHT + RectHeight(rcRect);

	//	Add a close button.

	if (!(dwOptions & OPTION_SESSION_NO_CANCEL_BUTTON))
		{
		//	If we have an OK button, then the label is Cancel.

		CString sCloseLabel = ((dwOptions & OPTION_SESSION_OK_BUTTON) ? CONSTLIT("Cancel") : CONSTLIT("Close"));
		const CG16bitImage &CloseIcon = VI.GetImage(imageCloseIcon);

		IAnimatron *pCloseButton;
		VI.CreateImageButton(pRoot, CMD_CLOSE_SESSION, RectWidth(rcRect) - BUTTON_WIDTH, yBottomBar + (TITLE_BAR_HEIGHT - BUTTON_HEIGHT) / 2, &CloseIcon, sCloseLabel, 0, &pCloseButton);

		pSession->RegisterPerformanceEvent(pCloseButton, EVENT_ON_CLICK, CMD_CLOSE_SESSION);
		}

	//	Add an OK button, if necessary

	if (dwOptions & OPTION_SESSION_OK_BUTTON)
		{
		const CG16bitImage &OKIcon = VI.GetImage(imageOKIcon);

		IAnimatron *pOKButton;
		VI.CreateImageButton(pRoot, CMD_OK_SESSION, (RectWidth(rcRect) - BUTTON_WIDTH) / 2, yBottomBar + (TITLE_BAR_HEIGHT - BUTTON_HEIGHT) / 2, &OKIcon, CONSTLIT("OK"), 0, &pOKButton);

		pSession->RegisterPerformanceEvent(pOKButton, EVENT_ON_CLICK, CMD_OK_SESSION);
		}

	//	Add extensions button

	else if (dwOptions & OPTION_SESSION_ADD_EXTENSION_BUTTON)
		{
		const CG16bitImage &OKIcon = VI.GetImage(imageSlotIcon);

		IAnimatron *pOKButton;
		VI.CreateImageButton(pRoot, CMD_OK_SESSION, (RectWidth(rcRect) - BUTTON_WIDTH) / 2, yBottomBar + (TITLE_BAR_HEIGHT - BUTTON_HEIGHT) / 2, &OKIcon, CONSTLIT("Add Extension"), 0, &pOKButton);

		pSession->RegisterPerformanceEvent(pOKButton, EVENT_ON_CLICK, CMD_OK_SESSION);
		}

	//	Add menu items, if necessary

	if (pMenu)
		{
		//	Menu is to the left.

		int xMenu = 0;
		int yMenu = yBottomBar + (TITLE_BAR_HEIGHT - BUTTON_HEIGHT) / 2;

		for (i = 0; i < pMenu->GetCount(); i++)
			{
			const SMenuEntry &Entry = pMenu->GetAt(i);

			IAnimatron *pButton;
			int cyHeight;
			VI.CreateLink(pRoot, Entry.sCommand, xMenu, yMenu, Entry.sLabel, 0, &pButton, NULL, &cyHeight);
			yMenu += cyHeight;

			pSession->RegisterPerformanceEvent(pButton, EVENT_ON_CLICK, Entry.sCommand);
			}
		}

	//	Done

	*retpControl = pRoot;
	}
Beispiel #8
0
void CEnemy10::Move() {
	Scale = CVector(1.2f, 1, 1)*0.22f;
	Position = Owner->Position + CVector(0.01, 0.06f, 0);
}
Beispiel #9
0
void CEnemy5::Reset() {
	Life = 20;
	Velocity = CVector(1, 1, 0)*0.008f;
	
}
Beispiel #10
0
//=====================================================BOSS体================================================================================================
void CEnemy2::Move() {

	Scale = CVector(1.1f, 1, 1)*0.35f;
	Velocity.Y -= 0.005f;

	//左向き
		if (Bst == 0){
			//if (Time % 140 == 0)New<CWeapon6>(Position, CVector(-0.15f, 0.3f, 0));
			//if (Time % 140 == 0)New<CWeapon6>(Position, CVector(-0.15f, 0.0f, 0));
			//Time++;

			Position.X -= 0.007f;
			Position += Velocity;
			if (Time % 300 == 0){
				//移動時JUMP(ガッコン)
				GetWave(L"se_maoudamashii_se_sound09.wav")->Play(1);
				GetWave(L"se_maoudamashii_se_sound09.wav")->SetVolume(0.07f);
				Velocity.Y += 0.07f; Position += Velocity;
			}
			if (Time % 125 == 20)Texture = GetTexture(L"boss_karada1.png");
			if (Time % 125 == 40)Texture = GetTexture(L"boss_karada2.png");
			if (Time % 125 == 60)Texture = GetTexture(L"boss_karada3.png");
			if (Time % 125 == 80)Texture = GetTexture(L"boss_karada4.png");
			if (Time % 125 == 100)Texture = GetTexture(L"boss_karada5.png");
			if (Time % 125 == 120)Texture = GetTexture(L"boss_karada6.png");
			Time++;
		}
	//右向き
		if (Bst == 1){
			//if (Time % 140 == 0)New<CWeapon6>(Position, CVector(0.15f, 0.3f, 0));
			//if (Time % 140 == 0)New<CWeapon6>(Position, CVector(0.15f, 0.0f, 0));
			//Time++;

			Position.X += 0.007f;
			Position += Velocity;

			if (Time % 300 == 0){
				//移動時JUMP(ガッコン)
				GetWave(L"se_maoudamashii_se_sound09.wav")->Play(1);
				GetWave(L"se_maoudamashii_se_sound09.wav")->SetVolume(0.07f);
				Velocity.Y += 0.07f; Position += Velocity;
			}
			if (Time % 120 == 20)Texture = GetTexture(L"boss_karada1R.png");
			if (Time % 120 == 40)Texture = GetTexture(L"boss_karada2R.png");
			if (Time % 120 == 60)Texture = GetTexture(L"boss_karada3R.png");
			if (Time % 120 == 80)Texture = GetTexture(L"boss_karada4R.png");
			if (Time % 120 == 100)Texture = GetTexture(L"boss_karada5R.png");
			if (Time % 120 == 120)Texture = GetTexture(L"boss_karada6R.png");
			Time++;

		}
	

	/*if(ATP==0){
		if (Time % 180 == 0){
			Enemy8List.Apply([&](CMover* b) {
				b->Color = CColor(1, 1, 1, 1.0f);
				//b->Life = 0;
			});
		}
		ATP = 1;
	}

	if (ATP == 1){
		if (Time % 240 == 0){
			Enemy8List.Apply([&](CMover* b) {
				b->Color = CColor(1, 1, 1, 1.0f);
			});
		}
		ATP = 0;
	}*/

	CHitRectangle hit;
	Apply(BlockList, hit);
	Apply(Block1List, hit);
	Apply(Block2List, hit);
	Apply(Block3List, hit);
	Apply(Block6List, hit);
	Apply(Block7List, hit);
	Apply(Block8List, hit);
	Apply(Block9List, hit);
	Apply(Block10List, hit);
	Apply(Block11List, hit);
	Apply(Block12List, hit);
	Apply(Block13List, hit);
	Apply(Block14List, hit);
	Apply(Block15List, hit);
	Apply(Block16List, hit);
	Apply(Block17List, hit);
	Apply(Block18List, hit);
	Apply(Block19List, hit);
	Apply(Block20List, hit);
	Apply(Block22List, hit);
	Apply(Block23List, hit);
	Apply(Block28List, hit);
	Apply(Block29List, hit);
	//Apply(Block30List, hit);
	


	Block30List.Apply([&](CMover* b) {//ブロック接触
		if (Length(Position - b->Position) <0.6f) {
			Color.A = 0.9f;
			Bst = 1;
			BSST = 1;
		}
	});

	Block31List.Apply([&](CMover* b) {//ブロック接触
		if (Length(Position - b->Position) < 0.6f) {
			Color.A = 0.9f;
			Bst = 0;
			BSST = 0;
		}
	});
	
}
Beispiel #11
0
//BOSS顔
void CEnemy8::Move() {
	Position += Velocity;
	//Texture = GetTexture(L"boss_kao1.png");
	//if (Time % 300 == 0)

	//左向き
	if (BSST == 0){
		/*if (kao == 0){
			Scale = CVector(1.2f, 1, 1)*0.27f;
			Position = Owner->Position + CVector(0.04, 0.89f, 0);
		}*/

		/*if (Time % 120 == 0){
			Position.X -= 0.6f;
			Position += Velocity;
		}*/

		if (Time % 120 == 20)Texture = GetTexture(L"boss_kao1.png");
		if (Time % 120 == 40)Texture = GetTexture(L"boss_kao2.png");
		if (Time % 120 == 60)Texture = GetTexture(L"boss_kao3.png");
		if (Time % 120 == 80)Texture = GetTexture(L"boss_kao4.png");
		if (Time % 120 == 100)Texture = GetTexture(L"boss_kao5.png");
		if (Time % 120 == 120)Texture = GetTexture(L"boss_kao6.png");
		Time++;
	}
	//右向き
	if (BSST == 1){
		//Scale = CVector(1.2f, 1, 1)*0.27f;
		//Position = Owner->Position + CVector(-0.04, 0.89f, 0);

		if (Time % 120 == 20)Texture = GetTexture(L"boss_kao1R.png");
		if (Time % 120 == 40)Texture = GetTexture(L"boss_kao2R.png");
		if (Time % 120 == 60)Texture = GetTexture(L"boss_kao3R.png");
		if (Time % 120 == 80)Texture = GetTexture(L"boss_kao4R.png");
		if (Time % 120 == 100)Texture = GetTexture(L"boss_kao5R.png");
		if (Time % 120 == 120)Texture = GetTexture(L"boss_kao6R.png");
		Time++;
	}

	if (Type == 1) {
		//頭飛ばす変数
		if (atama == 0){
			if (Time % 420 == 0){ 
				Color = CColor(1, 0, 0, 1);
				if (Time % 60 == 0)atama = 1;
				Time++;
			}
		}

		if (State == 0) {
			Position = Owner->Position + CVector(0, 0.59f, 0);
			if (atama==1){
					KM = 0, State = 1;
					atama = 0;
			}
		}
		if (State == 1) {//飛んでく頭
			MyShipList.Apply([&](CMover* m) {
					Position += Normalize(m->Position - Position)*0.04f;
					KM++; BOSSC = 1;
					if (KM == 60) State = 2;
					New<CEffect20>(Position);
					//飛んでいく頭の音(シュビビビビーン)
					GetWave(L"se_maoudamashii_battle02.wav")->Play(1);
					GetWave(L"se_maoudamashii_battle02.wav")->SetVolume(0.02f);
			});
		}
		if (State == 2) {//戻ってくるスピード
			CVector target = Owner->Position + CVector(0, 0.59f, 0);
			Position += Normalize(target - Position)*0.05f;
			if (Length(target - Position)<0.02f) State = 0;
			BOSSC = 0;
			New<CEffect20>(Position);
			Color = CColor(1, 1, 1, 1);
		}
	}

	//BOSS顔接触時ダメージ
	MyShipList.Apply([&](CMover* m) {
		if (Length(m->Position - Position)<0.44f) {
			m->Life -= wp;
		}
	});
	//攻撃判定透明化
	if (MutekiTime1 == 0) {
		WeaponList.Apply([&](CMover* e) {
			if (Length(Position - e->Position) < 0.5f) {
				//Life--;
				MutekiTime1 = 1;
				MutekiTime = 1;
				Color.A = 0.7f;
			}
		});
		if (MutekiTime1 == 1)MutekiTime1 = 0;
	}
	

	if (MutekiTime1 == 0) {
		Weapon2List.Apply([&](CMover* e) {
			if (Length(Position - e->Position) < 0.4f) {
				//Life--;
				MutekiTime1 = 1;
				MutekiTime = 1;
				Color.A = 0.7f;
			}
		});
		if (MutekiTime1 == 1)MutekiTime1 = 0;
	}

	if (MutekiTime1 == 0) {
		Weapon7List.Apply([&](CMover* e) {
			if (Length(Position - e->Position) < 0.4f) {
				//Life--;
				MutekiTime1 = 1;
				MutekiTime = 1;
				Color.A = 0.7f;
			}
		});
		if (MutekiTime1 == 1)MutekiTime1 = 0;
	}

	CHitRectangle hit;
	Apply(Block14List, hit);
	Apply(Block15List, hit);
	Apply(Block2List, hit);
	Apply(Block6List, hit);
	Apply(Block7List, hit);
}
Beispiel #12
0
// 敵の移動
void CEnemy::Move() {
	CHitRectangle hit;
	Apply(BlockList, hit);
	Apply(Block1List, hit);
	Apply(Block2List, hit);
	Apply(Block3List, hit);
	Apply(Block5List, hit);
	Apply(Block6List, hit);
	Apply(Block7List, hit);
	Apply(Block8List, hit);
	Apply(Block9List, hit);
	Apply(Block10List, hit);
	Apply(Block11List, hit);
	Apply(Block12List, hit);
	Apply(Block13List, hit);
	Apply(Block14List, hit);
	Apply(Block15List, hit);
	Apply(Block16List, hit);
	Apply(Block17List, hit);
	Apply(Block18List, hit);
	Apply(Block19List, hit);
	Apply(Block20List, hit);
	Apply(Block22List, hit);
	Apply(Block23List, hit);
	Apply(Block28List, hit);
	Apply(Block29List, hit);
	//Apply(EnemyList, hit);

	
	Velocity.Y -= 0.002f;
	Position += Velocity;
	
Block3List.Apply([&](CMover* b) {//赤ブロック接触
	if (Length(Position - b->Position) < 0.21f) {
		Color.A = 1;
		Ept = 1;
	}
});

Block5List.Apply([&](CMover* b) {//黒ブロック接触
	if (Length(Position - b->Position) < 0.21f) {
		Color.A = 1;
		Ept = 2;
	}
});

	if (Ept == 1){//左向き
		if (Time % 30 == 10)Texture = GetTexture(L"kuma_r.png");
		if (Time % 30 == 20)Texture = GetTexture(L"kuma_r1.png");
		if (Time % 30 == 25)Texture = GetTexture(L"kuma_r2.png");
		Time++;
		
	}

	if (Ept == 2){//右向き
		if (Time % 30 == 10)Texture = GetTexture(L"kuma_l.png");
		if (Time % 30 == 20)Texture = GetTexture(L"kuma_l1.png");
		if (Time % 30 == 25)Texture = GetTexture(L"kuma_l2.png");
		Time++;	
	}

	MyShipList.Apply([&](CMover* m) {
		float f = Length(Position - m->Position);//自機と敵との距離計算

		if (f < 0.2 && Ept == 1 && hit.Down){//左近距離行動
			Velocity.Y += 0.03f;
			Velocity.X -= 0.012f;
			Position += Velocity;
		}
		if (f < 1.5 &&f > 0.2 && Ept == 1){//左中距離行動
			if (Time % 40 == 5)New<CWeapon6>(Position, CVector(-0.05f, 0, 0));
			Time++;
			if (hit.Down)Position.X += -0.005f;
		}
		
		if (f < 0.2 && Ept == 2 && hit.Down){//右近距離行動
			Velocity.Y += 0.03f;
			Velocity.X += 0.012f;
			Position += Velocity;
		}
		if (f < 1.5 &&f > 0.2 && Ept == 2){//右中距離行動
			if (Time % 40 == 5)New<CWeapon6>(Position, CVector(0.05f, 0, 0));
			Time++;
			if (hit.Down)Position.X += 0.005f;
		}
	});
	
}
void Stage_001::Update()
{
    m_frame++;
    
    m_pConnection->Update();
    
    for (int i = 0; i < MAX_MULTI_PLAYER; i++) {
        if (m_clientPositionQueues[i].empty() || 0 == m_pOtherPlayers[i]) {
            continue;
        }
        
        m_pOtherPlayers[i]->position = m_clientPositionQueues[i].front();
        m_clientPositionQueues[i].pop();
    }
    
    bool isMove = false;
    CVector moveVector = m_pPlayer->GetMoveVector();
    
    if (sKeyPadManager->GetMainKeyPad()->IsOn(KeyPadLeft)) {
        isMove = true;
        moveVector.x -= 4.0f;
    }
    /*
    if (sKeyPadManager->GetMainKeyPad()->IsOn(KeyPadTop)) {
        isMove = true;
        moveVector.y -= 4.0f;
    }*/
    
    if (sKeyPadManager->GetMainKeyPad()->IsOn(KeyPadRight)) {
        isMove = true;
        moveVector.x += 4.0f;
    }
    /*
    if (sKeyPadManager->GetMainKeyPad()->IsOn(KeyPadBottom)) {
        isMove = true;
        moveVector.y += 4.0f;
    }*/
    
    if (0.0f == moveVector.y && sKeyPadManager->GetMainKeyPad()->IsPress(KeyPadA)) {
        isMove = true;
        moveVector.y -= 16.0f;
        if (sKeyPadManager->GetMainKeyPad()->IsOn(KeyPadB)) {
            moveVector.y -= 4.0f;
        }
    }
    
    if (isMove) {
        m_pPlayer->SetMoveVector(moveVector);
        
        if (sKeyPadManager->GetMainKeyPad()->IsOn(KeyPadB)) {
            m_pPlayer->AddMoveVector(CVector(moveVector.x, 0.0f, 0.0f));
        }
    }
    
    if (sKeyPadManager->GetMainKeyPad()->IsPress(KeyPadStart)) {
        if (0 == CSocket::GetIP()) {
            m_pView->SetTransition(new CTransitionFadeIn(0.2f, this, Stage_001TransitionID_Entry));
            m_pView->RunTransition();
        }
        else {
            m_pConnection->Search();
        }
    }
    
    CRect drawRect = GetDrawRect();
    CRect stepRect = CRect(drawRect.left - m_drawSize.width, drawRect.top - m_drawSize.height, drawRect.right + m_drawSize.width, drawRect.bottom + m_drawSize.height);
    m_pWorld->Step(stepRect);
    
    std::list<CBody *> bodies = m_pWorld->GetBodyList();
    std::list<CBody *>::iterator i = bodies.begin();
    while (i != bodies.end()) {
        CRect bodyRect = (*i)->GetRect();
        if (CCollision::RectOnRect(bodyRect, drawRect)) {
            CPoint position = (*i)->position;
            position.x -= m_drawOffset.x;
            CView *surface = (*i)->GetSurface();
            surface->SetPosition(position);
        }
        
        ++i;
    }
    
    CVector vector = m_pPlayer->GetMoveVector();
    vector.x = 0.0f;
    m_pPlayer->SetMoveVector(vector);
    
    // プレイヤーの位置に合わせてステージの表示領域を移動
    CPoint center = CPoint(m_drawOffset.x + m_drawSize.width / 2.0f, m_drawOffset.y + m_drawSize.height / 2.0f);
    m_drawOffset.x += m_pPlayer->GetRect().right - center.x;
    if (0.0f > m_drawOffset.x || (0.0f >= (GetStageSize().width - m_drawSize.width))) {
        m_drawOffset.x = 0.0f;
    }
    else if ((GetStageSize().width - m_drawSize.width) < m_drawOffset.x) {
        m_drawOffset.x = GetStageSize().width - m_drawSize.width;
    }
    
    CPoint realPosition = m_pPlayer->GetSurface()->GetPosition() + m_drawOffset;
    m_pConnection->Move(realPosition);
}
Beispiel #14
0
CPolygon::CPolygon()
{
	//not computed
	m_cached_midpoint = CVector(FLT_EPSILON,FLT_EPSILON,FLT_EPSILON); 
	m_normal = CVector(FLT_EPSILON,FLT_EPSILON,FLT_EPSILON);
}
Beispiel #15
0
void mrqmin( double x[], double y[], double sig[], int ndata, CVector a,   
        int ia[], int ma, CMatrix covar, CMatrix alpha, double *chisq,   
        void (*funcs)(double, double [], double *, double [], int),   
        double *alamda)   
{   
  int j,k,l,m;   
  static int mfit;   
  static double ochisq;   
  CMatrix oneda;   
  CVector atry,beta,da;   
   
  if (*alamda < 0.0) {   
    atry=CVector(1,ma);   
    beta=CVector(1,ma);   
    da=CVector(1,ma);   
    for (mfit=0,j=1;j<=ma;j++)   
      if (ia[j]) mfit++;   
    oneda=CMatrix(1,mfit);   
    *alamda=0.001;   
    mrqcof(x,y,sig,ndata,a,ia,ma,alpha,beta,chisq,funcs);   
    ochisq=(*chisq);   
    for (j=1;j<=ma;j++) atry[j]=a[j];   
  }   
  for (j=0,l=1;l<=ma;l++) {   
    if (ia[l]) {   
      for (j++,k=0,m=1;m<=ma;m++) {   
    if (ia[m]) {   
      k++;   
      covar[j][k]=alpha[j][k];   
    }   
      }   
      covar[j][j]=alpha[j][j]*(1.0+(*alamda));   
      oneda[j][1]=beta[j];   
    }   
  }   
  covar.ColMax();   
  for (j=1;j<=mfit;j++) da[j]=oneda[j][1];   
  if (*alamda == 0.0) {   
    covsrt(covar,ma,ia,mfit);   
    return;   
  }   
  for (j=0,l=1;l<=ma;l++)   
    if (ia[l]) atry[l]=a[l]+da[++j];   
  mrqcof(x,y,sig,ndata,atry,ia,ma,covar,da,chisq,funcs);   
  if (*chisq < ochisq) {   
    *alamda *= 0.1;   
    ochisq=(*chisq);   
    for (j=0,l=1;l<=ma;l++) {   
      if (ia[l]) {   
    for (j++,k=0,m=1;m<=ma;m++) {   
      if (ia[m]) {   
        k++;   
        alpha[j][k]=covar[j][k];   
      }   
    }   
    beta[j]=da[j];   
    a[l]=atry[l];   
      }   
    }   
  } else {   
    *alamda *= 10.0;   
    *chisq=ochisq;   
  }   
}   
void PlayerMoveComponent::determineDirection(){
	//Je nach dem welche Taste eingegeben wurde wird mit maximaler Beschleunigung in die zugwiesene Richtung beschleunigt
	if(keyStates['w'] || keyStates['W']){
		if(keyStates['a'] || keyStates['A'])
			setAccel(CVector(-MAX_ACCEL,MAX_ACCEL));
		else if(keyStates['d'] || keyStates['D'])
			setAccel(CVector(MAX_ACCEL,MAX_ACCEL));
		else setAccel(CVector(0.0,MAX_ACCEL));
		return;
	}

	if(keyStates['a'] || keyStates['A']){
		if(keyStates['w'] || keyStates['W'])
			setAccel(CVector(-MAX_ACCEL,MAX_ACCEL));
		else if(keyStates['s'] || keyStates['S'])
			setAccel(CVector(-MAX_ACCEL,-MAX_ACCEL));
		else setAccel(CVector(-MAX_ACCEL,0));
		return;
	}

	if(keyStates['s'] || keyStates['S']){
		if(keyStates['d'] || keyStates['D'])
			setAccel(CVector(MAX_ACCEL,-MAX_ACCEL));
		else if(keyStates['a'] || keyStates['A'])
			setAccel(CVector(-MAX_ACCEL,-MAX_ACCEL));
		else setAccel(CVector(0,-MAX_ACCEL));
		return;
	}

	if(keyStates['d'] || keyStates['D']){
		if(keyStates['s'] || keyStates['S'])
			setAccel(CVector(MAX_ACCEL,-MAX_ACCEL));
		else if(keyStates['w'] || keyStates['W'])
			setAccel(CVector(MAX_ACCEL,MAX_ACCEL));
		else setAccel(CVector(MAX_ACCEL,0));
		return;
	}

	//Wenn nichts gedrückt wurde, kommt der Spieler langsam zum stehen
	if(velocity!=CVector(0,0)){
		float x = 0.0;
		float y = 0.0;
		if(velocity[0]>0)
			x = -MAX_ACCEL;
		else
			x = MAX_ACCEL;

		if(velocity[1]>0)
			y = -MAX_ACCEL;
		else
			y = MAX_ACCEL;
		setAccel(CVector(x,y));
	}
}
Beispiel #17
0
void CFoo::Test ( const char* szString )
{
    CClientManager* pManager = g_pClientGame->GetManager ();
    CClientPlayer* pLocal = pManager->GetPlayerManager ()->GetLocalPlayer ();
    CClientVehicleManager* pVehicleManager = pManager->GetVehicleManager ();
    CVector vecLocal;
    pLocal->GetPosition ( vecLocal );
    CClientCamera* pCamera = pManager->GetCamera ();



    // ChrML: Trying to reproduce mantis issue #2760
    if ( stricmp ( szString, "2760" ) == 0 )
    {
        vecLocal = CVector ( 0.0f, 0.0f, 5.0f );

        for ( int i = 0; i < 20; i++ )
        {
            vecLocal.fX += 5.0f;
            CClientPlayer* pPlayer = new CClientPlayer ( pManager, i + 50 );
            pPlayer->SetDeadOnNetwork ( false );
            pPlayer->SetModel ( 168 + i );
            pPlayer->AttachTo ( NULL );
            pPlayer->SetFrozen ( false );
            pPlayer->RemoveAllWeapons ();
            pPlayer->Teleport ( vecLocal );
            pPlayer->SetCameraRotation ( 0 );
            pPlayer->ResetInterpolation ();
            pPlayer->SetMoveSpeed ( CVector () );
            pPlayer->SetHealth ( 100.0f );
            pPlayer->SetArmor ( 0 );
            pPlayer->SetCurrentRotation ( 0 );
            pPlayer->SetInterior ( 0 );
            pPlayer->SetDimension ( 0 );
        }

        pLocal->SetDeadOnNetwork ( false );
        pLocal->SetModel ( 145 );
        pLocal->AttachTo ( NULL );
        pLocal->SetFrozen ( false );
        pLocal->RemoveAllWeapons ();
        pLocal->Teleport ( vecLocal );
        pLocal->SetCameraRotation ( 0 );
        pLocal->ResetInterpolation ();
        pLocal->SetMoveSpeed ( CVector () );
        pLocal->SetHealth ( 100.0f );
        pLocal->SetArmor ( 0 );
        pLocal->SetCurrentRotation ( 0 );
        pLocal->SetInterior ( 0 );
        pLocal->SetDimension ( 0 );
        g_pClientGame->SetAllDimensions ( 0 );

        // Reset return position so we can't warp back to where we were if local player
        g_pClientGame->GetNetAPI ()->ResetReturnPosition ();

        // Make sure the camera is normal
        pCamera->SetFocusToLocalPlayer ();
        pCamera->FadeIn ( 0.0f );
    }
    




    // Player load crash
    else if ( stricmp ( szString, "2741" ) == 0 )
    {
        bFoo_PlayerLimitCrash = true;
    }


    // 
    else if ( strnicmp ( szString, "interp", 6 ) == 0 )
    {
        if ( pVehicleManager->Count () > 0 )
        {
            CClientVehicle* pVehicle = *pVehicleManager->IterBegin ();

            float fdelta = atof ( szString + 7 );

            CVector vecT;
            pVehicle->GetPosition ( vecT );
            vecT.fZ = fdelta;
            pVehicle->SetTargetPosition ( vecT, TICK_RATE );

            g_pCore->ChatPrintf ( "Done %f", false, fdelta );

            static_cast < CDeathmatchVehicle* > ( pVehicle )->SetIsSyncing ( false );
        }
    }


    // 
    else if ( strnicmp ( szString, "interr", 6 ) == 0 )
    {
        if ( pVehicleManager->Count () > 0 )
        {
            CClientVehicle* pVehicle = *pVehicleManager->IterBegin ();

            CVector vecT;
            pVehicle->GetRotationDegrees ( vecT );
            vecT.fZ = atof ( szString + 7 );
            pVehicle->SetTargetRotation ( vecT, TICK_RATE );

            g_pCore->ChatPrintf ( "Done %f", false, atof ( szString + 7 ) );

            static_cast < CDeathmatchVehicle* > ( pVehicle )->SetIsSyncing ( false );
        }
    }


    else if ( stricmp ( szString, "choke" ) == 0 )
    {
        g_pClientGame->GetLocalPlayer ()->SetChoking ( true );
    }


    // 
    else if ( strnicmp ( szString, "static", 6 ) == 0 )
    {
        if ( pVehicleManager->Count () > 0 )
        {
            CClientVehicle* pVehicle = *pVehicleManager->IterBegin ();

            pVehicle->GetGameVehicle ()->SetRemap ( atoi ( szString + 7 ) );
            g_pCore->ChatPrintf ( "Set %i", false, atoi ( szString + 7 ) );
        }
    }


    // 
    else if ( strnicmp ( szString, "getmass", 7 ) == 0 )
    {
        CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle ();
        if ( pVehicle )
        {
            g_pCore->ChatPrintf ( "Mass == %f", false, pVehicle->GetGameVehicle ()->GetMass () );
        }
    }

    else if ( strnicmp ( szString, "setmass", 7 ) == 0 )
    {
        CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle ();
        if ( pVehicle )
        {
            pVehicle->GetGameVehicle ()->SetMass ( atof ( szString + 8 ) );
            g_pCore->ChatPrintf ( "Set mass to %f", false, pVehicle->GetGameVehicle ()->GetMass () );
        }
    }


    // 
    /*
    else if ( strnicmp ( szString, "setmm", 5 ) == 0 )
    {
        CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle ();
        if ( pVehicle )
        {
            float fVal = atof ( szString + 6);
            szString += 4;
            float* fMass = (float*) atoi ( szString + 6 );
            *fMass = fVal;
            g_pCore->ChatPrintf ( "Set %X to %f", false, fMass, fVal );
        }
    }
    */

    /*
    else if ( stricmp ( szString, "getmm" ) == 0 )
    {
        CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle ();
        if ( pVehicle )
        {
            float* fMass = (float*) atoi ( szString );
            g_pCore->ChatPrintf ( "Get %f", false, *fMass );
        }
    }
    */



    /*
    else if ( stricmp ( szString, "dump" ) == 0 )
    {
        FILE* poo = fopen ( "vehs.txt", "w+" );
        if ( poo )
        {
            tHandlingData* pHandling = (tHandlingData*) 0xC2B9E0;
            unsigned int uiIndex = 0;
            for ( ; uiIndex < 219; uiIndex++ )
            {
                fprintf ( poo, "\n\n\n\n####### VEHICLE ID %u #######\n", uiIndex );

                fprintf ( poo, "fMass = %f\n", pHandling->fMass );
                fprintf ( poo, "fUnknown1 = %f\n", pHandling->fUnknown1 );
                fprintf ( poo, "fTurnMass = %f\n", pHandling->fTurnMass );

                fprintf ( poo, "fDragCoeff = %f\n", pHandling->fDragCoeff );
                fprintf ( poo, "vecCenterOfMass = %f, %f, %f\n", pHandling->vecCenterOfMass.fX, pHandling->vecCenterOfMass.fY, pHandling->vecCenterOfMass.fZ );
                fprintf ( poo, "uiPercentSubmerged = %u\n", pHandling->uiPercentSubmerged );

                fprintf ( poo, "fUnknown2 = %f\n", pHandling->fUnknown2 );

                fprintf ( poo, "fTractionMultiplier = %f\n", pHandling->fTractionMultiplier );

                fprintf ( poo, "Transmission.fUnknown [0] = %f\n", pHandling->Transmission.fUnknown [0] );
                fprintf ( poo, "Transmission.fUnknown [1] = %f\n", pHandling->Transmission.fUnknown [1] );
                fprintf ( poo, "Transmission.fUnknown [2] = %f\n", pHandling->Transmission.fUnknown [2] );
                fprintf ( poo, "Transmission.fUnknown [3] = %f\n", pHandling->Transmission.fUnknown [3] );
                fprintf ( poo, "Transmission.fUnknown [4] = %f\n", pHandling->Transmission.fUnknown [4] );
                fprintf ( poo, "Transmission.fUnknown [5] = %f\n", pHandling->Transmission.fUnknown [5] );
                fprintf ( poo, "Transmission.fUnknown [6] = %f\n", pHandling->Transmission.fUnknown [6] );
                fprintf ( poo, "Transmission.fUnknown [7] = %f\n", pHandling->Transmission.fUnknown [7] );
                fprintf ( poo, "Transmission.fUnknown [8] = %f\n", pHandling->Transmission.fUnknown [8] );
                fprintf ( poo, "Transmission.fUnknown [9] = %f\n", pHandling->Transmission.fUnknown [9] );
                fprintf ( poo, "Transmission.fUnknown [10] = %f\n", pHandling->Transmission.fUnknown [10] );
                fprintf ( poo, "Transmission.fUnknown [11] = %f\n", pHandling->Transmission.fUnknown [11] );
                fprintf ( poo, "Transmission.fUnknown [12] = %f\n", pHandling->Transmission.fUnknown [12] );
                fprintf ( poo, "Transmission.fUnknown [13] = %f\n", pHandling->Transmission.fUnknown [13] );
                fprintf ( poo, "Transmission.fUnknown [14] = %f\n", pHandling->Transmission.fUnknown [14] );
                fprintf ( poo, "Transmission.fUnknown [15] = %f\n", pHandling->Transmission.fUnknown [15] );
                fprintf ( poo, "Transmission.fUnknown [16] = %f\n", pHandling->Transmission.fUnknown [16] );
                fprintf ( poo, "Transmission.fUnknown [17] = %f\n", pHandling->Transmission.fUnknown [17]  );

                fprintf ( poo, "Transmission.ucDriveType = %c\n", pHandling->Transmission.ucDriveType );
                fprintf ( poo, "Transmission.ucEngineType = %c\n", pHandling->Transmission.ucEngineType );
                fprintf ( poo, "Transmission.ucNumberOfGears = %u\n", pHandling->Transmission.ucNumberOfGears );
                fprintf ( poo, "Transmission.ucUnknown = %u\n", pHandling->Transmission.ucUnknown );

                fprintf ( poo, "Transmission.uiHandlingFlags = 0x%X\n", pHandling->Transmission.uiHandlingFlags );

                fprintf ( poo, "Transmission.fEngineAccelleration = %f\n", pHandling->Transmission.fEngineAccelleration );
                fprintf ( poo, "Transmission.fEngineInertia = %f\n", pHandling->Transmission.fEngineInertia );
                fprintf ( poo, "Transmission.fMaxVelocity = %f\n", pHandling->Transmission.fMaxVelocity );

                fprintf ( poo, "Transmission.fUnknown2 [0] = %f\n", pHandling->Transmission.fUnknown2 [0]  );
                fprintf ( poo, "Transmission.fUnknown2 [1] = %f\n", pHandling->Transmission.fUnknown2 [1]  );
                fprintf ( poo, "Transmission.fUnknown2 [2] = %f\n", pHandling->Transmission.fUnknown2 [2]  );

                fprintf ( poo, "fBrakeDecelleration = %f\n", pHandling->fBrakeDecelleration );
                fprintf ( poo, "fBrakeBias = %f\n", pHandling->fBrakeBias );
                fprintf ( poo, "bABS = %u\n", pHandling->bABS );

                fprintf ( poo, "fSteeringLock = %f\n", pHandling->fSteeringLock );
                fprintf ( poo, "fTractionLoss = %f\n", pHandling->fTractionLoss );
                fprintf ( poo, "fTractionBias = %f\n", pHandling->fTractionBias );

                fprintf ( poo, "fSuspensionForceLevel = %f\n", pHandling->fSuspensionForceLevel );
                fprintf ( poo, "fSuspensionDamping = %f\n", pHandling->fSuspensionDamping );
                fprintf ( poo, "fSuspensionHighSpdDamping = %f\n", pHandling->fSuspensionHighSpdDamping );
                fprintf ( poo, "fSuspensionUpperLimit = %f\n", pHandling->fSuspensionUpperLimit );
                fprintf ( poo, "fSuspensionLowerLimit = %f\n", pHandling->fSuspensionLowerLimit );
                fprintf ( poo, "fSuspensionFrontRearBias = %f\n", pHandling->fSuspensionFrontRearBias );
                fprintf ( poo, "fSuspensionAntidiveMultiplier = %f\n", pHandling->fSuspensionAntidiveMultiplier );

                fprintf ( poo, "fCollisionDamageMultiplier = %f\n", pHandling->fCollisionDamageMultiplier );

                fprintf ( poo, "uiModelFlags = %X\n", pHandling->uiModelFlags );
                fprintf ( poo, "uiHandlingFlags = %X\n", pHandling->uiHandlingFlags );
                fprintf ( poo, "fSeatOffsetDistance = %f\n", pHandling->fSeatOffsetDistance );
                fprintf ( poo, "uiMonetary = %u\n", pHandling->uiMonetary );

                fprintf ( poo, "ucHeadLight = 0x%X\n", pHandling->ucHeadLight );
                fprintf ( poo, "ucTailLight = 0x%X\n", pHandling->ucTailLight );
                fprintf ( poo, "ucAnimGroup = 0x%X\n", pHandling->ucAnimGroup );
                fprintf ( poo, "ucUnused = 0x%X\n", pHandling->ucUnused );

                fprintf ( poo, "iUnknown7 = %f, %X\n", pHandling->iUnknown7, pHandling->iUnknown7 );

                pHandling += 1;
            }


            g_pCore->ChatPrintf ( "Dumped", false );
            fclose ( poo );
        }
    }
    */



    else if ( strnicmp ( szString, "moveug", 6 ) == 0 )
    {
        if ( pVehicleManager->Count () > 0 )
        {
            CClientVehicle* pVehicle = *pVehicleManager->IterBegin ();

            /*
            CClientPed* pModel = pVehicle->GetOccupant ( 0 );
            if ( !pModel )
            {
                CClientPlayer* pPlayer = new CClientPlayer ( g_pClientGame->GetManager (), 50 );
                pModel = pPlayer->LoadModel ( 0 );
                pModel->WarpIntoVehicle ( pVehicle );
            }
            */

            

            pVehicle->RemoveTargetPosition ();
            pVehicle->RemoveTargetRotation ();


            CVector vecT;
            pVehicle->GetPosition ( vecT );
            vecT.fZ = atof ( szString + 7 );
            pVehicle->SetPosition ( vecT );

            g_pCore->ChatPrintf ( "Done", false );
        }
    }

    else if ( strnicmp ( szString, "nocol", 5 ) == 0 )
    {
        if ( pVehicleManager->Count () > 0 )
        {
            CClientVehicle* pVehicle = *pVehicleManager->IterBegin ();
            pVehicle->SetCollisionEnabled ( false );

            g_pCore->ChatPrintf ( "Done", false );
        }
    }

    else if ( stricmp ( szString, "resetdamage" ) == 0 )
    {
        g_pClientGame->GetPlayerManager ()->GetLocalPlayer ()->GetGamePlayer ()->ResetLastDamage ();
    }


    else if ( strnicmp ( szString, "fuckveh", 7 ) == 0 )
    {
        CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle ();
        if ( pVehicle )
        {
            pVehicle->SetTargetPosition ( CVector ( 0, 0, 0 ), TICK_RATE );
            pVehicle->SetTargetRotation ( CVector ( 0, 0, 0 ), TICK_RATE );

            g_pCore->ChatPrintf ( "Done", false );
        }
    }

    else if ( stricmp ( szString, "ped" ) == 0 )
    {
        CClientPed* pPed = new CClientPed ( g_pClientGame->GetManager (), INVALID_ELEMENT_ID, 9 );
        vecLocal.fX += 5.0f;
        pPed->SetPosition ( vecLocal );
    }

    else if ( strnicmp ( szString, "callit", 6 ) == 0 )
    {
        FILE* pFile = fopen ( "C:/dump.txt", "w+" );

        for ( int i = 0; i < 400; i++ )
        {
            int iIndex = i;
            const char* szName = NULL;
            _asm
            {
                mov     eax, 0x4D3A30
                push    iIndex
                call    eax
                mov     szName, eax
                add     esp, 4
            }

            fprintf ( pFile, "%i: %s\n", iIndex, szName );
        }

        fclose ( pFile );
    }


    else if ( strnicmp ( szString, "veh", 3 ) == 0 )
    {
        int i = 600;
        FILE* p = fopen ( "C:/dump.txt", "w+" );

        for ( int a = 0; a < 13; a++ )
        {
            g_pGame->GetModelInfo ( i )->AddRef ( true );

            CVehicle* pVehicle = g_pGame->GetPools ()->AddVehicle ( (eVehicleTypes)i );
            DWORD* dw2 = (DWORD*)(((DWORD)pVehicle->GetVehicleInterface ()) + 0xE1 * 4 );
            DWORD dw = *dw2;
            dw = dw + 4;
            dw = dw - 0xC2B9E0;
            dw = dw / 224;
            fprintf ( p, "Array [%u] = %u;\n", i, dw );

            g_pGame->GetPools ()->RemoveVehicle ( pVehicle );

            fflush ( p );

            g_pGame->GetModelInfo ( i )->RemoveRef ( );

            i++;
        }

        fclose ( p );
    }


    else if ( strnicmp ( szString, "groups", 6 ) == 0 )
    {
        FILE* pFile = fopen ( "C:/dump.txt", "w+" );


        int i = 0;
        for ( ; i < 139; i++ )
        {
            fprintf ( pFile, "==%s [%s] (%i)==\n", pGroups [i].szGroupName, pGroups [i].szSomething, i );
            int i2 = 0;
            for ( ; i2 < pGroups [i].ulAnimCount; i2++ )
            {
                const char* szAnimName = pGroups [i].pAnimNames [i2];
                if ( szAnimName [0] )
                {
                    fprintf ( pFile, "''%i'': %s<br>\n", i2, szAnimName );
                }
            }

            fprintf ( pFile, "\n" );
        }

        fclose ( pFile );
    }


    else if ( strnicmp ( szString, "getshot", 7 ) == 0 )
    {
        if ( pLocal->GetGamePlayer ()->GetCanBeShotInVehicle () )
        {
            g_pCore->ChatEcho ( "true" );
        }
        else
        {
            g_pCore->ChatEcho ( "false" );
        }
    }

    else if ( strnicmp ( szString, "gettest", 7 ) == 0 )
    {
        if ( pLocal->GetGamePlayer ()->GetTestForShotInVehicle () )
        {
            g_pCore->ChatEcho ( "true" );
        }
        else
        {
            g_pCore->ChatEcho ( "false" );
        }
    }


    else if ( strnicmp ( szString, "setshot", 7 ) == 0 )
    {
        pLocal->GetGamePlayer ()->SetCanBeShotInVehicle ( true );
    }


    else if ( strnicmp ( szString, "settest", 8 ) == 0 )
    {
        pLocal->GetGamePlayer ()->SetTestForShotInVehicle ( true );
    }


    else if ( stricmp ( szString, "applytest" ) == 0 )
    {
        DWORD oldProt, oldProt2;
        VirtualProtect((LPVOID)0x5E8FFB,6,PAGE_EXECUTE_READWRITE,&oldProt);		

        *(unsigned char*) (0x5E8FFB ) = 0x90;
        *(unsigned char*) (0x5E8FFC ) = 0x90;
        *(unsigned char*) (0x5E8FFD ) = 0x90;
        *(unsigned char*) (0x5E8FFE ) = 0x90;
        *(unsigned char*) (0x5E8FFF ) = 0x90;
        *(unsigned char*) (0x5E9000 ) = 0x90;

        VirtualProtect((LPVOID)0x5E8FFB,6,oldProt,&oldProt2); 
    }
}
//Mittels des Seperating Axis Theorem wird auf eine Kolission mit den Hindernissen geprüft
void PlayerMoveComponent::quadColission()
{

	CVector position = getPosition();
	double size = parent->getSize();

	//Die Eckpunkte des Spielers
	CVector v1 = CVector(position[0]-size,position[1]+size);
	CVector v2 = CVector(position[0]+size,position[1]+size);
	CVector v3 = CVector(position[0]+size,position[1]-size);
	CVector v4 = CVector(position[0]-size,position[1]-size);

	//Die zu prüfenden Achsen werden mit Hilfe der Vektoren der Spielerposition erstellt

	CVector a1 = v1 - v2;
	a1 = CVector(a1[1],-a1[0]);
	a1.normalize();

	CVector a2 = v2 - v3;
	a2 = CVector(a2[1],-a2[0]);
	a2.normalize();

	CVector a3 = v3 - v4;
	a3 = CVector(a3[1],-a3[0]);
	a3.normalize();

	CVector a4 = v4 - v1;
	a4 = CVector(a4[1],-a4[0]);
	a4.normalize();

	CVector a[4] = {a1,a2,a3,a4};
	CVector v[4] = {CVector(-size,size),CVector(size,size),CVector(size,-size),CVector(-size,-size)};

	vector<Character *> characters = parent->getCharacterManager()->getAllNearbyCharacters(getPosition(),OBSTACLE_TAG,200.0);

	vector<Character *>::iterator it = characters.begin();

	while(it != characters.end())
	{
		Character *c = (*it);
		it++;

		CVector cPos = c->getPosition()-position;
		double cSize = c->getSize();

		//Die Eckpunkte eines Obstacles
		CVector w1 = CVector(cPos[0]-cSize,cPos[1]+cSize);
		CVector w2 = CVector(cPos[0]+cSize,cPos[1]+cSize);
		CVector w3 = CVector(cPos[0]+cSize,cPos[1]-cSize);
		CVector w4 = CVector(cPos[0]-cSize,cPos[1]-cSize);

		CVector w[4] = {w1,w2,w3,w4};

		CVector moveVector = CVector(9999999,9999999); 

		//Die Punkte werden auf eine Achse projiziert. Anschließend werden die Maxima und Minima miteinander verglichen
		for(int i = 0; i<4; ++i){
			CVector maxV = CVector();
			CVector minV = CVector();
			CVector	maxW = CVector();
			CVector minW = CVector();

			for(int j = 0; j<4; ++j){

				CVector projV = (a[i] * v[j]) * a[i];
			
				if(projV[0]>maxV[0] || maxV.isNil())
					maxV[0] = projV[0];
				if(projV[1]>maxV[1] || maxV.isNil())
					maxV[1] = projV[1];
				if(projV[0]<minV[0] || minV.isNil())
					minV[0] = projV[0];
				if(projV[1]<minV[1] || minV.isNil())
					minV[1] = projV[1];

				
				CVector projW = (a[i] * w[j]) * a[i];
				if(projW[0]>maxW[0] || maxW.isNil())
					maxW[0] = projW[0];
				if(projW[1]>maxW[1] || maxW.isNil())
					maxW[1] = projW[1];
				if(projW[0]<minW[0] || minW.isNil())
					minW[0] = projW[0];
				if(projW[1]<minW[1] || minW.isNil())
					minW[1] = projW[1];
				
			}

			//Der Vektor in dessen Richtung der Spieler abgestoßen wird,wird berechnet...
			if((maxV[0]>=minW[0] && maxV[1]>=minW[1])&& (minV[0] <= maxW[0] && minV[1] <= maxW[1])){
				CVector vec = (maxV - minW).getLength() < (minV - maxW).getLength() ? maxV-minW : minV - maxW;
				if(moveVector.getLength() > vec.getLength()){
					moveVector = vec;
					
				}
			} else {
				moveVector = CVector();
				break;
			}

		}

		//...und auf die Position des Spielers übertragen
		if(!moveVector.isNil()){
			position-=moveVector;
			moveVector.normalize();
			moveVector *= MAX_VELOCITY/4;
			velocity = -moveVector;
		}

	}
	setPosition(position);
}
Beispiel #19
0
void CUIHelper::CreateInputErrorMessage (IHISession *pSession, const RECT &rcRect, const CString &sTitle, CString &sDesc, IAnimatron **retpMsg) const

//	CreateInputErrorMessage
//
//	Creates an input error message box

	{
	const CVisualPalette &VI = m_HI.GetVisuals();
	const CG16bitFont &TitleFont = VI.GetFont(fontLargeBold);
	const CG16bitFont &DescFont = VI.GetFont(fontMedium);

	//	Start with a sequencer as a parent of everything

	CAniSequencer *pMsg;
	CAniSequencer::Create(CVector(rcRect.left, rcRect.top), &pMsg);

	//	Create a controller to handle dismissing the message

	CInputErrorMessageController *pController = new CInputErrorMessageController(pSession);
	pMsg->AddTrack(pController, 0);

	//	Add a button to handle a click

	CAniButton *pButton = new CAniButton;
	pButton->SetPropertyVector(PROP_POSITION, CVector(0, 0));
	pButton->SetPropertyVector(PROP_SCALE, CVector(RectWidth(rcRect), RectHeight(rcRect)));
	pButton->SetStyle(STYLE_DOWN, NULL);
	pButton->SetStyle(STYLE_HOVER, NULL);
	pButton->SetStyle(STYLE_NORMAL, NULL);
	pButton->SetStyle(STYLE_DISABLED, NULL);
	pButton->SetStyle(STYLE_TEXT, NULL);
	pButton->AddListener(EVENT_ON_CLICK, pController);

	pMsg->AddTrack(pButton, 0);

	//	Figure out where the text goes

	int x = INPUT_ERROR_PADDING_LEFT;
	int cxWidth = RectWidth(rcRect) - (INPUT_ERROR_PADDING_LEFT + INPUT_ERROR_PADDING_RIGHT);
	int y = INPUT_ERROR_PADDING_TOP;
	int yEnd = RectHeight(rcRect) - INPUT_ERROR_PADDING_BOTTOM;
	int cxText = 0;

	//	Title text

	IAnimatron *pTitle = new CAniText;
	pTitle->SetPropertyVector(PROP_POSITION, CVector(x, y));
	pTitle->SetPropertyVector(PROP_SCALE, CVector(cxWidth, TitleFont.GetHeight()));
	((CAniText *)pTitle)->SetPropertyFont(PROP_FONT, &TitleFont);
	pTitle->SetPropertyColor(PROP_COLOR, VI.GetColor(colorTextWarningMsg));
	pTitle->SetPropertyString(PROP_TEXT, sTitle);

	y += TitleFont.GetHeight();
	cxText += TitleFont.GetHeight();

	//	Description

	IAnimatron *pDesc = new CAniText;
	pDesc->SetPropertyVector(PROP_POSITION, CVector(x, y));
	pDesc->SetPropertyVector(PROP_SCALE, CVector(cxWidth, 1000));
	((CAniText *)pDesc)->SetPropertyFont(PROP_FONT, &DescFont);
	pDesc->SetPropertyColor(PROP_COLOR, VI.GetColor(colorTextWarningMsg));
	pDesc->SetPropertyString(PROP_TEXT, sDesc);

	RECT rcDesc;
	pDesc->GetSpacingRect(&rcDesc);
	cxText += RectHeight(rcDesc);

	//	Now that we know the height of the text, add a rectangle as a background

	int cxFrame = Max(RectHeight(rcRect), cxText + INPUT_ERROR_PADDING_TOP + INPUT_ERROR_PADDING_BOTTOM);

	IAnimatron *pRect = new CAniRoundedRect;
	pRect->SetPropertyVector(PROP_POSITION, CVector());
	pRect->SetPropertyVector(PROP_SCALE, CVector(RectWidth(rcRect), cxFrame));
	pRect->SetPropertyColor(PROP_COLOR, VI.GetColor(colorAreaWarningMsg));
	pRect->SetPropertyOpacity(PROP_OPACITY, 255);
	pRect->SetPropertyInteger(PROP_UL_RADIUS, INPUT_ERROR_CORNER_RADIUS);
	pRect->SetPropertyInteger(PROP_UR_RADIUS, INPUT_ERROR_CORNER_RADIUS);
	pRect->SetPropertyInteger(PROP_LL_RADIUS, INPUT_ERROR_CORNER_RADIUS);
	pRect->SetPropertyInteger(PROP_LR_RADIUS, INPUT_ERROR_CORNER_RADIUS);

	pMsg->AddTrack(pRect, 0);

	//	Add title and desc

	pMsg->AddTrack(pTitle, 0);
	pMsg->AddTrack(pDesc, 0);

	//	Fade after some time

	pMsg->AnimateLinearFade(INPUT_ERROR_TIME, 5, 30);

	//	If we already have an input error box, delete it

	pSession->StopPerformance(ID_DLG_INPUT_ERROR);

	//	Start a new one

	pSession->StartPerformance(pMsg, ID_DLG_INPUT_ERROR, CReanimator::SPR_FLAG_DELETE_WHEN_DONE);

	//	Done

	if (retpMsg)
		*retpMsg = pMsg;
	}
void CIATestMainWindow::OnDraw(IGenericRender *piRender)
{
	if(!m_FrameManager.m_piFrameManager)
	{
		return;
	}

	m_FrameManager.m_piFrameManager->ProcessFrame();
	double dTimeFraction=m_FrameManager.m_piFrameManager->GetTimeFraction();
	double dRealTimeFraction=m_FrameManager.m_piFrameManager->GetRealTimeFraction();

	if(m_bPauseOnNextFrame)
	{
		m_FrameManager.m_piFrameManager->SetPauseOnNextFrame(true);
		m_bPauseOnNextFrame=false;
	}

	ProcessInput(dTimeFraction,dRealTimeFraction);

	if(m_FrameManager.m_piFrameManager->GetTimeFraction()>0)
	{
		ProcessPhysics(dTimeFraction);
		ProcessIA(dTimeFraction);
	}

	double dAspectRatio=m_rRealRect.h/m_rRealRect.w;
	double dNearPlane=0,dFarPlane=0;
	double dViewAngle=m_Camera.m_piCamera->GetViewAngle();
	CVector vAngles,vPosition;

	m_Camera.m_piCamera->SetAspectRatio(dAspectRatio);
	m_Camera.m_piCamera->GetClippingPlanes(dNearPlane,dFarPlane);
	vAngles=m_Camera.m_piCamera->GetAngles();
	vPosition=m_Camera.m_piCamera->GetPosition();


	piRender->SetPerspectiveProjection(dViewAngle,dNearPlane,100000);
	piRender->SetCamera(vPosition,vAngles.c[YAW],vAngles.c[PITCH],vAngles.c[ROLL]);

	glGetDoublev(GL_MODELVIEW_MATRIX,(double*)m_pdModelMatrix);
	glGetDoublev(GL_PROJECTION_MATRIX,(double*)m_pdProjectionMatrix);
	glGetIntegerv(GL_VIEWPORT,m_pnViewport);

	RenderBox(CVector(0,0,-dBaseThickness),CVector(dBaseSize,dBaseSize,0),CVector(0.3,0.3,0.3));
	RenderAxises();

	char A[200];
	sprintf(A,"Fps: %.02f",m_FrameManager.m_piFrameManager->GetCurrentFps());
	m_piSTFps->SetText(A);

	sprintf(A,"Time: %.02f",((double)m_FrameManager.m_piFrameManager->GetCurrentTime())/1000.0);
	if(m_FrameManager.m_piFrameManager->IsPaused())
	{
		strcat(A," (Paused)");
	}
	m_piSTTime->SetText(A);

	CVector entityPos=m_pSelectedEntity?m_pSelectedEntity->GetPosition():CVector(0,0,0);
	sprintf(A,"Pos: %.02f , %.02f , %.02f",entityPos.c[0],entityPos.c[1],entityPos.c[2]);
	m_piSTEntityPos->SetText(A);

	CVector entityVel=m_pSelectedEntity?m_pSelectedEntity->GetVelocity():CVector(0,0,0);
	sprintf(A,"Vel: %.02f , %.02f , %.02f - %.02f/%.02f ",entityVel.c[0],entityVel.c[1],entityVel.c[2],(double)entityVel,m_pSelectedEntity?m_pSelectedEntity->GetMaxVelocity():0);
	m_piSTEntityVel->SetText(A);

	map<string,CIAEntityBase *>::iterator i;
	for(i=m_mEntities.begin();i!=m_mEntities.end();i++)
	{
		i->second->Render();
	}
}
Beispiel #21
0
CVector CVector::mul (CVector b)
{
  return(CVector(x*b.x, y*b.y, z*b.z));
}
Beispiel #22
0
// Create a sphere primitive
void CRegionView::DoCreatePrimitiveSphere(CVector &vCenter, int nSubdivisionsX, int nSubdivisionsY, CReal fRadius, BOOL bDome)
{
	// Do some error checking on the parameters
	if (nSubdivisionsX <= 0 || nSubdivisionsY <= 0 || fRadius <= 0.0f)
	{
		ASSERT(FALSE);
		return;
	}

	// Setup a new brush
	CEditBrush *pNewBrush = no_CreateNewBrush(GetRegion(), GetRegion()->GetActiveParentNode());
	ASSERT( pNewBrush );
	if( !pNewBrush )
	{
		return;
	}

	// Setup an undo.
	GetRegionDoc()->Modify(new CPreAction(ACTION_ADDEDNODE, pNewBrush), TRUE);

	// The number of polygons for the center bands
	int nNumPolies=nSubdivisionsX*(nSubdivisionsY-1);

	// Add the number of polies for the bottom cap
	if (bDome)
	{
		nNumPolies++;
	}
	else
	{
		nNumPolies+=nSubdivisionsX;
	}

	// Add the number of polies for the top cap
	nNumPolies+=nSubdivisionsX;

	CEditPoly **ppNewPoly=new CEditPoly*[nNumPolies];

	int i;
	for (i=0; i < nNumPolies; i++)
	{
		ppNewPoly[i]=new CEditPoly(pNewBrush);
	}
	
	// The height for the middle bands is slightly less (one band worth total) than the radius.
	// This is so the triangle caps can be added.
	float fHeight=(fRadius-(fRadius/nSubdivisionsY/2.0f))*2.0f;

	// Initialize the vertices for the strips
	int nSubY;
	for (nSubY=0; nSubY < nSubdivisionsY; nSubY++)
	{
		// The percentage of the sphere that we are on in the Y direction
		// For example, the middle subdivision is 0.50
		float fYPercent;

		// Create the top half of the sphere if we are in dome mode
		if (bDome)
		{
			fYPercent=0.5f+((float)nSubY/(float)(nSubdivisionsY-1)/2.0f);
		}
		else
		{
			fYPercent=(float)nSubY/(float)(nSubdivisionsY-1);
		}
				
		// Calculate the Y position for this subdivision		
		float fYPos=(0.0f-(fHeight/2))+(fYPercent*fHeight);		

		// Calculate the radius (girth) for this subdivision
		float fCurrentRadius=cos(asin(fYPos/fRadius))*fRadius;

		int nSubX;
		for (nSubX=0; nSubX < nSubdivisionsX; nSubX++)
		{			
			// The percentage around the circle
			float fXPercent=(float)nSubX/(float)(nSubdivisionsX-1);

			// The current angle in radians
			float theta=fXPercent*3.14159f*2.0f;

			// Calculate the X and Y positions
			float fXPos=cos(theta)*fCurrentRadius;
			float fZPos=sin(theta)*fCurrentRadius;

			// Set the vertex
			CVector vPoint=CVector(fXPos, fYPos, fZPos)+vCenter;
			pNewBrush->m_Points.Append(vPoint);			
		}
	}

	// Add the top point
	CEditVert v;
	v.x = vCenter.x;
	v.y = vCenter.y + fRadius;
	v.z = vCenter.z;

	pNewBrush->m_Points.Append(v);
	int nTopPointIndex=pNewBrush->m_Points.GetSize()-1;

	// Add the bottom point if we aren't in dome mode
	int nBottomPointIndex;
	if (!bDome)
	{
		v.x = vCenter.x;
		v.y = vCenter.y - fRadius;
		v.z = vCenter.z;

		pNewBrush->m_Points.Append(v);
		nBottomPointIndex=pNewBrush->m_Points.GetSize()-1;
	}

	// Create the polygons for the center bands
	int nCurrentPoly=0;
	for (nSubY=0; nSubY < nSubdivisionsY-1; nSubY++)
	{
		int nSubX;
		for (nSubX=0; nSubX < nSubdivisionsX; nSubX++)
		{				
			// Calculate the polygon indices
			int nIndex1=(nSubY*nSubdivisionsX)+nSubX;							// Bottom left
			int nIndex2=((nSubY+1)*nSubdivisionsX)+nSubX;						// Top left
			int nIndex3=((nSubY+1)*nSubdivisionsX)+((nSubX+1)%nSubdivisionsX);	// Top right			
			int nIndex4=(nSubY*nSubdivisionsX)+((nSubX+1)%nSubdivisionsX);		// Bottom right
			
			// Add the polygon indices
			ppNewPoly[nCurrentPoly]->m_Indices.Append(nIndex1);
			ppNewPoly[nCurrentPoly]->m_Indices.Append(nIndex2);
			ppNewPoly[nCurrentPoly]->m_Indices.Append(nIndex3);
			ppNewPoly[nCurrentPoly]->m_Indices.Append(nIndex4);

			// Add the polygon			
			pNewBrush->m_Polies.Append(ppNewPoly[nCurrentPoly]);

			// Go to the next polygon
			nCurrentPoly++;
		}
	}

	// Add the bottom of the sphere
	if (bDome)
	{
		// Dome mode
		int nSubX;
		for (nSubX=0; nSubX < nSubdivisionsX; nSubX++)
		{		
			// Add the polygon indices
			ppNewPoly[nCurrentPoly]->m_Indices.Append(nSubX);			
		}

		// Add the polygon			
		pNewBrush->m_Polies.Append(ppNewPoly[nCurrentPoly]);

		// Go to the next polygon
		nCurrentPoly++;
	}
	else
	{
		// Sphere mode
		int nSubX;
		for (nSubX=0; nSubX < nSubdivisionsX; nSubX++)
		{
			// Calculate the polygon indices
			int nIndex1=nBottomPointIndex;
			int nIndex2=nSubX;
			int nIndex3=(nSubX+1)%nSubdivisionsX;

			// Add the polygon indices
			ppNewPoly[nCurrentPoly]->m_Indices.Append(nIndex1);
			ppNewPoly[nCurrentPoly]->m_Indices.Append(nIndex2);
			ppNewPoly[nCurrentPoly]->m_Indices.Append(nIndex3);

			// Add the polygon			
			pNewBrush->m_Polies.Append(ppNewPoly[nCurrentPoly]);

			// Go to the next polygon
			nCurrentPoly++;
		}
	}

	// Add the top of the sphere
	int nTopStartIndex=(nSubdivisionsY-1)*nSubdivisionsX;

	int nSubX;
	for (nSubX=0; nSubX < nSubdivisionsX; nSubX++)
	{
		// Calculate the polygon indices
		int nIndex1=nTopStartIndex+nSubX;
		int nIndex2=nTopPointIndex;
		int nIndex3=nTopStartIndex+((nSubX+1)%nSubdivisionsX);

		// Add the polygon indices
		ppNewPoly[nCurrentPoly]->m_Indices.Append(nIndex1);
		ppNewPoly[nCurrentPoly]->m_Indices.Append(nIndex2);
		ppNewPoly[nCurrentPoly]->m_Indices.Append(nIndex3);

		// Add the polygon			
		pNewBrush->m_Polies.Append(ppNewPoly[nCurrentPoly]);

		// Go to the next polygon
		nCurrentPoly++;
	}

	// Delete the temp array of poly pointers
	delete []ppNewPoly;
	ppNewPoly=NULL;

	GetRegion()->UpdateBrushGeometry(pNewBrush);
	GetRegion()->CleanupGeometry();

	// Make the new brush the selection.
	if( GetMainFrame()->GetNodeSelectionMode() != MULTI_SELECTION )
	{
		GetRegion()->ClearSelections();
	}
	
	GetRegion()->SelectNode( pNewBrush->AsNode() );
	GetRegionDoc()->NotifySelectionChange();

	// Redraw all of the views
	GetRegionDoc()->RedrawAllViews();
}
Beispiel #23
0
// ***************************************************************************
void	CAnimatedMaterial::update()
{
    if(isTouched(OwnerBit) && _Material!=NULL /*&& _Material->isLighted()*/)
    {

        // well, just update all...  :)

        // diffuse part.
        CRGBA	diff= _Diffuse.Value;
        sint c= (sint)(_Opacity.Value*255);
        clamp(c, 0, 255);
        diff.A= c;

        // setup material.
        if (_Material->isLighted())
        {
            _Material->setLighting(true, _Emissive.Value, _Ambient.Value, diff, _Specular.Value, _Shininess.Value);
        }
        else
        {
            _Material->setColor(diff);
        }

        // clear flags.
        clearFlag(AmbientValue);
        clearFlag(DiffuseValue);
        clearFlag(SpecularValue);
        clearFlag(ShininessValue);
        clearFlag(EmissiveValue);
        clearFlag(OpacityValue);


        // Texture Anim.
        if(isTouched(TextureValue))
        {
            nlassert(_MaterialBase);

            uint32	id= _Texture.Value;
            if(_MaterialBase->validAnimatedTexture(id))
            {
                _Material->setTexture(0, _MaterialBase->getAnimatedTexture(id) );
            }
            clearFlag(TextureValue);
        }

        // Get texture matrix from animated value to setup the material
        for (uint k = 0; k < IDRV_MAT_MAXTEXTURES; ++k)
        {
            if (_Material->isUserTexMatEnabled(k))
            {
                const CTexAnimatedMatValues &texMatAV = _TexAnimatedMatValues[k];

                CMatrix convMat; // exported v are already inverted (todo : optim this if needed, this matrix shouldn't be necessary)
                convMat.setRot(CVector::I, -CVector::J, CVector::K);
                convMat.setPos(CVector::J);
                float fCos = cosf(texMatAV._WRot.Value);
                float fSin = sinf(texMatAV._WRot.Value);
                CMatrix SR;
                SR.setRot(CVector(texMatAV._UScale.Value * fCos, texMatAV._VScale.Value * fSin, 0.f),
                          CVector(- texMatAV._UScale.Value * fSin, texMatAV._VScale.Value * fCos, 0.f),
                          CVector::K);
                CVector half(0.5f, 0.5f, 0.f);
                SR.setPos(SR.mulVector(- half - CVector(texMatAV._UTrans.Value, texMatAV._VTrans.Value, 0.f)) + half);
                _Material->setUserTexMat(k, convMat * SR * convMat);
            }
        }

        // We are OK!
        IAnimatable::clearFlag(OwnerBit);
    }
}
Beispiel #24
0
void TV::IterativeReconstruction(CVector &data_gpu, CVector &x, CVector &b1_gpu)
{
  unsigned N = width * height * frames;

  ComputeTimeSpaceWeights(params.timeSpaceWeight, params.ds, params.dt);
  Log("Setting ds: %.3e, dt: %.3e\n", params.ds, params.dt);
  Log("Setting Primal-Dual Gap of %.3e  as stopping criterion \n", params.stopPDGap);

  // primal
  CVector x_old(N);
  CVector ext(N);

  agile::copy(x, ext);

  // dual
  std::vector<CVector> y;
  y.push_back(CVector(N));
  y.push_back(CVector(N));
  y.push_back(CVector(N));
  y[0].assign(N, 0);
  y[1].assign(N, 0);
  y[2].assign(N, 0);

  std::vector<CVector> tempGradient;
  tempGradient.push_back(CVector(N));
  tempGradient.push_back(CVector(N));
  tempGradient.push_back(CVector(N));

  CVector z(data_gpu.size());
  zTemp.resize(data_gpu.size(), 0.0);
  z.assign(z.size(), 0.0);

  CVector norm(N);

  unsigned loopCnt = 0; 
  // loop 
  Log("Starting iteration\n"); 
  while ( loopCnt < params.maxIt )
  {
    // dual ascent step
    utils::Gradient(ext, tempGradient, width, height, params.ds, params.ds,
                    params.dt);
    agile::addScaledVector(y[0], params.sigma, tempGradient[0], y[0]);
    agile::addScaledVector(y[1], params.sigma, tempGradient[1], y[1]);
    agile::addScaledVector(y[2], params.sigma, tempGradient[2], y[2]);

    mrOp->BackwardOperation(ext, zTemp, b1_gpu);
    agile::addScaledVector(z, params.sigma, zTemp, z);

    // Proximal mapping
    utils::ProximalMap3(y, 1.0);

    agile::subScaledVector(z, params.sigma, data_gpu, z);
    agile::scale((float)(1.0 / (1.0 + params.sigma / params.lambda)), z, z);
    // primal descent
    mrOp->ForwardOperation(z, imgTemp, b1_gpu);
    utils::Divergence(y, divTemp, width, height, frames, params.ds, params.ds,
                      params.dt);
    agile::subVector(imgTemp, divTemp, divTemp);
    agile::subScaledVector(x, params.tau, divTemp, ext);

    // save x_n+1
    agile::copy(ext, x_old);

    // extra gradient
    agile::scale(2.0f, ext, ext);
    agile::subVector(ext, x, ext);

    // x_n = x_n+1
    agile::copy(x_old, x);

    // adapt step size
    if (loopCnt < 10 || (loopCnt % 50 == 0))
    {
      CVector temp(N);
      agile::subVector(ext, x, temp);
      AdaptStepSize(temp, b1_gpu);
    }
    
    // compute PD Gap (export,verbose,stopping)
    if ( (verbose && (loopCnt < 10 || (loopCnt % 50 == 0)) ) ||
         ((debug) && (loopCnt % debugstep == 0)) || 
         ((params.stopPDGap > 0) && (loopCnt % 20 == 0)) )
    {
      RType pdGap =
            ComputePDGap(x, y, z, data_gpu, b1_gpu);
      pdGap=pdGap/N;
 
      pdGapExport.push_back( pdGap );
      Log("Normalized Primal-Dual Gap after %d iterations: %.4e\n", loopCnt, pdGap);     
      
      if ( pdGap < params.stopPDGap )
        return;
    }

    loopCnt++;
    if (loopCnt % 10 == 0)
      std::cout << "." << std::flush;
  }
  std::cout << std::endl;
}
BOOL CRVTrackerNodeMove::OnUpdate(const CUIEvent &cEvent)
{
	// Only update on idle
	if (cEvent.GetType() != UIEVENT_NONE)
		return TRUE;

	// Don't update if it hasn't moved
	if (m_cCurPt == m_cLastPt)
		return TRUE;

	LTVector newVert, moveOffset, translateAmount;
	DWORD i, j;
	CWorldNode *pNode;
	CEditBrush *pBrush;
	CEditPoly *pPoly;

	// If the mouse is outside of the view, then autoscroll the view
	DoAutoScroll();

	// Use the current mouse position and use the delta from the last to update the 
	// position of the node in 3d views...
	if( m_pView->GetVertexFromPoint(m_cCurPt, newVert))
	{
		moveOffset = newVert - m_vStartVec;

		// Snap the movement to the current move axis (may be all axis)
		moveOffset.x *= m_vMoveSnapAxis.x;
		moveOffset.y *= m_vMoveSnapAxis.y;
		moveOffset.z *= m_vMoveSnapAxis.z;

		// If the shift key is pressed, then snap the object to horizontal or vertical movement if
		// that hasn't been done already.		
		if (m_bLockAxis)
		{
			// Make sure that there isn't currently a move axis defined
			if (m_vMoveSnapAxis == CVector(1.0f, 1.0f, 1.0f))
			{
				// Create an absolute vector so that the magnitudes can be compared
				CVector vAbsolute(fabs(m_vTotalMoveOffset.x), fabs(m_vTotalMoveOffset.y), fabs(m_vTotalMoveOffset.z));

				// Check to see if we should snap to the x axis
				if (vAbsolute.x > vAbsolute.y && vAbsolute.x > vAbsolute.z)
				{
					// Cancel the movement along the y and z axis
					moveOffset.y=(-1)*m_vTotalMoveOffset.y;
					moveOffset.z=(-1)*m_vTotalMoveOffset.z;

					m_vMoveSnapAxis=CVector(1.0f, 0.0f, 0.0f);
				}

				// Check to see if we should snap to the y axis
				if (vAbsolute.y > vAbsolute.x && vAbsolute.y > vAbsolute.z)
				{
					// Cancel the movement along the y and z axis
					moveOffset.x=(-1)*m_vTotalMoveOffset.x;
					moveOffset.z=(-1)*m_vTotalMoveOffset.z;

					m_vMoveSnapAxis=CVector(0.0f, 1.0f, 0.0f);
				}

				// Check to see if we should snap to the z axis
				if (vAbsolute.z > vAbsolute.x && vAbsolute.z > vAbsolute.y)
				{
					// Cancel the movement along the y and z axis
					moveOffset.x=(-1)*m_vTotalMoveOffset.x;
					moveOffset.y=(-1)*m_vTotalMoveOffset.y;

					m_vMoveSnapAxis=CVector(0.0f, 0.0f, 1.0f);
				}
			}
		}
		else
		{
			m_vMoveSnapAxis=CVector(1.0f, 1.0f, 1.0f);
		}

		// Update the total move offset.  This is used to snap the nodes when the shift key is pressed.
		m_vTotalMoveOffset+=moveOffset;

		// Go through all the selected nodes and move them...
		for( i=0; i < m_pView->GetRegion()->m_Selections; i++ )
		{
			pNode = m_pView->GetRegion()->m_Selections[i];

			// Handle movement for Brush nodes...
			if(pNode->GetType() == Node_Brush)
			{
				// Get the brush pointer...
				pBrush = pNode->AsBrush();

				// Check for perpendicular movement...
				if(m_bPerp)
				{
					translateAmount = -(m_pView->EditGrid().Forward() * (CReal)(m_cCurPt.y - m_cLastPt.y));
				}
				// planar movement...
				else
				{
					translateAmount = moveOffset;
				}

				for( j=0; j < pBrush->m_Points; j++ )
					pBrush->m_Points[j] += translateAmount;

				// Update the texture space on the polies that are stuck.
				for(j=0; j < pBrush->m_Polies; j++)
				{
					pPoly = pBrush->m_Polies[j];
				
					for(uint32 nCurrTex = 0; nCurrTex < CEditPoly::NUM_TEXTURES; nCurrTex++)
					{
						CTexturedPlane& Texture = pPoly->GetTexture(nCurrTex);

						pPoly->SetTextureSpace(nCurrTex, Texture.GetO() + translateAmount, Texture.GetP(), Texture.GetQ());
					}
				}

				m_pView->GetRegion()->UpdateBrush(pBrush);
			}
			// Handle movement for object nodes...
			else if((pNode->GetType() == Node_Object) || 
					(pNode->GetType() == Node_PrefabRef))
			{
				// Check if perpendicular movement...
				if(m_bPerp)
				{
					LTVector vCurPos = pNode->GetPos();
					vCurPos -= m_pView->EditGrid().Forward() * (CReal)(m_cCurPt.y - m_cLastPt.y);
					pNode->SetPos(vCurPos);
				}
				// planar movement...
				else
				{
					pNode->SetPos(pNode->GetPos() + moveOffset);
				}
			}
		}

		// Update starting vertex for next pass...
		m_vStartVec = newVert;
	}

	// If user wants all the views updated, then do it...
	if( GetApp()->m_bFullUpdate )
	{
		m_pView->GetDocument()->UpdateAllViews(m_pView);
		m_pView->DrawRect();
	}

	m_cLastPt = m_cCurPt;

	return TRUE;
}
Beispiel #26
0
int main(int argc, char *argv[])
{
    // Engine init
    ENGINE_INIT(argc, argv);
    MapName="terrain_map.xml";
    look_in_mouse=false;
    k_MouseClick=false;
    if (!ENGINE)
    {
        fprintf(stderr,"Can't load main Engine module! Exiting...\n");
        return 1;
    };
    printf("Welcome to AmberSkyNet ( %s %d )\n",__FILE__,__LINE__);
    // Load world
    FILER->AddPath("samples/TerrainTest/", false);
    ENGINE->LoadDataFile(MapName.c_str());
    myWorld = ENGINE->GetWorld();
    if (!myWorld) {
        printf("Can't get world! Exiting... :(\n");
        return 1;
    };
    printf("World loaded.\n");
    // Camera
    myCam = myWorld->GetCamera( myWorld->AddCamera("CameraSimple") );
    myCam->SetScreen(0,0,1,1/*0.5*/);
    // ?
    FOV=initFOV;
    UpdatePerspective();
    // Camera Walker listener
    IEventListener *myList = EVENTER->AddEventListener( "EvListCamWalker" );
    if (!myList)
    {
        printf("Class EvListCamWalker can't found :(\n");
        return 1;
    }
    myList->SetPtrParam("Camera",myCam);
    myList->SetParam("step", camStep);
    printf("Camera walker created.\n");
    // Camera Looker listener
    myList = EVENTER->AddEventListener( "EvListCamLooker" );
    if (!myList)
    {
        printf("Class EvListCamWalker can't found :(\n");
        return 1;
    }
    myList->SetPtrParam("Camera",myCam);
    printf("Camera looker created.\n");
    // Camera position
    myCam->SetPos( CVector(5,128,0) );
    myCam->SetRotY( 0 );
    // Search terrains
    myWorld->FindChildrenByInterface("ASNITerrain", &Terrains);
    for (int i=0; i<Terrains.nums; i++)
        TerrainInterfaces.push_back((ASNITerrain*)(Terrains.getItem(i)->GetInterface("ASNITerrain")));
    // ?
    int evt;
    bool non_exit=true;

    ENGINE->SetPtrParam("UpdateCallback",(void*)UpdateCallback);
    ENGINE->SetPtrParam("DrawCallback",(void*)DrawCallback);
    // Main loop
    ENGINE->EngineStart();
    // End of work
    clearPtrList(&Terrains);
    printf("----End----\n");

    return 0;
};
Beispiel #27
0
void CSphereModel::MakeModel ( const unsigned int slices, const unsigned int stacks )
{
    unsigned int uiNumVertices = ( slices + 1 ) * ( stacks + 1 );
    CVertex* pVertices = new CVertex [ uiNumVertices ];
    unsigned int uiNumIndices = slices * stacks * 6;
    unsigned int* pIndices = new unsigned int [ uiNumIndices ];
    CMatrix matRotation;

    /* La esfera se genera "tumbada", así que aplicaremos una rotación a todos los vértices generados */
    CMatrixFactory::GetXRotationMatrix ( matRotation, PI/2 );

    /* Generamos los vértices de la esfera con la ecuación paramétrica de la esfera */
    for ( unsigned int i = 0; i <= stacks; ++i )
    {
        double vSin = sin ( i * PI / stacks );
        double vCos = cos ( i * PI / stacks );

        for ( unsigned int j = 0; j <= slices; ++j )
        {
            double uSin = sin ( j * PI2 / slices );
            double uCos = cos ( j * PI2 / slices );

            unsigned int uiCurVertex = j + i * ( slices + 1 );
            CVertex& cur = pVertices [ uiCurVertex ];

            CVector vecPosition = CVector ( uSin * vSin, uCos * vSin, vCos ) * matRotation;
            cur.SetPosition ( vecPosition );
            cur.SetNormal ( vecPosition );

            /* Asumimos que el mapeado de texturas de planetas será cilíndrico */
            cur.SetTexture ( CVector ( (float)j / slices, (float)i / stacks ) );
        }
    }

    /* Generamos los índices. La esfera se genera con quads, pero la triangulamos. */
    unsigned int uiCurIndex = 0;
    unsigned int v1, v2, v3;
    for ( unsigned int i = 0; i < stacks; ++i )
    {
        for ( unsigned int j = 0; j < slices; ++j )
        {
            unsigned int uiRing = i * ( slices + 1 );
            unsigned int uiNextRing = ( i + 1 ) * ( slices + 1 );

            /* Primer triángulo */
            v1 = j + uiRing;
            v2 = j + uiNextRing;
            v3 = 1 + j + uiNextRing;

            if ( pVertices [ v1 ].GetPosition ( ) != pVertices [ v2 ].GetPosition ( ) &&
                 pVertices [ v1 ].GetPosition ( ) != pVertices [ v3 ].GetPosition ( ) &&
                 pVertices [ v2 ].GetPosition ( ) != pVertices [ v3 ].GetPosition ( ) )
            {
                pIndices [ uiCurIndex++ ] = v3;
                pIndices [ uiCurIndex++ ] = v2;
                pIndices [ uiCurIndex++ ] = v1;
            }

            /* Segundo triángulo */
            v2 = 1 + j + uiNextRing;
            v3 = 1 + j + uiRing;
            if ( pVertices [ v1 ].GetPosition ( ) != pVertices [ v2 ].GetPosition ( ) &&
                 pVertices [ v1 ].GetPosition ( ) != pVertices [ v3 ].GetPosition ( ) &&
                 pVertices [ v2 ].GetPosition ( ) != pVertices [ v3 ].GetPosition ( ) )
            {
                pIndices [ uiCurIndex++ ] = v3;
                pIndices [ uiCurIndex++ ] = v2;
                pIndices [ uiCurIndex++ ] = v1;
            }
        }
    }

    /* Construímos el grupo de índices */
    SModelGroup group;
    group.material.SetAmbient ( CColor ( 1.0f, 1.0f, 1.0f, 1.0f ) );
    group.pIndices = pIndices;
    group.uiNumFaces = uiCurIndex / 3;
    group.szName = L"planet_mesh";

    CModel::Set ( L"planet", pVertices, uiNumVertices, &group, 1, 0 );

    delete [] pIndices;
    delete [] pVertices;
}
Beispiel #28
0
// ==================================================================================================================
// BEGIN: main
// ==================================================================================================================
int main(int argc, char *argv[])
{
  OptionsParser op;

  if (!op.ParseOptions(argc, argv))
    return -1;

  std::string outputDir = utils::GetParentDirectory(op.outputFilename);

  communicator_type com;
  com.allocateGPU();
  agile::GPUTimer timer;
  timer.start();

  agile::GPUEnvironment::printInformation(std::cout);
  std::cout << std::endl;

  // kdata
  CVector kdata;
  // kspace mask/trajectory
  RVector mask;

  // density compensation in case of nonuniform data
  RVector w(0);

  // get data dimensions
  std::string extension = utils::GetFileExtension(op.kdataFilename);
  std::cout << "Extension:" << extension << std::endl;
  
  Dimension dims; // = op.dims;
  if (extension.compare(".bin") == 0)
    dims = op.dims;
  else if (extension.compare(".cfl") == 0)
  {
      long dimensions[4];
      utils::ReadCflHeader(op.kdataFilename, dimensions);
      dims.width=dimensions[0];
      dims.height=dimensions[1];
      dims.depth=dimensions[2];
 
      dims.readouts=dimensions[0];
      dims.encodings=dimensions[1];
      dims.encodings2=dimensions[2];

      dims.coils=dimensions[3];
      dims.frames=dimensions[3];
      std::cout << "DIMS main; nx: " << dims.width << " / ny:" << dims.height << " / nz:" << dims.depth << " / nc:" << dims.coils << std::endl;
      std::cout << "DIMS main; nRO: " << dims.readouts << " / nENC1:" << dims.encodings << " / nENC2:" << dims.encodings2 << " / nframes:" << dims.frames << std::endl;
  }

  if (op.rawdata)
  {
    PerformRawDataPreparation(dims, op, kdata, mask, w);
  }
  else
  {
    std::cout << "Binary files defined...." << std::endl;
    if (!LoadGPUVectorFromFile(op.kdataFilename, kdata))
      return -1;
    else
      std::cout << "Data File " << op.kdataFilename << " successfully loaded." << std::endl;
 
    if (!LoadGPUVectorFromFile(op.maskFilename, mask))
      return -1;
    else
      std::cout << "Mask File " << op.maskFilename  << " successfully loaded." << std::endl;
    
  
    // set values in data-array to zero according to mask
    if (!op.nonuniform)
    { 
      if (op.method==TGV2_3D)
      {
        for (unsigned coil = 0; coil < dims.coils; coil++)
        {
          unsigned offset = dims.width * dims.height * dims.depth * coil;
           agile::lowlevel::multiplyElementwise(
              kdata.data() + offset, mask.data(),
              kdata.data() + offset, dims.width * dims.height * dims.depth);
        }
      }
      else
      {
        for (unsigned frame = 0; frame < dims.frames; frame++)
        {
          unsigned offset = dims.width * dims.height * dims.coils * frame;
          for (unsigned coil = 0; coil < dims.coils; coil++)
            {
            unsigned int x_offset = offset + coil * dims.width * dims.height;
            agile::lowlevel::multiplyElementwise(
              kdata.data() + x_offset, mask.data() + dims.width * dims.height * frame,
              kdata.data() + x_offset, dims.width * dims.height);
            }
        }
      }
    }
  }

  BaseOperator *baseOp = NULL;

  unsigned N;
  if (op.method==TGV2_3D)
    N = dims.width * dims.height * dims.depth;
  else 
    N = dims.width * dims.height;

  CVector b1, u0;
  // init b1 and u0
  b1 = CVector(N * dims.coils);
  b1.assign(N * dims.coils, 1.0);
  u0 = CVector(N);
  u0.assign(N, 0.0);

  // check if b1 and u0 data is provided
  if (LoadGPUVectorFromFile(op.sensitivitiesFilename, b1))
  {
    std::cout << "B1 File " << op.sensitivitiesFilename
              << " successfully loaded." << std::endl;
    
    if (LoadGPUVectorFromFile(op.u0Filename, u0))
    {
      std::cout << " initial solution (u0) file " << op.u0Filename
                << " successfully loaded." << std::endl;
    }
    else
    {
      std::cout << "no initial solution (u0) data provided!" << std::endl;
    }
  }
  else
  {
    
    if (op.method==TGV2_3D)
    {
       std::cerr << "Coil Construction for 3D reconstruction not implemented! Provide b1 seperately!"
                << std::endl;
       return -1;
    }
    
    std::cout << "Performing Coil Construction!" << std::endl;
    CVector u(N * dims.coils);
    u.assign(N * dims.coils, 0.0);

    if (op.nonuniform)
    {
      PerformNonCartesianCoilConstruction(dims, op, kdata, u, b1, mask, w, com);
    }
    else
    {
      PerformCartesianCoilConstruction(dims, op, kdata, u, b1, mask, com);
    }
    utils::GetSubVector(u, u0, dims.coils - 1, N);

    ExportAdditionalResultsToMatlabBin(outputDir.c_str(),
                                       "b1_reconstructed.bin", b1);
    ExportAdditionalResultsToMatlabBin(outputDir.c_str(),
                                       "u0_reconstructed.bin", u0);
  }

  if (op.nonuniform)
  {
    unsigned nFE = dims.readouts;
    unsigned spokesPerFrame = dims.encodings;

    std::cout << "Init NonCartesian Operator using kernelWidth:"
              << op.gpuNUFFTParams.kernelWidth
              << " sectorWidth:" << op.gpuNUFFTParams.sectorWidth
              << " OSF:" << op.gpuNUFFTParams.osf << std::endl;

    // Create 2d-t MR Operator
    baseOp = new NoncartesianOperator(
        dims.width, dims.height, dims.coils, dims.frames,
        spokesPerFrame * dims.frames, nFE, spokesPerFrame, mask, w, b1,
        op.gpuNUFFTParams.kernelWidth, op.gpuNUFFTParams.sectorWidth,
        op.gpuNUFFTParams.osf);
  }
  else
  {
    // Create 3d MR Operator
    if (op.method==TGV2_3D)
    {
      baseOp = new CartesianOperator3D(dims.width, dims.height, dims.depth,
                                   dims.coils, mask, false);
    }
    else
    {
      baseOp = new CartesianOperator(dims.width, dims.height, dims.coils,
                                   dims.frames, mask, false);
    }
  }

  // ==================================================================================================================
  // BEGIN: Perform iterative (TV, TGV2, TGV_3D, ICTGV2) reconstruction
  // ==================================================================================================================
  PDRecon *recon = NULL;
  GenerateReconOperator(&recon, op, baseOp);

  CVector x(0); // resize at runtime
  if (op.method==TGV2_3D)
  {
    x.resize(N, 0.0);
    agile::copy(u0, x);
  }
  else
  {
    x.resize(N * dims.frames, 0.0);
    for (unsigned frame = 0; frame < dims.frames; frame++)
    {
      utils::SetSubVector(u0, x, frame, N);
    }
  }
 
  std::cout << "Initialization time: " << timer.stop() / 1000 << "s"
            << std::endl;

  timer.start();

  // run reconstruction
  recon->IterativeReconstruction(kdata, x, b1);
  std::cout << "Execution time: " << timer.stop() / 1000 << "s" << std::endl; 
  // ==================================================================================================================
  // END: Perform iterative (TV, TGV2, TGV_3D, ICTGV2) reconstruction
  // ==================================================================================================================


  // ==================================================================================================================
  // BEGIN: Define output 
  // ================================================================================================================== 
    std::string extension_out = utils::GetFileExtension(op.outputFilename);
    std::vector<CType> xHost;
    x.copyToHost(xHost);
 
  // write reconstruction to bin file 
  if (extension_out.compare(".bin") == 0)
  {
    std::cout << "writing output file to: " << op.outputFilename << std::endl;
    agile::writeVectorFile(op.outputFilename.c_str(), xHost); 
  }
  // write reconstruction to h5 file 
  else if (extension_out.compare(".h5") == 0)
  {
    std::vector<size_t> dimVec;
    dimVec.push_back(dims.width);
    dimVec.push_back(dims.height);
    dimVec.push_back(dims.frames);
    utils::WriteH5File(op.outputFilename, "recon", dimVec, xHost);
  }
  // write reconstruction to dicom file 
  else if (extension_out.compare(".dcm") == 0)   
  {
    agile::DICOM dicomfile;
    std::string filenamewoe = utils::GetFilename(op.outputFilename);
    std::ostringstream ss;	 
    for (unsigned frame = 0; frame < dims.frames; frame++) 
    {
      std::vector<float> xoutmag;
      std::vector<float> xoutphs;
      for( unsigned i = N*frame; i < N*(frame+1); i++ )
        {
        xoutmag.push_back( (float)std::sqrt( pow(real(xHost[i]),2) + pow(std::imag(xHost[i]),2) ) ) ;
        xoutphs.push_back( (float)std::atan2( real(xHost[i]),std::imag(xHost[i]) ) );
        }
      
      ss << std::setw(3) << std::setfill('0') << frame;
      // magnitude
      const std::string str = ss.str();      
      std::string outputPath1 = boost::lexical_cast<std::string>(outputDir) + "/" + filenamewoe + "_magframe" + ss.str() + ".dcm"; 
      std::cout << "writing dicom file to: " << outputPath1 << std::endl;   
      //dicomfile.set_dicominfo(_in_dicomfile.get_dicominfo());  
      dicomfile.gendicom(outputPath1.c_str(), xoutmag, dims.height, dims.width); 
 
      // phase     
      std::string outputPath2 = boost::lexical_cast<std::string>(outputDir) + "/" + filenamewoe + "_phsframe" + ss.str() + ".dcm"; 
      std::cout << "writing dicom file to: " << outputPath2 << std::endl; 
  
      //dicomfile.set_dicominfo(_in_dicomfile.get_dicominfo());  
      dicomfile.gendicom(outputPath2.c_str(), xoutphs, dims.height, dims.width); 
 
      ss.str("");   
    }
  }
  else
  {
     // write reconstruction to binary file
     agile::writeVectorFile(op.outputFilename.c_str(), xHost);
  }

  // export additional information (pdgap, ictgv-component)
  if (op.extradata)
    recon->ExportAdditionalResults(outputDir.c_str(),
                                   &ExportAdditionalResultsToMatlabBin);
  // ==================================================================================================================
  // END: Define output 
  // ================================================================================================================== 

  delete recon;
  delete baseOp;
}
/////////////////////////////////////////////////////////////
//
// CAdditionalVertexStreamManager::UpdateAdditionalStreamContent
//
// Generate data in the additional stream
//
/////////////////////////////////////////////////////////////
bool CAdditionalVertexStreamManager::UpdateAdditionalStreamContent ( SCurrentStateInfo& state, SAdditionalStreamInfo* pAdditionalInfo, uint ReadOffsetStart, uint ReadSize, uint WriteOffsetStart, uint WriteSize )
{
    //HRESULT hr;
    IDirect3DVertexBuffer9* pStreamDataPT = state.stream1.pStreamData;
    IDirect3DVertexBuffer9* pStreamDataN = pAdditionalInfo->pStreamData;
    uint StridePT = 20;
    uint StrideN = 12;
    uint NumVerts = ReadSize / StridePT;
    assert ( NumVerts == WriteSize / StrideN );

    // Get the source vertex bytes
    std::vector < uchar > sourceArray;
    sourceArray.resize ( ReadSize );
    uchar* pSourceArrayBytes = &sourceArray[0];
    {
        void* pVertexBytesPT = NULL;
        if ( FAILED( pStreamDataPT->Lock ( ReadOffsetStart, ReadSize, &pVertexBytesPT, D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY ) ) )
            return false;
        memcpy ( pSourceArrayBytes, pVertexBytesPT, ReadSize );
        pStreamDataPT->Unlock ();
    }

    // Create dest byte buffer
    std::vector < uchar > destArray;
    destArray.resize ( WriteSize );
    uchar* pDestArrayBytes = &destArray[0];

    // Compute dest bytes
    {
        // Get index buffer
        if ( FAILED( m_pDevice->GetIndices( &state.pIndexData ) ) )
            return false;

        // Get index buffer desc
        D3DINDEXBUFFER_DESC IndexBufferDesc;
        state.pIndexData->GetDesc ( &IndexBufferDesc );

        uint numIndices = state.args.primCount + 2;
        uint step = 1;
        if ( state.args.PrimitiveType == D3DPT_TRIANGLELIST )
        {
            numIndices = state.args.primCount * 3;
            step = 3;
        }
        assert ( IndexBufferDesc.Size >= ( numIndices + state.args.startIndex ) * 2 );

        // Get index buffer data
        std::vector < uchar > indexArray;
        indexArray.resize ( ReadSize );
        uchar* pIndexArrayBytes = &indexArray[0];
        {
            void* pIndexBytes = NULL;
            if ( FAILED( state.pIndexData->Lock ( state.args.startIndex*2, numIndices*2, &pIndexBytes, D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY ) ) )
                return false;
            memcpy ( pIndexArrayBytes, pIndexBytes, numIndices*2 );
            state.pIndexData->Unlock ();
        }

        // Calc normals
        std::vector < CVector > NormalList;
        NormalList.insert ( NormalList.end (), NumVerts, CVector () );

        std::map < long long, CVector > doneTrisMap;

        // For each triangle
        for ( uint i = 0 ; i < numIndices - 2 ; i += step )
        {
            // Get triangle vertex indici
            WORD v0 = ((WORD*)pIndexArrayBytes)[ i ];
            WORD v1 = ((WORD*)pIndexArrayBytes)[ i + 1 ];
            WORD v2 = ((WORD*)pIndexArrayBytes)[ i + 2 ];

            if ( v0 >= NumVerts || v1 >= NumVerts || v2 >= NumVerts )
                continue;   // vert index out of range

            if ( v0 == v1 || v0 == v2 || v1 == v2 )
                continue;   // degenerate tri

            // Get vertex positions from original stream
            CVector* pPos0 = (CVector*)( pSourceArrayBytes + v0 * 20 );
            CVector* pPos1 = (CVector*)( pSourceArrayBytes + v1 * 20 );
            CVector* pPos2 = (CVector*)( pSourceArrayBytes + v2 * 20 );

            // Calculate the normal
            CVector Dir1 = *pPos2 - *pPos1;
            CVector Dir2 = *pPos0 - *pPos1;

            CVector Normal = Dir1;
            Normal.CrossProduct ( &Dir2 );
            Normal.Normalize ();

            // Flip normal if triangle was flipped
            if ( state.args.PrimitiveType == D3DPT_TRIANGLESTRIP && ( i & 1 ) )
                Normal = -Normal;

            // Try to improve results by ignoring duplicated triangles
            long long key = getTriKey ( v0, v1, v2 );
            if ( CVector* pDoneTriPrevNormal = MapFind ( doneTrisMap, key ) )
            {
                // Already done this tri - Keep prev tri if it has a better 'up' rating
                if ( pDoneTriPrevNormal->fZ > Normal.fZ )
                    continue;

                // Remove effect of prev tri
                NormalList[ v0 ] -= *pDoneTriPrevNormal;
                NormalList[ v1 ] -= *pDoneTriPrevNormal;
                NormalList[ v2 ] -= *pDoneTriPrevNormal;
            }
            MapSet ( doneTrisMap, key, Normal );

            // Add normal weight to used vertices
            NormalList[ v0 ] += Normal;
            NormalList[ v1 ] += Normal;
            NormalList[ v2 ] += Normal;
        }

        // Validate normals and set dest data
        for ( uint i = 0 ; i < NumVerts ; i++ )
        {
            // Validate
            CVector& Normal = NormalList[i];
            if ( Normal.Normalize () < FLOAT_EPSILON )
                Normal = CVector ( 0, 0, 1 );

            // Set
            CVector* pNormal = (CVector*)( pDestArrayBytes + i * 12 );
            *pNormal = Normal;
        }
    }

    // Set the dest bytes
    {
        void* pVertexBytesN = NULL;
        if ( FAILED( pStreamDataN->Lock ( WriteOffsetStart, WriteSize, &pVertexBytesN, D3DLOCK_NOSYSLOCK ) ) )
            return false;
        memcpy ( pVertexBytesN, pDestArrayBytes, WriteSize );
        pStreamDataN->Unlock ();
    }

    return true;
}
const NLMISC::CMatrix& CEvent3dMouseListener::getViewMatrix ()
{
	// Mode first person ?
	if (_MouseMode==firstPerson)
	{
		// CVector
		CVector dir (0,0,0);
		bool find=false;

		// Key pushed ?
		if (_AsyncListener.isKeyDown (KeyUP))
		{
			dir+=CVector (0, 1, 0);
			find=true;
		}
		if (_AsyncListener.isKeyDown (KeyDOWN))
		{
			dir+=CVector (0, -1, 0);
			find=true;
		}
		if (_AsyncListener.isKeyDown (KeyRIGHT))
		{
			dir+=CVector (1, 0, 0);
			find=true;
		}
		if (_AsyncListener.isKeyDown (KeyLEFT))
		{
			dir+=CVector (-1, 0, 0);
			find=true;
		}
		if (_AsyncListener.isKeyDown (KeyNEXT))
		{
			dir+=CVector (0, 0, -1);
			find=true;
		}
		if (_AsyncListener.isKeyDown (KeyPRIOR))
		{
			dir+=CVector (0, 0, 1);
			find=true;
		}

		// key found ?
		if (find)
		{
			// Time elapsed
			uint32 milli=(uint32)(CTime::getLocalTime ()-_LastTime);

			// Speed
			float dPos=_Speed*(float)milli/1000.f;

			// Good direction
			dir.normalize ();
			dir*=dPos;

			// Orientation
			dir=_Matrix.mulVector (dir);

			// New position
			_Matrix.setPos (_Matrix.getPos ()+dir);
		}
	}

	// Last time
	_LastTime=CTime::getLocalTime ();


	// Return the matrix
	return _Matrix;
}