-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
monkstone
committed
Nov 10, 2015
1 parent
dd8661f
commit a1e6a10
Showing
7 changed files
with
142 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.inc | ||
*~ | ||
*.jar | ||
*.gem | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'toxiclibs' | ||
|
||
attr_reader :gfx, :mesh0, :mesh1, :mesh2 | ||
|
||
def settings | ||
size(200, 200, P3D) | ||
smooth 4 | ||
end | ||
|
||
def setup | ||
sketch_title('FTest') | ||
@gfx = Gfx::ToxiclibsSupport.new(self) | ||
# define a rounded cube using the SuperEllipsoid surface function | ||
vert = AABB.fromMinMax(TVec3D.new(-1.0, -3.5, -1.0), TVec3D.new(1.0, 3.5, 1.0)) | ||
box = AABB.fromMinMax(TVec3D.new(1.0, -1.5, -1.0), TVec3D.new(3.0, -3.5, 1.0)) | ||
box2 = AABB.fromMinMax(TVec3D.new(1.0, 2.0, -1.0), TVec3D.new(3.0, 0.0, 1.0)) | ||
@mesh0 = box.to_mesh | ||
@mesh1 = vert.to_mesh | ||
@mesh2 = box2.to_mesh | ||
mesh0.add_mesh(mesh1) | ||
mesh0.add_mesh(mesh2) | ||
mesh0.compute_face_normals | ||
mesh0.compute_vertex_normals | ||
fileID = 'FTest' | ||
pm = Gfx::POVMesh.new(self) | ||
file = java.io.File.new(sketchPath(fileID + '.inc')) | ||
pm.begin_save(file) | ||
pm.set_texture(Gfx::Textures::CHROME) | ||
pm.saveAsPOV(mesh0.faceOutwards, false) | ||
# pm.set_texture(Textures::RED) | ||
# pm.saveAsPOV(mesh1, false) | ||
# pm.set_texture(Textures::WHITE) | ||
# pm.saveAsPOV(mesh2, false) | ||
pm.end_save | ||
# exit | ||
end | ||
|
||
def draw | ||
background 50, 50, 200 | ||
lights | ||
translate(width / 2, height / 2) | ||
scale(10) | ||
rotateY(20.radians) | ||
gfx.choose_stroke_fill(false, Toxi::TColor::WHITE, Toxi::TColor::RED) | ||
gfx.mesh(mesh0) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
require 'toxiclibs' | ||
|
||
# A 3D Tentacle by Nikolaus Gradwohl http://www.local-guru.net | ||
# Adapted for JRubyArt and mesh to PShape, and mesh2 export by Martin Prout | ||
|
||
attr_reader :mesh, :gfx, :tentacle | ||
|
||
def settings | ||
size(500, 500, P3D) | ||
end | ||
|
||
def setup | ||
sketch_title 'Tentacle' | ||
ArcBall.init(self) | ||
@gfx = Gfx::MeshToVBO.new(self) | ||
volume = VolumetricSpaceArray.new(TVec3D.new(100, 200, 100), 100, 100, 100) | ||
surface = ArrayIsoSurface.new(volume) | ||
@mesh = TriangleMesh.new | ||
brush = RoundBrush.new(volume, 10) | ||
20.times do |i| | ||
brush.set_size(i * 1.2 + 6) | ||
x = cos(i * TWO_PI / 20) * 10 | ||
y = sin(i * TWO_PI / 20) * 10 | ||
brush.draw_at_absolute_pos(TVec3D.new(x, -25 + i * 7, y), 1) | ||
end | ||
(4..20).step(4) do |i| | ||
brush.set_size(i / 1.5 + 4) | ||
x = cos(i * TWO_PI / 20) * (i * 1.2 + 16) | ||
y = sin(i * TWO_PI / 20) * (i * 1.2 + 16) | ||
brush.draw_at_absolute_pos(TVec3D.new(x, -25 + i * 7, y), 1) | ||
brush.set_size(i / 2 + 2) | ||
x2 = cos(i * TWO_PI / 20) * (i * 1.2 + 18) | ||
y2 = sin(i * TWO_PI / 20) * (i * 1.2 + 18) | ||
brush.draw_at_absolute_pos(TVec3D.new(x2, -25 + i * 7, y2), -1.4) | ||
end | ||
volume.close_sides | ||
surface.reset | ||
surface.compute_surface_mesh(mesh, 0.5) | ||
no_stroke | ||
@tentacle = gfx.mesh_to_shape(mesh, true) | ||
tentacle.set_fill(color(200, 10, 10)) | ||
tentacle.set_ambient(80) | ||
tentacle.set_specular(80) | ||
end | ||
|
||
def draw | ||
background(150) | ||
lights | ||
setup_lights | ||
shape(tentacle) | ||
end | ||
|
||
def setup_lights | ||
lights | ||
ambient_light(100, 100, 100) | ||
directional_light(100, 100, 100, -1, -1, 1) | ||
light_specular(50, 50, 50) | ||
end | ||
|
||
def key_pressed | ||
case key | ||
when 'p', 'P' | ||
fileID = 'Tentacle' | ||
pm = Gfx::POVMesh.new(self) | ||
pm.begin_save(java.io.File.new(fileID + '.inc')) | ||
pm.set_texture(Gfx::Textures::RED) # red with Phong texture | ||
pm.saveAsPOV(mesh, true) | ||
pm.end_save | ||
exit | ||
when 's', 'S' | ||
save_frame('Tentacle.png') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters