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


C++ Box3f::center方法代码示例

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


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

示例1: frame

void BackdropNodeGadget::frame( const std::vector<Gaffer::Node *> &nodes )
{
	GraphGadget *graph = ancestor<GraphGadget>();
	if( !graph )
	{
		return;
	}
	
	Box3f b;
	for( std::vector<Node *>::const_iterator it = nodes.begin(), eIt = nodes.end(); it != eIt; ++it )
	{
		NodeGadget *nodeGadget = graph->nodeGadget( *it );
		if( nodeGadget )
		{
			b.extendBy( nodeGadget->transformedBound( NULL ) );
		}
	}
	
	if( b.isEmpty() )
	{
		return;
	}
	
	graph->setNodePosition( node(), V2f( b.center().x, b.center().y ) );
	
	V2f s( b.size().x / 2.0f, b.size().y / 2.0f );
	
	boundPlug()->setValue(
		Box2f( 
			V2f( -s ) - V2f( g_margin ),
			V2f( s ) + V2f( g_margin + 2.0f * g_margin )
		)
	);
}
开发者ID:JohanAberg,项目名称:gaffer,代码行数:34,代码来源:BackdropNodeGadget.cpp

示例2: frame

void CameraController::frame( const Imath::Box3f &box, const Imath::V3f &viewDirection, const Imath::V3f &upVector )
{
	// make a matrix to centre the camera on the box, with the appropriate view direction
	M44f cameraMatrix = rotationMatrixWithUpDir( V3f( 0, 0, -1 ), viewDirection, upVector );
	M44f translationMatrix;
	translationMatrix.translate( box.center() );
	cameraMatrix *= translationMatrix;

	// translate the camera back until the box is completely visible
	M44f inverseCameraMatrix = cameraMatrix.inverse();
	Box3f cBox = transform( box, inverseCameraMatrix );

	Box2f screenWindow = m_data->screenWindow->readable();
	if( m_data->projection->readable()=="perspective" )
	{
		// perspective. leave the field of view and screen window as is and translate
		// back till the box is wholly visible. this currently assumes the screen window
		// is centred about the camera axis.
		float z0 = cBox.size().x / screenWindow.size().x;
		float z1 = cBox.size().y / screenWindow.size().y;

		m_data->centreOfInterest = std::max( z0, z1 ) / tan( M_PI * m_data->fov->readable() / 360.0 ) + cBox.max.z +
			m_data->clippingPlanes->readable()[0];

		cameraMatrix.translate( V3f( 0.0f, 0.0f, m_data->centreOfInterest ) );
	}
	else
	{
		// orthographic. translate to front of box and set screen window
		// to frame the box, maintaining the aspect ratio of the screen window.
		m_data->centreOfInterest = cBox.max.z + m_data->clippingPlanes->readable()[0] + 0.1; // 0.1 is a fudge factor
		cameraMatrix.translate( V3f( 0.0f, 0.0f, m_data->centreOfInterest ) );

		float xScale = cBox.size().x / screenWindow.size().x;
		float yScale = cBox.size().y / screenWindow.size().y;
		float scale = std::max( xScale, yScale );

		V2f newSize = screenWindow.size() * scale;
		screenWindow.min.x = cBox.center().x - newSize.x / 2.0f;
		screenWindow.min.y = cBox.center().y - newSize.y / 2.0f;
		screenWindow.max.x = cBox.center().x + newSize.x / 2.0f;
		screenWindow.max.y = cBox.center().y + newSize.y / 2.0f;
	}

	m_data->transform->matrix = cameraMatrix;
	m_data->screenWindow->writable() = screenWindow;
}
开发者ID:davidsminor,项目名称:cortex,代码行数:47,代码来源:CameraController.cpp

示例3: inputNoduleContainer

Imath::Box3f StandardNodeGadget::bound() const
{
	Box3f b = IndividualContainer::bound();
	
	LinearContainer::Orientation orientation = inputNoduleContainer()->getOrientation();

	if( orientation == LinearContainer::X )
	{
		// enforce a minimum width
		float width = std::max( b.size().x, g_minWidth );
		float c = b.center().x;
		b.min.x = c - width / 2.0f;
		b.max.x = c + width / 2.0f;
	}
	
	// add the missing spacing to the border if we have no nodules on a given side
			
	Box3f inputContainerBound = inputNoduleContainer()->transformedBound( this );
	Box3f outputContainerBound = outputNoduleContainer()->transformedBound( this );
	if( inputContainerBound.isEmpty() )
	{
		if( orientation == LinearContainer::X )
		{
			b.max.y += g_spacing + g_borderWidth;
		}
		else
		{
			b.min.x -= g_spacing + g_borderWidth;		
		}
	}
	
	if( outputContainerBound.isEmpty() )
	{
		if( orientation == LinearContainer::X )
		{
			b.min.y -= g_spacing + g_borderWidth;
		}
		else
		{
			b.max.x += g_spacing + g_borderWidth;
		}
	}
	
	// add on a little bit in the major axis, so that the nodules don't get drawn in the frame corner
	
	if( orientation == LinearContainer::X )
	{
		b.min.x -= g_borderWidth;
		b.max.x += g_borderWidth;
	}
	else
	{
		b.min.y -= g_borderWidth;
		b.max.y += g_borderWidth;
	}
	
	return b;
}
开发者ID:7on7on,项目名称:gaffer,代码行数:58,代码来源:StandardNodeGadget.cpp

