• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ V3fVectorDataPtr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中V3fVectorDataPtr的典型用法代码示例。如果您正苦于以下问题:C++ V3fVectorDataPtr类的具体用法?C++ V3fVectorDataPtr怎么用?C++ V3fVectorDataPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: dagPath

IECoreScene::PrimitiveVariable FromMayaMeshConverter::points() const
{
	MFnMesh fnMesh;
	const MDagPath *d = dagPath( true );
	if( d )
	{
		fnMesh.setObject( *d );
	}
	else
	{
		fnMesh.setObject( object() );
	}

	V3fVectorDataPtr points = new V3fVectorData;
	points->setInterpretation( GeometricData::Point );
	int numVerts = fnMesh.numVertices();
	points->writable().resize( numVerts );

	if( space() == MSpace::kObject )
	{
		const V3f* rawPoints = ( const V3f* )fnMesh.getRawPoints(0);
		copy( rawPoints, rawPoints + numVerts, points->writable().begin() );
	}
	else
	{
		MFloatPointArray mPoints;
		fnMesh.getPoints( mPoints, space() );
		std::transform( MArrayIter<MFloatPointArray>::begin( mPoints ), MArrayIter<MFloatPointArray>::end( mPoints ), points->writable().begin(), VecConvert<MFloatPoint, V3f>() );
	}

	return PrimitiveVariable( PrimitiveVariable::Vertex, points );
}
开发者ID:appleseedhq,项目名称:cortex,代码行数:32,代码来源:FromMayaMeshConverter.cpp


示例2: addWireframeCurveState

IECoreGL::ConstRenderablePtr StandardLightVisualiser::pointRays()
{
    IECoreGL::GroupPtr group = new IECoreGL::Group();
    addWireframeCurveState( group.get() );

    IECore::CompoundObjectPtr parameters = new CompoundObject;
    parameters->members()["aimType"] = new IntData( 1 );
    group->getState()->add(
        new IECoreGL::ShaderStateComponent( ShaderLoader::defaultShaderLoader(), TextureLoader::defaultTextureLoader(), faceCameraVertexSource(), "", IECoreGL::Shader::constantFragmentSource(), parameters )
    );

    IntVectorDataPtr vertsPerCurve = new IntVectorData;
    V3fVectorDataPtr p = new V3fVectorData;

    const int numRays = 8;
    for( int i = 0; i < numRays; ++i )
    {
        const float angle = M_PI * 2.0f * float(i)/(float)numRays;
        const V2f dir( cos( angle ), sin( angle ) );
        addRay( dir * .5, dir * 1, vertsPerCurve->writable(), p->writable() );
    }

    IECoreGL::CurvesPrimitivePtr curves = new IECoreGL::CurvesPrimitive( IECore::CubicBasisf::linear(), false, vertsPerCurve );
    curves->addPrimitiveVariable( "P", IECore::PrimitiveVariable( IECore::PrimitiveVariable::Vertex, p ) );
    curves->addPrimitiveVariable( "Cs", IECore::PrimitiveVariable( IECore::PrimitiveVariable::Constant, new Color3fData( Color3f( 1.0f, 0.835f, 0.07f ) ) ) );

    group->addChild( curves );

    return group;
}
开发者ID:HughMacdonald,项目名称:gaffer,代码行数:30,代码来源:StandardLightVisualiser.cpp


示例3: V3fVectorData

IECore::ObjectPtr FromNukePointsConverter::doConversion( IECore::ConstCompoundObjectPtr operands ) const
{

	// get points
	V3fVectorDataPtr p = new V3fVectorData();
	if( const DD::Image::PointList *pl = m_geo->point_list() )
	{
		p->writable().resize( pl->size() );
		std::transform( pl->begin(), pl->end(), p->writable().begin(), IECore::convert<Imath::V3f, DD::Image::Vector3> );
	}

	PointsPrimitivePtr result = new PointsPrimitive( p );

	// get colour
	const DD::Image::Attribute *colorAttr = m_geo->get_typed_attribute( "Cf", DD::Image::VECTOR4_ATTRIB );
	if( colorAttr && colorAttr->size()==result->getNumPoints() )
	{
		Color3fVectorDataPtr colorData = new Color3fVectorData();
		colorData->writable().resize( result->getNumPoints() );
		std::transform( colorAttr->vector4_list->begin(), colorAttr->vector4_list->end(), colorData->writable().begin(), IECore::convert<Imath::Color3f, DD::Image::Vector4> );
		result->variables["Cs"] = PrimitiveVariable( PrimitiveVariable::Vertex, colorData );
	}

	/// \todo Other primitive variables

	return result;
}
开发者ID:ImageEngine,项目名称:cortex,代码行数:27,代码来源:FromNukePointsConverter.cpp


示例4: setTopology

MeshPrimitive::MeshPrimitive( ConstIntVectorDataPtr verticesPerFace, ConstIntVectorDataPtr vertexIds,
                              const std::string &interpolation, V3fVectorDataPtr p )
{
    setTopology( verticesPerFace, vertexIds, interpolation );
    if( p )
    {
        V3fVectorDataPtr pData = p->copy();
        pData->setInterpretation( GeometricData::Point );
        variables.insert( PrimitiveVariableMap::value_type("P", PrimitiveVariable(PrimitiveVariable::Vertex, pData)) );
    }
}
开发者ID:,项目名称:,代码行数:11,代码来源:


示例5: setTopology

