Box2D and Geometry Plug-In available

oz.Box2D Plugin is now available from http://www.benoitlahoz.net/

 

oz.Box2D is a plug-in bundle for the graphic development environment Quartz Composer.

It is based on the 2D physics library Box2D and configure some of its functions to be usable through node-based programming.

It makes complex shapes easy to include in physics simulation and contains helper patches to provide the user with some custom functions not basically included in Box2D.

Version 1.0

  • Based on Box2D 2.3.1: the user might want to check his knowledge of the Box2D principles before posting issues.
  • 32 / 64 bits, 10.7+
  • To be installed in Quartz Composer Plug-Ins folder.
  • IS NOT COMPATIBLE WITH ANY OTHER Box2D BASED PLUG-IN
  • Use poly2tri for triangulation through custom library OZGeom (also used in oz.Strings and oz.Geometry plug-ins,please make sure these plug-ins are updated too if you use them)
  • Is made to output values to be rendered with Kineme GL Tools (or other GL based rendering plug-ins).
  • Contains 11 patches:
    • World (processor): it’s the central patch of the bundle. The setting pane let the user choose the number of « Object » inputs. Outputs bodies data and bodies count.
    • Simple Body: let the user choose if he wants to create a Box or a Circle, with according parameters. Outputs a body Object.
    • Body With Line Structure: takes a 2D or 3D line structure in input(only the 2D points will be considered) and triangulate it (if filled body) to get displayable triangles (with U, V coordinates). Outputs a body Object.
    • Body With Triangles Structure: takes a 2D or 3D triangles structure in input(only the 2D points will be considered). Triangles may be organized like in the Kineme GL Triangle Structure patch: a 2D (X, Y, Z) vertices structure defining triangles. Outputs a body Object.
    • Model Emitter: takes a body Object in input and allow the user to emit (on trigger or continuously) multiple instances of this body. If the body model changes only the newly emitted bodies are concerned by the change. Manages lifetime of individual bodies. Outputs a body group Object.
    • Hit Test: takes 2 Objects in input (body or body group). Outputs a boolean, contact coordinates (2D structure that can be plugged in Kineme GL Point Structure) and contact normals (3D structure of lines).
    • Break Body: takes a body (not body group, only filled bodies) Object in input and breaks it on trigger. To be inserted between the body Object and the World patch.
    • Destroy Body: takes a body or body group Object in input and breaks it on trigger. To be inserted between the body Object and the World patch.
    • Body Info: takes a body (not a body group) Object in input. Outputs body ID, (X, Y) positions, Z rotation, body’s size (if relevant), body’s vertices and triangles (if relevant) and contact points.
    • Group Info: takes a body group (not a body) Object in input. Outputs body ID, (X, Y) positions, Z rotation, body’s size (if relevant), body’s vertices and triangles (if relevant) and contact points as a structure for each body of the group.
    • Mouse Joint: takes (X, Y) coordinates and boolean in input and allows the user to catch and drag bodies . Outputs a mouse joint Object to be plugged directly in the World patch.
  • Support self-intersecting polygons (see oz.Geometry plug-in for triangulation with holes, and oz.Strings plug-in to get triangles from strings)
  • Includes examples via the patches descriptions
  • USE AT YOUR OWN RISK !
  • Is released as DonationWare
  • Is licensed under Creative Commons Share Alike Attribution 4.0 (Commercial).
  • Concepts:
    • Object: Quartz Composer does not allow to create custom input or output ports, so the plug-in uses structures to get and set the bodies, joints, etc., to be shared between patches. An object can be a body, a body group (like in emitter) or a joint for the moment and is pluggable to the World patch directly or via another patch. The user is responsible to check what kind of object goes where.
    • Line Structure and Triangle Structure: ozBox2D outputs positions data in a Kineme GL-like way so the bodies’ data can be rendered with these patches.
  • Known issues:
    • Box2D ‘degenerate polygons’: generated triangles may sometimes be too thin. The plug-ins try hard to get themBox2D-able but in some particular (and rare) cases Box2D may crash with this issue.
    • Emitter / broken bodies performance: due to the way the plug-in has to cache bodies for re-use and generate values for rendering, body groups Objects may be slow (in particular with circles: only one circle is 96 triangles for filling and 33 vertices for stroke). User might want to adjust FPS and PTM in the World patch to keep a fluid animation below a certain number of bodies emitted, or to use plug-ins specifically made to emit bodies (like the1024 one).
    • Changing too fast (at each frame for example) the Emitter model body’s parameters may result in some (rare) cases in some issues with the bodies creation in the World (ie. bodies not considered by the plug-in then not rendered, but living in the Box2D world).
    • Does not support creating bodies in iterators due to the current bodies IDs management based on each body’s memory address (that remain the same in an iterator).
    • Some triangles output by oz.Strings Triangulate Character Structure patch or oz.Geometry Constrained Delaunay With Holes may not keep the exact position and U,V coordinates after breaking.
  • Todo list:
    • Huge ! But…
    • Debug what has to be debugged
    • Provide better examples (these are so ugly)
    • Joints creation and management
    • Forces creation and management
    • Raycasting
    • Iterators support
    • More callbacks to get instantaneous and user-selected world data
    • Helper patches for bodies creation: drawing, structure of bodies, jointed bodies, etc.
    • Helper patches to allow more conditions
    • Helper patches to get more data from bodies
    • Bridging with my OpenCV plug-in (new version currently in dev)

