/** * @ingroup VuoTransform * Produces a brief human-readable summary of @c value. */ char * VuoTransform_summaryFromValue(const VuoTransform value) { if (VuoTransform_isIdentity(value)) return strdup("identity transform (no change)"); if (value.type == VuoTransformTypeTargeted) return VuoText_format("position (%g, %g, %g)<br>target (%g, %g, %g)<br>up (%g, %g, %g)", value.translation.x, value.translation.y, value.translation.z, value.rotationSource.target.x, value.rotationSource.target.y, value.rotationSource.target.z, value.rotationSource.upDirection.x, value.rotationSource.upDirection.y, value.rotationSource.upDirection.z); char *rotation; if (value.type == VuoTransformTypeQuaternion) rotation = VuoText_format("(%g, %g, %g, %g) quaternion", value.rotationSource.quaternion.x, value.rotationSource.quaternion.y, value.rotationSource.quaternion.z, value.rotationSource.quaternion.w); else { VuoPoint3d r = VuoPoint3d_multiply(value.rotationSource.euler, 180./M_PI); rotation = VuoText_format("(%g°, %g°, %g°) euler", r.x, r.y, r.z); } char *valueAsString = VuoText_format("translation (%g, %g, %g)<br>rotation %s<br>scale (%g, %g, %g)", value.translation.x, value.translation.y, value.translation.z, rotation, value.scale.x, value.scale.y, value.scale.z); free(rotation); return valueAsString; }
/** * Returns a scene object that renders a quad with the specified shader. * * The quad includes normals, tangents, or bitangents. * * @param shader The shader used to render the object. * @param center The object's center, specified in scene coordinates. * @param rotation The object's rotation, specified in degrees. * @param width The object's width, specified in scene coordinates. * @param height The object's height, specified in scene coordinates. * @return The quad scene object. * * @threadAnyGL */ VuoSceneObject VuoSceneObject_makeQuadWithNormals(VuoShader shader, VuoPoint3d center, VuoPoint3d rotation, VuoReal width, VuoReal height) { return VuoSceneObject_make( VuoMesh_makeQuad(), shader, VuoTransform_makeEuler( center, VuoPoint3d_multiply(rotation, M_PI/180.), VuoPoint3d_make(width,height,1) ), NULL ); }
/** * @ingroup VuoTransform * Produces a brief human-readable summary of @c value. */ char * VuoTransform_summaryFromValue(const VuoTransform value) { if (VuoTransform_isIdentity(value)) return strdup("identity transform (no change)"); if (value.type == VuoTransformTypeTargeted) { const char *format = "position (%g, %g, %g)<br>target (%g, %g, %g)<br>up (%g, %g, %g)"; int size = snprintf(NULL, 0, format, value.translation.x, value.translation.y, value.translation.z, value.rotationSource.target.x, value.rotationSource.target.y, value.rotationSource.target.z, value.rotationSource.upDirection.x, value.rotationSource.upDirection.y, value.rotationSource.upDirection.z); char *valueAsString = (char *)malloc(size+1); snprintf(valueAsString, size+1, format, value.translation.x, value.translation.y, value.translation.z, value.rotationSource.target.x, value.rotationSource.target.y, value.rotationSource.target.z, value.rotationSource.upDirection.x, value.rotationSource.upDirection.y, value.rotationSource.upDirection.z); return valueAsString; } const char *format = "translation (%g, %g, %g)<br>rotation %s<br>scale (%g, %g, %g)"; char *rotation; if (value.type == VuoTransformTypeQuaternion) { const char *format = "(%g, %g, %g, %g) quaternion"; int size = snprintf(NULL, 0, format, value.rotationSource.quaternion.x, value.rotationSource.quaternion.y, value.rotationSource.quaternion.z, value.rotationSource.quaternion.w); rotation = (char *)malloc(size+1); snprintf(rotation, size+1, format, value.rotationSource.quaternion.x, value.rotationSource.quaternion.y, value.rotationSource.quaternion.z, value.rotationSource.quaternion.w); } else { const char *format = "(%g°, %g°, %g°) euler"; VuoPoint3d r = VuoPoint3d_multiply(value.rotationSource.euler, 180./M_PI); int size = snprintf(NULL, 0, format, r.x, r.y, r.z); rotation = (char *)malloc(size+1); snprintf(rotation, size+1, format, r.x, r.y, r.z); } int size = snprintf(NULL, 0, format, value.translation.x, value.translation.y, value.translation.z, rotation, value.scale.x, value.scale.y, value.scale.z); char * valueAsString = (char *)malloc(size+1); snprintf(valueAsString, size+1, format, value.translation.x, value.translation.y, value.translation.z, rotation, value.scale.x, value.scale.y, value.scale.z); free(rotation); return valueAsString; }
/** * Returns 2 values for Simplex noise at a 3D location. */ VuoPoint2d VuoGradientNoise_simplex_VuoPoint3d_VuoPoint2d(VuoPoint3d point) { return VuoPoint2d_make(VuoGradientNoise_simplex_VuoPoint3d_VuoReal(point), VuoGradientNoise_simplex_VuoPoint3d_VuoReal(VuoPoint3d_multiply(point,-1))); }
"node": { "isInterface" : false, "exampleCompositions" : [ "Compare4Cameras.vuo", "SwitchCameras.vuo" ] } }); void nodeEvent ( VuoInputData(VuoText, {"default":"camera"}) name, VuoInputData(VuoPoint3d, {"default":{"x":0.0,"y":0.0,"z":1.0}, "suggestedStep":{"x":0.1,"y":0.1,"z":0.1}}) position, VuoInputData(VuoPoint3d, {"default":{"x":0.0,"y":0.0,"z":0.0}, "suggestedMin":{"x":0.0,"y":0.0,"z":0.0}, "suggestedMax":{"x":360.0,"y":360.0,"z":360.0}, "suggestedStep":{"x":15.0,"y":15.0,"z":15.0}}) rotation, VuoInputData(VuoReal, {"default":90.0, "suggestedMin":0.01, "suggestedMax":179.9, "suggestedStep":1.0}) fieldOfView, VuoInputData(VuoReal, {"default":0.1, "suggestedMin":0.01, "suggestedStep":1.0}) distanceMin, VuoInputData(VuoReal, {"default":10.0, "suggestedMin":0.01, "suggestedStep":1.0}) distanceMax, VuoOutputData(VuoSceneObject) object ) { VuoTransform transform = VuoTransform_makeEuler( position, VuoPoint3d_multiply(rotation, M_PI/180.f), VuoPoint3d_make(1,1,1) ); *object = VuoSceneObject_makePerspectiveCamera( name, transform, fieldOfView, distanceMin, distanceMax ); }
* @file * vuo.transform.make 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" : "Make 3D Transform", "keywords" : [ "Euler", "translation", "rotation", "scale", "shift", "move", "position", "angle", "yaw", "pitch", "roll", "axis", "size", "grow", "shrink" ], "version" : "1.0.0", "node": { "exampleCompositions" : [ ] } }); void nodeEvent ( VuoInputData(VuoPoint3d, {"default":{"x":0,"y":0,"z":0},"suggestedStep":{"x":0.1,"y":0.1,"z":0.1}}) translation, VuoInputData(VuoPoint3d, {"default":{"x":0,"y":0,"z":0},"suggestedMin":{"x":0,"y":0,"z":0},"suggestedMax":{"x":360,"y":360,"z":360},"suggestedStep":{"x":15,"y":15,"z":15}}) rotation, VuoInputData(VuoPoint3d, {"default":{"x":1,"y":1,"z":1},"suggestedStep":{"x":0.1,"y":0.1,"z":0.1}}) scale, VuoOutputData(VuoTransform) transform ) { *transform = VuoTransform_makeEuler(translation, VuoPoint3d_multiply(rotation, M_PI/180.), scale); }
#include "node.h" VuoModuleMetadata({ "title" : "Make Spotlight", "keywords" : [ "draw", "opengl", "scenegraph", "graphics", "directional", "lighting", "point", "source" ], "version" : "1.0.0", "node": { "exampleCompositions" : [ "AimFlashlight.vuo", "CompareLights.vuo" ] } }); void nodeEvent ( VuoInputData(VuoColor,{"default":{"r":1.,"g":1.,"b":1.,"a":1.}}) color, VuoInputData(VuoReal, {"default":1.0, "suggestedMin":0., "suggestedMax":1., "suggestedStep":0.1}) brightness, VuoInputData(VuoPoint3d, {"default":{"x":0.,"y":0.,"z":1.}, "suggestedStep":{"x":0.1,"y":0.1,"z":0.1}}) position, VuoInputData(VuoPoint2d, {"default":{"x":0.,"y":0.}, "suggestedMin":{"x":0.0,"y":0.0}, "suggestedMax":{"x":360.0,"y":360.0}, "suggestedStep":{"x":15.0,"y":15.0}}) rotation, VuoInputData(VuoReal, {"default":30., "suggestedMin":0., "suggestedMax":180., "suggestedStep":15.}) cone, VuoInputData(VuoReal, {"default":10., "suggestedMin":0., "suggestedStep":0.1}) range, VuoInputData(VuoReal, {"default":0.9, "suggestedMin":0., "suggestedMax":1., "suggestedStep":0.1}) sharpness, VuoOutputData(VuoSceneObject) object ) { // For vector (1,0,0), Euler rotations about the x, y, and z axes respectively mean roll, yaw, and pitch. // Since spotlights are unaffected by roll, this node only takes 2 rotational values. VuoPoint3d rotation3d = VuoPoint3d_make(0, rotation.x+90., rotation.y); *object = VuoSceneObject_makeSpotlight(color, brightness, VuoTransform_makeEuler(position, VuoPoint3d_multiply(rotation3d, M_PI/180.), VuoPoint3d_make(1,1,1)), cone*M_PI/180., range, sharpness); }