Changeset 14310
- Timestamp:
- 06/20/08 22:55:55 (5 years ago)
- Location:
- lang/ruby/pitagora/trunk/ode_ruby
- Files:
-
- 14 added
- 5 modified
-
build.sh (modified) (1 diff)
-
demo/objects.rb (modified) (7 diffs)
-
demo/test2.rb (modified) (9 diffs)
-
diffs/DIFF_ode-0.9.txt (modified) (1 diff)
-
src/ode_cpp.i (modified) (2 diffs)
-
textures (added)
-
textures/RubyKaigi08_LT_Pitagora.odp (added)
-
textures/ground.ppm (added)
-
textures/sky.ppm (added)
-
textures/user_001.png (added)
-
textures/user_001.ppm (added)
-
textures/user_002.png (added)
-
textures/user_002.ppm (added)
-
textures/user_011.ppm (added)
-
textures/user_012.ppm (added)
-
textures/user_013.ppm (added)
-
textures/user_014.ppm (added)
-
textures/user_015.ppm (added)
-
textures/wood.ppm (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/pitagora/trunk/ode_ruby/build.sh
r14282 r14310 20 20 -x "dstest \ 21 21 -r ../ode-0.9_orig ../ode-0.9_fix > diffs/DIFF_ode-0.9.txt 22 cat DIFF_ode-0.9.txt 22 23 cp diffs/DIFF_ode-0.9.txt "diffs/DIFF_ode-0.9_`date`.txt" 23 cat DIFF_ode-0.9.txt 24 24 25 25 26 -
lang/ruby/pitagora/trunk/ode_ruby/demo/objects.rb
r14282 r14310 20 20 # wrap objects 21 21 class Base 22 attr_reader :geom, :body, :color, :pars 22 attr_reader :geom, :body, :color, :pars, :texture 23 23 @@color_index = 0 24 24 def initialize(*_pars) 25 25 @color = COLORS[@@color_index] #[1.0, 0.0, 0.0] 26 @texture = 0 26 27 @@color_index += 1 27 28 @@color_index = @@color_index % COLORS.size … … 52 53 rot = (0..11).collect{|n| pRot[n] } 53 54 end 55 def rotation=(r) 56 @body.setRotation(r) 57 end 58 def quaternion=(q) 59 @body.setQuaternion(q) 60 end 54 61 def color=(rgb) 55 62 @color = rgb.collect{|n| n.to_f } … … 59 66 @pars = _pars.dup 60 67 reset 68 end 69 def texture=(t) 70 @texture = t 61 71 end 62 72 def draw … … 102 112 def ds_draw 103 113 DrawStuff::DSLib.dsSetColor(*color) 114 DrawStuff::DSLib.dsSetTexture(@texture) 104 115 DrawStuff::DSLib.dsDrawBoxD(self.position, self.rotation, @geom.getLengths) 105 116 end … … 131 142 def ds_draw 132 143 DrawStuff::DSLib.dsSetColor(*color) 133 #DrawStuff::DSLib.dsSetTexture(1)144 DrawStuff::DSLib.dsSetTexture(@texture) 134 145 DrawStuff::DSLib.dsDrawSphereD(self.position, self.rotation, @geom.getRadius) 135 146 end … … 163 174 def ds_draw 164 175 DrawStuff::DSLib.dsSetColor(*color) 165 #DrawStuff::DSLib.dsSetTexture(1)176 DrawStuff::DSLib.dsSetTexture(@texture) 166 177 radius,length = @geom.getParams 167 178 DrawStuff::DSLib.dsDrawCapsuleD(self.position, self.rotation, length, radius) … … 196 207 def ds_draw 197 208 DrawStuff::DSLib.dsSetColor(*color) 198 #DrawStuff::DSLib.dsSetTexture(1)209 DrawStuff::DSLib.dsSetTexture(@texture) 199 210 radius,length = @geom.getParams 200 211 DrawStuff::DSLib.dsDrawCylinderD(self.position, self.rotation, length, radius) -
lang/ruby/pitagora/trunk/ode_ruby/demo/test2.rb
r14282 r14310 13 13 # ポインタを拡充 14 14 # colors 15 # blog / coderepos / 動画 16 # ppmを動画にする方法 15 # 3Dプレゼン テクスチャ切替 17 16 18 17 … … 26 25 window_width = 352*2 27 26 window_height = 228*2 27 DEG_TO_RAD = Math::PI/180.0 28 28 29 29 #-------------------------------------------------------------- … … 84 84 create_capsule_cylinder 85 85 create_pins 86 create_slides 86 87 #ray = Ray.new(1) 87 88 #ray.position = [0, -4, 5] … … 126 127 obj.color = hash[:color] 127 128 obj.position = hash[:position] 128 # obj.rotation = hash[:rotation] # TODO!!129 obj.rotation = hash[:rotation] 129 130 end 130 131 end … … 166 167 slope.position = [7, 0, 3.2] 167 168 slope.color = [1.0, 0.7, 0] 169 #slope.texture = 1001 168 170 end 169 171 … … 190 192 end 191 193 end 194 195 def create_slides 196 [[15, 6, 1], 197 [10, 8, 1], 198 [ 5, 10, 1], 199 [ 0, 12, 1], 200 [-5, 10, 1], 201 ].each_with_index do |pos,index| 202 s = Box.new([1, 1, 0.5], 1) 203 s.position = pos 204 s.color = [2,2,2] 205 s.texture = 1011+index 206 r = Ode_cpp::dRFromAxisAndAngle(0, 1, 0, 80*DEG_TO_RAD) 207 s.rotation = r 208 end 209 210 #r1 = Ode_cpp::dRFromAxisAndAngle(0, 1, 0, 45*DEG_TO_RAD) 211 #r2 = Ode_cpp::dRFromAxisAndAngle(0, 0, 1, -45*DEG_TO_RAD) 212 #q1 = Ode_cpp::dQfromR(r1) 213 #q2 = Ode_cpp::dQfromR(r2) 214 #q = Ode_cpp::dQMultiply0(q1, q2) 215 #r = Ode_cpp::dRFromAxisAndAngle(0, 1, 0, -90*DEG_TO_RAD) 216 #s1.quaternion = q 217 end 218 192 219 193 220 def rand_within(from, to) … … 214 241 215 242 require "draw_stuff" 216 path_to_textures = File.join(File.dirname(__FILE__), "../../ode-0.9_fix/drawstuff/textures") 243 #path_to_textures = File.join(File.dirname(__FILE__), "../../ode-0.9_fix/drawstuff/textures") 244 path_to_textures = File.join(File.dirname(__FILE__), "../textures") 217 245 ds = DrawStuff.new(:world=>$world, 218 246 :width =>window_width, … … 237 265 #xyz = [ 50.0, 0.0, 1.0] # 視点の位置 238 266 #hpr = [-180.0, 0.0, 0.0] # 視線の方向 239 xyz = [18.7891311645508, 10.3102083206177, 4.46602010726929] 240 hpr = [-134.198913574219, -13.0999450683594, 0.0] 267 #xyz = [18.7891311645508, 10.3102083206177, 4.46602010726929] 268 #hpr = [-134.198913574219, -13.0999450683594, 0.0] 269 xyz=[15.7971229553223, 5.94557666778564, 1.14663815498352] 270 hpr=[177.560760498047, -10.6020441055298, 0.0] 241 271 self.set_viewpoint(xyz, hpr) 242 272 end … … 616 646 617 647 def wii_remote_client=(c) @wii_remote_client = c; end 618 DEG_TO_RAD = Math::PI/180.0619 648 #// call this to update the current camera position. the bits in `mode' say 620 649 #// if the left (1), middle (2) or right (4) mouse button is pressed, and -
lang/ruby/pitagora/trunk/ode_ruby/diffs/DIFF_ode-0.9.txt
r14282 r14310 1 diff -x '*.in' -x '*.o' -x '*.a' -x 'demo_*' -x Makefile -x '*.m4' -x configure -x 'config.*' -x .deps -x 'stamp-h1 -x libode.dylib' -x 'ode-config -x ode_unit_test' -x 'autom4te.cache -x dstest' -r ../ode-0.9_orig/.svn/all-wcprops ../ode-0.9_fix/.svn/all-wcprops 2 3,4c3,4 3 < V 59 4 < /share/!svn/ver/14282/lang/ruby/pitagora/trunk/ode-0.9_orig 5 --- 6 > V 58 7 > /share/!svn/ver/14282/lang/ruby/pitagora/trunk/ode-0.9_fix 8 diff -x '*.in' -x '*.o' -x '*.a' -x 'demo_*' -x Makefile -x '*.m4' -x configure -x 'config.*' -x .deps -x 'stamp-h1 -x libode.dylib' -x 'ode-config -x ode_unit_test' -x 'autom4te.cache -x dstest' -r ../ode-0.9_orig/.svn/entries ../ode-0.9_fix/.svn/entries 9 5c5 10 < http://svn.coderepos.org/share/lang/ruby/pitagora/trunk/ode-0.9_orig 11 --- 12 > http://svn.coderepos.org/share/lang/ruby/pitagora/trunk/ode-0.9_fix 1 13 Only in ../ode-0.9_fix: autom4te.cache 2 14 Only in ../ode-0.9_fix/drawstuff/dstest: dstest 15 diff -x '*.in' -x '*.o' -x '*.a' -x 'demo_*' -x Makefile -x '*.m4' -x configure -x 'config.*' -x .deps -x 'stamp-h1 -x libode.dylib' -x 'ode-config -x ode_unit_test' -x 'autom4te.cache -x dstest' -r ../ode-0.9_orig/drawstuff/src/drawstuff.cpp ../ode-0.9_fix/drawstuff/src/drawstuff.cpp 16 887a888,890 17 > #define USER_TEXTURE_OFFSET 1000 18 > #define USER_TEXTURE_COUNT 100 19 > static Texture* user_textures[USER_TEXTURE_COUNT]; 20 907a911,937 21 > 22 > //----- 23 > //user_textures = new Texture[100]; 24 > for(int i=0; i<USER_TEXTURE_COUNT; i++){ // 0..99 25 > int file_ok = 0; 26 > char *fn = (char*) alloca(20); 27 > strcpy (s,prefix); 28 > sprintf(fn, "/user_%.3d.ppm", i); 29 > strcat (s, fn); 30 > //dsDebug(fn); 31 > FILE *f = fopen (s,"rb"); 32 > if(!f){ 33 > file_ok = 0; 34 > //dsError ("Can't open image file `%s'",fn); 35 > }else{ 36 > file_ok = 1; 37 > fclose(f); 38 > } 39 > if(file_ok){ 40 > user_textures[i] = new Texture(s); 41 > //dsDebug("OK"); 42 > }else{ 43 > user_textures[i] = 0; 44 > //dsDebug("NG"); 45 > } 46 > } 47 > //----- 48 928a959,960 49 > 50 > //TODO load user_textures 51 938a971,978 52 > for(int i=0; i<USER_TEXTURE_COUNT; i++){ 53 > Texture* t = user_textures[i]; 54 > if(t){ 55 > delete t; 56 > user_textures[i] = 0; 57 > } 58 > } 59 > //delete user_textures; 60 941a982 61 > //user_textures = 0; 62 1201c1242,1254 63 < wood_texture->bind (1); 64 --- 65 > // wood_texture->bind (1); 66 > //----- 67 > if(USER_TEXTURE_OFFSET<=tnum){ 68 > Texture* t = user_textures[tnum-USER_TEXTURE_OFFSET]; 69 > if(t){ 70 > t->bind (1); 71 > }else{ 72 > wood_texture->bind (1); 73 > } 74 > }else{ 75 > wood_texture->bind (1); 76 > } 77 > //----- 78 1203a1257 79 > 80 1206,1207c1260,1265 81 < static GLfloat s_params[4] = {1.0f,1.0f,0.0f,1}; 82 < static GLfloat t_params[4] = {0.817f,-0.817f,0.817f,1}; 83 --- 84 > //static GLfloat s_params[4] = { 1.0f, 1.0f, 0.0f, 1}; 85 > //static GLfloat t_params[4] = {0.817f, -0.817f, 0.817f, 1}; 86 > 87 > //glTranslated(-0.5, -0.5, 0.0); 88 > static GLfloat s_params[4] = { 0.0f, 1.0f, 0.0f, 0.5f}; 89 > static GLfloat t_params[4] = { 1.0f, 0.0f, 0.0f, 0.5f}; 90 Only in ../ode-0.9_fix/drawstuff/src: drawstuff.cpp~ 3 91 diff -x '*.in' -x '*.o' -x '*.a' -x 'demo_*' -x Makefile -x '*.m4' -x configure -x 'config.*' -x .deps -x 'stamp-h1 -x libode.dylib' -x 'ode-config -x ode_unit_test' -x 'autom4te.cache -x dstest' -r ../ode-0.9_orig/include/ode/mass.h ../ode-0.9_fix/include/ode/mass.h 4 92 106a107,110 -
lang/ruby/pitagora/trunk/ode_ruby/src/ode_cpp.i
r14282 r14310 73 73 } 74 74 75 76 // [const dMatrix3 R] ************************************ 77 //void setRotation (const dMatrix3 R) 78 // { dGeomSetRotation (_id,R); } 79 80 //------------------------------------------------------- 81 // for dMatrix3 input param 82 %typemap(in) const dMatrix3 R { 83 $1 = (dReal*)malloc(sizeof(dMatrix3)); 84 VALUE r = $input; 85 $1[0] = NUM2DBL(rb_ary_entry(r, 0)); 86 $1[1] = NUM2DBL(rb_ary_entry(r, 1)); 87 $1[2] = NUM2DBL(rb_ary_entry(r, 2)); 88 $1[3] = NUM2DBL(rb_ary_entry(r, 3)); 89 $1[4] = NUM2DBL(rb_ary_entry(r, 4)); 90 $1[5] = NUM2DBL(rb_ary_entry(r, 5)); 91 $1[6] = NUM2DBL(rb_ary_entry(r, 6)); 92 $1[7] = NUM2DBL(rb_ary_entry(r, 7)); 93 $1[8] = NUM2DBL(rb_ary_entry(r, 8)); 94 $1[9] = NUM2DBL(rb_ary_entry(r, 9)); 95 $1[10] = NUM2DBL(rb_ary_entry(r, 10)); 96 $1[11] = NUM2DBL(rb_ary_entry(r, 11)); 97 } 98 %typemap(freearg) const dMatrix3 R { 99 free($1); 100 } 101 102 //------------------------------------------------------- 103 // for dMatrix3 output param 104 %typemap(ignore) dMatrix3 R { 105 $1 = (dReal*)malloc(sizeof(dMatrix3)); 106 } 107 %typemap(argout) dMatrix3 R { 108 $result = rb_ary_new(); 109 rb_ary_push($result, rb_float_new($1[0])); 110 rb_ary_push($result, rb_float_new($1[1])); 111 rb_ary_push($result, rb_float_new($1[2])); 112 rb_ary_push($result, rb_float_new($1[3])); 113 rb_ary_push($result, rb_float_new($1[4])); 114 rb_ary_push($result, rb_float_new($1[5])); 115 rb_ary_push($result, rb_float_new($1[6])); 116 rb_ary_push($result, rb_float_new($1[7])); 117 rb_ary_push($result, rb_float_new($1[8])); 118 rb_ary_push($result, rb_float_new($1[9])); 119 rb_ary_push($result, rb_float_new($1[10])); 120 rb_ary_push($result, rb_float_new($1[11])); 121 } 122 %typemap(freearg) dMatrix3 R { 123 free($1); 124 } 125 126 127 128 //------------------------------------------------------- 129 // for dQuaternion input param 130 %typemap(in) const dQuaternion q { 131 $1 = (dReal*)malloc(sizeof(dQuaternion)); 132 VALUE r = $input; 133 $1[0] = NUM2DBL(rb_ary_entry(r, 0)); 134 $1[1] = NUM2DBL(rb_ary_entry(r, 1)); 135 $1[2] = NUM2DBL(rb_ary_entry(r, 2)); 136 $1[3] = NUM2DBL(rb_ary_entry(r, 3)); 137 } 138 %typemap(freearg) const dQuaternion q { 139 free($1); 140 } 141 %apply const dQuaternion q { const dQuaternion quat }; 142 %apply const dQuaternion q { const dQuaternion B }; 143 144 145 //------------------------------------------------------- 146 // for dQuaternion output param 147 %typemap(ignore) dQuaternion q { 148 $1 = (dReal*)malloc(sizeof(dQuaternion)); 149 } 150 %typemap(argout) dQuaternion q { 151 $result = rb_ary_new(); 152 rb_ary_push($result, rb_float_new($1[0])); 153 rb_ary_push($result, rb_float_new($1[1])); 154 rb_ary_push($result, rb_float_new($1[2])); 155 rb_ary_push($result, rb_float_new($1[3])); 156 } 157 %typemap(freearg) dQuaternion q { 158 free($1); 159 } 160 %apply dQuaternion q { dQuaternion qa }; 161 75 162 #define ODE_API extern 76 163 %include "ode/mass.h" 164 %include "ode/rotation.h" 77 165 #undef ODE_API 78 166 %include "ode/contact.h" 167 168 169 170 /* matrix multiplication. all matrices are stored in standard row format. 171 * the digit refers to the argument that is transposed: 172 * 0: A = B * C (sizes: A:p*r B:p*q C:q*r) 173 * 1: A = B' * C (sizes: A:p*r B:q*p C:q*r) 174 * 2: A = B * C' (sizes: A:p*r B:p*q C:r*q) 175 * case 1,2 are equivalent to saying that the operation is A=B*C but 176 * B or C are stored in standard column format. 177 */ 178 //ODE_API void dMultiply0 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); 179 //ODE_API void dMultiply1 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); 180 //ODE_API void dMultiply2 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); 181 182 183 79 184 80 185 … … 160 265 //END C API 161 266 162 163 267 %include "ode/odecpp.h" 164 268 %include "ode/odecpp_collision.h"
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)