NURBSPrimitive::NURBSPrimitive( int uOrder, ConstFloatVectorDataPtr uKnot, float uMin, float uMax,
	int vOrder, ConstFloatVectorDataPtr vKnot, float vMin, float vMax, ConstV3fVectorDataPtr p )
{
	setTopology( uOrder, uKnot, uMin, uMax, vOrder, vKnot, vMin, vMax );
	if( p )
	{
		V3fVectorDataPtr pData = p->copy();
		pData->setInterpretation( GeometricData::Point );
		variables.insert( PrimitiveVariableMap::value_type( "P", PrimitiveVariable( PrimitiveVariable::Vertex, pData ) ) );
	}
}
开发者ID:AtomicFiction,项目名称:cortex,代码行数:11,代码来源:NURBSPrimitive.cpp


示例6: m_basis

CurvesPrimitive::CurvesPrimitive( ConstIntVectorDataPtr vertsPerCurve, const CubicBasisf &basis, bool periodic, ConstV3fVectorDataPtr p )
	: 	m_basis( CubicBasisf::linear() )
{
	setTopology( vertsPerCurve, basis, periodic );

	if( p )
	{
		V3fVectorDataPtr pData = p->copy();
		pData->setInterpretation( GeometricData::Point );
		variables["P"] = PrimitiveVariable( PrimitiveVariable::Vertex, pData );
	}
}
开发者ID:ImageEngine,项目名称:cortex,代码行数:12,代码来源:CurvesPrimitive.cpp


示例7: pointParameter

ObjectPtr PointNormalsOp::doOperation( const CompoundObject *operands )
{
	const int numNeighbours = m_numNeighboursParameter->getNumericValue();

	const Object * points = pointParameter()->getValue();
	ObjectPtr result = nullptr;
	switch( points->typeId() )
	{
		case V3fVectorDataTypeId :
			{
				V3fVectorDataPtr resultT = new V3fVectorData;
				normals<V3f>( static_cast<const V3fVectorData *>( points )->readable(), numNeighbours, resultT->writable() );
				result = resultT;
			}
			break;
		case V3dVectorDataTypeId :
			{
				V3dVectorDataPtr resultT = new V3dVectorData;
				normals<V3d>( static_cast<const V3dVectorData *>( points )->readable(), numNeighbours, resultT->writable() );
				result = resultT;
			}
			break;
		default :
			// should never get here
			assert( 0 );
	}

	return result;
}
开发者ID:ImageEngine,项目名称:cortex,代码行数:29,代码来源:PointNormalsOp.cpp


示例8: shaderPlug

IECore::ConstObjectPtr OSLObject::computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const
{
	const Primitive *inputPrimitive = runTimeCast<const Primitive>( inputObject.get() );
	if( !inputPrimitive )
	{
		return inputObject;
	}

	if( !inputPrimitive->variableData<V3fVectorData>( "P", PrimitiveVariable::Vertex ) )
	{
		return inputObject;
	}

	OSLRenderer::ConstShadingEnginePtr shadingEngine = OSLImage::shadingEngine( shaderPlug() );
	if( !shadingEngine )
	{
		return inputObject;	
	}
	
	CompoundDataPtr shadingPoints = new CompoundData;
	for( PrimitiveVariableMap::const_iterator it = inputPrimitive->variables.begin(), eIt = inputPrimitive->variables.end(); it != eIt; ++it )
	{
		if( it->second.interpolation == PrimitiveVariable::Vertex )
		{
			// cast is ok - we're only using it to be able to reference the data from the shadingPoints,
			// but nothing will modify the data itself.
			shadingPoints->writable()[it->first] = constPointerCast<Data>( it->second.data );
		}
	}

	PrimitivePtr outputPrimitive = inputPrimitive->copy();

	ConstCompoundDataPtr shadedPoints = shadingEngine->shade( shadingPoints );
	const std::vector<Color3f> &ci = shadedPoints->member<Color3fVectorData>( "Ci" )->readable();
	
	V3fVectorDataPtr p = new V3fVectorData;
	p->writable().reserve( ci.size() );
	std::copy( ci.begin(), ci.end(), back_inserter( p->writable() ) );
	
	outputPrimitive->variables["P"] = PrimitiveVariable( PrimitiveVariable::Vertex, p );

	/// \todo Allow shaders to write arbitrary primitive variables.
			
	return outputPrimitive;
}
开发者ID:7on7on,项目名称:gaffer,代码行数:45,代码来源:OSLObject.cpp


示例9: shade

IECore::CompoundDataPtr IECoreRI::SXRendererImplementation::shadePlane( const V2i &resolution ) const
{
	IECore::CompoundDataPtr points = new IECore::CompoundData();
	
	V3fVectorDataPtr pData = new IECore::V3fVectorData();
	V3fVectorDataPtr nData = new IECore::V3fVectorData();
	FloatVectorDataPtr sData = new IECore::FloatVectorData();
	FloatVectorDataPtr tData = new IECore::FloatVectorData();

	std::vector<V3f> &p = pData->writable();
	std::vector<V3f> &n = nData->writable();
	std::vector<float> &s = sData->writable();
	std::vector<float> &t = tData->writable();
	
	unsigned numPoints = resolution[0] * resolution[1];
	
	p.resize( numPoints );
	n.resize( numPoints );
	s.resize( numPoints );
	t.resize( numPoints );
	
	unsigned xResMinus1 = resolution[0] - 1;
	unsigned yResMinus1 = resolution[1] - 1;
	
	unsigned i = 0;
	for( int y = 0; y < resolution[1]; y++ )
	{
		for( int x = 0; x < resolution[0]; x++ )
		{
			p[i] = V3f( float(x) / xResMinus1 , float(y) / yResMinus1, 0.0 );	
			s[i] = p[i][0];
			t[i] = p[i][1];
			n[i] = V3f( 0.0f, 0.0f, 1.0f );
			i++;
		}
	}	
	
	points->writable()[ "P" ] = pData;
	points->writable()[ "N" ] = nData;
	points->writable()[ "s" ] = sData;
	points->writable()[ "t" ] = tData;
	
	return shade( points, resolution );
}
开发者ID:engmsaleh,项目名称:cortex,代码行数:44,代码来源:SXRendererImplementation.cpp


