Exemple #1
0
UCECube::UCECube(const class FObjectInitializer& PCIP) : Super(PCIP)
{
	// Размер куба 100*100*100 (по 50 от центра)
	BoxExtent = FVector(50, 50, 50);
	// Включаем отслеживание трассировки лучей
	SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block);
	SetCollisionEnabled(ECollisionEnabled::Type::QueryAndPhysics);
}
Exemple #2
0
// Bounding collision region
void Item::CreateBoundingRegion(vec3 origin, BoundingRegionType boundingType, float radius, float xWidth, float yWidth, float zWidth, float scale)
{
	if(m_vpBoundingRegionList.size() >= 1)
	{
		return;
	}

	SetCollisionEnabled(true);

	BoundingRegion* lpNewRegion = new BoundingRegion();

	lpNewRegion->m_origin = origin;
	lpNewRegion->m_boundingType = boundingType;
	lpNewRegion->m_radius = radius;
	lpNewRegion->m_x_length = xWidth;
	lpNewRegion->m_y_length = yWidth;
	lpNewRegion->m_z_length = zWidth;
	lpNewRegion->m_scale = scale;

	Matrix4x4 transformMatrix;
	lpNewRegion->UpdatePlanes(transformMatrix, 1.0f);

	m_vpBoundingRegionList.push_back(lpNewRegion);
}
void CClientObject::Create ( void )
{
    // Not already created an object?
    if ( !m_pObject )
    {
        // Check again that the limit isn't reached. We are required to do so because
        // we load async. The streamer isn't always aware of our limits.
        if ( !CClientObjectManager::IsObjectLimitReached () )
        {
            // Add a reference to the object
            m_pModelInfo->ModelAddRef ( BLOCKING, "CClientObject::Create" );

            // If the new object is not breakable, allow it into the vertical line test
            g_pMultiplayer->AllowCreatedObjectsInVerticalLineTest ( !CClientObjectManager::IsBreakableModel ( m_usModel ) );

            // Create the object
            m_pObject = g_pGame->GetPools ()->AddObject ( m_usModel, m_bIsLowLod, m_bBreakingDisabled );

            // Restore default behaviour
            g_pMultiplayer->AllowCreatedObjectsInVerticalLineTest ( false );

            if ( m_pObject )
            {                
                // Put our pointer in its stored pointer
                m_pObject->SetStoredPointer ( this );

                // Add XRef
                g_pClientGame->GetGameEntityXRefManager ()->AddEntityXRef ( this, m_pObject );

                // If set to true,this has the effect of forcing the object to be static at all times
                m_pObject->SetStaticWaitingForCollision ( m_bIsStatic );

                // Apply our data to the object
                m_pObject->Teleport ( m_vecPosition.fX, m_vecPosition.fY, m_vecPosition.fZ );
                m_pObject->SetOrientation ( m_vecRotation.fX, m_vecRotation.fY, m_vecRotation.fZ );
                #ifndef MTA_BUILDINGS
                m_pObject->ProcessCollision ();
                #endif
                m_pObject->SetupLighting ();

                UpdateVisibility ();
                if ( !m_bUsesCollision ) SetCollisionEnabled ( false );
                if ( m_vecScale.fX != 1.0f &&
                     m_vecScale.fY != 1.0f &&
                     m_vecScale.fZ != 1.0f)
                    SetScale ( m_vecScale );
                m_pObject->SetAreaCode ( m_ucInterior );
                SetAlpha ( m_ucAlpha );
                m_pObject->SetHealth ( m_fHealth );

                // Set object mass
                if ( m_fMass != -1.0f )
                    m_pObject->SetMass ( m_fMass );

                // Reattach to an entity + any entities attached to this
                ReattachEntities ();

                // Validate this entity again
                m_pManager->RestoreEntity ( this );

                // Tell the streamer we've created this object
                NotifyCreate ();

                // Done
                return;
            }
            else
            {
                // Remove our reference to the object again
                m_pModelInfo->RemoveRef ();
            }
        }

        // Tell the streamer we could not create it
        NotifyUnableToCreate ();
    }
}