oz.Geometry Plug-In

 

Version 1.0

  • 32 / 64 bits, 10.7+
  • Uses my OZGeom library also used in oz.Strings and oz.Box2D, please make sure these plug-ins are updated too if you use them.
  • Use poly2tri for triangulation
  • Use Clipper library for clipping
  • To be installed in Quartz Composer Plug-Ins folder.
  • Is made to output values to be rendered with Kineme GL Tools (or other GL based rendering plug-ins).
  • Contains 21 patches:
    • 2D Ellipse: build a simple 2D (at Z = Z input) ellipse closed line structure according to the input number of vertices
    • 2D Rectangle: build a simple 2D (at Z = Z input) rectangle closed line structure according to the input number of vertices
    • 3D Bounds: get the bounds and center point of a 3D line structure.
    • 3D Is Counter ClockWise: checks if the input Line STructure has been built counter clockwise.
    • 3D Is Point Inside Bounds: checks if a point is inside the bounds of a 3D Line Structure.
    • 2D Contains: checks if a Line Structure contaisn another Line Structure.
    • 3D Close Polygon: closes a polygon by duplicating the first vertex of a Line Structure.
    • 3D Remove Duplicates: removes the duplicates in a Line Structure.
    • 2D Smooth Line Structure: smooth a Line Structure according to the input ratio and steps (points between each original vertex).
    • 3D Simplify Line Structure: simplify an input Line Structure according to the input tolerance.
    • 2D Rotate Z: rotates a Line Structure around the Z axis.
    • 3D Scale: scales a Line Structure.
    • 3D Translate: translates a Line Structure.
    • 3D Flip: flip horizontally, vertically or in depth a Line Structure
    • 3D Grow Line Structure: grows the input Line STructure according to a normalized input ratio (begin -> end)
    • 3D Follow Path: outputs an (X, Y, Z) point on the input Line Structure according to the input ratio (0. -> 1.)
    • 3D Morph Line Structure: morphs a Line Structue to another one according to the input ratio (0. -> 1.)
    • 2D Convex Hull: outputs a closed line structure of the input Line Structure’s convex hull
    • 2D Clipper: outputs a line structure made of the clipping operation between input Line Structure 1 and input Line Structure 2
    • 2D Constrained Delaunay: performs a 2D Constrained Delaunay operation on the input Line Structure and output a resulting Triangle Structure (handles self-intersecting polygons via clipping)
    • 2D Constrained Delaunay With Holes: performs a 2D Constrained Delaunay operation on the input structure of Line Structures and output a resulting Triangle Structure (handles self-intersecting polygons via clipping; compared to the oz.Strings Triangulate patch it is 1D less)
  • Support self-intersecting polygons (see oz.Geometry plug-in for triangulation with holes, and oz.Strings plug-in to get triangles from strings)
  • Does not include examples (in the TODO list)
  • USE AT YOUR OWN RISK !
  • Is released as DonationWare
  • Is licensed under Creative Commons Share Alike Attribution 4.0 (Commercial).
  • Known issues:
    • TO BE TESTED BETTER
    • 2D functions are – most of the time – not working with 3D: make evrything 3D (oops… triangulation…)
  • Todo list:
    • TO BE TESTED BETTER
    • Feed the library with others geometric functions
    • Implement my « old » Line->’Width Polygon’ function
    • Implement my « old » editor that allows drawing directly in QC
    • Implement « get structure in bounds »
    • 3D Rotations with matrices
    • Make examples
    • Be inspired…
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s