Esempio n. 1
0
	void BMaxObject::UpdateGeometry()
	{
		SetGeometryDirty(false);
		if (m_pAnimatedMesh && m_pAnimatedMesh->IsLoaded())
		{
			Vector3 vMin, vMax;
			if (m_pAnimatedMesh->GetBoundingBox(&vMin, &vMax))
			{
				Matrix4 mat;
				GetLocalTransform(&mat);
				CShapeOBB obb(CShapeBox(vMin, vMax), mat);
				CShapeBox minmaxBox;
				minmaxBox.Extend(obb);
				if (GetScaling()!= 1.0){
					minmaxBox.SetMinMax(minmaxBox.GetMin() * GetScaling(), minmaxBox.GetMax() * GetScaling());
				}
				SetAABB(&minmaxBox.GetMin(), &minmaxBox.GetMax());
			}

			UnloadPhysics();
			if (m_dwPhysicsMethod == 0)
				m_dwPhysicsMethod = PHYSICS_LAZY_LOAD;
			else if (IsPhysicsEnabled() && ((m_dwPhysicsMethod&PHYSICS_ALWAYS_LOAD)>0))
			{
				LoadPhysics();
			}
		}
	}
Esempio n. 2
0
void RPG_Trigger::PostInitialize()
{
  RPG_BaseEntity::PostInitialize();

  if(Vision::Editor.IsPlayingTheGame() && !m_displayDebug)
  {
    // Trigger should be invisible during the game unless we're displaying the mesh for debug purposes.
    SetVisibleBitmask(VIS_ENTITY_INVISIBLE);
  }

  // create a box based off of the entity scaling. a scale of (1,1,1) = .001 meter cube in havok units.
  
  m_aabb.setInvalid();

  m_aabb.set(-GetScaling() * 0.5f, GetScaling() * 0.5f);

  hkvMat4 aabbTransform(GetRotationMatrix(), GetPosition());
  m_aabb.transformFromOrigin(aabbTransform);

  hkVector4 minBoundary;
  RPG_VisionHavokConversion::VisionToHavokPoint(m_aabb.m_vMin, minBoundary);

  hkVector4 maxBoundary;
  RPG_VisionHavokConversion::VisionToHavokPoint(m_aabb.m_vMax, maxBoundary);

  // Create the AABB
  hkAabb fixedAabb;
  fixedAabb.setEmpty();
  fixedAabb.m_min = minBoundary;
  fixedAabb.m_max = maxBoundary;

  // Create the phantom
  m_aabbPhantom = new RPG_AabbPhantom(this, fixedAabb);

  // Set entity type for the triggers' data collection
  //m_aabbPhantom->setUserData( (hkUlong)this );

  // Add the phantom to the world
  
  vHavokPhysicsModule::GetInstance()->MarkForWrite();
  {
    vHavokPhysicsModule::GetInstance()->GetPhysicsWorld()->addPhantom(m_aabbPhantom);
  }
  vHavokPhysicsModule::GetInstance()->UnmarkForWrite();


  // Set color
  //HK_SET_OBJECT_COLOR((hkUlong)fixedPhantomCallbackShapeRB->getCollidable(), m_fixedPhantomCallbackShape->m_colourNoHit);

  // Cache trigger sources: note that these may not exist in serialized scenes if nothing referenced them
  if(!m_onEnterSource)
    m_onEnterSource = static_cast<VisTriggerSourceComponent_cl*>(Components().GetComponentOfTypeAndName(V_RUNTIME_CLASS(VisTriggerSourceComponent_cl), "OnEnter"));

  if(!m_onExitSource)
    m_onExitSource = static_cast<VisTriggerSourceComponent_cl*>(Components().GetComponentOfTypeAndName(V_RUNTIME_CLASS(VisTriggerSourceComponent_cl), "OnExit"));

  if(!m_onInsideSource)
    m_onInsideSource = static_cast<VisTriggerSourceComponent_cl*>(Components().GetComponentOfTypeAndName(V_RUNTIME_CLASS(VisTriggerSourceComponent_cl), "OnInside"));
}
Esempio n. 3
0
static void	OnMouseMove(HWND hwnd,UINT	message,WPARAM wParam,LPARAM lParam)
{
//	RECT	rc;
	float	s;
	static POINT	p;
	static POINTS	viewcentral;
	POINTS	t;
	switch(message)
	{
	case WM_MOUSEMOVE:
		if(wParam & MK_LBUTTON	)
		{
		s=GetScaling(hwnd);
		//将视图中心点移动这么多
		t=viewcentral;
		t.x += (p.x - (lParam & 0xFFFF))/s;
		t.y += (p.y - (lParam >> 16))/s;
		SetWindowLong(hwnd,FIELD_OFFSET(ShowPicClass,central),*((DWORD*)(&t)));		
		//设置滚动条
		

		//更新视图
		InvalidateRect(hwnd,0,0);
		}break;
	case WM_LBUTTONUP:
		ReleaseCapture();
		break;
	case WM_LBUTTONDOWN:
		*((DWORD*)(&viewcentral))=GetWindowLong(hwnd,FIELD_OFFSET(ShowPicClass,central));
		SetCapture(hwnd);
		//得到鼠标点击地
		p.x = (lParam & 0xFFFF);
		p.y = (lParam >>16 );
	}
Esempio n. 4
0
static void	OnCommand(HWND	hWnd,WPARAM wParam,LPARAM lParam)
{
	switch(wParam & 0xFFFF)
	{
	case IDM_AUTOSTRECH:
		SendMessage(hWnd,WM_SETFLAG,0,GetWindowLong(hWnd,0) ^ SHP_ZOOMAUTOSTRECH);
		break;
	case IDM_ZOOM_B:
		SetScaling(hWnd,GetScaling(hWnd)*2);
		if(GetScaling(hWnd)>20)
			SetScaling(hWnd,20);
		break;
	case IDM_ZOOM_S:
		SetScaling(hWnd,GetScaling(hWnd)/2);
		if(GetScaling(hWnd)< 0.1f)
			SetScaling(hWnd,0.1f);
		break;
	case IDM_ZOOM_ORIG:
		SetScaling(hWnd,1);
		break;
	}
	InvalidateRect(hWnd,0,0);
}
Esempio n. 5
0
	Matrix4* BMaxObject::GetRenderMatrix(Matrix4& mxWorld, int nRenderNumber /*= 0*/)
	{
		mxWorld.identity();

		// order of rotation: roll * pitch * yaw , where roll is applied first. 
		bool bIsIdentity = true;

		float fScaling = GetScaling();
		if (fScaling != 1.f)
		{
			Matrix4 matScale;
			ParaMatrixScaling((Matrix4*)&matScale, fScaling, fScaling, fScaling);
			mxWorld = (bIsIdentity) ? matScale : matScale.Multiply4x3(mxWorld);
			bIsIdentity = false;
		}

		float fYaw = GetYaw();
		if (fYaw != 0.f)
		{
			Matrix4 matYaw;
			ParaMatrixRotationY((Matrix4*)&matYaw, fYaw);
			mxWorld = (bIsIdentity) ? matYaw : matYaw.Multiply4x3(mxWorld);
			bIsIdentity = false;
		}

		if (GetPitch() != 0.f)
		{
			Matrix4 matPitch;
			ParaMatrixRotationX(&matPitch, GetPitch());
			mxWorld = (bIsIdentity) ? matPitch : matPitch.Multiply4x3(mxWorld);
			bIsIdentity = false;
		}

		if (GetRoll() != 0.f)
		{
			Matrix4 matRoll;
			ParaMatrixRotationZ(&matRoll, GetRoll());
			mxWorld = (bIsIdentity) ? matRoll : matRoll.Multiply4x3(mxWorld);
			bIsIdentity = false;
		}

		// world translation
		Vector3 vPos = GetRenderOffset();
		mxWorld._41 += vPos.x;
		mxWorld._42 += vPos.y;
		mxWorld._43 += vPos.z;

		return &mxWorld;
	}
Esempio n. 6
0
	Matrix4* BMaxObject::GetAttachmentMatrix(Matrix4& matOut, int nAttachmentID /*= 0*/, int nRenderNumber /*= 0*/)
	{
		if (m_pAnimatedMesh && m_pAnimatedMesh->IsLoaded())
		{
			CParaXModel* pModel = m_pAnimatedMesh->GetModel();
			if (pModel)
			{
				Matrix4* pOut = &matOut;
				if (pModel->GetAttachmentMatrix(pOut, nAttachmentID, m_CurrentAnim, AnimIndex(), 0.f))
				{
					Matrix4 matScale;
					float fScaling = GetScaling();
					if (fabs(fScaling - 1.0f) > FLT_TOLERANCE)
					{
						ParaMatrixScaling(&matScale, fScaling, fScaling, fScaling);
						(*pOut) = (*pOut)*matScale;
					}
					return pOut;
				}
			}
		}
		return NULL;
	}
Esempio n. 7
0
//==================================================================================================
// PIXEndFrame
//==================================================================================================
BOOL WINAPI PIXEndFrame( PIXCOUNTERID id, UINT iFrame, DWORD* pdwReturnBytes, BYTE** ppReturnData )
{
    switch( id )
    {
        case CTR_EFFECTSCALING:
            return GetScaling( pdwReturnBytes, ppReturnData );
        case CTR_EFFECTLIMIT:
            return GetEffectLimit( pdwReturnBytes, ppReturnData );
        case CTR_EFFECTLIFE:
            return GetEffectLife( pdwReturnBytes, ppReturnData );
        case CTR_NORMALIZATION:
            return GetNormalization( pdwReturnBytes, ppReturnData );
        case CTR_UPDATEFREQUENCY:
            return GetUpdateFrequency( pdwReturnBytes, ppReturnData );
        case CTR_STREAMOUT:
            return GetStreamOut( pdwReturnBytes, ppReturnData );
        case CTR_SCREENEFFECTS:
            return GetScreenEffects( pdwReturnBytes, ppReturnData );
        case CTR_FIREWORKS:
            return GetFireworks( pdwReturnBytes, ppReturnData );
        default:
            return FALSE;
    }
}
Esempio n. 8
0
//{ return GetRadiusWithMargin() / GetScaling()[(StandardAxis)((this->GetUpStandardAxis()+2)%3)] - GetBulletCapsuleShape()->getMargin(); }
Real CapsuleCollisionShape::GetCleanHeight() const
//{ return 2.0* ((GetBulletCapsuleShape()->getHalfHeight()+GetBulletCapsuleShape()->getMargin()) / GetScaling()[this->GetUpStandardAxis()] - GetBulletCapsuleShape()->getMargin()); }
{
    return 2.0* ((GetBulletCapsuleShape()->getHalfHeight()) / GetScaling()[this->GetUpStandardAxis()]);
}
Esempio n. 9
0
Real CapsuleCollisionShape::GetCleanRadius() const
{
    return (this->GetRadius()+GetBulletCapsuleShape()->getMargin()) / GetScaling()[(StandardAxis)((this->GetUpStandardAxis()+2)%3)] - GetBulletCapsuleShape()->getMargin();
}
Esempio n. 10
0
static void OnPaint(HWND hwnd,HDC hdc)
{
	long	flag;
	RECT	updata;
	POINT	central;
	POINTS	bmprc;
	POINTS	viewcentral;
	RECT	clientRect;
	RECT	upbmp;
	float	Scale;
	//最新得到旗标	
	flag=GetWindowLong(hwnd,FIELD_OFFSET(ShowPicClass,flag));
	
	//先得到客户区的大小
	GetClientRect(hwnd,&clientRect);
	//再得到窗口中心的坐标
	central.x = clientRect.right/2;
	central.y = clientRect.bottom/2;
	//得到图片大小
	*((DWORD*)(&bmprc))= GetWindowLong(hwnd,FIELD_OFFSET(ShowPicClass,bmRC));
	//得到更新区域
//	GetUpdateRect(hwnd,&updata,1);
//	updata.right+=5;
//	updata.left-=5;/
//	updata.top-=5;
//	updata.bottom+=5;
	GetClientRect(hwnd,&updata);

	//得到视图中心在图片上的位置
	if(flag & SHP_ZOOMAUTOSTRECH )
	{
		GetClientRect(hwnd,&updata);
		upbmp.left = 0;
		upbmp.right = bmprc.x;
		upbmp.top = 0;
		upbmp.bottom = bmprc.y;
		
		viewcentral.x = bmprc.x/2,viewcentral.y = bmprc.y/2;
		//得到更新区域对应于图片的矩形区域 --> upbmp;
		if(flag & SHP_ZOOMKEEPRATIO)
		{
		/*纵横比*/Scale = (float)viewcentral.x/viewcentral.y;
			upbmp.top  = (long)(viewcentral.y - (viewcentral.y * Scale));
			if(upbmp.top < 0 ) //很宽啊!
			{
				upbmp.bottom = (long)(viewcentral.y + viewcentral.y * Scale);
				upbmp.left = 0;
				upbmp.right = bmprc.x;
			}else
			{
				upbmp.top = 0;
				upbmp.bottom = bmprc.y;
				upbmp.right = (long)(viewcentral.x + viewcentral.x * Scale);
				upbmp.left  = (long)(viewcentral.x - viewcentral.x * Scale);
			}
		}else
		{
			// 客户区域对应于图片的矩形区域就是整张图片
			upbmp.left = upbmp.top =0;
			upbmp.bottom = bmprc.y;
			upbmp.right = bmprc.x;
		}
//		upbmp.left  =(long)(((float)updata.left)  /clientRect.right * (upbmp.right-upbmp.left));
//		upbmp.right =(long)(((float)updata.right) /clientRect.right * (upbmp.right-upbmp.left));
//		upbmp.top   =(long)(((float)updata.top )  /clientRect.bottom* (upbmp.bottom - upbmp.top));
//		upbmp.bottom=(long)(((float)updata.bottom)/clientRect.bottom* (upbmp.bottom - upbmp.top));
	}
	else 
	{

		*((DWORD*)(&viewcentral))=GetWindowLong(hwnd,FIELD_OFFSET(ShowPicClass,central));
		
		//缩放率
		Scale =1/GetScaling(hwnd);

		//依据缩放率调整

		upbmp.left = viewcentral.x - (updata.right - updata.left) * Scale / 2;
		upbmp.right = viewcentral.x + (updata.right - updata.left) * Scale / 2;

		upbmp.top = viewcentral.y -  (updata.bottom - updata.top) * Scale / 2;
		upbmp.bottom = viewcentral.y + (updata.bottom - updata.top) * Scale / 2;

		
		if(upbmp.top < 0)
		{
			updata.top += ((-upbmp.top)/Scale+0.5);
			upbmp.top =0;
		}

		if (upbmp.left < 0)
		{
			updata.left  += ((-upbmp.left)/Scale+0.5);
			upbmp.left = 0;
		}

		if(upbmp.right > bmprc.x)
		{
			updata.right -= ((upbmp.right - bmprc.x)/Scale + 0.5);
			upbmp.right = bmprc.x;
		}
		
		if(upbmp.bottom > bmprc.y)
		{
			updata.bottom -= (  (upbmp.bottom - bmprc.y)/Scale+0.5  );
			upbmp.bottom = bmprc.y;		
		}
		
	}
	//把位图里要更新的部分画到更新区域
	//rePaint(hwnd,updata,upbmp);
	Repaint(hwnd,updata,upbmp,hdc);
}
Esempio n. 11
0
 Real ConeCollisionShape::GetHeightScaling() const
     { return GetScaling()[GetUpStandardAxis()]; }
Esempio n. 12
0
 Real ConeCollisionShape::GetRadiusScaling() const
     { return (GetScaling()[GetAxisMathBS()[0]]+GetScaling()[GetAxisMathBS()[2]])/2.0; }