示例10: createBox

CurvesPrimitivePtr CurvesPrimitive::createBox( const Imath::Box3f &b )
{
	IntVectorDataPtr vertsPerCurveData = new IntVectorData;
	std::vector<int> &vertsPerCurve = vertsPerCurveData->writable();
	vertsPerCurve.reserve( 6 );

	V3fVectorDataPtr pData = new V3fVectorData;
	std::vector<V3f> &p = pData->writable();
	p.reserve( 18 );

	vertsPerCurve.push_back( 5 );
	p.push_back( b.min );
	p.push_back( V3f( b.max.x, b.min.y, b.min.z ) );
	p.push_back( V3f( b.max.x, b.min.y, b.max.z ) );
	p.push_back( V3f( b.min.x, b.min.y, b.max.z ) );
	p.push_back( b.min );

	vertsPerCurve.push_back( 5 );
	p.push_back( V3f( b.min.x, b.max.y, b.min.z ) );
	p.push_back( V3f( b.max.x, b.max.y, b.min.z ) );
	p.push_back( V3f( b.max.x, b.max.y, b.max.z ) );
	p.push_back( V3f( b.min.x, b.max.y, b.max.z ) );
	p.push_back( V3f( b.min.x, b.max.y, b.min.z ) );

	vertsPerCurve.push_back( 2 );
	p.push_back( b.min );
	p.push_back( V3f( b.min.x, b.max.y, b.min.z ) );

	vertsPerCurve.push_back( 2 );
	p.push_back( V3f( b.max.x, b.min.y, b.min.z ) );
	p.push_back( V3f( b.max.x, b.max.y, b.min.z ) );

	vertsPerCurve.push_back( 2 );
	p.push_back( V3f( b.max.x, b.min.y, b.max.z ) );
	p.push_back( V3f( b.max.x, b.max.y, b.max.z ) );

	vertsPerCurve.push_back( 2 );
	p.push_back( V3f( b.min.x, b.min.y, b.max.z ) );
	p.push_back( V3f( b.min.x, b.max.y, b.max.z ) );

	return new CurvesPrimitive( vertsPerCurveData, CubicBasisf::linear(), false, pData );
}
开发者ID:ImageEngine,项目名称:cortex,代码行数:42,代码来源:CurvesPrimitive.cpp


示例11: computeObject

IECore::ConstObjectPtr Grid::computeObject( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
	if( path.size() == 2 )
	{
		IntVectorDataPtr vertsPerCurveData = new IntVectorData;
		vector<int> &vertsPerCurve = vertsPerCurveData->writable();

		V3fVectorDataPtr pData = new V3fVectorData;
		pData->setInterpretation( GeometricData::Point );
		vector<V3f> &p = pData->writable();

		bool periodic = false;
		Color3f cs( 1 );

		const V2f halfDimensions = dimensionsPlug()->getValue() / 2.0f;
		if( path.back() == g_gridLinesName )
		{
			const float spacing = spacingPlug()->getValue();
			const V2i n = V2f( halfDimensions / spacing ) - V2f( 0.01 );
			for( int d = 0; d < 2; ++d )
			{
				const int d0 = d;
				const int d1 = d == 0 ? 1 : 0;
				for( int i = -n[d]; i <= n[d]; ++i )
				{
					if( i == 0 )
					{
						continue;
					}
					vertsPerCurve.push_back( 2 );
					V3f e( 0 );
					e[d0] = i * spacing;
					e[d1] = -halfDimensions[d1];
					p.push_back( e );
					e[d1] = halfDimensions[d1];
					p.push_back( e );
				}
			}
			cs = gridColorPlug()->getValue();
		}
		else if( path.back() == g_centerLinesName )
		{
			vertsPerCurve.push_back( 2 );
			p.push_back( V3f( halfDimensions.x, 0, 0 ) );
			p.push_back( V3f( -halfDimensions.x, 0, 0 ) );
			vertsPerCurve.push_back( 2 );
			p.push_back( V3f( 0, halfDimensions.y, 0 ) );
			p.push_back( V3f( 0, -halfDimensions.y, 0 ) );
			cs = centerColorPlug()->getValue();
		}
		else if( path.back() == g_borderLinesName )
		{
			vertsPerCurve.push_back( 4 );
			p.push_back( V3f( -halfDimensions.x, -halfDimensions.y, 0 ) );
			p.push_back( V3f( halfDimensions.x, -halfDimensions.y, 0 ) );
			p.push_back( V3f( halfDimensions.x, halfDimensions.y, 0 ) );
			p.push_back( V3f( -halfDimensions.x, halfDimensions.y, 0 ) );
			periodic = true;
			cs = borderColorPlug()->getValue();
		}

		CurvesPrimitivePtr result = new CurvesPrimitive( vertsPerCurveData, CubicBasisf::linear(), periodic, pData );
		result->variables["Cs"] = PrimitiveVariable( PrimitiveVariable::Constant, new Color3fData( cs ) );
		return result;
	}
	return outPlug()->objectPlug()->defaultValue();
}
开发者ID:cwmartin,项目名称:gaffer,代码行数:67,代码来源:Grid.cpp


示例12: imageParameter

