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


C++ CompositorContext类代码示例

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


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

示例1: convertToOperations

void TimeNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	SetValueOperation *operation = new SetValueOperation();
	bNode *node = this->getbNode();

	/* stack order output: fac */
	float fac = 0.0f;
	const int framenumber = context.getFramenumber();

	if (framenumber < node->custom1) {
		fac = 0.0f;
	}
	else if (framenumber > node->custom2) {
		fac = 1.0f;
	}
	else if (node->custom1 < node->custom2) {
		fac = (context.getFramenumber() - node->custom1) / (float)(node->custom2 - node->custom1);
	}

	curvemapping_initialize((CurveMapping *)node->storage);
	fac = curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac);
	operation->setValue(clamp_f(fac, 0.0f, 1.0f));
	converter.addOperation(operation);

	converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
开发者ID:bdancer,项目名称:blender-for-vray,代码行数:26,代码来源:COM_TimeNode.cpp

示例2: ScaleOperation

void Stabilize2dNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	NodeInput *imageInput = this->getInputSocket(0);
	MovieClip *clip = (MovieClip *)getbNode()->id;
	
	ScaleOperation *scaleOperation = new ScaleOperation();
	scaleOperation->setSampler((PixelSampler)this->getbNode()->custom1);
	RotateOperation *rotateOperation = new RotateOperation();
	rotateOperation->setDoDegree2RadConversion(false);
	TranslateOperation *translateOperation = new TranslateOperation();
	MovieClipAttributeOperation *scaleAttribute = new MovieClipAttributeOperation();
	MovieClipAttributeOperation *angleAttribute = new MovieClipAttributeOperation();
	MovieClipAttributeOperation *xAttribute = new MovieClipAttributeOperation();
	MovieClipAttributeOperation *yAttribute = new MovieClipAttributeOperation();
	SetSamplerOperation *psoperation = new SetSamplerOperation();
	psoperation->setSampler((PixelSampler)this->getbNode()->custom1);
	
	scaleAttribute->setAttribute(MCA_SCALE);
	scaleAttribute->setFramenumber(context.getFramenumber());
	scaleAttribute->setMovieClip(clip);
	
	angleAttribute->setAttribute(MCA_ANGLE);
	angleAttribute->setFramenumber(context.getFramenumber());
	angleAttribute->setMovieClip(clip);
	
	xAttribute->setAttribute(MCA_X);
	xAttribute->setFramenumber(context.getFramenumber());
	xAttribute->setMovieClip(clip);
	
	yAttribute->setAttribute(MCA_Y);
	yAttribute->setFramenumber(context.getFramenumber());
	yAttribute->setMovieClip(clip);
	
	converter.addOperation(scaleAttribute);
	converter.addOperation(angleAttribute);
	converter.addOperation(xAttribute);
	converter.addOperation(yAttribute);
	converter.addOperation(scaleOperation);
	converter.addOperation(translateOperation);
	converter.addOperation(rotateOperation);
	converter.addOperation(psoperation);
	
	converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0));
	converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
	converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
	
	converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
	converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));

	converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
	converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
	converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
	
	converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0));
	converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket());
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:56,代码来源:COM_Stabilize2dNode.cpp

示例3: start

void WorkScheduler::start(CompositorContext &context)
{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
	unsigned int index;
	g_cpuqueue = BLI_thread_queue_init();
	BLI_init_threads(&g_cputhreads, thread_execute_cpu, g_cpudevices.size());
	for (index = 0; index < g_cpudevices.size(); index++) {
		Device *device = g_cpudevices[index];
		BLI_insert_thread(&g_cputhreads, device);
	}
#ifdef COM_OPENCL_ENABLED
	if (context.getHasActiveOpenCLDevices()) {
		g_gpuqueue = BLI_thread_queue_init();
		BLI_init_threads(&g_gputhreads, thread_execute_gpu, g_gpudevices.size());
		for (index = 0; index < g_gpudevices.size(); index++) {
			Device *device = g_gpudevices[index];
			BLI_insert_thread(&g_gputhreads, device);
		}
		g_openclActive = true;
	}
	else {
		g_openclActive = false;
	}
#endif
#endif
}
开发者ID:Walid-Shouman,项目名称:Blender,代码行数:26,代码来源:COM_WorkScheduler.cpp

