Example #1
0
void DynamicObject::RemoveFromWorld()
{
    ///- Remove the dynamicObject from the accessor
    if (IsInWorld())
    {
        WorldObject::RemoveFromWorld();
        GetMap()->RemoveFromObjMap(GetGUID());
        GetViewPoint().Event_RemovedFromWorld();
    }
}
void DynamicObject::RemoveFromWorld()
{
    ///- Remove the dynamicObject from the accessor
    if(IsInWorld())
    {
        GetMap()->GetObjectsStore().erase<DynamicObject>(GetGUID(), (DynamicObject*)NULL);
        GetViewPoint().Event_RemovedFromWorld();
    }

    Object::RemoveFromWorld();
}
Example #3
0
//-----------------------------------------------------------------------------
// Purpose: Sets the camera target, rebuilding the view matrix.
// Input  : ViewTarget - the point in world space that the camera should look at.
//-----------------------------------------------------------------------------
void CCamera::SetViewTarget(const Vector &ViewTarget)
{
	Vector ViewOrigin;
	Vector ViewForward;

	GetViewPoint( ViewOrigin );

	VectorSubtract(ViewTarget, ViewOrigin, ViewForward);
	VectorNormalize(ViewForward);

	//
	// Ideally we could replace the math below with standard VectorAngles stuff, but Hammer
	// camera matrices use a different convention from QAngle (sadly).
	//
	float fYaw = RAD2DEG(atan2(ViewForward[0], ViewForward[1]));
	SetYaw(fYaw);

	float fPitch = -RAD2DEG(asin(ViewForward[2]));
	SetPitch(fPitch);
}
Example #4
0
TreeCtrlItem *duTreeCtrl::GetFirstVisibleItem(int &nOffset)
{
	nOffset = 0;
	if (m_nItems == 0)
		return m_pRoot;
	
	POINT ptScroll = GetViewPoint();
	int nCalcHeight = 0;
	TreeCtrlItem *pTreeItem = GetNextVisibleItem(m_pRoot);
	while (pTreeItem)
	{
		nCalcHeight += m_nItemHeight;
		if (nCalcHeight > ptScroll.y)
		{
			nOffset = (ptScroll.y + m_nItemHeight) - nCalcHeight;
			return pTreeItem;
		}

		pTreeItem = GetNextVisibleItem(pTreeItem);
	}

	return NULL;
}
Example #5
0
TreeCtrlItem *duTreeCtrl::yHitTest(const duRect &rcTreeCtrl, const POINT pt, duRect &rcItem)
{
	POINT ptClient(pt);
	ptClient.x -= rcTreeCtrl.left;
	ptClient.y -= rcTreeCtrl.top;
	
	int nOffsetY = 0;
	TreeCtrlItem *pFirstVisible = GetFirstVisibleItem(nOffsetY);
	if (pFirstVisible == NULL || pFirstVisible == m_pRoot)
		return NULL;
	
	POINT ptView = GetViewPoint();
	duSize sizeView;
	GetViewSize(&sizeView);
	int nDrawHeight = -nOffsetY;
	TreeCtrlItem *pItem = pFirstVisible;
	while (pItem)
	{
		rcItem.SetRectEmpty();
		rcItem.left = -ptView.x;
		rcItem.right = rcItem.left + sizeView.cx;
		rcItem.top = nDrawHeight;
		rcItem.bottom = rcItem.top + m_nItemHeight;

		if (rcItem.PtInRect(ptClient))
			return pItem;

		if (nDrawHeight - nOffsetY > rcTreeCtrl.Height())
			break;

		nDrawHeight += m_nItemHeight;
		pItem = GetNextVisibleItem(pItem);
	}
	
	return NULL;
}
Example #6
0
void duTreeCtrl::DrawObject(HDC hDC)
{
	duRect rcTreeCtrl;
	Plugin_GetRect(this, &rcTreeCtrl);
	rcTreeCtrl.OffsetRect(-rcTreeCtrl.left, -rcTreeCtrl.top);

	BITMAPINFO bmInfo;
	BYTE *pBits;

	HDC hMemDC = ::CreateCompatibleDC(hDC);
	InitBitmapInfo(&bmInfo, rcTreeCtrl.Width(), rcTreeCtrl.Height());
	HBITMAP hBmp = ::CreateDIBSection(hDC, &bmInfo, DIB_RGB_COLORS,(void**)&pBits, 0, 0);
	HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemDC, hBmp);

	BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
	::AlphaBlend(hMemDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), hDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), bf);


	duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP);
	if (pStyleGroup)
		pStyleGroup->Draw(hMemDC, &rcTreeCtrl, GetState(), NULL, GetAlpha());
	
	int nOffsetY = 0;
	TreeCtrlItem *pFirstVisible = GetFirstVisibleItem(nOffsetY);
	if (pFirstVisible == NULL || pFirstVisible == m_pRoot)
		return;
		
	duRect rcClient = _GetClientRect();
	
	POINT ptView = GetViewPoint();
	duFont *pFont = (duFont *)GetResObj(m_szFont, DU_RES_FONT);
	
	duSize sizeView;
	GetViewSize(&sizeView);
	
	int nDrawHeight = -nOffsetY;
	TreeCtrlItem *pItem = pFirstVisible;
	while (pItem)
	{
		duRect rcItem;
		
		rcItem.left   = -ptView.x;
		rcItem.right  = rcClient.right;
		rcItem.top    = nDrawHeight;
		rcItem.bottom = rcItem.top + m_nItemHeight;

		UINT uItemState = DU_STATE_NORMAL;
		if (pItem == m_pHot)
			uItemState = DU_STATE_OVER;
		
		if (pItem == m_pSelect)
			uItemState = DU_STATE_PRESS;
		
		DrawByStyle(this, m_szItemStyle, hMemDC, &rcItem, uItemState, NULL, GetAlpha());

		// draw indent[-+]
		int nLeft = (pItem->nLevel - 1) * m_nIndentWidth;
		duRect rcIndent = CalcVCenterRect(rcItem, nLeft, m_nIndentWidth, m_nIndentHeight);
		if (ItemHasChildren(pItem))
		{
			UINT nIndentState = pItem->fExpand ? DU_STATE_NORMAL : DU_STATE_CHECKED;
			DrawByStyle(this, m_szIndentStyle, hMemDC, &rcIndent, nIndentState, NULL, GetAlpha());
		}

		// draw icon
		nLeft += (m_nIndentWidth + m_nIndentIconSpace);
		duRect rcIcon = CalcVCenterRect(rcItem, nLeft, m_nIconWidth, m_nIconHeight);
		duImage *pIcon = (duImage *)GetResObj(pItem->strImage.c_str(), DU_RES_IMAGE);
		if (pIcon)
			DrawNormal(hMemDC, rcIcon.left, rcIcon.top, rcIcon.Width(), rcIcon.Height(), pIcon, 0, 0, GetAlpha());

		// draw text
		duRect rcText;
		nLeft += (m_nIconWidth + m_nIconTextSpace);
		rcText = rcItem;
		rcText.left = rcItem.left + nLeft;
		if (pItem->strText.length() > 0)
			DrawText32Bpp(hMemDC, pFont, m_clrText, pItem->strText.c_str(), pItem->strText.length(), &rcText, DT_LEFT|DT_VCENTER|DT_SINGLELINE, GetAlpha());

		if (nDrawHeight - nOffsetY > rcTreeCtrl.Height())
			break;

		nDrawHeight += m_nItemHeight;
		pItem = GetNextVisibleItem(pItem);
	}

	::AlphaBlend(hDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), hMemDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), bf);

	::SelectObject(hMemDC, hOldBitmap);
	::DeleteObject(hBmp);
	::DeleteDC(hMemDC);
}
Example #7
0
void CPROC EditResizeCallback( uintptr_t dwUser  )
{
	PEDITOR pe = (PEDITOR)dwUser;
	//PFACETSET *ppfs;
	//PFACET pf;

	//PLINESEGPSET *pplps;
	//PMYLINESEGSET *ppls;
	//PMYLINESEG pl;
	//int l;
	// ShowCurrent();
	//ClearImage( surface );
	{
		//IMAGE_RECTANGLE r;
		//GetDisplayPosition( pe->hVideo, pe->ptUpperLeft, pe->ptUpperLeft + 1, NULL, NULL );
		/*
		GetWindowRect( pe->hVideo->hWndOutput, &r );
		pe->ptUpperLeft[0] = r.left //+ GetSystemMetrics( SM_CXBORDER )
									  + GetSystemMetrics( SM_CXFRAME );
		pe->ptUpperLeft[1] = r.top + GetSystemMetrics( SM_CYBORDER )
									 + GetSystemMetrics( SM_CYFRAME )
									 + GetSystemMetrics( SM_CYCAPTION );
									 */
	}
#if 0
	SetClip( (RCOORD)GetDisplayImage( pe->hVideo )->width,
				(RCOORD)GetDisplayImage( pe->hVideo )->height );
	ppfs = pe->pCurrent->objinfo->ppFacetPool;
	ppls = GetFromSet( LINEPSEG, pe->pCurrent->objinfo->ppLinePool );
	//ForAllInSet( FACET, &pe->pCurrent->objinfo->ppFacetPool, DrawLineSegs );
	//int f;
	//for( f = 0; f < ; f++ )
	{
		int lines;
		//pf = GetFromSet( FACET, pfs->pFacets + f;
		pplps = &pf->pLineSet;
		lines = CountUsedInSet( LINESEGP, pf->pLineSet );
		for( l = 0; l < lines; l++ )
		{
			RAY ld; // local directional...
			PLINESEGP plsp = GetSetMember( LINESEGP, pplps, l );
			pl = GetSetMember( MYLINESEG, ppls, plsp->nLine );
			if( pl == pe->pCurrentLine )
			{
				ApplyInverseR( pe->TView, &ld, &pl->r );
				DrawLine(surface, ld.o, ld.n, pl->dFrom-5, pl->dFrom, Color( 192, 192, 0 ) );
				DrawLine(surface, ld.o, ld.n, pl->dFrom, pl->dTo, Color( 0, 150, 0 ) );
				DrawLine(surface, ld.o, ld.n, pl->dTo, pl->dTo+5, Color( 192, 192, 0 ) );
				GetViewPoint(surface, &pe->ptO, ld.o );
				add( ld.o, ld.o, ld.n ); // add one slope to origin to get slope point
				GetViewPoint(surface, &pe->ptN, ld.o );
				MarkOrigin( pe, surface );
				MarkSlope( pe,surface );
			}
			else
			if( pf = pe->pCurrentFacet )
			{
				ApplyInverseR( pe->TView, &ld, &pl->r );
				DrawLine(surface, ld.o, ld.n, pl->dFrom, pl->dTo, Color( 0, 0, 150 ) );
			}
			else
			{
				ApplyInverseR( pe->TView, &ld, &pl->r );
				DrawLine(surface, ld.o, ld.n, pl->dFrom, pl->dTo, Color( 92, 92, 92 ) );
			}
		}
	}
	UpdateDisplay( pe->hVideo );
#endif
}