Permalink
Browse files

Merge pull request #251 from Teslos/master

Fixing the ODE Library and adding support for DrawStuff Library
  • Loading branch information...
2 parents e36e74c + 5fde867 commit 5d35419414065b7bf8c487b19b9d282d2316ffdf @stevedekorte committed Sep 18, 2013
@@ -54,7 +54,7 @@ add_subdirectory(Blowfish)
add_subdirectory(Box)
#add_subdirectory(CFFI)
add_subdirectory(CGI)
-#add_subdirectory(Cairo) # XXX: Broken on OSX: ld: library not found for -lpng12
+add_subdirectory(Cairo) # XXX: Broken on OSX: ld: library not found for -lpng12
add_subdirectory(Clutter)
add_subdirectory(ContinuedFraction)
#add_subdirectory(Curses)
@@ -80,7 +80,7 @@ add_subdirectory(MySQL)
#add_subdirectory(NetworkAdapter)
add_subdirectory(NotificationCenter)
#add_subdirectory(Oauth) # OAuth should no longer break CMake configuration on Windows now.
-#add_subdirectory(ODE) # XXX: Can't meet dependencies
+add_subdirectory(ODE) # XXX: Can't meet dependencies
add_subdirectory(ObjcBridge) # XXX: Broken for me -- Objective-C 2.0 not supported
add_subdirectory(Obsidian)
add_subdirectory(Ogg)
@@ -4,6 +4,7 @@
# Builds the ODE addon
# Find ODE
+find_package(ODE)
find_package(OpenGL)
find_package(GLUT)
@@ -12,7 +13,7 @@ make_build_bundle(_build)
# Did we find ODE? if so, set up the targets and all the support
# variables.
-if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND)
+if(ODE_FOUND AND OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND)
# Output our dynamic library to the top-level _build hierarchy
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/_build/dll)
@@ -21,6 +22,7 @@ if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND)
${OPENGL_INCLUDE_DIR}
${GLUT_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../OpenGL/source
+ ${DRAWSTUFF_INCLUDE_DIR}
)
# Generate the IoODEInit.c file.
@@ -48,15 +50,16 @@ if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND)
"${CMAKE_CURRENT_SOURCE_DIR}/source/IoODESlider.c"
"${CMAKE_CURRENT_SOURCE_DIR}/source/IoODEUniversal.c"
"${CMAKE_CURRENT_SOURCE_DIR}/source/IoODEWorld.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoDrawStuff.c"
"${CMAKE_CURRENT_SOURCE_DIR}/source/IoSeq_ode.c"
)
# Now build the shared library
add_library(IoODE SHARED ${SRCS})
add_dependencies(IoODE iovmall)
- target_link_libraries(IoODE iovmall ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
+ target_link_libraries(IoODE iovmall ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${ODE_LIBRARY} ${DRAWSTUFF_LIBRARY})
# Install the addon to our global addons hierarchy.
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION lib/io/addons)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/_build DESTINATION lib/io/addons/ODE)
-endif(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND)
+endif(ODE_FOUND AND OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND)
@@ -0,0 +1,26 @@
+#!/usr/bin/env io
+
+// drawstuff.io - A simple DrawStuff test program
+// (C) ∃teslos 2013
+ODE
+DrawStuff
+
+DrawStuffApp := DrawStuff clone do(
+ appendProto(DrawStuff)
+
+ start := method(xyz, hpr,
+ xyz := vector(0,0,0)
+ hpr := vector(0,0,0)
+ dsGetViewpoint(xyz, hpr)
+ dsSetViewpoint(xyz, hpr)
+ )
+ step := nil
+ run := method(
+ writeln("Running run method")
+ eventTarget(self)
+ self dsSimulationLoop(400,400)
+ )
+)
+
+//DrawStuffApp clone run
+
@@ -0,0 +1,79 @@
+#!/usr/bin/env io
+
+// drawstuff.io - A simple DrawStuff test program
+// (C) ∃teslos 2013
+// Based on dstest in ode-0.12 distribution
+
+ODE
+DrawStuff
+
+DrawStuffApp := DrawStuff clone do(
+ appendProto(DrawStuff)
+
+ start := method(xyz, hpr,
+ xyz := vector(0,0,0)
+ hpr := vector(0,0,0)
+ dsGetViewpoint(xyz, hpr)
+ dsSetViewpoint(xyz, hpr)
+ )
+ a := Number clone
+ step := method(paused,
+ DS_WOOD := 1
+ DS_NONE := 0
+ pi := Number constants pi
+ if(paused==0, a = a + 0.02)
+ if(a > 2*pi, a = a - 2*pi)
+ ca := a cos
+ sa := a sin
+ dsSetTexture(DS_WOOD)
+
+ b := if(a > pi, 2*(a-pi), a*2)
+ pos := vector(-0.3,0, (0.1*(2*pi*b-b*b)+0.65))
+ R := Vector clone setSize(12)
+ R atPut(0,ca); R atPut(1,0); R atPut(2,-sa)
+ R atPut(4,0 ); R atPut(5,1); R atPut(6, 0)
+ R atPut(8,sa); R atPut(9,0); R atPut(10,ca)
+ dsSetColor(1.0,0.8,0.6)
+ dsDrawSphere(pos,R,0.3)
+ dsSetTexture(DS_WOOD)
+
+ // draw the box
+ pos := vector(-0.2, 0.8, 0.4)
+ sides := vector(0.1,0.4,0.8)
+ // define the rotation matrix
+ R atPut(0,ca); R atPut(1,-sa); R atPut(2, 0)
+ R atPut(4,sa); R atPut(5, ca); R atPut(6, 0)
+ R atPut(8, 0); R atPut(9, 0); R atPut(10,1)
+ dsSetColor(0.6,0.6,1);
+ dsDrawBox(pos, R, sides)
+
+ // draw the cylinder
+ r := 0.3
+ d := (a*2) cos * 0.4;
+ cd := (-d/r) cos
+ sd := (-d/r) sin
+ pos := vector(-0.2,-1+d,0.3)
+ R atPut(0, 0); R atPut(1, 0); R atPut(2,-1)
+ R atPut(4,-sd); R atPut(5,cd); R atPut(6, 0)
+ R atPut(8, cd); R atPut(9,sd); R atPut(10,0)
+ dsSetColor(0.4,1,1)
+ dsDrawCylinder(pos,R, 0.8,r)
+
+ // draw capsule
+ pos := vector(0,0,0.2)
+ R atPut(0,0); R atPut(1,sa); R atPut(2,-ca)
+ R atPut(4,0); R atPut(5,ca); R atPut(6, sa)
+ R atPut(8,1); R atPut(9, 0); R atPut(10, 0)
+ dsSetColor(1,0.9,0.2)
+ dsDrawCapsule(pos,R,0.8, 0.2)
+
+ )
+
+ run := method(
+ eventTarget(self)
+ self dsSimulationLoop(400,400)
+ )
+)
+
+DrawStuffApp clone run
+
@@ -0,0 +1,32 @@
+#!/usr/bin/env io
+
+
+ODE
+DrawStuff
+
+DrawStuffSampleApp := DrawStuff clone do(
+appendProto(ODE)
+
+step := method(paused,
+ radius := 0.4
+ dsSetColor(1.0,0.0,0.0)
+ pos := vector(0.0,0.0,0.6)
+ R := Vector clone setSize(12)
+ R atPut(0,1); R atPut(5,1); R atPut(10,1);
+ dsDrawSphere(pos,R,radius)
+)
+
+start := method(
+ xyz := vector(0.0,-3.0,1.0)
+ hpr := vector(90.0,0.0,0.0)
+ dsSetViewpoint(xyz, hpr)
+)
+
+run := method(
+ eventTarget(self)
+ dsSimulationLoop(352,288)
+)
+)
+
+DrawStuffSampleApp run
+
@@ -0,0 +1,67 @@
+#!/usr/bin/env io
+
+# Port of http://pyode.sourceforge.net/tutorials/tutorial2.html
+// (C) ∃teslos 2013
+// Based on tutorial2.io
+// Based on glballs.io - A simple program (C) 2002 Mike Austin
+ODE
+DrawStuff
+
+# Create a world object
+world := ODEWorld clone
+world setGravity(0,0, -9.81)
+
+# Create two bodies
+body1 := world Body clone
+body1 setMass(ODEMass clone setSphereMass(1, 0.05))
+body1 setPosition(0, 1, 2)
+
+body2 := world Body clone
+body2 setMass(ODEMass clone setSphereMass(1, 0.05))
+body2 setPosition(0, 2, 2)
+
+# Connect body1 with the static environment
+jg := world JointGroup clone
+j1 := jg Ball clone
+j1 attach(body1)
+j1 setAnchor(0, 0, 2)
+
+# Connect body2 with body1
+j2 := jg Ball clone
+j2 attach(body1, body2)
+j2 setAnchor(0, 2, 2)
+
+
+# DrawStuff events object
+Screen := DrawStuff clone do(
+ appendProto(DrawStuff)
+ width ::= 512
+ height ::= 512
+
+ start := method(xyz, hpr,
+ xyz := vector(0,0,0)
+ hpr := vector(0,0,0)
+ dsGetViewpoint(xyz, hpr)
+ dsSetViewpoint(xyz, hpr)
+ )
+
+ step := method(paused,
+ world step(0.01)
+ DS_WOOD := 1
+ dsSetTexture(DS_WOOD)
+ R := Vector clone setSize(12)
+ R atPut(0,1); R atPut(5,1); R atPut(10,1)
+ dsSetColor(1.0,0.8,0.6)
+ pos1 := body1 position + vector(0.0, 0, 1)
+ pos2 := body2 position + vector(0.0, 0, 1)
+ dsDrawSphere(pos1, R, 0.3 )
+ dsDrawSphere(pos2, R, 0.3 )
+ )
+
+ run := method(
+ eventTarget(self)
+ self dsSimulationLoop(width, height)
+ )
+)
+
+Screen run
@@ -2,7 +2,7 @@
# Port of http://pyode.sourceforge.net/tutorials/tutorial1.html
-r := DynLib clone setPath("/opt/local/lib/libode.dylib") open
+r := DynLib clone setPath("/usr/local/lib/libode.la") open
writeln("r = ", r)
writeln("loaded ode")
Oops, something went wrong.

0 comments on commit 5d35419

Please sign in to comment.