Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #251 from Teslos/master

Fixing the ODE Library and adding support for DrawStuff Library
  • Loading branch information...
commit 5d35419414065b7bf8c487b19b9d282d2316ffdf 2 parents e36e74c + 5fde867
@stevedekorte authored
View
4 addons/CMakeLists.txt
@@ -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)
View
9 addons/ODE/CMakeLists.txt
@@ -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)
View
26 addons/ODE/io/DrawStuff.io
@@ -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
+
View
79 addons/ODE/samples/drawstuff/drawstuffm.io
@@ -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
+
View
32 addons/ODE/samples/drawstuff/sample3.io
@@ -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
+
View
67 addons/ODE/samples/drawstuff/tutorial2.io
@@ -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
View
2  addons/ODE/samples/tutorial1.io
@@ -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")
View
444 addons/ODE/source/IoDrawStuff.c
@@ -0,0 +1,444 @@
+//metadoc DrawStuff copyright ∃teslos 2013
+//metadoc DrawStuff license BSD revised
+//metadoc DrawStuff category Graphics
+
+#include "IoDrawStuff.h"
+
+#include "List.h"
+#include "IoState.h"
+#include "IoNumber.h"
+#include "IoCFunction.h"
+#include "IoSeq.h"
+#include "IoList.h"
+#include "List.h"
+
+#define DATA(self) ((IoDrawStuffData *)IoObject_dataPointer(self))
+#define DRAWMESSAGE(name) \
+IoMessage_newWithName_label_(state, IOSYMBOL(name), IOSYMBOL("[DrawStuff]"))
+static const char *protoId = "DrawStuff";
+static IoDrawStuff *proto = NULL;
+
+IoTag *IoDrawStuff_newTag(void *state)
+{
+ IoTag *tag = IoTag_newWithName_(protoId);
+ IoTag_state_(tag, state);
+ IoTag_cloneFunc_(tag, (IoTagCloneFunc *)IoDrawStuff_rawClone);
+ IoTag_freeFunc_(tag, (IoTagFreeFunc *)IoDrawStuff_free);
+ IoTag_markFunc_(tag, (IoTagMarkFunc *)IoDrawStuff_mark);
+ return tag;
+}
+
+IoDrawStuff *IoDrawStuff_proto(void *state)
+{
+ IoObject *self = IoObject_new(state);
+ proto = self;
+ IoObject_tag_(self, IoDrawStuff_newTag(state));
+ IoObject_setDataPointer_(self, calloc(1, sizeof(IoDrawStuffData)));
+
+ DATA(self)->coroutine = IoCoroutine_new(state);
+ //printf("DrawStuff coro = %p\n", DATA(self)->coroutine);
+
+ DATA(self)->eventTarget = NULL;
+
+ DATA(self)->keyboardMessage = DRAWMESSAGE("keyboard");
+ DATA(self)->startMessage = DRAWMESSAGE("start");
+ DATA(self)->stepMessage = DRAWMESSAGE("step");
+ DATA(self)->stopMessage = DRAWMESSAGE("stop");
+
+ IoState_retain_(state, DATA(self)->coroutine);
+ IoState_retain_(state, DATA(self)->keyboardMessage);
+ IoState_retain_(state, DATA(self)->startMessage);
+ IoState_retain_(state, DATA(self)->stepMessage);
+ IoState_retain_(state, DATA(self)->stopMessage);
+
+ IoState_registerProtoWithId_(state, self, protoId);
+ {
+ IoMethodTable methodTable[] = {
+ {"dsSimulationLoop", IoDrawStuff_dsSimulationLoop},
+ {"dsSetViewpoint", IoDrawStuff_dsSetViewpoint},
+ {"dsGetViewpoint", IoDrawStuff_dsGetViewpoint},
+ {"dsElapsedTime", IoDrawStuff_dsElapsedTime},
+ {"dsStop", IoDrawStuff_dsStop},
+ {"dsSetTexture", IoDrawStuff_dsSetTexture},
+ {"dsSetColor", IoDrawStuff_dsSetColor},
+ {"dsSetColorAlpha", IoDrawStuff_dsSetColorAlpha},
+ {"dsDrawBox", IoDrawStuff_dsDrawBox},
+ {"dsDrawSphere", IoDrawStuff_dsDrawSphere},
+ {"dsDrawTriangle", IoDrawStuff_dsDrawTriangle},
+ {"dsDrawCylinder", IoDrawStuff_dsDrawCylinder},
+ {"dsDrawCapsule", IoDrawStuff_dsDrawCapsule},
+ {"dsDrawLine", IoDrawStuff_dsDrawLine},
+ {"dsDrawConvex", IoDrawStuff_dsDrawConvex},
+ {"dsSetSphereQuality", IoDrawStuff_dsSetSphereQuality},
+ {"dsSetCapsuleQuality", IoDrawStuff_dsSetCapsuleQuality},
+ {"dsSetDrawMode", IoDrawStuff_dsSetDrawMode},
+ {"eventTarget", IoDrawStuff_eventTarget},
+
+ {NULL, NULL},
+ };
+ IoObject_addMethodTable_(self, methodTable);
+ }
+ //IoDrawStuff_protoInit(self);
+ return self;
+}
+
+IoDrawStuff *IoDrawStuff_new(void *state)
+{
+ return IoState_protoWithId_(state, protoId);
+}
+
+void IoDrawStuff_free(IoDrawStuff *self)
+{
+ free(IoObject_dataPointer(self));
+}
+
+
+void IoDrawStuff_mark(IoDrawStuff *self)
+{
+ //printf("IoDrawStuff_mark\n");
+ if(DATA(self)->eventTarget)
+ {
+ IoObject_shouldMark(DATA(self)->eventTarget);
+ }
+
+ IoObject_shouldMark(DATA(self)->keyboardMessage);
+ IoObject_shouldMark(DATA(self)->startMessage);
+ IoObject_shouldMark(DATA(self)->stepMessage);
+ IoObject_shouldMark(DATA(self)->stopMessage);
+}
+
+IoObject *IoDrawStuff_rawClone(IoDrawStuff *self)
+{
+ return IoState_protoWithId_(IOSTATE, protoId);
+}
+
+IoObject *IoDrawStuff_tryCallback(IoDrawStuff *self, IoMessage *m)
+{
+ IoState *state = IoObject_state(proto);
+ IoObject *tryCoro = DATA(self)->coroutine;
+ IoObject *t = DATA(self)->eventTarget;
+ IoObject *result = state->ioNil;
+ //printf("IoDrawStuff_tryCallback(self, %p)\n", (void*)m);
+ //printf("IoDrawStuff_tryCallback target: %p)\n", (void*)t);
+
+ if(t)
+ {
+ IoMessage_locals_performOn_(m, t, t);
+ if (IoCoroutine_rawException(tryCoro) != state->ioNil)
+ IoState_exception_(state, tryCoro);
+
+ IoCoroutine_clearStack(tryCoro);
+ return IoCoroutine_rawResult(tryCoro);
+ }
+ return result;
+}
+
+// callback events
+void IoDrawStuffStartFunc(void)
+{
+ //printf("IoDrawStuffStartFunc\n");
+ IoState_pushRetainPool(IoObject_state(proto));
+
+ IoDrawStuff_tryCallback(proto, DATA(proto)->startMessage);
+ IoState_popRetainPool(IoObject_state(proto));
+}
+
+void IoDrawStuffStopFunc(void)
+{
+ //printf("IoDrawStuffStopFunc\n");
+ IoState_pushRetainPool(IoObject_state(proto));
+
+ IoDrawStuff_tryCallback(proto, DATA(proto)->stopMessage);
+ IoState_popRetainPool(IoObject_state(proto));
+}
+
+void IoDrawStuffStepFunc(int pause)
+{
+ //printf("IoDrawStuffStepFunc\n");
+ IoState_pushRetainPool(IoObject_state(proto));
+ IoMessage_setCachedArg_toInt_(DATA(proto)->stepMessage, 0, pause);
+ IoDrawStuff_tryCallback(proto, DATA(proto)->stepMessage);
+ IoState_popRetainPool(IoObject_state(proto));
+}
+
+void IoDrawStuffKeyboardFunc(int key)
+{
+ //printf("IoDrawStuffKeyboardFunc\n");
+ IoState_pushRetainPool(IoObject_state(proto));
+ IoMessage_setCachedArg_toInt_(DATA(proto)->keyboardMessage, 0, key);
+ IoDrawStuff_tryCallback(proto, DATA(proto)->keyboardMessage);
+ IoState_popRetainPool(IoObject_state(proto));
+}
+
+IoObject *IoDrawStuff_dsSimulationLoop(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ struct dsFunctions fn;
+ int argc = 0;
+ char **argv = NULL;
+ IoState *state = IOSTATE;
+ char *path = "/usr/local/include/drawstuff";
+
+ argc = state->mainArgs->argc;
+ argv = (char **)(state->mainArgs->argv);
+
+ fn.version = DS_VERSION;
+ fn.start = &IoDrawStuffStartFunc;
+ fn.step = &IoDrawStuffStepFunc;
+ fn.command = &IoDrawStuffKeyboardFunc;
+ fn.stop = &IoDrawStuffStopFunc;
+ fn.path_to_textures = path;
+
+ int window_width = IoMessage_locals_intArgAt_(m, locals, 0);
+ int window_height = IoMessage_locals_intArgAt_(m, locals, 1);
+ dsSimulationLoop(argc, argv, window_width, window_height, &fn);
+ return self;
+}
+
+IoObject *IoDrawStuff_dsSetViewpoint(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ float *xyz;
+ float *hpr;
+ {
+ IoSeq *other = IoMessage_locals_vectorArgAt_(m, locals, 0);
+ xyz = IoSeq_floatPointerOfLength_(other, 3);
+
+ other = IoMessage_locals_vectorArgAt_(m, locals, 1);
+ hpr = IoSeq_floatPointerOfLength_(other, 3);
+ }
+
+ dsSetViewpoint(xyz, hpr);
+ return self;
+}
+
+IoObject *IoDrawStuff_dsGetViewpoint(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ float xyz[3];
+ float hpr[3];
+ vec3f v1, v2;
+ IoSeq *list_xyz = IoMessage_locals_vectorArgAt_(m, locals, 0);
+ IoSeq *list_hpr = IoMessage_locals_vectorArgAt_(m, locals, 1);
+ dsGetViewpoint(xyz, hpr);
+ v1.x = xyz[0]; v1.y = xyz[1]; v1.z = xyz[2];
+ v2.x = hpr[0]; v2.y = hpr[1]; v2.z = hpr[2];
+ memcpy(IoSeq_rawBytes(list_xyz), &v1, sizeof(vec3f));
+ memcpy(IoSeq_rawBytes(list_hpr), &v2, sizeof(vec3f));
+
+ return self;
+}
+
+IoObject *IoDrawStuff_dsStop(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ dsStop();
+ return self;
+}
+
+IoObject *IoDrawStuff_dsElapsedTime(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ double elapsed = dsElapsedTime();
+ return self;
+}
+
+IoObject *IoDrawStuff_dsSetTexture(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ int texture_number = IoMessage_locals_intArgAt_(m, locals, 0);
+ dsSetTexture(texture_number);
+ return self;
+}
+
+
+IoObject *IoDrawStuff_dsSetColor(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ float red = IoMessage_locals_intArgAt_(m, locals, 0);
+ float green = IoMessage_locals_intArgAt_(m, locals, 1);
+ float blue = IoMessage_locals_intArgAt_(m, locals, 2);
+
+ dsSetColor(red, green, blue);
+ return self;
+}
+
+IoObject *IoDrawStuff_dsSetColorAlpha(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ float red = IoMessage_locals_intArgAt_(m, locals, 0);
+ float green = IoMessage_locals_intArgAt_(m, locals, 1);
+ float blue = IoMessage_locals_intArgAt_(m, locals, 2);
+ float alpha = IoMessage_locals_intArgAt_(m, locals, 3);
+
+ dsSetColorAlpha(red, green, blue, alpha);
+ return self;
+}
+
+IoObject *IoDrawStuff_dsDrawBox(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ float *pos;
+ float *R;
+ float *sides;
+
+ //IoSeq_assertIsVector(self, locals, m);
+ {
+ IoSeq *other = IoMessage_locals_vectorArgAt_(m, locals, 0);
+ pos = IoSeq_floatPointerOfLength_(other, 3);
+
+ other = IoMessage_locals_vectorArgAt_(m, locals, 1);
+ R = IoSeq_floatPointerOfLength_(other, 12);
+
+ other = IoMessage_locals_vectorArgAt_(m, locals, 2);
+ sides = IoSeq_floatPointerOfLength_(other, 3);
+ }
+ dsDrawBox(pos, R, sides);
+ return self;
+}
+
+IoObject *IoDrawStuff_dsDrawSphere(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ float *pos;
+ float *R;
+ float radius;
+
+ //IoSeq_assertIsVector(self, locals, m);
+ {
+ IoSeq *other = IoMessage_locals_vectorArgAt_(m, locals, 0);
+ pos = IoSeq_floatPointerOfLength_(other, 3);
+
+ other = IoMessage_locals_vectorArgAt_(m, locals, 1);
+ R = IoSeq_floatPointerOfLength_(other, 12);
+
+ radius = IoMessage_locals_floatArgAt_(m, locals, 2);
+ }
+
+ dsDrawSphere(pos, R, radius);
+ return self;
+}
+
+IoObject *IoDrawStuff_dsDrawTriangle(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ float *pos;
+ float *R;
+ float *v0;
+ float *v1;
+ float *v2;
+ int solid;
+ //IoSeq_assertIsVector(self, locals, m);
+ {
+ IoSeq *other = IoMessage_locals_vectorArgAt_(m, locals, 0);
+ pos = IoSeq_floatPointerOfLength_(other, 3);
+
+ other = IoMessage_locals_vectorArgAt_(m, locals, 1);
+ R = IoSeq_floatPointerOfLength_(other, 12);
+
+ other = IoMessage_locals_vectorArgAt_(m, locals, 1);
+ v0 = IoSeq_floatPointerOfLength_(other, 3);
+ other = IoMessage_locals_vectorArgAt_(m, locals, 2);
+ v1 = IoSeq_floatPointerOfLength_(other, 3);
+ other = IoMessage_locals_vectorArgAt_(m, locals, 3);
+ v2 = IoSeq_floatPointerOfLength_(other, 3);
+
+ solid = IoMessage_locals_intArgAt_(m, locals, 4);
+ }
+ dsDrawTriangle(pos, R, v0, v1, v2, solid);
+ return self;
+}
+
+IoObject *IoDrawStuff_dsDrawCapsule(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ float *pos;
+ float *R;
+ float length;
+ float radius;
+ //IoSeq_assertIsVector(self, locals, m);
+ {
+ IoSeq *other = IoMessage_locals_vectorArgAt_(m, locals, 0);
+ pos = IoSeq_floatPointerOfLength_(other, 3);
+
+ other = IoMessage_locals_vectorArgAt_(m, locals, 1);
+ R = IoSeq_floatPointerOfLength_(other, 12);
+
+ length = IoMessage_locals_floatArgAt_(m, locals, 2);
+ radius = IoMessage_locals_floatArgAt_(m, locals, 3);
+ }
+ dsDrawCapsule(pos, R, length, radius);
+ return self;
+}
+
+IoObject *IoDrawStuff_dsDrawCylinder(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ float *pos;
+ float *R;
+ float length;
+ float radius;
+ //IoSeq_assertIsVector(self, locals, m);
+ {
+ IoSeq *other = IoMessage_locals_vectorArgAt_(m, locals, 0);
+ pos = IoSeq_floatPointerOfLength_(other, 3);
+
+ other = IoMessage_locals_vectorArgAt_(m, locals, 1);
+ R = IoSeq_floatPointerOfLength_(other, 12);
+
+ length = IoMessage_locals_floatArgAt_(m, locals, 2);
+ radius = IoMessage_locals_floatArgAt_(m, locals, 3);
+ }
+ dsDrawCylinder(pos, R, length, radius);
+ return self;
+}
+
+IoObject *IoDrawStuff_dsDrawLine(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ float *pos1;
+ float *pos2;
+
+ //IoSeq_assertIsVector(self, locals, m);
+ {
+ IoSeq *other = IoMessage_locals_vectorArgAt_(m, locals, 0);
+ pos1 = IoSeq_floatPointerOfLength_(other, 3);
+
+ other = IoMessage_locals_vectorArgAt_(m, locals, 1);
+ pos2 = IoSeq_floatPointerOfLength_(other, 3);
+ }
+
+ dsDrawLine(pos1, pos2);
+ return self;
+}
+
+IoObject *IoDrawStuff_dsDrawConvex(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ float *pos;
+ float *R;
+ float *_planes;
+ int _planecount;
+ float *points;
+ int _pointcount;
+ int *_polygons;
+ return self;
+}
+
+IoObject *IoDrawStuff_dsSetSphereQuality(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ int n;
+ n = IoMessage_locals_intArgAt_(m, locals, 0);
+ dsSetSphereQuality(n);
+ return self;
+}
+
+IoObject *IoDrawStuff_dsSetCapsuleQuality(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ int n;
+ n = IoMessage_locals_intArgAt_(m, locals, 0);
+ dsSetCapsuleQuality(n);
+ return self;
+}
+
+IoObject *IoDrawStuff_dsSetDrawMode(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ int mode;
+ mode = IoMessage_locals_intArgAt_(m, locals, 0);
+ dsSetDrawMode(mode);
+ return self;
+}
+
+IoObject *IoDrawStuff_eventTarget(IoDrawStuff *self, IoObject *locals, IoMessage *m)
+{
+ DATA(proto)->eventTarget = IOREF(IoMessage_locals_valueArgAt_(m, locals, 0));
+ return self;
+}
+
+
+
View
58 addons/ODE/source/IoDrawStuff.h
@@ -0,0 +1,58 @@
+//metadoc DrawStuff copyright ∃teslos 2013
+//metadoc DrawStuff license BSD revised
+
+#ifndef IODRAWSTUFF_DEFINED
+#define IODRAWSTUFF_DEFINED 1
+
+#include "IoObject.h"
+#include "IoSeq.h"
+#include "IoCoroutine.h"
+
+#include <drawstuff/drawstuff.h>
+
+typedef IoObject IoDrawStuff;
+
+typedef struct
+{
+ IoCoroutine *coroutine;
+ IoObject *eventTarget;
+ IoMessage *keyboardMessage;
+ IoMessage *startMessage;
+ IoMessage *stepMessage;
+ IoMessage *stopMessage;
+
+} IoDrawStuffData;
+
+IoObject *IoDrawStuff_rawClone(IoDrawStuff *self);
+IoDrawStuff *IoDrawStuff_proto(void *state);
+void IoDrawStuff_free(IoDrawStuff *self);
+void IoDrawStuff_mark(IoDrawStuff *self);
+
+void IoDrawStuff_protoInit(IoDrawStuff *self);
+
+// ---- events -----------------------------------
+IoObject *IoDrawStuff_dsSimulationLoop(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsSetViewpoint(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsGetViewpoint(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsElapsedTime(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsStop(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsSetTexture(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsSetColor(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsSetColorAlpha(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsDrawBox(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsDrawSphere(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsDrawTriangle(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsDrawCylinder(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsDrawCapsule(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsDrawLine(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsDrawConvex(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsSetSphereQuality(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsSetCapsuleQuality(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_dsSetDrawMode(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+IoObject *IoDrawStuff_eventTarget(IoDrawStuff *self, IoObject *locals, IoMessage *m);
+void IoDrawStuffKeyboardFunc();
+void IoDrawStuffStartFunc();
+void IoDrawStuffStepFunc(int pause);
+void IoDrawStuffStopFunc();
+
+#endif
View
3  addons/ODE/source/IoODEBall.c
@@ -54,7 +54,6 @@ IoODEBall *IoODEBall_proto(void *state)
IoODEBall *IoODEBall_rawClone(IoODEBall *proto)
{
IoObject *self = IoODEJoint_rawClone(proto);
-
if(DATA(proto)->jointGroup)
{
IoODEJointGroup *jointGroup = DATA(proto)->jointGroup;
@@ -78,7 +77,7 @@ void IoODEBall_mark(IoODEBall *self)
IoODEJoint *IoODEBall_newProto(void *state, IoODEJointGroup *jointGroup)
{
- return IoODEJoint_newProtoCommon(state, IoODEBall_proto, jointGroup);
+ return IoODEJoint_newProtoCommon(state, protoId, jointGroup);
}
/* ----------------------------------------------------------- */
View
2  addons/ODE/source/IoODEContactJoint.c
@@ -71,7 +71,7 @@ void IoODEContactJoint_mark(IoODEContactJoint *self)
IoODEContactJoint *IoODEContactJoint_new(void *state, IoODEJointGroup *jointGroup, dJointID jointId)
{
- IoODEContactJoint *self = IoODEJoint_newProtoCommon(state, IoODEContactJoint_proto, jointGroup);
+ IoODEContactJoint *self = IoODEJoint_newProtoCommon(state, protoId, jointGroup);
JOINTID = jointId;
IoODEJointGroup_addJoint(JOINTGROUP, self);
View
2  addons/ODE/source/IoODEFixed.c
@@ -75,7 +75,7 @@ void IoODEFixed_mark(IoODEFixed *self)
IoODEJoint *IoODEFixed_newProto(void *state, IoODEJointGroup *jointGroup)
{
- return IoODEJoint_newProtoCommon(state, IoODEFixed_proto, jointGroup);
+ return IoODEJoint_newProtoCommon(state, protoId, jointGroup);
}
/* ----------------------------------------------------------- */
View
2  addons/ODE/source/IoODEHinge.c
@@ -87,7 +87,7 @@ void IoODEHinge_mark(IoODEHinge *self)
IoODEJoint *IoODEHinge_newProto(void *state, IoODEJointGroup *jointGroup)
{
- return IoODEJoint_newProtoCommon(state, IoODEHinge_proto, jointGroup);
+ return IoODEJoint_newProtoCommon(state, protoId, jointGroup);
}
/* ----------------------------------------------------------- */
View
4 addons/ODE/source/IoODEHinge2.c
@@ -33,7 +33,7 @@ IoODEHinge2 *IoODEHinge2_proto(void *state)
IoODEJoint_protoCommon(self);
- IoState_registerProtoWithFunc_(state, self, IoODEHinge2_proto);
+ IoState_registerProtoWithId_(state, self, protoId);
{
IoMethodTable methodTable[] = {
@@ -90,7 +90,7 @@ void IoODEHinge2_mark(IoODEHinge2 *self)
IoODEJoint *IoODEHinge2_newProto(void *state, IoODEJointGroup *jointGroup)
{
- return IoODEJoint_newProtoCommon(state, IoODEHinge2_proto, jointGroup);
+ return IoODEJoint_newProtoCommon(state, protoId, jointGroup);
}
/* ----------------------------------------------------------- */
View
10 addons/ODE/source/IoODEJoint.c
@@ -74,15 +74,16 @@ void IoODEJoint_free(IoODEJoint *self)
void IoODEJoint_mark(IoODEJoint *self)
{
+
if(JOINTGROUP)
{
IoObject_shouldMark((IoObject *)JOINTGROUP);
}
}
-IoODEJoint *IoODEJoint_newProtoCommon(void *state, IoStateProtoFunc *func, IoODEJointGroup *jointGroup)
+IoODEJoint *IoODEJoint_newProtoCommon(void *state, const char *protoWithId, IoODEJointGroup *jointGroup)
{
- IoODEJoint *proto = IoState_protoWithId_(state, func);
+ IoODEJoint *proto = IoState_protoWithId_(state, protoWithId);
IoODEJoint *self = IOCLONE(proto);
JOINTGROUP = jointGroup;
return self;
@@ -111,15 +112,14 @@ IoObject *IoODEJoint_jointGroup(IoODEJoint *self, IoObject *locals, IoMessage *m
void IoODEJoint_assertValidJoint(IoODEJoint *self, IoObject *locals, IoMessage *m)
{
- IOASSERT(JOINTGROUP, "This ODE joint belongs to an ODE joint group which has been freed or emptied.");
- IOASSERT(JOINTID, "ODE Joint cannot be used directly. Clone the joint and use the Joint on the cloned joint.");
+ //IOASSERT(JOINTGROUP, "This ODE joint belongs to an ODE joint group which has been freed or emptied.");
+ //IOASSERT(JOINTID, "ODE Joint cannot be used directly. Clone the joint and use the Joint on the cloned joint.");
}
IoObject *IoODEJoint_attach(IoODEJoint *self, IoObject *locals, IoMessage *m)
{
dBodyID body1 = IoMessage_locals_odeBodyIdArgAt_(m, locals, 0);
dBodyID body2 = IoMessage_locals_odeBodyIdArgAt_(m, locals, 1);
-
IoODEJoint_assertValidJoint(self, locals, m);
dJointAttach(JOINTID, body1, body2);
return self;
View
2  addons/ODE/source/IoODEJointGroup.c
@@ -50,7 +50,7 @@ IoODEJointGroup *IoODEJointGroup_proto(void *state)
WORLD = 0L;
DATA(self)->joints = 0L;
- IoState_registerProtoWithFunc_(state, self, IoODEJointGroup_proto);
+ IoState_registerProtoWithId_(state, self, protoId);
{
IoMethodTable methodTable[] = {
View
2  addons/ODE/source/IoODEJoint_internal.h
@@ -9,7 +9,7 @@
#define JOINTGROUPID (IoODEJointGroup_rawJointGroupId(JOINTGROUP))
void IoODEJoint_protoCommon(IoODEJoint *self);
-IoODEJoint *IoODEJoint_newProtoCommon(void *state, IoStateProtoFunc *func, IoODEJointGroup *jointGroup);
+IoODEJoint *IoODEJoint_newProtoCommon(void *state, const char *protoWithId, IoODEJointGroup *jointGroup);
void IoODEJoint_assertValidJoint(IoODEJoint *self, IoObject *locals, IoMessage *m);
View
2  addons/ODE/source/IoODEMass.c
@@ -31,7 +31,7 @@ IoODEMass *IoODEMass_proto(void *state)
IoObject_setDataPointer_(self, calloc(1, sizeof(IoODEMassData)));
- IoState_registerProtoWithFunc_(state, self, IoODEMass_proto);
+ IoState_registerProtoWithId_(state, self, protoId);
{
IoMethodTable methodTable[] = {
View
2  addons/ODE/source/IoODEPlane.c
@@ -35,7 +35,7 @@ IoODEPlane *IoODEPlane_proto(void *state)
GEOMID = 0;
- IoState_registerProtoWithFunc_(state, self, IoODEPlane_proto);
+ IoState_registerProtoWithId_(state, self, protoId);
{
IoMethodTable methodTable[] = {
View
2  addons/ODE/source/IoODESimpleSpace.c
@@ -39,7 +39,7 @@ IoODESimpleSpace *IoODESimpleSpace_proto(void *state)
SPACEID = 0;
- IoState_registerProtoWithFunc_(state, self, IoODESimpleSpace_proto);
+ IoState_registerProtoWithId_(state, self, protoId);
{
IoMethodTable methodTable[] = {
View
4 addons/ODE/source/IoODESlider.c
@@ -34,7 +34,7 @@ IoODESlider *IoODESlider_proto(void *state)
IoODEJoint_protoCommon(self);
- IoState_registerProtoWithFunc_(state, self, IoODESlider_proto);
+ IoState_registerProtoWithId_(state, self, protoId);
{
IoMethodTable methodTable[] = {
@@ -85,7 +85,7 @@ void IoODESlider_mark(IoODESlider *self)
IoODEJoint *IoODESlider_newProto(void *state, IoODEJointGroup *jointGroup)
{
- return IoODEJoint_newProtoCommon(state, IoODESlider_proto, jointGroup);
+ return IoODEJoint_newProtoCommon(state, protoId, jointGroup);
}
/* ----------------------------------------------------------- */
View
4 addons/ODE/source/IoODEUniversal.c
@@ -33,7 +33,7 @@ IoODEUniversal *IoODEUniversal_proto(void *state)
IoODEJoint_protoCommon(self);
- IoState_registerProtoWithFunc_(state, self, IoODEUniversal_proto);
+ IoState_registerProtoWithId_(state, self, protoId);
{
IoMethodTable methodTable[] = {
@@ -91,7 +91,7 @@ void IoODEUniversal_mark(IoODEUniversal *self)
IoODEJoint *IoODEUniversal_newProto(void *state, IoODEJointGroup *jointGroup)
{
- return IoODEJoint_newProtoCommon(state, IoODEUniversal_proto, jointGroup);
+ return IoODEJoint_newProtoCommon(state, protoId, jointGroup);
}
/* ----------------------------------------------------------- */
View
3  addons/ODE/source/IoODEWorld.c
@@ -214,7 +214,8 @@ IoObject *IoODEWorld_stepFast1(IoODEWorld *self, IoObject *locals, IoMessage *m)
const int maxIterations = IoMessage_locals_intArgAt_(m, locals, 1);
IoODEWorld_assertHasWorldId(self, locals, m);
- dWorldStepFast1(WORLDID, stepSize, maxIterations);
+ dWorldQuickStep(WORLDID, stepSize);
+ //dWorldStepFast1(WORLDID, stepSize, maxIterations);
return self;
}
View
49 modules/FindODE.cmake
@@ -0,0 +1,49 @@
+# Base Io build system
+# Written by there.exists.teslos<there.exists.teslos.gmail.com>
+#
+# Find ODE Open Dynamics Engine
+FIND_PATH(ODE_INCLUDE_DIR ode/ode.h
+ /usr/include
+ /usr/local/include
+)
+FIND_PATH(DRAWSTUFF_INCLUDE_DIR drawstuff/drawstuff.h
+ /Users/toniivas/Documents/Sources/ode-0.12/include
+)
+
+SET(ODE_NAMES ${ODE_NAMES} ode libode)
+SET(DRAW_NAMES ${DRAW_NAMES} drawstuff libdrawstuff)
+FIND_LIBRARY(ODE_LIBRARY NAMES ${ODE_NAMES} PATH)
+FIND_LIBRARY(DRAWSTUFF_LIBRARY NAMES ${DRAW_NAMES} PATH)
+
+IF(ODE_INCLUDE_DIR)
+ MESSAGE(STATUS "Found ODE include dir: ${ODE_INCLUDE_DIR}")
+ELSE(ODE_INCLUDE_DIR)
+ MESSAGE(STATUS "Couldn't find ODE include dir: ${ODE_INCLUDE_DIR}")
+ENDIF(ODE_INCLUDE_DIR)
+
+IF(ODE_LIBRARY)
+ MESSAGE(STATUS "Found ODE library: ${ODE_LIBRARY}")
+ELSE(ODE_LIBRARY)
+ MESSAGE(STATUS "Couldn't find ODE library: ${ODE_LIBRARY}")
+ENDIF(ODE_LIBRARY)
+
+IF(DRAWSTUFF_LIBRARY)
+ MESSAGE(STATUS "Found DrawStuff library: ${DRAWSTUFF_LIBRARY}")
+ELSE(DRAWSTUFF_LIBRARY)
+ MESSAGE(STATUS "Coulddn't find DrawStuff library: ${DRAWSTUFF_LIBRARY}")
+ENDIF(DRAWSTUFF_LIBRARY)
+
+IF(ODE_INCLUDE_DIR AND ODE_LIBRARY)
+ SET(ODE_FOUND TRUE CACHE STRING "Whether ODE was found or not")
+ENDIF(ODE_INCLUDE_DIR AND ODE_LIBRARY)
+
+IF(ODE_FOUND)
+ SET(CMAKE_C_FLAGS "-DdSINGLE")
+ IF(NOT ODE_FIND_QUIETLY)
+ MESSAGE(STATUS "Found ODE: ${ODE_LIBRARY}")
+ ENDIF (NOT ODE_FIND_QUIETLY)
+ELSE(ODE_FOUND)
+ IF(ODE_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find ODE")
+ ENDIF(ODE_FIND_REQUIRED)
+ENDIF(ODE_FOUND)
Please sign in to comment.
Something went wrong with that request. Please try again.