ObjectPtr EnvMapSampler::doOperation( const CompoundObject * operands )
{
	ImagePrimitivePtr image = static_cast<ImagePrimitive *>( imageParameter()->getValue() )->copy();
	Box2i dataWindow = image->getDataWindow();

	// find the rgb channels
	ConstFloatVectorDataPtr redData = image->getChannel<float>( "R" );
	ConstFloatVectorDataPtr greenData = image->getChannel<float>( "G" );
	ConstFloatVectorDataPtr blueData = image->getChannel<float>( "B" );
	if( !(redData && greenData && blueData) )
	{
		throw Exception( "Image does not contain valid RGB float channels." );
	}
	const vector<float> &red = redData->readable();
	const vector<float> &green = greenData->readable();
	const vector<float> &blue = blueData->readable();

	// get a luminance channel
	LuminanceOpPtr luminanceOp = new LuminanceOp();
	luminanceOp->inputParameter()->setValue( image );
	luminanceOp->copyParameter()->getTypedValue() = false;
	luminanceOp->removeColorPrimVarsParameter()->getTypedValue() = false;
	luminanceOp->operate();

	// do the median cut thing to get some samples
	MedianCutSamplerPtr sampler = new MedianCutSampler;
	sampler->imageParameter()->setValue( image );
	sampler->subdivisionDepthParameter()->setNumericValue( subdivisionDepthParameter()->getNumericValue() );
	ConstCompoundObjectPtr samples = boost::static_pointer_cast<CompoundObject>( sampler->operate() );
	const vector<V2f> &centroids = boost::static_pointer_cast<V2fVectorData>( samples->members().find( "centroids" )->second )->readable();
	const vector<Box2i> &areas = boost::static_pointer_cast<Box2iVectorData>( samples->members().find( "areas" )->second )->readable();

	// get light directions and colors from the samples
	V3fVectorDataPtr directionsData = new V3fVectorData;
	Color3fVectorDataPtr colorsData = new Color3fVectorData;
	vector<V3f> &directions = directionsData->writable();
	vector<Color3f> &colors = colorsData->writable();

	float radiansPerPixel = M_PI / (dataWindow.size().y + 1);
	float angleAtTop = ( M_PI - radiansPerPixel ) / 2.0f;

	for( unsigned i=0; i<centroids.size(); i++ )
	{
		const Box2i &area = areas[i];
		Color3f color( 0 );
		for( int y=area.min.y; y<=area.max.y; y++ )
		{
			int yRel = y - dataWindow.min.y;

			float angle = angleAtTop - yRel * radiansPerPixel;
			float weight = cosf( angle );
			int index = (area.min.x - dataWindow.min.x) + (dataWindow.size().x + 1 ) * yRel;
			for( int x=area.min.x; x<=area.max.x; x++ )
			{
				color[0] += weight * red[index];
				color[1] += weight * green[index];
				color[2] += weight * blue[index];
				index++;
			}
		}
		color /= red.size();
		colors.push_back( color );

		float phi = angleAtTop - (centroids[i].y - dataWindow.min.y) * radiansPerPixel;

		V3f direction;
		direction.y = sinf( phi );
		float r = cosf( phi );
		float theta = 2 * M_PI * lerpfactor( (float)centroids[i].x, (float)dataWindow.min.x, (float)dataWindow.max.x );
		direction.x = r * cosf( theta );
		direction.z = r * sinf( theta );

		directions.push_back( -direction ); // negated so we output the direction the light shines in
	}

	// return the result
	CompoundObjectPtr result = new CompoundObject;
	result->members()["directions"] = directionsData;
	result->members()["colors"] = colorsData;
	return result;
}
开发者ID:AtomicFiction,项目名称:cortex,代码行数:81,代码来源:EnvMapSampler.cpp


示例13: InvalidArgumentException

