postspectacular / toxiclibs Goto Github PK
View Code? Open in Web Editor NEWOfficial master repo (Git version)
Home Page: http://toxiclibs.org
License: GNU Lesser General Public License v2.1
Official master repo (Git version)
Home Page: http://toxiclibs.org
License: GNU Lesser General Public License v2.1
As part of #1, I am manually inserting library.properties
to the zipped library compilation, but would be good for this to be part of the ANT build.
The methods used in the examples are not in the source code posted here. Perhaps an older version is displayed here? For example, the computeVertices
method of Spline2D is nowhere to be found in the code while being crucial to the class. I would appreciate the full source as I need some more details on the implementation.
I'm trying to figure out how exactly to set control points on the ends of splines to make a "spline loop". The delta
array holds the control point data presumably, but I'm not exactly sure what to set as the deltas at the endpoints. This is why I need to see the implemention; it's not clear to me what the delta
array holds even after looking at the data it contains.
Dear Toxi,
First let me thank you for this fascinating tool that is toxiclibs.
I've recently been trying to port this growth algorithm presented on the iGeo library webpage (7th sketch from top - "Finding Edges to Divide on Closed Surface") using toxiclibs but I'm having difficulties with the WETriangleMesh class.
In the following example code I'm trying to add 3 new faces on top of one of the original 4 faces of a tetrahedron mesh. The mesh vertices are connected by springs.
My problem is that the vertices of the newly added faces don't match the original tetrahedron, as if they were disconnected from the mesh (top grey 3D triangle).
It is all the more surprising that the newly added springs that share the same vertices positions DO fit the tetrahedron (top 3 red lines)
Questions:
add_library('toxiclibs')
add_library('peasycam')
from toxi.physics3d.behaviors import GravityBehavior3D, AttractionBehavior3D
from toxi.physics3d import VerletPhysics3D, VerletParticle3D, VerletSpring3D
def setup():
global physics, mesh, gfx
perspective(60 * DEG_TO_RAD, width/float(height), 2, 6000)
size(690, 460, P3D)
smooth(8)
cam = PeasyCam(this, 150)
physics = VerletPhysics3D()
physics.setDrag(1.1)
physics.setWorldBounds(AABB(Vec3D(), Vec3D(width, height, height)))
mesh = WETriangleMesh()
gfx = ToxiclibsSupport(this)
#Create 4 particles to form a tetrahedron
for i in range(4):
p = VerletParticle3D(Vec3D.randomVector())
physics.addParticle(p)
physics.addBehavior(AttractionBehavior3D(p, 10, -4))
#Adding springs between particles
for p1 in physics.particles:
for p2 in physics.particles:
if p1 != p2:
s = VerletSpring3D(p1, p2, 60, .1)
physics.addSpring(s)
#Adding faces between particles
p1 = physics.particles.get(0)
p2 = physics.particles.get(1)
p3 = physics.particles.get(2)
p4 = physics.particles.get(3)
mesh.addFace(p1, p2, p3)
mesh.addFace(p1, p3, p4)
mesh.addFace(p1, p2, p4)
mesh.addFace(p2, p3, p4)
def draw():
background(30)
#Update physics
physics.update()
#Display WETriangle mesh
noStroke()
fill(255, 200)
gfx.mesh(mesh)
#Update mesh based on particles position
for i in range(len(physics.particles)):
if mesh.getVertexForID(i) is not None:
mesh.getVertexForID(i).set(physics.particles.get(i))
#Draw springs
for i in range(len(physics.springs)):
stroke(255, 30, 30)
strokeWeight(1)
line(physics.springs.get(i).a.x(), physics.springs.get(i).a.y(), physics.springs.get(i).a.z(),
physics.springs.get(i).b.x(), physics.springs.get(i).b.y(), physics.springs.get(i).b.z())
def keyReleased():
f = mesh.getFaces().get(0)
centroid = VerletParticle3D(Triangle3D(f.a, f.b, f.c).computeCentroid())
a = physics.particles.get(physics.particles.index(f.a))
b = physics.particles.get(physics.particles.index(f.b))
c = physics.particles.get(physics.particles.index(f.c))
CreateFaces(a, b, c, centroid)
def CreateFaces(a, b, c, n):
#Add centroid to physics + set repulsive behavior
physics.addParticle(n)
physics.addBehavior(AttractionBehavior3D(n, 10, -4))
#Attach springs between the face vertices and the centroid
s1 = VerletSpring3D(a, n, 60, .1)
s2 = VerletSpring3D(b, n, 60, .1)
s3 = VerletSpring3D(c, n, 60, .1)
physics.addSpring(s1)
physics.addSpring(s2)
physics.addSpring(s3)
#Remove original face
mesh.removeFace(mesh.getFaces().get(0))
#Add faces of the newly formed tetrahedron to the mesh
mesh.addFace(n, a, b)
mesh.addFace(n, b, c)
mesh.addFace(n, a, c)
Respectfully,
solub
Dear toxi,
I'd like to use the BasicNurbsSurface class but haven't found a single example sketch on the web and it seems the corresponding Javadoc is missing.
Would you mind sharing a very basic example sketch demonstrating how to handle a nurb surface with toxiclibs ?
Respectfully,
solub
Hi,
I would like to know if it's possible to override a voronoi cell position while the sketch is iterating without having to clear the Voronoi() class and adding new points at every frame.
I was thinking the following would do the trick but it didn't:
voronoi.getSites().get(i).set(Vec2D(p.x, p.y))
(p
being a moving VerletParticle2D object)
For now I'm clearing/ appending points at each iteration but the frameRate drops very quickly after 100 moving particles displayed on the screen:
def draw():
#Clears voronoi
voronoi = Voronoi()
for i, p in enumerate(collection):
p.growth()
p.display()
#Appending points
voronoi.addPoint(physics.particles.get(i))
Hello,
your website is pointing to bitbucket instead of github.
http://toxiclibs.org/downloads/
I was directed there from this example:
Thanks for doing this
the issue is as the title.
Excuse me.
The toxiclibs official website: http://toxiclibs.org/ may not be accessed normally.
Where to get the entire released jar library?
Processing v4 has updated parse grammar rules, which now are classifying color
also as reserved keyword if used within a multipart, dot-separated package name and thus breaking any project which attempts to import toxi.color.*;
. The P5 team seems to have marked this as working-as-intended, breaking 2 decades old existing behavior. Therefore, I will now have to rename this package to something similar and attempt to build a new release, incl. updated examples...
Proposals for the new package name are gladly accepted!
See relevant issues:
Website is down!!!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.