当前位置: 首页>>代码示例>>C++>>正文


C++ AABB::Transform方法代码示例

本文整理汇总了C++中AABB::Transform方法的典型用法代码示例。如果您正苦于以下问题:C++ AABB::Transform方法的具体用法?C++ AABB::Transform怎么用?C++ AABB::Transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AABB的用法示例。


在下文中一共展示了AABB::Transform方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Update

    void GameObjectGroup::Update(const FrameTime& fr, UpdateTypeEnum updateType)
    {
        bool boundDirty = m_boundsDirty;
        super::Update(fr,updateType);
        m_boundsDirty = boundDirty;
        for( auto it = m_children.begin(); it != m_children.end(); ++it)
        {
            (*it)->Update(fr,updateType);
        }


        // Update bounds
        if(m_boundsDirty)
        {            
            bool usechildbounds = false;
            AABB childbounds; // default ctor will set initial value of min and max.
            // merge bounds for the the visibile children.
            for (auto it = m_children.begin(); it != m_children.end(); ++it)
            {
                if( (*it)->IsVisible())
                {                    
                    AABB local = (*it)->GetLocalBounds();
                    local.Transform((*it)->GetTransform());
                    childbounds.Extend( local );
                    usechildbounds = true;
                }
            }
                 
            // set local bounds 
            m_localBounds = usechildbounds ? childbounds : AABB(float3(-0.5f,-0.5f,-0.5f), float3(0.5f,0.5f,0.5f));
            UpdateWorldAABB();                      
        }
    }
开发者ID:Anters,项目名称:LevelEditor,代码行数:33,代码来源:GameObjectGroup.cpp

示例2: UpdateBounds

// ------------------------------------------------------------------------------------------------
void Model::UpdateBounds()
{
    assert(m_constructed==true);
    const GeometryDict& geos = Geometries();
    if(geos.size()==0)
    {
        return;
    }

    float3 min = float3(FLT_MAX, FLT_MAX, FLT_MAX);
    float3 max = float3(-FLT_MAX, -FLT_MAX, -FLT_MAX);
    const NodeDict& nodes = Nodes();
    for(auto nodeIt = nodes.begin(); nodeIt != nodes.end(); ++nodeIt)
    {
        Node* node = nodeIt->second;
        for(auto geoIt = node->geometries.begin(); geoIt != node->geometries.end(); ++geoIt)
        {
            Geometry * geo = (*geoIt);
            AABB bbox = geo->mesh->bounds;
            bbox.Transform(m_nodeTransforms[node->index]);
            min = minimize(min, bbox.Min());
            max = maximize(max, bbox.Max());
        }
    }
    // note: min & max already transformed by entire object world matrix
    m_bounds = AABB(min, max);
}
开发者ID:Clever-Boy,项目名称:XLE,代码行数:28,代码来源:Model.cpp

示例3:

OBB operator *(const Quat &transform, const AABB &aabb)
{
	return aabb.Transform(transform);
}
开发者ID:ChunHungLiu,项目名称:MathGeoLib,代码行数:4,代码来源:AABB.cpp

示例4: Update

void CurveGob::Update(const FrameTime& fr, UpdateTypeEnum updateType)
{
    bool boundDirty = m_boundsDirty;
    super::Update(fr,updateType);
    m_boundsDirty = boundDirty;

    if(!m_boundsDirty) return;

    m_mesh.pos.clear();    
    if(m_needsRebuild)
    {        
        SAFE_DELETE(m_mesh.vertexBuffer);
    }

    if(m_points.size()<2)
    {
        m_localBounds = AABB(float3(-0.5f,-0.5f,-0.5f), float3(0.5f,0.5f,0.5f));
        UpdateWorldAABB();       
        return;
    }

    // compute local bounds.
    m_localBounds =  m_points[0]->GetLocalBounds();
    m_localBounds.Transform(m_points[0]->GetTransform());
    for( auto it = m_points.begin(); it != m_points.end(); ++it)
    {
        (*it)->Update(fr,updateType);
        AABB local = (*it)->GetLocalBounds();
        local.Transform((*it)->GetTransform());
        m_localBounds.Extend(local);
    }

    // compute world bound.
    float3 min,max;
    min = m_points[0]->GetBounds().Min();
    max = m_points[0]->GetBounds().Max();
    for( auto it = m_points.begin(); it != m_points.end(); ++it)
    {
        min = minimize(min, (*it)->GetBounds().Min());
        max = maximize(max, (*it)->GetBounds().Max());
    }
    m_bounds = AABB(min,max);                    
    m_boundsDirty = false;
    std::vector<float3> verts;
    switch(m_type)
    {
    default:
        Logger::Log(OutputMessageType::Error, "Invalid curve type, '%d'\n", m_type);
        // fall through and just pretend it is Linear

    case Linear:
        {// add all the normal control point positions
            
            for(auto it = m_points.begin(); it != m_points.end(); ++it)
            {
                float3 vert = float3(&(*it)->GetTransform().M41);
                verts.push_back(vert);
            }
            if(m_closed)
            {
                verts.push_back(verts[0]);
            }
            break;
        }
    case CatmullRom:
        {          
            std::vector<float3> points;
            //// since catmull-rom interpolation requires additional points, we want to calculate
            //// to 'fake' points to be the endpoints. That way our line will exists for all the
            //// actual control points.
            size_t size = m_points.size();
            if(m_closed)
            {
                // add the last point before others for consistent interpolation
                points.push_back(float3(&m_points[size-1]->GetTransform().M41));
            }
            else
            {
                // add an extra point in front of the 1st control point for interpolation
                float3 p1(&m_points[0]->GetTransform().M41);
                float3 p2(&m_points[1]->GetTransform().M41);
                float3 delta = p1 - p2; // from p2 to p1
                points.push_back(p1 + delta);
            }

            // add all normal control point positions
            for(auto it = m_points.begin(); it != m_points.end(); ++it)
            {
                points.push_back(float3(&(*it)->GetTransform().M41));
            }

            if(m_closed)
            {
                // add first and second points for consistent interpolation
                points.push_back(&m_points[0]->GetTransform().M41);
                points.push_back(&m_points[1]->GetTransform().M41);
            }
            else
            {
                // add an extra point in after of the last control point for interpolation
//.........这里部分代码省略.........
开发者ID:Anters,项目名称:LevelEditor,代码行数:101,代码来源:CurveGob.cpp

示例5: UpdateLightCamera

//---------------------------------------------------------------------------
void ShadowMaps::UpdateLightCamera( ID3D11DeviceContext* dc, const DirLight* light, const AABB& renderedArea )
{
    float3 worldUp(0,1,0);
    float3 lightDir = normalize(light->dir);

    // compute ligtcam params.
    float dt = dot(-lightDir, worldUp);
    float3 center = renderedArea.GetCenter();
    float dim = length(renderedArea.Max() - renderedArea.Min());
    float radi = dim * 0.5f;

    float3 camPos = center - (radi * lightDir);
    float3 up;
    float3 right;

    if ((dt + Epsilon) >= 1)
    {
        up = float3(0, 0, -1);
        right = float3(1, 0, 0);

    }
    else
    {
        right = normalize(cross(lightDir, worldUp));
        up = normalize(cross(right, lightDir));
        right = cross(lightDir, worldUp);
        up = cross(right, lightDir);
    }


    // create view matrix from right, up and look, and position.
     float rp = -dot(right, camPos);
     float upp = -dot(up, camPos);
     float zp = dot(lightDir, camPos);
     Matrix view(
                right.x, up.x, -lightDir.x, 0.0f,
                right.y, up.y, -lightDir.y, 0.0f,
                right.z, up.z, -lightDir.z, 0.0f,
                rp, upp, zp, 1.0f);

    // compute the width, height, near, far by transforming the AABB into view space.
    AABB lbounds = renderedArea;
    lbounds.Transform(view);
    float3 vmin = lbounds.Min();
    float3 vmax = lbounds.Max();
    float width = vmax.x - vmin.x;
    float height = vmax.y - vmin.y;
    float nearz = 0.0f;
    float farz = dim;

    Matrix proj = Matrix::CreateOrthographic(width,height, nearz, farz);
    //Matrix proj = Matrix::CreateOrthographicOffCenter(vmin.x, vmax.x, vmin.y, vmax.y, nearz, farz);
    m_lightCamera.SetViewProj(view, proj);

    // update cb        
    m_cbShadow.Data.texelSize  = ( 1.0f / MapSize() );        

    // udpate constant buffer using lightcamera.
    // transform coords from NDC space to texture space.
    float4x4 ndcToTexSpace(  0.5f,  0.0f, 0.0f, 0.0f,
                             0.0f, -0.5f, 0.0f, 0.0f,
                             0.0f,  0.0f, 1.0f, 0.0f,
                             0.5f,  0.5f, 0.0f, 1.0f);
                                 
    float4x4 shadowViewProjection = (m_lightCamera.View() * m_lightCamera.Proj()) * ndcToTexSpace;
    Matrix::Transpose(shadowViewProjection, m_cbShadow.Data.xform);    
    m_cbShadow.Update(dc);
}
开发者ID:Anters,项目名称:LevelEditor,代码行数:69,代码来源:ShadowMaps.cpp


注:本文中的AABB::Transform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。