示例4: convertToOperations

void BokehBlurNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	bNode *b_node = this->getbNode();

	NodeInput *inputSizeSocket = this->getInputSocket(2);

	bool connectedSizeSocket = inputSizeSocket->isLinked();
	const bool extend_bounds = (b_node->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0;

	if ((b_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) && connectedSizeSocket) {
		VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
		operation->setQuality(context.getQuality());
		operation->setThreshold(0.0f);
		operation->setMaxBlur(b_node->custom4);
		operation->setDoScaleSize(true);
		
		converter.addOperation(operation);
		converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
		converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
		converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
		converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
	}
	else {
		BokehBlurOperation *operation = new BokehBlurOperation();
		operation->setQuality(context.getQuality());
		operation->setExtendBounds(extend_bounds);
		
		converter.addOperation(operation);
		converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
		converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));

		// NOTE: on the bokeh blur operation the sockets are switched.
		// for this reason the next two lines are correct.
		// Fix for T43771
		converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(3));
		converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(2));

		converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());

		if (!connectedSizeSocket) {
			operation->setSize(this->getInputSocket(2)->getEditorValueFloat());
		}
	}
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:44,代码来源:COM_BokehBlurNode.cpp

示例5: testSocketLink

void RenderLayersNode::testSocketLink(NodeConverter &converter,
                                      const CompositorContext &context,
                                      NodeOutput *output,
                                      RenderLayersProg *operation,
                                      Scene *scene,
                                      int layerId,
                                      bool is_preview) const
{
	operation->setScene(scene);
	operation->setLayerId(layerId);
	operation->setRenderData(context.getRenderData());
	operation->setViewName(context.getViewName());

	converter.mapOutputSocket(output, operation->getOutputSocket());
	converter.addOperation(operation);

	if (is_preview) /* only for image socket */
		converter.addPreview(operation->getOutputSocket());
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:19,代码来源:COM_RenderLayersNode.cpp

示例6: convertToOperations

void CompositorNode::convertToOperations(NodeConverter &converter,
                                         const CompositorContext &context) const
{
  bNode *editorNode = this->getbNode();
  bool is_active = (editorNode->flag & NODE_DO_OUTPUT_RECALC) || context.isRendering();
  bool ignore_alpha = (editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0;

  NodeInput *imageSocket = this->getInputSocket(0);
  NodeInput *alphaSocket = this->getInputSocket(1);
  NodeInput *depthSocket = this->getInputSocket(2);

  CompositorOperation *compositorOperation = new CompositorOperation();
  compositorOperation->setScene(context.getScene());
  compositorOperation->setSceneName(context.getScene()->id.name);
  compositorOperation->setRenderData(context.getRenderData());
  compositorOperation->setViewName(context.getViewName());
  compositorOperation->setbNodeTree(context.getbNodeTree());
  /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */
  compositorOperation->setUseAlphaInput(ignore_alpha || alphaSocket->isLinked());
  compositorOperation->setActive(is_active);

  converter.addOperation(compositorOperation);
  converter.mapInputSocket(imageSocket, compositorOperation->getInputSocket(0));
  /* only use alpha link if "use alpha" is enabled */
  if (ignore_alpha) {
    converter.addInputValue(compositorOperation->getInputSocket(1), 1.0f);
  }
  else {
    converter.mapInputSocket(alphaSocket, compositorOperation->getInputSocket(1));
  }
  converter.mapInputSocket(depthSocket, compositorOperation->getInputSocket(2));

  converter.addNodeInputPreview(imageSocket);
}
开发者ID:dfelinto,项目名称:blender,代码行数:34,代码来源:COM_CompositorNode.cpp

示例7: convertToOperations

void BilateralBlurNode::convertToOperations(NodeConverter &converter,
                                            const CompositorContext &context) const
{
  NodeBilateralBlurData *data = (NodeBilateralBlurData *)this->getbNode()->storage;
  BilateralBlurOperation *operation = new BilateralBlurOperation();
  operation->setQuality(context.getQuality());
  operation->setData(data);

  converter.addOperation(operation);
  converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
  converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
  converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
开发者ID:dfelinto,项目名称:blender,代码行数:13,代码来源:COM_BilateralBlurNode.cpp

示例8: convertToOperations

void SplitViewerNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	bNode *editorNode = this->getbNode();
	bool do_output = (editorNode->flag & NODE_DO_OUTPUT_RECALC || context.isRendering()) && (editorNode->flag & NODE_DO_OUTPUT);

	NodeInput *image1Socket = this->getInputSocket(0);
	NodeInput *image2Socket = this->getInputSocket(1);
	Image *image = (Image *)this->getbNode()->id;
	ImageUser *imageUser = (ImageUser *) this->getbNode()->storage;

	SplitOperation *splitViewerOperation = new SplitOperation();
	splitViewerOperation->setSplitPercentage(this->getbNode()->custom1);
	splitViewerOperation->setXSplit(!this->getbNode()->custom2);

	converter.addOperation(splitViewerOperation);
	converter.mapInputSocket(image1Socket, splitViewerOperation->getInputSocket(0));
	converter.mapInputSocket(image2Socket, splitViewerOperation->getInputSocket(1));

	ViewerOperation *viewerOperation = new ViewerOperation();
	viewerOperation->setImage(image);
	viewerOperation->setImageUser(imageUser);
	viewerOperation->setViewSettings(context.getViewSettings());
	viewerOperation->setDisplaySettings(context.getDisplaySettings());

	/* defaults - the viewer node has these options but not exposed for split view
	 * we could use the split to define an area of interest on one axis at least */
	viewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT);
	viewerOperation->setCenterX(0.5f);
	viewerOperation->setCenterY(0.5f);

	converter.addOperation(viewerOperation);
	converter.addLink(splitViewerOperation->getOutputSocket(), viewerOperation->getInputSocket(0));

	converter.addPreview(splitViewerOperation->getOutputSocket());

	if (do_output)
		converter.registerViewer(viewerOperation);
}
开发者ID:SuriyaaKudoIsc,项目名称:blender-git,代码行数:38,代码来源:COM_SplitViewerNode.cpp

示例9: convertToOperations

void MovieDistortionNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	bNode *bnode = this->getbNode();
	MovieClip *clip = (MovieClip *)bnode->id;
	
	NodeInput *inputSocket = this->getInputSocket(0);
	NodeOutput *outputSocket = this->getOutputSocket(0);
	
	MovieDistortionOperation *operation = new MovieDistortionOperation(bnode->custom1 == 1);
	operation->setMovieClip(clip);
	operation->setFramenumber(context.getFramenumber());
	converter.addOperation(operation);

	converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
	converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:16,代码来源:COM_MovieDistortionNode.cpp

示例10: convertToOperations

void KeyingScreenNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	bNode *editorNode = this->getbNode();
	MovieClip *clip = (MovieClip *) editorNode->id;
	NodeKeyingScreenData *keyingscreen_data = (NodeKeyingScreenData *) editorNode->storage;

	NodeOutput *outputScreen = this->getOutputSocket(0);

	// always connect the output image
	KeyingScreenOperation *operation = new KeyingScreenOperation();
	operation->setMovieClip(clip);
	operation->setTrackingObject(keyingscreen_data->tracking_object);
	operation->setFramenumber(context.getFramenumber());
	converter.addOperation(operation);

	converter.mapOutputSocket(outputScreen, operation->getOutputSocket());
}
开发者ID:bdancer,项目名称:blender-for-vray,代码行数:17,代码来源:COM_KeyingScreenNode.cpp

示例11: convertToOperations

void BoxMaskNode::convertToOperations(NodeConverter &converter,
                                      const CompositorContext &context) const
{
  NodeInput *inputSocket = this->getInputSocket(0);
  NodeOutput *outputSocket = this->getOutputSocket(0);

  BoxMaskOperation *operation;
  operation = new BoxMaskOperation();
  operation->setData((NodeBoxMask *)this->getbNode()->storage);
  operation->setMaskType(this->getbNode()->custom1);
  converter.addOperation(operation);

  if (inputSocket->isLinked()) {
    converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
    converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
  }
  else {
    /* Value operation to produce original transparent image */
    SetValueOperation *valueOperation = new SetValueOperation();
    valueOperation->setValue(0.0f);
    converter.addOperation(valueOperation);

    /* Scale that image up to render resolution */
    const RenderData *rd = context.getRenderData();
    ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation();

    scaleOperation->setIsAspect(false);
    scaleOperation->setIsCrop(false);
    scaleOperation->setOffset(0.0f, 0.0f);
    scaleOperation->setNewWidth(rd->xsch * rd->size / 100.0f);
    scaleOperation->setNewHeight(rd->ysch * rd->size / 100.0f);
    scaleOperation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE);
    converter.addOperation(scaleOperation);

    converter.addLink(valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0));
    converter.addLink(scaleOperation->getOutputSocket(0), operation->getInputSocket(0));
    converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
  }

  converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
}
开发者ID:dfelinto,项目名称:blender,代码行数:41,代码来源:COM_BoxMaskNode.cpp

示例12: convertToOperations

void TrackPositionNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	bNode *editorNode = this->getbNode();
	MovieClip *clip = (MovieClip *) editorNode->id;
	NodeTrackPosData *trackpos_data = (NodeTrackPosData *) editorNode->storage;
	
	NodeOutput *outputX = this->getOutputSocket(0);
	NodeOutput *outputY = this->getOutputSocket(1);

	int frame_number;
	if (editorNode->custom1 == CMP_TRACKPOS_ABSOLUTE_FRAME) {
		frame_number = editorNode->custom2;
	}
	else {
		frame_number = context.getFramenumber();
	}

	TrackPositionOperation *operationX = new TrackPositionOperation();
	operationX->setMovieClip(clip);
	operationX->setTrackingObject(trackpos_data->tracking_object);
	operationX->setTrackName(trackpos_data->track_name);
	operationX->setFramenumber(frame_number);
	operationX->setAxis(0);
	operationX->setPosition(editorNode->custom1);
	operationX->setRelativeFrame(editorNode->custom2);
	converter.addOperation(operationX);
	
	TrackPositionOperation *operationY = new TrackPositionOperation();
	operationY->setMovieClip(clip);
	operationY->setTrackingObject(trackpos_data->tracking_object);
	operationY->setTrackName(trackpos_data->track_name);
	operationY->setFramenumber(frame_number);
	operationY->setAxis(1);
	operationY->setPosition(editorNode->custom1);
	operationY->setRelativeFrame(editorNode->custom2);
	converter.addOperation(operationY);
	
	converter.mapOutputSocket(outputX, operationX->getOutputSocket());
	converter.mapOutputSocket(outputY, operationY->getOutputSocket());
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:40,代码来源:COM_TrackPositionNode.cpp

示例13: convertToOperations

void TranslateNode::convertToOperations(NodeConverter &converter,
                                        const CompositorContext &context) const
{
  bNode *bnode = this->getbNode();
  NodeTranslateData *data = (NodeTranslateData *)bnode->storage;

  NodeInput *inputSocket = this->getInputSocket(0);
  NodeInput *inputXSocket = this->getInputSocket(1);
  NodeInput *inputYSocket = this->getInputSocket(2);
  NodeOutput *outputSocket = this->getOutputSocket(0);

  TranslateOperation *operation = new TranslateOperation();
  if (data->relative) {
    const RenderData *rd = context.getRenderData();
    float fx = rd->xsch * rd->size / 100.0f;
    float fy = rd->ysch * rd->size / 100.0f;

    operation->setFactorXY(fx, fy);
  }

  converter.addOperation(operation);
  converter.mapInputSocket(inputXSocket, operation->getInputSocket(1));
  converter.mapInputSocket(inputYSocket, operation->getInputSocket(2));
  converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));

  if (data->wrap_axis) {
    WriteBufferOperation *writeOperation = new WriteBufferOperation(COM_DT_COLOR);
    WrapOperation *wrapOperation = new WrapOperation(COM_DT_COLOR);
    wrapOperation->setMemoryProxy(writeOperation->getMemoryProxy());
    wrapOperation->setWrapping(data->wrap_axis);

    converter.addOperation(writeOperation);
    converter.addOperation(wrapOperation);
    converter.mapInputSocket(inputSocket, writeOperation->getInputSocket(0));
    converter.addLink(wrapOperation->getOutputSocket(), operation->getInputSocket(0));
  }
  else {
    converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
  }
}
开发者ID:dfelinto,项目名称:blender,代码行数:40,代码来源:COM_TranslateNode.cpp

示例14: convertToOperations

void BlurNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	bNode *editorNode = this->getbNode();
	NodeBlurData *data = (NodeBlurData *)editorNode->storage;
	NodeInput *inputSizeSocket = this->getInputSocket(1);
	bool connectedSizeSocket = inputSizeSocket->isLinked();

	const float size = this->getInputSocket(1)->getEditorValueFloat();
	
	CompositorQuality quality = context.getQuality();
	NodeOperation *input_operation = NULL, *output_operation = NULL;

	if (data->filtertype == R_FILTER_FAST_GAUSS) {
		FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation();
		operationfgb->setData(data);
		converter.addOperation(operationfgb);
		
		converter.mapInputSocket(getInputSocket(1), operationfgb->getInputSocket(1));
		
		input_operation = operationfgb;
		output_operation = operationfgb;
	}
	else if (editorNode->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) {
		MathAddOperation *clamp = new MathAddOperation();
		SetValueOperation *zero = new SetValueOperation();
		zero->setValue(0.0f);
		clamp->setUseClamp(true);
		
		converter.addOperation(clamp);
		converter.addOperation(zero);
		converter.mapInputSocket(getInputSocket(1), clamp->getInputSocket(0));
		converter.addLink(zero->getOutputSocket(), clamp->getInputSocket(1));
		
		GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation();
		operationx->setData(data);
		operationx->setQuality(quality);
		operationx->setSize(1.0f);
		operationx->setFalloff(PROP_SMOOTH);
		operationx->setSubtract(false);
		
		converter.addOperation(operationx);
		converter.addLink(clamp->getOutputSocket(), operationx->getInputSocket(0));
		
		GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
		operationy->setData(data);
		operationy->setQuality(quality);
		operationy->setSize(1.0f);
		operationy->setFalloff(PROP_SMOOTH);
		operationy->setSubtract(false);
		
		converter.addOperation(operationy);
		converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));
		
		GaussianBlurReferenceOperation *operation = new GaussianBlurReferenceOperation();
		operation->setData(data);
		operation->setQuality(quality);
		
		converter.addOperation(operation);
		converter.addLink(operationy->getOutputSocket(), operation->getInputSocket(1));
		
		output_operation = operation;
		input_operation = operation;
	}
	else if (!data->bokeh) {
		GaussianXBlurOperation *operationx = new GaussianXBlurOperation();
		operationx->setData(data);
		operationx->setQuality(quality);
		
		converter.addOperation(operationx);
		converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1));
		
		GaussianYBlurOperation *operationy = new GaussianYBlurOperation();
		operationy->setData(data);
		operationy->setQuality(quality);

		converter.addOperation(operationy);
		converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1));
		converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));

		if (!connectedSizeSocket) {
			operationx->setSize(size);
			operationy->setSize(size);
		}

		input_operation = operationx;
		output_operation = operationy;
	}
	else {
		GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation();
		operation->setData(data);
		operation->setQuality(quality);
		
		converter.addOperation(operation);
		converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));

		if (!connectedSizeSocket) {
			operation->setSize(size);
		}

		input_operation = operation;
//.........这里部分代码省略.........
开发者ID:floored,项目名称:blender,代码行数:101,代码来源:COM_BlurNode.cpp

示例15: convertToOperations

void ImageNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
	/// Image output
	NodeOutput *outputImage = this->getOutputSocket(0);
	bNode *editorNode = this->getbNode();
	Image *image = (Image *)editorNode->id;
	ImageUser *imageuser = (ImageUser *)editorNode->storage;
	int framenumber = context.getFramenumber();
	int numberOfOutputs = this->getNumberOfOutputSockets();
	bool outputStraightAlpha = (editorNode->custom1 & CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT) != 0;
	BKE_image_user_frame_calc(imageuser, context.getFramenumber(), 0);
	/* force a load, we assume iuser index will be set OK anyway */
	if (image && image->type == IMA_TYPE_MULTILAYER) {
		bool is_multilayer_ok = false;
		ImBuf *ibuf = BKE_image_acquire_ibuf(image, imageuser, NULL);
		if (image->rr) {
			RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer);
			if (rl) {
				NodeOutput *socket;
				int index;

				is_multilayer_ok = true;

				for (index = 0; index < numberOfOutputs; index++) {
					NodeOperation *operation = NULL;
					socket = this->getOutputSocket(index);
					bNodeSocket *bnodeSocket = socket->getbNodeSocket();
					RenderPass *rpass = (RenderPass *)BLI_findstring(&rl->passes, bnodeSocket->identifier, offsetof(RenderPass, internal_name));
					int view = 0;

					/* Passes in the file can differ from passes stored in sockets (#36755).
					 * Look up the correct file pass using the socket identifier instead.
					 */
#if 0
					NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage;*/
					int passindex = storage->pass_index;*/
					RenderPass *rpass = (RenderPass *)BLI_findlink(&rl->passes, passindex);
#endif

					/* returns the image view to use for the current active view */
					if (BLI_listbase_count_ex(&image->rr->views, 2) > 1) {
						const int view_image = imageuser->view;
						const bool is_allview = (view_image == 0); /* if view selected == All (0) */

						if (is_allview) {
							/* heuristic to match image name with scene names
							 * check if the view name exists in the image */
							view = BLI_findstringindex(&image->rr->views, context.getViewName(), offsetof(RenderView, name));
							if (view == -1) view = 0;
						}
						else {
							view = view_image - 1;
						}
					}

					if (rpass) {
						switch (rpass->channels) {
							case 1:
								operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index,
								                              rpass->passtype, view, COM_DT_VALUE);
								break;
								/* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */
								/* XXX any way to detect actual vector images? */
							case 3:
								operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index,
								                              rpass->passtype, view, COM_DT_VECTOR);
								break;
							case 4:
								operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index,
								                              rpass->passtype, view, COM_DT_COLOR);
								break;
							default:
								/* dummy operation is added below */
								break;
						}
						if (index == 0 && operation) {
							converter.addPreview(operation->getOutputSocket());
						}
						if (rpass->passtype == SCE_PASS_COMBINED) {
							BLI_assert(operation != NULL);
							BLI_assert(index < numberOfOutputs - 1);
							NodeOutput *outputSocket = this->getOutputSocket(index + 1);
							SeparateChannelOperation *separate_operation;
							separate_operation = new SeparateChannelOperation();
							separate_operation->setChannel(3);
							converter.addOperation(separate_operation);
							converter.addLink(operation->getOutputSocket(), separate_operation->getInputSocket(0));
							converter.mapOutputSocket(outputSocket, separate_operation->getOutputSocket());
							index++;
						}
					}

					/* incase we can't load the layer */
					if (operation == NULL)
						converter.setInvalidOutput(getOutputSocket(index));
				}
			}
		}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:98,代码来源:COM_ImageNode.cpp


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