예제 #1
0
/**
 * @file
 * vuo.type.list.integer.real node implementation.
 *
 * @copyright Copyright © 2012–2014 Kosada Incorporated.
 * This code may be modified and distributed under the terms of the MIT License.
 * For more information, see http://vuo.org/license.
 */

#include "node.h"

VuoModuleMetadata({
					  "title": "Convert Integer List to Real List",
					  "description": "Outputs a list containing real number equivalents to the input list's integers.",
					  "version": "1.0.0"
				 });

void nodeEvent
(
	VuoInputData(VuoList_VuoInteger) integers,
	VuoOutputData(VuoList_VuoReal) reals
)
{
	*reals = VuoListCreate_VuoReal();
	unsigned long count = VuoListGetCount_VuoInteger(integers);
	for (unsigned long i = 1; i <= count; ++i)
		VuoListAppendValue_VuoReal(*reals, VuoListGetValue_VuoInteger(integers, i));
}
예제 #2
0
				{"x": 0.0, "y": 0.5, "z":0},
			] }) positions,
		VuoInputData(VuoList_VuoInteger, {"default": [ 0, 1, 2 ]}) elements,
		VuoInputData(VuoList_VuoPoint3d, {"default": [] }) normals,
		VuoInputData(VuoList_VuoPoint2d, {"default": [
				{"x": 0.0, "y": 0.0},
				{"x": 1.0, "y": 0.0},
				{"x": 0.5, "y": 0.8},
			] }) textures,
		VuoOutputData(VuoMesh) mesh
)
{
	VuoSubmesh submesh;

	unsigned int vertexCount = VuoListGetCount_VuoPoint3d(positions);
	unsigned int elementCount = VuoListGetCount_VuoInteger(elements);

	if(vertexCount < 3 || elementCount < 3) return;

	// These two must always be present
	VuoPoint4d* m_positions = (VuoPoint4d*)malloc(sizeof(VuoPoint4d) * vertexCount);
	unsigned int* m_elements = (unsigned int*)malloc(sizeof(unsigned int) * elementCount);

	// Populate positions
	for(int i = 0; i < vertexCount; i++)
	{
		VuoPoint3d v = VuoListGetValue_VuoPoint3d(positions, i+1);
		m_positions[i] = (VuoPoint4d) {v.x, v.y, v.z, 1.};
	}

	for(int i = 0; i < elementCount; i++)