示例4: renderLabel

void StandardNodule::renderLabel( const Style *style ) const
{
	const NodeGadget *nodeGadget = ancestor<NodeGadget>();
	if( !nodeGadget )
	{
		return;
	}

	const std::string &label = plug()->getName().string();

	// we rotate the label based on the angle the connection exits the node at.
	V3f tangent = nodeGadget->noduleTangent( this );
	float theta = IECore::radiansToDegrees( atan2f( tangent.y, tangent.x ) );

	// but we don't want the text to be vertical, so we bend it away from the
	// vertical axis.
	if( ( theta > 0.0f && theta < 90.0f ) || ( theta < 0.0f && theta >= -90.0f ) )
	{
		theta = sign( theta ) * lerp( 0.0f, 45.0f, fabs( theta ) / 90.0f );
	}
	else
	{
		theta = sign( theta ) * lerp( 135.0f, 180.0f, (fabs( theta ) - 90.0f) / 90.0f );
	}

	// we also don't want the text to be upside down, so we correct the rotation
	// if that would be the case.
	Box3f labelBound = style->textBound( Style::LabelText, label );
	V2f anchor( labelBound.min.x - 1.0f, labelBound.center().y );

	if( theta > 90.0f || theta < -90.0f )
	{
		theta = theta - 180.0f;
		anchor.x = labelBound.max.x + 1.0f;
	}

	// now we can actually do the rendering.

	if( getHighlighted() )
	{
		glScalef( 1.2, 1.2, 1.2 );
	}

	glRotatef( theta, 0, 0, 1.0f );
	glTranslatef( -anchor.x, -anchor.y, 0.0f );

	style->renderText( Style::LabelText, label );
}
开发者ID:cedriclaunay,项目名称:gaffer,代码行数:48,代码来源:StandardNodule.cpp

示例5: getTransformationToBox

static Mat4f getTransformationToBox(Box3f box)
{
	// T_to_box to transform the unit circle in the bounding box
    Vec3f mid=box.center();
    Vec3f size=box.size();


	float max_size=box.maxsize();
	size=Vec3f(max_size,max_size,max_size);

    float cos_pi_4= cos((float)M_PI/4.0);

	float _mat[16]={
	   size.x?(0.5*size.x/cos_pi_4):1.0f , 0                                , 0                               , mid.x,  
	   0                                 , size.y?(0.5*size.y/cos_pi_4):1.0f, 0                               , mid.y, 
	   0                                 , 0                                , size.z?0.5*size.z/cos_pi_4:1.0f , mid.z, 
	   0                                 , 0                                , 0                               , 1    
	};

    Mat4f T_to_box=Mat4f(_mat);
	return T_to_box;
}
开发者ID:blackvladimir,项目名称:pyplasm,代码行数:22,代码来源:manipulator.cpp

示例6: createBox

Mesh Mesh::createBox(const Box3f &box) {
    Vector3f center = box.center();
    Vector3f extents = box.extents() * 0.5;
    Mesh mesh;
    int i = 0;
    for (int f = 0; f < 3; ++f) {
        for (int s = -1; s <= 1; s += 2) {
            Vector3f p(center), n(0.f), u(0.f), v(0.f);
            p[f] += extents[f] * s;
            n[f] = s;
            u[(f + 1) % 3] = extents[(f + 1) % 3];
            v[(f + 2) % 3] = extents[(f + 2) % 3];
            mesh.addVertex(p - u - v, n, Vector2f(0.f, 0.f));
            mesh.addVertex(p + u - v, n, Vector2f(1.f, 0.f));
            mesh.addVertex(p - u + v, n, Vector2f(0.f, 1.f));
            mesh.addVertex(p + u + v, n, Vector2f(1.f, 1.f));
            mesh.addTriangle(i, i + 1, i + 2);
            mesh.addTriangle(i + 1, i + 2, i + 3);
            i += 4;
        }
    }
    return mesh;
}
开发者ID:Seashell2011,项目名称:pbsproject,代码行数:23,代码来源:Mesh.cpp

示例7: prepareForRender

void MultiQuadLight::prepareForRender()
{
    Bvh::PrimVector prims;
    prims.reserve(_geometry.size());

    _bounds = Box3f();

    for (int i = 0; i < _geometry.size(); ++i) {
        Box3f bounds = _geometry.bounds(i);
        _bounds.grow(bounds);

        prims.emplace_back(bounds, bounds.center(), i);
    }

    _triangleAreas.resize(_geometry.triangleCount());
    for (int i = 0; i < _geometry.triangleCount(); ++i) {
        const QuadGeometry::TriangleInfo &t = _geometry.triangle(i);
        _triangleAreas[i] = MathUtil::triangleArea(t.p0, t.p1, t.p2);
    }

    _bvh.reset(new Bvh::BinaryBvh(std::move(prims), 1));

    constructSampleBounds();
}
开发者ID:ProjectAsura,项目名称:tungsten,代码行数:24,代码来源:MultiQuadLight.cpp

示例8:

// static
Box3f Box3f::scale( const Box3f& b, const Vector3f& s )
{
    Vector3f size = s * b.size;
    return{ b.center() - 0.5f * size, size };
}
开发者ID:jiawen,项目名称:libcgt,代码行数:6,代码来源:Box3f.cpp


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