void YUVImageWriter::writeImage( const vector<string> &names, const ImagePrimitive * image, const Box2i &dataWindow ) const
{
	const V2f &kBkR = m_kBkRParameter->getTypedValue();
	const Box3f &range = m_rangeParameter->getTypedValue();

	if ( range.isEmpty() )
	{
		throw InvalidArgumentException("YUVImageWriter: Empty YUV range specified ");
	}

	const float kB = kBkR.x;
	const float kR = kBkR.y;

	int displayWidth  = 1 + image->getDisplayWindow().size().x;
	int displayHeight = 1 + image->getDisplayWindow().size().y;

	if ( displayWidth % 2 != 0 || displayHeight % 2 != 0 )
	{
		throw IOException("YUVImageWriter: Unsupported resolution");
	}

	vector<string>::const_iterator rIt = std::find( names.begin(), names.end(), "R" );
	vector<string>::const_iterator gIt = std::find( names.begin(), names.end(), "G" );
	vector<string>::const_iterator bIt = std::find( names.begin(), names.end(), "B" );

	if ( rIt == names.end() || gIt == names.end() || bIt == names.end() )
	{
		throw IOException("YUVImageWriter: Unsupported channel names specified");
	}

	std::ofstream outFile( fileName().c_str(), std::ios::trunc | std::ios::binary | std::ios::out );
	if (! outFile.is_open() )
	{
		throw IOException("Could not open '" + fileName() + "' for writing.");
	}

	Color3fVectorDataPtr rgbData = new Color3fVectorData();
	rgbData->writable().resize( displayWidth * displayHeight, Color3f(0,0,0) );

	try
	{
		for ( vector<string>::const_iterator it = names.begin(); it != names.end(); it++ )
		{
			const string &name = *it;

			if (!( name == "R" || name == "G" || name == "B" ) )
			{
				msg( Msg::Warning, "YUVImageWriter", format( "Channel \"%s\" was not encoded." ) % name );
				continue;
			}

			int channelOffset = 0;
			if ( name == "R" )
			{
				channelOffset = 0;
			}
			else if ( name == "G" )
			{
				channelOffset = 1;
			}
			else
			{
				assert( name == "B" );
				channelOffset = 2;
			}

			// get the image channel
			assert( image->variables.find( name ) != image->variables.end() );
			DataPtr dataContainer = image->variables.find( name )->second.data;
			assert( dataContainer );

			ChannelConverter converter( *it, image, dataWindow, channelOffset, rgbData );

			despatchTypedData<
				ChannelConverter,
				TypeTraits::IsNumericVectorTypedData,
				ChannelConverter::ErrorHandler
			>( dataContainer, converter );

		}

		V3fVectorDataPtr yuvData = new V3fVectorData();
		yuvData->writable().resize( displayWidth * displayHeight, V3f(0,0,0) );

		assert( yuvData->readable().size() == rgbData->readable().size() );

		for ( int i = 0; i < displayWidth * displayHeight; i ++ )
		{
			Color3f rgb = rgbData->readable()[i];

			if ( rgb.x < 0.0 ) rgb.x = 0;
			if ( rgb.x > 1.0 ) rgb.x = 1.0;

			if ( rgb.y < 0.0 ) rgb.y = 0;
			if ( rgb.y > 1.0 ) rgb.y = 1.0;

			if ( rgb.z < 0.0 ) rgb.z = 0;
			if ( rgb.z > 1.0 ) rgb.z = 1.0;

			V3f yPbPr;
//.........这里部分代码省略.........
开发者ID:Alwnikrotikz,项目名称:cortex-vfx,代码行数:101,代码来源:YUVImageWriter.cpp


示例14: MeshPrimitive

IECore::ObjectPtr MeshFromNuke::doConversion( IECore::ConstCompoundObjectPtr operands ) const
{
	// topology
	IntVectorDataPtr verticesPerFaceData = new IntVectorData;
	IntVectorDataPtr vertexIdsData = new IntVectorData;
	std::vector<int> &verticesPerFace = verticesPerFaceData->writable();
	std::vector<int> &vertexIds = vertexIdsData->writable();

	unsigned numPrimitives = m_geo->primitives();
	const DD::Image::Primitive **primitives = m_geo->primitive_array();
	std::vector<unsigned> tmpFaceVertices;
	for( unsigned primIndex=0; primIndex<numPrimitives; primIndex++ )
	{
		const DD::Image::Primitive *prim = primitives[primIndex];

		unsigned numFaces = prim->faces();
		for( unsigned faceIndex=0; faceIndex<numFaces; faceIndex++ )
		{
			unsigned numFaceVertices = prim->face_vertices( faceIndex );
			verticesPerFace.push_back( numFaceVertices );
			tmpFaceVertices.resize( numFaceVertices );
			prim->get_face_vertices( faceIndex, &(tmpFaceVertices[0]) );
			for( unsigned i=0; i<numFaceVertices; i++ )
			{
				vertexIds.push_back( prim->vertex( tmpFaceVertices[i] ) );
			}
		}
	}

	MeshPrimitivePtr result = new MeshPrimitive( verticesPerFaceData, vertexIdsData, "linear" );

	// points
	if( const DD::Image::PointList *pl = m_geo->point_list() )
	{
		V3fVectorDataPtr p = new V3fVectorData();
		p->writable().resize( pl->size() );
		std::transform( pl->begin(), pl->end(), p->writable().begin(), IECore::convert<Imath::V3f, DD::Image::Vector3> );
		result->variables["P"] = PrimitiveVariable( PrimitiveVariable::Vertex, p );
	}

	// uvs
	PrimitiveVariable::Interpolation uvInterpolation = PrimitiveVariable::Vertex;
	const DD::Image::Attribute *uvAttr = m_geo->get_typed_group_attribute( DD::Image::Group_Points, "uv", DD::Image::VECTOR4_ATTRIB );
	if( !uvAttr )
	{
		uvAttr = m_geo->get_typed_group_attribute( DD::Image::Group_Vertices, "uv", DD::Image::VECTOR4_ATTRIB );
		uvInterpolation = PrimitiveVariable::FaceVarying;
	}

	if( uvAttr )
	{
		V2fVectorDataPtr uvData = new V2fVectorData();
		uvData->setInterpretation( GeometricData::UV );
		std::vector<Imath::V2f> &uvs = uvData->writable();
		uvs.reserve( uvAttr->size() );
		unsigned numUVs = uvAttr->size();
		for( unsigned i=0; i<numUVs; i++ )
		{
			// as of Cortex 10, we take a UDIM centric approach
			// to UVs, which clashes with Nuke, so we must flip
			// the v values during conversion.
			uvs.emplace_back( uvAttr->vector4( i ).x, 1.0 - uvAttr->vector4( i ).y );
		}
		result->variables["uv"] = PrimitiveVariable( uvInterpolation, uvData );
	}

	// normals
	PrimitiveVariable::Interpolation nInterpolation = PrimitiveVariable::Vertex;
	const DD::Image::Attribute *nAttr = m_geo->get_typed_group_attribute( DD::Image::Group_Points, "N", DD::Image::NORMAL_ATTRIB );
	if( !nAttr )
	{
		nAttr = m_geo->get_typed_group_attribute( DD::Image::Group_Vertices, "N", DD::Image::NORMAL_ATTRIB );
		nInterpolation = PrimitiveVariable::FaceVarying;
	}

	if( nAttr )
	{
		V3fVectorDataPtr nd = new V3fVectorData();
		std::vector<Imath::V3f> &n = nd->writable();
		n.resize( nAttr->size() );
		for( unsigned i=0; i<n.size(); i++ )
		{
			n[i] = IECore::convert<Imath::V3f, DD::Image::Vector3>( nAttr->normal( i ) );
		}
		result->variables["N"] = PrimitiveVariable( nInterpolation, nd );
	}

	return result;
}
开发者ID:ImageEngine,项目名称:cortex,代码行数:89,代码来源:MeshFromNuke.cpp


示例15: shadingPlug

IECore::ConstCompoundDataPtr OSLImage::computeShading( const Gaffer::Context *context ) const
{
	OSLRenderer::ConstShadingEnginePtr shadingEngine;
	if( const OSLShader *shader = runTimeCast<const OSLShader>( shaderPlug()->source<Plug>()->node() ) )
	{
		shadingEngine = shader->shadingEngine();
	}

	if( !shadingEngine )
	{
		return static_cast<const CompoundData *>( shadingPlug()->defaultValue() );
	}

	const V2i tileOrigin = context->get<V2i>( ImagePlug::tileOriginContextName );
	const Format format = inPlug()->formatPlug()->getValue();

	CompoundDataPtr shadingPoints = new CompoundData();

	V3fVectorDataPtr pData = new V3fVectorData;
	FloatVectorDataPtr uData = new FloatVectorData;
	FloatVectorDataPtr vData = new FloatVectorData;

	vector<V3f> &pWritable = pData->writable();
	vector<float> &uWritable = uData->writable();
	vector<float> &vWritable = vData->writable();

	const size_t tileSize = ImagePlug::tileSize();
	pWritable.reserve( tileSize * tileSize );
	uWritable.reserve( tileSize * tileSize );
	vWritable.reserve( tileSize * tileSize );

	/// \todo Non-zero display window origins - do we have those?
	const float uStep = 1.0f / format.width();
	const float uMin = 0.5f * uStep;

	const float vStep = 1.0f / format.height();
	const float vMin = 0.5f * vStep;

	const size_t xMax = tileOrigin.x + tileSize;
	const size_t yMax = tileOrigin.y + tileSize;
	for( size_t y = tileOrigin.y; y < yMax; ++y )
	{
		const float v = vMin + y * vStep;
		for( size_t x = tileOrigin.x; x < xMax; ++x )
		{
			uWritable.push_back( uMin + x * uStep );
			vWritable.push_back( v );
			pWritable.push_back( V3f( x, y, 0.0f ) );
		}
	}

	shadingPoints->writable()["P"] = pData;
	shadingPoints->writable()["u"] = uData;
	shadingPoints->writable()["v"] = vData;

	ConstStringVectorDataPtr channelNamesData = inPlug()->channelNamesPlug()->getValue();
	const vector<string> &channelNames = channelNamesData->readable();
	for( vector<string>::const_iterator it = channelNames.begin(), eIt = channelNames.end(); it != eIt; ++it )
	{
		shadingPoints->writable()[*it] = boost::const_pointer_cast<FloatVectorData>( inPlug()->channelData( *it, tileOrigin ) );
	}

	CompoundDataPtr result = shadingEngine->shade( shadingPoints.get() );

	// remove results that aren't suitable to become channels
	for( CompoundDataMap::iterator it = result->writable().begin(); it != result->writable().end();  )
	{
		CompoundDataMap::iterator nextIt = it; nextIt++;
		if( !runTimeCast<FloatVectorData>( it->second ) )
		{
			result->writable().erase( it );
		}
		it = nextIt;
	}

	return result;
}
开发者ID:cnpinto,项目名称:gaffer,代码行数:77,代码来源:OSLImage.cpp


示例16: f

ObjectPtr BINMeshReader::doOperation( const CompoundObject *operands )
{
	const std::string &fileName = m_fileNameParameter->getTypedValue();
	ifstream f( fileName.c_str() );

	f.seekg( 0, ios_base::beg );
	uint32_t magic = 0;
	readLittleEndian( f, magic );

	uint32_t version = 0;
	readLittleEndian( f, version );
	if ( version <= 3 )
	{
		throw IOException(( boost::format( "BINMeshReader: '%s' is of an unsupported version" ) % fileName ).str() );
	}

	MeshPrimitivePtr mesh = new MeshPrimitive();

	uint32_t numVertices = 0;

	bool foundGeometryChunk = false;
	bool done = false;

	uint32_t chunkId = 0;

	while ( !done && !f.fail() )
	{
		readLittleEndian( f, chunkId );
		if ( f.fail() )
		{
			throw IOException(( boost::format( "BINMeshReader: Error encountered while reading '%s'" ) % fileName ).str() );
		}

		if ( chunkId == 0xDEDEDEDE ) /// EOF marker
		{
			if ( !foundGeometryChunk )
			{
				throw IOException(( boost::format( "BINMeshReader: No geometry chunk encountered while reading '%s'" ) % fileName ).str() );
			}
			done = true;
		}
		else if ( chunkId == 0xCCCCCCCC ) /// geometry chunk
		{
			if ( foundGeometryChunk )
			{
				throw IOException(( boost::format( "BINMeshReader: Duplicate geometry chunk encountered while reading '%s'" ) % fileName ).str() );
			}
			foundGeometryChunk = true;

			V3fVectorDataPtr pData = new V3fVectorData();

			readLittleEndian( f, numVertices );

			pData->writable().resize( numVertices );
			for ( uint32_t i = 0; i < numVertices; i ++ )
			{
				V3f p;
				readLittleEndian( f, p.x );
				readLittleEndian( f, p.y );
				readLittleEndian( f, p.z );

				pData->writable()[i] = p;
			}


			uint32_t numFaces = 0;
			readLittleEndian( f, numFaces );

			IntVectorDataPtr vertsPerFaceData = new IntVectorData();

			/// All faces are triangles
			vertsPerFaceData->writable().resize( numFaces, 3 );

			IntVectorDataPtr vertIdsData = new IntVectorData();
			vertIdsData->writable().reserve( numFaces * 3 );

			for ( uint32_t i = 0; i < numFaces; i ++ )
			{
				uint32_t v0 = 0, v1 = 0, v2 = 0;
				readLittleEndian( f, v0 );
				readLittleEndian( f, v1 );
				readLittleEndian( f, v2 );

				vertIdsData->writable().push_back( v0 );
				vertIdsData->writable().push_back( v1 );
				vertIdsData->writable().push_back( v2 );
			}

			mesh->variables[ "P" ] = PrimitiveVariable( PrimitiveVariable::Vertex, pData );
			mesh->setTopology( vertsPerFaceData, vertIdsData, "linear" );

		}
		else if ( chunkId == 0xCCCCCC00 ) /// texture chunk
		{
			if ( !foundGeometryChunk )
			{
				throw IOException(( boost::format( "BINMeshReader: No geometry chunk encountered while reading '%s'" ) % fileName ).str() );
			}

			uint32_t numFluids = 0;
//.........这里部分代码省略.........
开发者ID:AtomicFiction,项目名称:cortex,代码行数:101,代码来源:BINMeshReader.cpp


示例17: lock

ObjectPtr SLOReader::doOperation( const CompoundObject * operands )
{
	tbb::mutex::scoped_lock lock( g_mutex );
	
	if( Slo_SetShader( (char *)fileName().c_str() ) )
	{
		throw Exception( boost::str( boost::format( "Unable to set shader to \"%s\"" ) % fileName() ) );
	}

	string name = Slo_GetName();
	string type = Slo_TypetoStr( Slo_GetType() );
	ShaderPtr result = new Shader( name, type );

	CompoundDataPtr typeHints = new CompoundData;
	result->blindData()->writable().insert( pair<string, DataPtr>( "ri:parameterTypeHints", typeHints ) );

	// we lose the ordering of parameter names when we put them in result->parameters(),
	// so we stick the correct order in the blind data as a workaround for anyone interested
	// in the true ordering.
	StringVectorDataPtr orderedParameterNames = new StringVectorData;
	result->blindData()->writable().insert( pair<string, DataPtr>( "ri:orderedParameterNames", orderedParameterNames ) );	

	// we don't have a way of communicating which parameters are outputs in the Shader::parametersData(),
	// so we work around that using the blind data too.
	StringVectorDataPtr outputParameterNames = new StringVectorData;
	result->blindData()->writable().insert( pair<string, DataPtr>( "ri:outputParameterNames", outputParameterNames ) );	

	int numArgs = Slo_GetNArgs();
	for( int i=1; i<=numArgs; i++ )
	{
		DataPtr data = 0;

		SLO_VISSYMDEF *arg = Slo_GetArgById( i );
		switch( arg->svd_type )
		{
			case SLO_TYPE_POINT :
			case SLO_TYPE_VECTOR :
			case SLO_TYPE_NORMAL :
				{
					if( arg->svd_arraylen==0 )
					{
						const SLO_POINT *p = arg->svd_default.pointval;
						if( p )
						{
							data = new V3fData( V3f( p->xval, p->yval, p->zval ) );
						}
						else
						{
							// 0 length and null value signifies a variable length array
							data = new V3fVectorData();
						}
					}
					else
					{
						V3fVectorDataPtr vData = new V3fVectorData();
						data = vData;
						for( int j=0; j<arg->svd_arraylen; j++ )
						{
							SLO_VISSYMDEF *a = Slo_GetArrayArgElement( arg, j );
							const SLO_POINT *p = a->svd_default.pointval;
							vData->writable().push_back( V3f( p->xval, p->yval, p->zval ) );
						}
					}
					typeHints->writable().insert( pair<string, DataPtr>( arg->svd_name, new StringData( Slo_TypetoStr( arg->svd_type ) ) ) );
					break;
				}

			case SLO_TYPE_COLOR :
				{
					if( arg->svd_arraylen==0 )
					{
						const SLO_POINT *p = arg->svd_default.pointval;
						if( p )
						{
							data = new Color3fData( Color3f( p->xval, p->yval, p->zval ) );
						}
						else
						{
							// 0 length and null value signifies a variable length array
							data = new Color3fVectorData();
						}
					}
					else
					{
						Color3fVectorDataPtr vData = new Color3fVectorData();
						data = vData;
						for( int j=0; j<arg->svd_arraylen; j++ )
						{
							SLO_VISSYMDEF *a = Slo_GetArrayArgElement( arg, j );
							const SLO_POINT *p = a->svd_default.pointval;
							vData->writable().push_back( Color3f( p->xval, p->yval, p->zval ) );
						}
					}
				}
				break;

			case SLO_TYPE_SCALAR :
				{
					if( arg->svd_arraylen==0 )
					{
//.........这里部分代码省略.........
开发者ID:Shockspot,项目名称:cortex,代码行数:101,代码来源:SLOReader.cpp


示例18: log

IECoreGL::ConstRenderablePtr StandardLightVisualiser::colorIndicator( const Imath::Color3f &color, bool faceCamera )
{

    float maxChannel = std::max( color[0], std::max( color[1], color[2] ) );
    float exposure = 0;
    Imath::Color3f indicatorColor = color;
    if( maxChannel > 1 )
    {
        indicatorColor = color / maxChannel;
        exposure = log( maxChannel ) / log( 2 );
    }
    IECoreGL::GroupPtr group = new IECoreGL::Group();
    IECoreGL::GroupPtr wirelessGroup = new IECoreGL::Group();

    IECore::CompoundObjectPtr parameters = new CompoundObject;
    parameters->members()["aimType"] = new IntData( 1 );
    group->getState()->add(
        new IECoreGL::ShaderStateComponent( ShaderLoader::defaultShaderLoader(), TextureLoader::defaultTextureLoader(), faceCamera ? faceCameraVertexSource() : "", "", IECoreGL::Shader::constantFragmentSource(), parameters )
    );

    wirelessGroup->getState()->add( new IECoreGL::Primitive::DrawWireframe( false ) );

    float indicatorRad = 0.3;
    int indicatorAxis = faceCamera ? 0 : 2;

    {
        IntVectorDataPtr vertsPerPoly = new IntVectorData;
        IntVectorDataPtr vertIds = new IntVectorData;
        V3fVectorDataPtr p = new V3fVectorData;

        addSolidArc( indicatorAxis, V3f( 0 ), indicatorRad, indicatorRad * 0.9, 0, 1, vertsPerPoly->writable(), vertIds->writable(), p->writable() );

        IECore::MeshPrimitivePtr mesh = new IECore::MeshPrimitive( vertsPerPoly, vertIds, "linear", p );
        mesh->variables["N"] = IECore::PrimitiveVariable( IECore::PrimitiveVariable::Constant, new V3fData( V3f( 0 ) ) );
        mesh->variables["Cs"] = IECore::PrimitiveVariable( IECore::PrimitiveVariable::Constant, new Color3fData( indicatorColor ) );
        ToGLMeshConverterPtr meshConverter = new ToGLMeshConverter( mesh );
        group->addChild( IECore::runTimeCast<IECoreGL::Renderable>( meshConverter->convert() ) );
    }
    {
        IntVectorDataPtr vertsPerPoly = new IntVectorData;
        IntVectorDataPtr vertIds = new IntVectorData;
        V3fVectorDataPtr p = new V3fVectorData;

        addSolidArc( indicatorAxis, V3f( 0 ), indicatorRad * 0.4, 0.0, 0, 1, vertsPerPoly->writable(), vertIds->writable(), p->writable() );

        for( int i = 0; i < exposure && i < 20; i++ )
        {
            float startAngle = 1 - pow( 0.875, i );
            float endAngle = 1 - pow( 0.875, std::min( i+1.0, (double)exposure ) );
            float maxEndAngle = 1 - pow( 0.875, i+1.0);
            float sectorScale = ( maxEndAngle - startAngle - 0.008 ) / ( maxEndAngle - startAngle );
            addSolidArc( indicatorAxis, V3f( 0 ), indicatorRad * 0.85, indicatorRad * 0.45, startAngle, startAngle + ( endAngle - startAngle ) * sectorScale, vertsPerPoly->writable(), vertIds->writable(), p->writable() );
        }

        IECore::MeshPrimitivePtr mesh = new IECore::MeshPrimitive( vertsPerPoly, vertIds, "linear", p );
        mesh->variables["N"] = IECore::PrimitiveVariable( IECore::PrimitiveVariable::Constant, new V3fData( V3f( 0 ) ) );
        mesh->variables["Cs"] = IECore::PrimitiveVariable( IECore::PrimitiveVariable::Constant, new Color3fData( indicatorColor ) );
        ToGLMeshConverterPtr meshConverter = new ToGLMeshConverter( mesh );
        wirelessGroup->addChild( IECore::runTimeCast<IECoreGL::Renderable>( meshConverter->convert() ) );
    }

    // For exposures greater than 20, draw an additional solid bar of a darker color at the very end, without any segment dividers
    if( exposure > 20 )
    {
        IntVectorDataPtr vertsPerPoly = new IntVectorData;
        IntVectorDataPtr vertIds = new IntVectorData;
        V3fVectorDataPtr p = new V3fVectorData;

        float startAngle = 1 - pow( 0.875, 20 );
        float endAngle = 1 - pow( 0.875, (double)exposure );
        addSolidArc( indicatorAxis, V3f( 0 ), indicatorRad * 0.85, indicatorRad * 0.45, startAngle, endAngle, vertsPerPoly->writable(), vertIds->writable(), p->writable() );

        IECore::MeshPrimitivePtr mesh = new IECore::MeshPrimitive( vertsPerPoly, vertIds, "linear", p );
        mesh->variables["N"] = IECore::PrimitiveVariable( IECore::PrimitiveVariable::Constant, new V3fData( V3f( 0 ) ) );
        mesh->variables["Cs"] = IECore::PrimitiveVariable( IECore::PrimitiveVariable::Constant, new Color3fData( 0.5f * indicatorColor ) );
        ToGLMeshConverterPtr meshConverter = new ToGLMeshConverter( mesh );
        wirelessGroup->addChild( IECore::runTimeCast<IECoreGL::Renderable>( meshConverter->convert() ) );
    }

    group->addChild( wirelessGroup );

    return group;
}
开发者ID:HughMacdonald,项目名称:gaffer,代码行数:83,代码来源:StandardLightVisualiser.cpp


示例19: createSphere

MeshPrimitivePtr MeshPrimitive::createSphere( float radius, float zMin, float zMax, float thetaMax, const Imath::V2i &divisions )
{
    IntVectorDataPtr vertexIds = new IntVectorData;
    IntVectorDataPtr verticesPerFace = new IntVectorData;
    std::vector<int> &vpf = verticesPerFace->writable();
    std::vector<int> &vIds = vertexIds->writable();

    V3fVectorDataPtr pData = new V3fVectorData;
    V3fVectorDataPtr nData = new V3fVectorData;
    std::vector<V3f> &pVector = pData->writable();
    std::vector<V3f> &nVector = nData->writable();

    FloatVectorDataPtr sData = new FloatVectorData;
    FloatVectorDataPtr tData = new FloatVectorData;
    std::vector<float> &sVector = sData->writable();
    std::vector<float> &tVector = tData->writable();

    float oMin = Math<float>::asin( zMin );
    float oMax = Math<float>::asin( zMax );
    const unsigned int nO = max( 4u, (unsigned int)( ( divisions.x + 1 ) * (oMax - oMin) / M_PI ) );

    float thetaMaxRad = thetaMax / 180.0f * M_PI;
    const unsigned int nT = max( 7u, (unsigned int)( ( divisions.y + 1 ) * thetaMaxRad / (M_PI*2) ) );

    for ( unsigned int i=0; i<nO; i++ )
    {
        float v = (float)i/(float)(nO-1);
        float o = lerp( oMin, oMax, v );
        float z = radius * Math<float>::sin( o );
        float r = radius * Math<float>::c 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ V8BindingPerIsolateData类代码示例发布时间:2022-05-31
下一篇:
C++ V3f类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap