├── Demo1-Leg-NoDefStyles ├── Legs-Benchmark-No-DefStyles.exe ├── glut32.dll └── shaders │ ├── deform.frag │ ├── deform.vert │ ├── matrices.frag │ ├── matrices.vert │ ├── matrices2.frag │ ├── matrices2.vert │ ├── normal.frag │ ├── normal.vert │ ├── shadow.frag │ └── shadow.vert ├── Demo1-Leg ├── Legs-Benchmark.exe ├── Legs-Demo.exe ├── glut32.dll └── shaders │ ├── deform.frag │ ├── deform.vert │ ├── matrices.frag │ ├── matrices.vert │ ├── matrices2.frag │ ├── matrices2.vert │ ├── normal.frag │ ├── normal.vert │ ├── shadow.frag │ └── shadow.vert ├── Demo2-Cuboid ├── Cuboid-Demo.exe ├── glut32.dll └── shaders │ ├── deform.frag │ ├── deform.vert │ ├── matrices.frag │ ├── matrices.vert │ ├── matrices2.frag │ ├── matrices2.vert │ ├── normal.frag │ ├── normal.vert │ ├── shadow.frag │ └── shadow.vert ├── Demo3-Arm ├── Char1-Demo.exe ├── Char2-Demo.exe ├── glut32.dll └── shaders │ ├── deform.frag │ ├── deform.vert │ ├── matrices.frag │ ├── matrices.vert │ ├── matrices2.frag │ ├── matrices2.vert │ ├── normal.frag │ ├── normal.vert │ ├── shadow.frag │ └── shadow.vert ├── LICENSE ├── README.md ├── SCA-Deformation-Styles-Paper.pdf ├── Source.Arm ├── Arm.vcproj ├── Bmp.cpp ├── Bmp.h ├── Deformer.h ├── GFX.cpp ├── GFX.h ├── Geometry.h ├── Main.cpp ├── Makefile.am ├── Makefile.in ├── MouseKeyboard.h ├── ObjControl.h ├── ObjManager.h ├── PBuffer.h ├── Spline.h ├── Tools.h ├── VecMath.cpp ├── VecMath.h ├── glsl.cpp ├── glsl.h ├── glut32.dll ├── render_matrices.h ├── render_matrices_2.h ├── render_to_vertexbuffer.h └── shaders │ ├── deform.frag │ ├── deform.vert │ ├── matrices.frag │ ├── matrices.vert │ ├── matrices2.frag │ ├── matrices2.vert │ ├── normal.frag │ ├── normal.vert │ ├── shadow.frag │ └── shadow.vert ├── Source.Cuboid ├── Bmp.cpp ├── Bmp.h ├── Deformer.h ├── GFX.cpp ├── GFX.h ├── Geometry.h ├── Main.cpp ├── Makefile.am ├── Makefile.in ├── MouseKeyboard.h ├── ObjControl.h ├── ObjManager.h ├── PBuffer.cpp ├── PBuffer.h ├── Spline.h ├── Tools.h ├── VecMath.cpp ├── VecMath.h ├── cuboid.vcproj ├── glsl.cpp ├── glsl.h ├── glut32.dll ├── render_matrices.h ├── render_matrices_2.h ├── render_to_vertexbuffer.h └── shaders │ ├── deform.frag │ ├── deform.vert │ ├── matrices.frag │ ├── matrices.vert │ ├── matrices2.frag │ ├── matrices2.vert │ ├── normal.frag │ ├── normal.vert │ ├── shadow.frag │ └── shadow.vert ├── Source.LegBench ├── Bmp.cpp ├── Bmp.h ├── Deformer.h ├── GFX.cpp ├── GFX.h ├── Geometry.h ├── LegBench.vcproj ├── Main.cpp ├── Makefile.am ├── Makefile.in ├── MouseKeyboard.h ├── ObjControl.h ├── ObjManager.h ├── PBuffer.cpp ├── PBuffer.h ├── Spline.h ├── Tools.h ├── VecMath.cpp ├── VecMath.h ├── glsl.cpp ├── glsl.h ├── glut32.dll ├── render_matrices.h ├── render_matrices_2.h ├── render_to_vertexbuffer.h └── shaders │ ├── deform.frag │ ├── deform.vert │ ├── matrices.frag │ ├── matrices.vert │ ├── matrices2.frag │ ├── matrices2.vert │ ├── normal.frag │ ├── normal.vert │ ├── shadow.frag │ └── shadow.vert ├── include ├── 3D │ ├── Matrix.h │ ├── Point.h │ ├── Quaternion.h │ ├── Tuple3.h │ ├── Tuple4.h │ ├── Vector.h │ └── basic.h ├── Cg │ ├── cg.h │ ├── cgContextManager.h │ ├── cgD3D.h │ ├── cgD3D8.h │ ├── cgD3D9.h │ ├── cgGL.h │ ├── cgGL_profiles.h │ ├── cgProgramManager.h │ ├── cgTemplates.h │ ├── cg_bindlocations.h │ ├── cg_datatypes.h │ ├── cg_enums.h │ ├── cg_errors.h │ └── cg_profiles.h ├── GL │ ├── glext.h │ ├── glut.def │ ├── glut.h │ ├── glut32.dll │ ├── glut32.lib │ ├── glxext.h │ └── wglext.h ├── config.h └── mathlib │ ├── CVS │ ├── Entries │ ├── Entries.Extra │ ├── Entries.Extra.Old │ ├── Entries.Old │ ├── Repository │ └── Root │ ├── _matrix33.h │ ├── _matrix33_sse.h │ ├── _matrix44.h │ ├── _matrix44_sse.h │ ├── _vector2.h │ ├── _vector3.h │ ├── _vector3_sse.h │ ├── _vector4.h │ ├── _vector4_sse.h │ ├── bbox.h │ ├── envelopecurve.h │ ├── euler.h │ ├── eulerangles.h │ ├── line.h │ ├── matrix.h │ ├── matrixdefs.h │ ├── nmath.h │ ├── noise.h │ ├── ntypes.h │ ├── pknorm.h │ ├── plane.h │ ├── polar.h │ ├── quaternion.h │ ├── rectangle.h │ ├── sphere.h │ ├── transform33.h │ ├── transform44.h │ ├── triangle.h │ ├── vector.h │ └── vector3envelopecurve.h ├── lib ├── cg.lib ├── cgD3D8.lib ├── cgD3D8d.lib ├── cgD3D9.lib ├── cgD3D9d.lib ├── cgGL.lib ├── glut32.lib ├── glutstatic.lib └── libGlee.lib ├── libGlee ├── GLee.c ├── GLee.h ├── extensionList.txt ├── libglee.dsp ├── libglee.vcproj └── readme.txt ├── media ├── bindleg2.bmp ├── box2.mtl ├── box2.obj ├── char3.mtl ├── char3.obj ├── female-bind.bmp ├── female-bind2.bmp ├── female-legs.mtl ├── female-legs.obj ├── female-weights.bmp ├── female3.mtl ├── female3.obj ├── style0 │ ├── displacement_back.bmp │ ├── displacement_front.bmp │ └── displacement_side.bmp ├── style1 │ ├── displacement_back.bmp │ ├── displacement_front.bmp │ └── displacement_left_right.bmp └── textures │ ├── deform1.bmp │ └── white.bmp ├── sample.vc8.sln └── sample └── release └── libGlee.lib /Demo1-Leg-NoDefStyles/Legs-Benchmark-No-DefStyles.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/Demo1-Leg-NoDefStyles/Legs-Benchmark-No-DefStyles.exe -------------------------------------------------------------------------------- /Demo1-Leg-NoDefStyles/glut32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/Demo1-Leg-NoDefStyles/glut32.dll -------------------------------------------------------------------------------- /Demo1-Leg-NoDefStyles/shaders/deform.vert: -------------------------------------------------------------------------------- 1 | //uniform sampler2D tex_points; 2 | 3 | varying vec3 normal; 4 | varying vec3 vertex; 5 | varying vec2 textureCoord; 6 | varying vec2 textureCoord1; 7 | varying vec2 textureCoord2; 8 | varying vec2 textureCoord3; 9 | varying vec2 textureCoord4; 10 | 11 | //uniform mat4 light2shadow; 12 | //uniform vec3 spline1_p1; 13 | 14 | void main(void) 15 | { 16 | //normal = gl_Color.xyz * vec3( 2.0,2.0,2.0 ) - vec3 (1.0,1.0,1.0); 17 | //vertex = gl_Vertex.xyz; 18 | 19 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 20 | textureCoord = gl_MultiTexCoord0.xy; 21 | textureCoord1 = gl_MultiTexCoord0.xy; 22 | textureCoord2 = gl_MultiTexCoord0.xy; 23 | textureCoord3 = gl_MultiTexCoord0.xy; 24 | textureCoord4 = gl_MultiTexCoord0.xy; 25 | 26 | textureCoord1.x = gl_MultiTexCoord0.x*4; 27 | textureCoord2.x = gl_MultiTexCoord0.x*4+1; 28 | textureCoord3.x = gl_MultiTexCoord0.x*4+2; 29 | textureCoord4.x = gl_MultiTexCoord0.x*4+3; 30 | } -------------------------------------------------------------------------------- /Demo1-Leg-NoDefStyles/shaders/matrices.frag: -------------------------------------------------------------------------------- 1 | 2 | uniform sampler2DRect texSplineRowX; 3 | uniform sampler2DRect texSplineRowY; 4 | uniform sampler2DRect texSplineRowZ; 5 | uniform sampler2DRect texSplineParams; 6 | //uniform float adjust_pos; 7 | //uniform float adjust_rot; 8 | //uniform float pose_ofs; 9 | 10 | varying vec2 texCoordMatrix; 11 | varying vec2 texCoordParams; 12 | 13 | varying float a; 14 | 15 | void main(void) 16 | { 17 | float pi = 3.14159265358979323846; 18 | 19 | vec4 param1 = texture2DRect(texSplineParams,texCoordParams); 20 | vec4 param2 = texture2DRect(texSplineParams,texCoordParams+vec2(1,0)); 21 | vec4 param3 = texture2DRect(texSplineParams,texCoordParams+vec2(2,0)); 22 | vec4 param4 = texture2DRect(texSplineParams,texCoordParams+vec2(3,0)); 23 | vec4 param5 = texture2DRect(texSplineParams,texCoordParams+vec2(5,0)); 24 | //.x:deformation_style 25 | //.y:spline_hardness 26 | //.z:spline_twist_adjust 27 | //.w:center_distort 28 | 29 | vec3 spline_p1 = param1.xyz; 30 | vec3 spline_d1 = param2.xyz; 31 | vec3 spline_d2 = param3.xyz; 32 | vec3 spline_normal = param4.xyz; 33 | float angle = param1.w; 34 | float twist = param2.w; 35 | float hardness = param5.y; 36 | float twist_adjust = param5.z; 37 | 38 | float a01 = clamp(a,0,1); 39 | 40 | float a_21 = a*2-1; 41 | float a_rot = sign(a_21) * (1-pow(1-abs(a_21),twist_adjust)) * 0.5 +0.5; 42 | 43 | float p = hardness; 44 | float pow_a = pow(a01 ,p); 45 | float pow_1a = pow(1-a01,p); 46 | float f2_a = a *pow_a; 47 | float f1_a = 1-(1-a)*pow_1a; 48 | float f2_da = pow_a; 49 | float f1_da = pow_1a; 50 | 51 | //vec4 pose= texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x,pose_ofs)); 52 | //vec4 pose_d = texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x+5,pose_ofs))-pose; 53 | 54 | vec3 pos= spline_p1 + spline_d1 * f1_a + spline_d2 * f2_a; 55 | vec3 n1 = spline_normal;// * pose.y; 56 | vec3 n3 = normalize (spline_d1 * f1_da + spline_d2 * f2_da); 57 | vec3 n2 = normalize (cross( n3,n1 )); 58 | 59 | //pos = pos - n2; 60 | 61 | //pos = pos + n2 * (pose.z-1)*1.5; 62 | //n2 = n2 * pose.x; 63 | 64 | mat4 bind_mat; 65 | mat4 spline_mat; 66 | 67 | spline_mat[0] = vec4(n1,0.0); 68 | spline_mat[1] = vec4(n2,0.0); 69 | spline_mat[2] = vec4(n3,0.0); 70 | spline_mat[3] = vec4(pos,1.0); 71 | 72 | spline_mat = transpose(spline_mat); 73 | 74 | vec4 row1= texture2DRect(texSplineRowX,texCoordMatrix); 75 | vec4 row2= texture2DRect(texSplineRowY,texCoordMatrix); 76 | vec4 row3= texture2DRect(texSplineRowZ,texCoordMatrix); 77 | 78 | float r = angle + twist * a_rot; 79 | float cos_a = cos(r); 80 | float sin_a = sin(r); 81 | 82 | mat4 rot_mat; 83 | rot_mat[0] = vec4 (cos_a,-sin_a,0.0,0.0); 84 | rot_mat[1] = vec4 (sin_a,cos_a,0.0,0.0); 85 | rot_mat[2] = vec4 (0.0,0.0,1.0,0.0); 86 | rot_mat[3] = vec4 (0.0,0.0,0.0,1.0); 87 | 88 | bind_mat[0] = row1; 89 | bind_mat[1] = row2; 90 | bind_mat[2] = row3; 91 | bind_mat[3] = vec4(0.0,0.0,0.0,1.0); 92 | 93 | /* 94 | spline_mat[0].w = spline_mat[0].w - dot( spline_mat[0].xyz, n2.x ); 95 | spline_mat[1].w = spline_mat[1].w - dot( spline_mat[1].xyz, n2.y ); 96 | spline_mat[2].w = spline_mat[2].w - dot( spline_mat[2].xyz, n2.z ); 97 | */ 98 | // mat4 final_mat = bind_mat * rot_mat * spline_mat; 99 | mat4 final_mat = rot_mat * spline_mat; 100 | 101 | //vec4 n2_xf = final_mat * vec4(n2.xyz,0.0); 102 | 103 | gl_FragData[0] = final_mat[0] ; 104 | gl_FragData[1] = final_mat[1] ; 105 | gl_FragData[2] = final_mat[2] ; 106 | } 107 | 108 | -------------------------------------------------------------------------------- /Demo1-Leg-NoDefStyles/shaders/matrices.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Demo1-Leg-NoDefStyles/shaders/matrices2.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2DRect texBindRowX; 2 | uniform sampler2DRect texBindRowY; 3 | uniform sampler2DRect texBindRowZ; 4 | 5 | uniform sampler2DRect texSplineRowX; 6 | uniform sampler2DRect texSplineRowY; 7 | uniform sampler2DRect texSplineRowZ; 8 | 9 | varying vec2 texCoordMatrix; 10 | 11 | void main(void) 12 | { 13 | mat4 bind; 14 | mat4 spline; 15 | bind[0]= texture2DRect(texBindRowX,texCoordMatrix); 16 | bind[1]= texture2DRect(texBindRowY,texCoordMatrix); 17 | bind[2]= texture2DRect(texBindRowZ,texCoordMatrix); 18 | bind[3]= vec4 (0.0,0.0,0.0,1.0); 19 | 20 | spline[0]= texture2DRect(texSplineRowX,texCoordMatrix); 21 | spline[1]= texture2DRect(texSplineRowY,texCoordMatrix); 22 | spline[2]= texture2DRect(texSplineRowZ,texCoordMatrix); 23 | spline[3]= vec4 (0.0,0.0,0.0,1.0); 24 | 25 | mat4 final_mat = bind * spline; 26 | 27 | gl_FragData[0] = final_mat[0] ; 28 | gl_FragData[1] = final_mat[1] ; 29 | gl_FragData[2] = final_mat[2] ; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Demo1-Leg-NoDefStyles/shaders/matrices2.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Demo1-Leg-NoDefStyles/shaders/normal.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D texLight; 2 | uniform sampler2D texDecal; 3 | uniform sampler2DShadow texDepth; 4 | 5 | uniform vec3 camPos; 6 | uniform vec3 lightPos; 7 | uniform vec4 ambient; 8 | uniform vec4 diffuse; 9 | uniform vec4 specular; 10 | 11 | varying vec3 normal; 12 | varying vec3 vertex; 13 | 14 | void main(void) 15 | { 16 | vec3 normalVec = normal; 17 | vec3 lightVec = vec3( normalize(lightPos-vertex) ); 18 | vec3 camVec = vec3( normalize(camPos-vertex) ); 19 | 20 | float l = clamp ( dot ( lightVec , normalVec ) ,0.0,1.0 ); 21 | vec3 r = reflect ( -camVec, normalVec ); 22 | float m = clamp ( dot ( r , lightVec ) ,0.0,1.0); 23 | float q = m*m; q=q*q; 24 | 25 | // gl_FragColor = vec4(normal,1.0) + 0.001 * (diffuse * l * 1.3 + specular * q + ambient); 26 | gl_FragColor = diffuse * l * 1.3 + specular * q + ambient; 27 | } -------------------------------------------------------------------------------- /Demo1-Leg-NoDefStyles/shaders/normal.vert: -------------------------------------------------------------------------------- 1 | 2 | varying vec3 normal; 3 | varying vec3 vertex; 4 | 5 | void main(void) 6 | { 7 | normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 8 | //normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)); 9 | //normal = gl_Normal;//frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 10 | vertex = gl_Vertex.xyz; 11 | gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz,1.0); 12 | } -------------------------------------------------------------------------------- /Demo1-Leg-NoDefStyles/shaders/shadow.frag: -------------------------------------------------------------------------------- 1 | 2 | void main(void) 3 | { 4 | gl_FragColor = vec4 (1.0,1.0,1.0,1.0); 5 | } -------------------------------------------------------------------------------- /Demo1-Leg-NoDefStyles/shaders/shadow.vert: -------------------------------------------------------------------------------- 1 | uniform float angle; 2 | uniform float twist; 3 | uniform vec3 spline_p; 4 | uniform vec3 spline_d1; 5 | uniform vec3 spline_d2; 6 | uniform vec3 spline_normal; 7 | 8 | uniform float arm_angle; 9 | uniform float arm_twist; 10 | uniform vec3 arm_spline_p; 11 | uniform vec3 arm_spline_d1; 12 | uniform vec3 arm_spline_d2; 13 | uniform vec3 arm_spline_normal; 14 | 15 | uniform float elbow_angle; 16 | uniform float elbow_twist; 17 | uniform vec3 elbow_spline_p; 18 | uniform vec3 elbow_spline_d1; 19 | uniform vec3 elbow_spline_d2; 20 | uniform vec3 elbow_spline_normal; 21 | 22 | uniform float body_angle; 23 | uniform float body_twist; 24 | uniform vec3 body_spline_p; 25 | uniform vec3 body_spline_d1; 26 | uniform vec3 body_spline_d2; 27 | uniform vec3 body_spline_normal; 28 | /* 29 | void eval_spline ( 30 | in float a, 31 | in twist, 32 | in angle, 33 | in vec3 spline_p, 34 | in vec3 spline_d1, 35 | in vec3 spline_d2, 36 | in vec3 spline_normal 37 | in p 38 | out) 39 | { 40 | 41 | } 42 | */ 43 | 44 | void main(void) 45 | { 46 | vec3 pos; 47 | vec3 n1; // x 48 | vec3 n2; // y 49 | vec3 n3; // z 50 | 51 | vec3 p = spline_p; 52 | vec3 d1= spline_d1; 53 | vec3 d2= spline_d2; 54 | 55 | float a = gl_MultiTexCoord1.x; 56 | float b = gl_MultiTexCoord1.y; 57 | float c = gl_MultiTexCoord1.z; 58 | float c01 = clamp ( c , 0.0 , 1.0 ); 59 | float alpha = 0.5 * 3.14159265358979323846 * c01; 60 | float cos_c = cos ( alpha ); 61 | float sin_c = sin ( alpha ); 62 | float min0 = min(c,0.0); 63 | float max1 = max(c,1.0); 64 | pos = p + d1 * sin_c + d2 * (1.0-cos_c) + d1 * min0 + d2 * max1; 65 | n3 = normalize(d1 * cos_c + d2 * sin_c); 66 | n1 = spline_normal; 67 | n2 = cross( n1,n3 ); 68 | 69 | float r = angle + twist*c01; 70 | float sin_r = sin ( r ); 71 | float cos_r = cos ( r ); 72 | float aa = cos_r * b + sin_r * a; 73 | float bb = cos_r * a - sin_r * b; 74 | 75 | vec3 result_pos = n1 * aa + n2 * bb + pos; 76 | 77 | gl_Position = gl_ModelViewProjectionMatrix * vec4 ( result_pos.xyz , 1 ) ; 78 | } -------------------------------------------------------------------------------- /Demo1-Leg/Legs-Benchmark.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/Demo1-Leg/Legs-Benchmark.exe -------------------------------------------------------------------------------- /Demo1-Leg/Legs-Demo.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/Demo1-Leg/Legs-Demo.exe -------------------------------------------------------------------------------- /Demo1-Leg/glut32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/Demo1-Leg/glut32.dll -------------------------------------------------------------------------------- /Demo1-Leg/shaders/deform.vert: -------------------------------------------------------------------------------- 1 | //uniform sampler2D tex_points; 2 | 3 | varying vec3 normal; 4 | varying vec3 vertex; 5 | varying vec2 textureCoord; 6 | varying vec2 textureCoord1; 7 | varying vec2 textureCoord2; 8 | varying vec2 textureCoord3; 9 | varying vec2 textureCoord4; 10 | 11 | //uniform mat4 light2shadow; 12 | //uniform vec3 spline1_p1; 13 | 14 | void main(void) 15 | { 16 | //normal = gl_Color.xyz * vec3( 2.0,2.0,2.0 ) - vec3 (1.0,1.0,1.0); 17 | //vertex = gl_Vertex.xyz; 18 | 19 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 20 | textureCoord = gl_MultiTexCoord0.xy; 21 | textureCoord1 = gl_MultiTexCoord0.xy; 22 | textureCoord2 = gl_MultiTexCoord0.xy; 23 | textureCoord3 = gl_MultiTexCoord0.xy; 24 | textureCoord4 = gl_MultiTexCoord0.xy; 25 | 26 | textureCoord1.x = gl_MultiTexCoord0.x*4; 27 | textureCoord2.x = gl_MultiTexCoord0.x*4+1; 28 | textureCoord3.x = gl_MultiTexCoord0.x*4+2; 29 | textureCoord4.x = gl_MultiTexCoord0.x*4+3; 30 | } -------------------------------------------------------------------------------- /Demo1-Leg/shaders/matrices.frag: -------------------------------------------------------------------------------- 1 | 2 | uniform sampler2DRect texSplineRowX; 3 | uniform sampler2DRect texSplineRowY; 4 | uniform sampler2DRect texSplineRowZ; 5 | uniform sampler2DRect texSplineParams; 6 | //uniform float adjust_pos; 7 | //uniform float adjust_rot; 8 | //uniform float pose_ofs; 9 | 10 | varying vec2 texCoordMatrix; 11 | varying vec2 texCoordParams; 12 | 13 | varying float a; 14 | 15 | void main(void) 16 | { 17 | float pi = 3.14159265358979323846; 18 | 19 | vec4 param1 = texture2DRect(texSplineParams,texCoordParams); 20 | vec4 param2 = texture2DRect(texSplineParams,texCoordParams+vec2(1,0)); 21 | vec4 param3 = texture2DRect(texSplineParams,texCoordParams+vec2(2,0)); 22 | vec4 param4 = texture2DRect(texSplineParams,texCoordParams+vec2(3,0)); 23 | vec4 param5 = texture2DRect(texSplineParams,texCoordParams+vec2(5,0)); 24 | //.x:deformation_style 25 | //.y:spline_hardness 26 | //.z:spline_twist_adjust 27 | //.w:center_distort 28 | 29 | vec3 spline_p1 = param1.xyz; 30 | vec3 spline_d1 = param2.xyz; 31 | vec3 spline_d2 = param3.xyz; 32 | vec3 spline_normal = param4.xyz; 33 | float angle = param1.w; 34 | float twist = param2.w; 35 | float hardness = param5.y; 36 | float twist_adjust = param5.z; 37 | 38 | float a01 = clamp(a,0,1); 39 | 40 | float a_21 = a*2-1; 41 | float a_rot = sign(a_21) * (1-pow(1-abs(a_21),twist_adjust)) * 0.5 +0.5; 42 | 43 | float p = hardness; 44 | float pow_a = pow(a01 ,p); 45 | float pow_1a = pow(1-a01,p); 46 | float f2_a = a *pow_a; 47 | float f1_a = 1-(1-a)*pow_1a; 48 | float f2_da = pow_a; 49 | float f1_da = pow_1a; 50 | 51 | //vec4 pose= texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x,pose_ofs)); 52 | //vec4 pose_d = texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x+5,pose_ofs))-pose; 53 | 54 | vec3 pos= spline_p1 + spline_d1 * f1_a + spline_d2 * f2_a; 55 | vec3 n1 = spline_normal;// * pose.y; 56 | vec3 n3 = normalize (spline_d1 * f1_da + spline_d2 * f2_da); 57 | vec3 n2 = normalize (cross( n3,n1 )); 58 | 59 | //pos = pos - n2; 60 | 61 | //pos = pos + n2 * (pose.z-1)*1.5; 62 | //n2 = n2 * pose.x; 63 | 64 | mat4 bind_mat; 65 | mat4 spline_mat; 66 | 67 | spline_mat[0] = vec4(n1,0.0); 68 | spline_mat[1] = vec4(n2,0.0); 69 | spline_mat[2] = vec4(n3,0.0); 70 | spline_mat[3] = vec4(pos,1.0); 71 | 72 | spline_mat = transpose(spline_mat); 73 | 74 | vec4 row1= texture2DRect(texSplineRowX,texCoordMatrix); 75 | vec4 row2= texture2DRect(texSplineRowY,texCoordMatrix); 76 | vec4 row3= texture2DRect(texSplineRowZ,texCoordMatrix); 77 | 78 | float r = angle + twist * a_rot; 79 | float cos_a = cos(r); 80 | float sin_a = sin(r); 81 | 82 | mat4 rot_mat; 83 | rot_mat[0] = vec4 (cos_a,-sin_a,0.0,0.0); 84 | rot_mat[1] = vec4 (sin_a,cos_a,0.0,0.0); 85 | rot_mat[2] = vec4 (0.0,0.0,1.0,0.0); 86 | rot_mat[3] = vec4 (0.0,0.0,0.0,1.0); 87 | 88 | bind_mat[0] = row1; 89 | bind_mat[1] = row2; 90 | bind_mat[2] = row3; 91 | bind_mat[3] = vec4(0.0,0.0,0.0,1.0); 92 | 93 | /* 94 | spline_mat[0].w = spline_mat[0].w - dot( spline_mat[0].xyz, n2.x ); 95 | spline_mat[1].w = spline_mat[1].w - dot( spline_mat[1].xyz, n2.y ); 96 | spline_mat[2].w = spline_mat[2].w - dot( spline_mat[2].xyz, n2.z ); 97 | */ 98 | // mat4 final_mat = bind_mat * rot_mat * spline_mat; 99 | mat4 final_mat = rot_mat * spline_mat; 100 | 101 | //vec4 n2_xf = final_mat * vec4(n2.xyz,0.0); 102 | 103 | gl_FragData[0] = final_mat[0] ; 104 | gl_FragData[1] = final_mat[1] ; 105 | gl_FragData[2] = final_mat[2] ; 106 | } 107 | 108 | -------------------------------------------------------------------------------- /Demo1-Leg/shaders/matrices.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Demo1-Leg/shaders/matrices2.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2DRect texBindRowX; 2 | uniform sampler2DRect texBindRowY; 3 | uniform sampler2DRect texBindRowZ; 4 | 5 | uniform sampler2DRect texSplineRowX; 6 | uniform sampler2DRect texSplineRowY; 7 | uniform sampler2DRect texSplineRowZ; 8 | 9 | varying vec2 texCoordMatrix; 10 | 11 | void main(void) 12 | { 13 | mat4 bind; 14 | mat4 spline; 15 | bind[0]= texture2DRect(texBindRowX,texCoordMatrix); 16 | bind[1]= texture2DRect(texBindRowY,texCoordMatrix); 17 | bind[2]= texture2DRect(texBindRowZ,texCoordMatrix); 18 | bind[3]= vec4 (0.0,0.0,0.0,1.0); 19 | 20 | spline[0]= texture2DRect(texSplineRowX,texCoordMatrix); 21 | spline[1]= texture2DRect(texSplineRowY,texCoordMatrix); 22 | spline[2]= texture2DRect(texSplineRowZ,texCoordMatrix); 23 | spline[3]= vec4 (0.0,0.0,0.0,1.0); 24 | 25 | mat4 final_mat = bind * spline; 26 | 27 | gl_FragData[0] = final_mat[0] ; 28 | gl_FragData[1] = final_mat[1] ; 29 | gl_FragData[2] = final_mat[2] ; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Demo1-Leg/shaders/matrices2.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Demo1-Leg/shaders/normal.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D texLight; 2 | uniform sampler2D texDecal; 3 | uniform sampler2DShadow texDepth; 4 | 5 | uniform vec3 camPos; 6 | uniform vec3 lightPos; 7 | uniform vec4 ambient; 8 | uniform vec4 diffuse; 9 | uniform vec4 specular; 10 | 11 | varying vec3 normal; 12 | varying vec3 vertex; 13 | 14 | void main(void) 15 | { 16 | vec3 normalVec = normal; 17 | vec3 lightVec = vec3( normalize(lightPos-vertex) ); 18 | vec3 camVec = vec3( normalize(camPos-vertex) ); 19 | 20 | float l = clamp ( dot ( lightVec , normalVec ) ,0.0,1.0 ); 21 | vec3 r = reflect ( -camVec, normalVec ); 22 | float m = clamp ( dot ( r , lightVec ) ,0.0,1.0); 23 | float q = m*m; q=q*q; 24 | 25 | // gl_FragColor = vec4(normal,1.0) + 0.001 * (diffuse * l * 1.3 + specular * q + ambient); 26 | gl_FragColor = diffuse * l * 1.3 + specular * q + ambient; 27 | } -------------------------------------------------------------------------------- /Demo1-Leg/shaders/normal.vert: -------------------------------------------------------------------------------- 1 | 2 | varying vec3 normal; 3 | varying vec3 vertex; 4 | 5 | void main(void) 6 | { 7 | normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 8 | //normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)); 9 | //normal = gl_Normal;//frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 10 | vertex = gl_Vertex.xyz; 11 | gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz,1.0); 12 | } -------------------------------------------------------------------------------- /Demo1-Leg/shaders/shadow.frag: -------------------------------------------------------------------------------- 1 | 2 | void main(void) 3 | { 4 | gl_FragColor = vec4 (1.0,1.0,1.0,1.0); 5 | } -------------------------------------------------------------------------------- /Demo1-Leg/shaders/shadow.vert: -------------------------------------------------------------------------------- 1 | uniform float angle; 2 | uniform float twist; 3 | uniform vec3 spline_p; 4 | uniform vec3 spline_d1; 5 | uniform vec3 spline_d2; 6 | uniform vec3 spline_normal; 7 | 8 | uniform float arm_angle; 9 | uniform float arm_twist; 10 | uniform vec3 arm_spline_p; 11 | uniform vec3 arm_spline_d1; 12 | uniform vec3 arm_spline_d2; 13 | uniform vec3 arm_spline_normal; 14 | 15 | uniform float elbow_angle; 16 | uniform float elbow_twist; 17 | uniform vec3 elbow_spline_p; 18 | uniform vec3 elbow_spline_d1; 19 | uniform vec3 elbow_spline_d2; 20 | uniform vec3 elbow_spline_normal; 21 | 22 | uniform float body_angle; 23 | uniform float body_twist; 24 | uniform vec3 body_spline_p; 25 | uniform vec3 body_spline_d1; 26 | uniform vec3 body_spline_d2; 27 | uniform vec3 body_spline_normal; 28 | /* 29 | void eval_spline ( 30 | in float a, 31 | in twist, 32 | in angle, 33 | in vec3 spline_p, 34 | in vec3 spline_d1, 35 | in vec3 spline_d2, 36 | in vec3 spline_normal 37 | in p 38 | out) 39 | { 40 | 41 | } 42 | */ 43 | 44 | void main(void) 45 | { 46 | vec3 pos; 47 | vec3 n1; // x 48 | vec3 n2; // y 49 | vec3 n3; // z 50 | 51 | vec3 p = spline_p; 52 | vec3 d1= spline_d1; 53 | vec3 d2= spline_d2; 54 | 55 | float a = gl_MultiTexCoord1.x; 56 | float b = gl_MultiTexCoord1.y; 57 | float c = gl_MultiTexCoord1.z; 58 | float c01 = clamp ( c , 0.0 , 1.0 ); 59 | float alpha = 0.5 * 3.14159265358979323846 * c01; 60 | float cos_c = cos ( alpha ); 61 | float sin_c = sin ( alpha ); 62 | float min0 = min(c,0.0); 63 | float max1 = max(c,1.0); 64 | pos = p + d1 * sin_c + d2 * (1.0-cos_c) + d1 * min0 + d2 * max1; 65 | n3 = normalize(d1 * cos_c + d2 * sin_c); 66 | n1 = spline_normal; 67 | n2 = cross( n1,n3 ); 68 | 69 | float r = angle + twist*c01; 70 | float sin_r = sin ( r ); 71 | float cos_r = cos ( r ); 72 | float aa = cos_r * b + sin_r * a; 73 | float bb = cos_r * a - sin_r * b; 74 | 75 | vec3 result_pos = n1 * aa + n2 * bb + pos; 76 | 77 | gl_Position = gl_ModelViewProjectionMatrix * vec4 ( result_pos.xyz , 1 ) ; 78 | } -------------------------------------------------------------------------------- /Demo2-Cuboid/Cuboid-Demo.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/Demo2-Cuboid/Cuboid-Demo.exe -------------------------------------------------------------------------------- /Demo2-Cuboid/glut32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/Demo2-Cuboid/glut32.dll -------------------------------------------------------------------------------- /Demo2-Cuboid/shaders/deform.vert: -------------------------------------------------------------------------------- 1 | //uniform sampler2D tex_points; 2 | 3 | varying vec3 normal; 4 | varying vec3 vertex; 5 | varying vec2 textureCoord; 6 | varying vec2 textureCoord1; 7 | varying vec2 textureCoord2; 8 | varying vec2 textureCoord3; 9 | varying vec2 textureCoord4; 10 | 11 | //uniform mat4 light2shadow; 12 | //uniform vec3 spline1_p1; 13 | 14 | void main(void) 15 | { 16 | //normal = gl_Color.xyz * vec3( 2.0,2.0,2.0 ) - vec3 (1.0,1.0,1.0); 17 | //vertex = gl_Vertex.xyz; 18 | 19 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 20 | textureCoord = gl_MultiTexCoord0.xy; 21 | textureCoord1 = gl_MultiTexCoord0.xy; 22 | textureCoord2 = gl_MultiTexCoord0.xy; 23 | textureCoord3 = gl_MultiTexCoord0.xy; 24 | textureCoord4 = gl_MultiTexCoord0.xy; 25 | 26 | textureCoord1.x = gl_MultiTexCoord0.x*4; 27 | textureCoord2.x = gl_MultiTexCoord0.x*4+1; 28 | textureCoord3.x = gl_MultiTexCoord0.x*4+2; 29 | textureCoord4.x = gl_MultiTexCoord0.x*4+3; 30 | } -------------------------------------------------------------------------------- /Demo2-Cuboid/shaders/matrices.frag: -------------------------------------------------------------------------------- 1 | 2 | uniform sampler2DRect texSplineRowX; 3 | uniform sampler2DRect texSplineRowY; 4 | uniform sampler2DRect texSplineRowZ; 5 | uniform sampler2DRect texSplineParams; 6 | uniform float adjust_pos; 7 | uniform float adjust_rot; 8 | //uniform float pose_ofs; 9 | 10 | varying vec2 texCoordMatrix; 11 | varying vec2 texCoordParams; 12 | 13 | varying float a; 14 | 15 | void main(void) 16 | { 17 | float pi = 3.14159265358979323846; 18 | 19 | vec4 param1 = texture2DRect(texSplineParams,texCoordParams); 20 | vec4 param2 = texture2DRect(texSplineParams,texCoordParams+vec2(1,0)); 21 | vec4 param3 = texture2DRect(texSplineParams,texCoordParams+vec2(2,0)); 22 | vec4 param4 = texture2DRect(texSplineParams,texCoordParams+vec2(3,0)); 23 | 24 | vec3 spline_p1 = param1.xyz; 25 | vec3 spline_d1 = param2.xyz; 26 | vec3 spline_d2 = param3.xyz; 27 | vec3 spline_normal = param4.xyz; 28 | float angle = param1.w; 29 | float twist = param2.w; 30 | 31 | float a01 = clamp(a,0,1); 32 | 33 | float a_21 = a*2-1; 34 | float a_rot = sign(a_21) * (1-pow(1-abs(a_21),adjust_rot)) * 0.5 +0.5; 35 | 36 | float p = adjust_pos; 37 | float pow_a = pow(a01 ,p); 38 | float pow_1a = pow(1-a01,p); 39 | float f2_a = a *pow_a; 40 | float f1_a = 1-(1-a)*pow_1a; 41 | float f2_da = pow_a; 42 | float f1_da = pow_1a; 43 | 44 | //vec4 pose= texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x,pose_ofs)); 45 | //vec4 pose_d = texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x+5,pose_ofs))-pose; 46 | 47 | vec3 pos= spline_p1 + spline_d1 * f1_a + spline_d2 * f2_a; 48 | vec3 n1 = spline_normal;// * pose.y; 49 | vec3 n3 = normalize (spline_d1 * f1_da + spline_d2 * f2_da); 50 | vec3 n2 = normalize (cross( n3,n1 )); 51 | 52 | //pos = pos - n2; 53 | 54 | //pos = pos + n2 * (pose.z-1)*1.5; 55 | //n2 = n2 * pose.x; 56 | 57 | mat4 bind_mat; 58 | mat4 spline_mat; 59 | 60 | spline_mat[0] = vec4(n1,0.0); 61 | spline_mat[1] = vec4(n2,0.0); 62 | spline_mat[2] = vec4(n3,0.0); 63 | spline_mat[3] = vec4(pos,1.0); 64 | 65 | spline_mat = transpose(spline_mat); 66 | 67 | vec4 row1= texture2DRect(texSplineRowX,texCoordMatrix); 68 | vec4 row2= texture2DRect(texSplineRowY,texCoordMatrix); 69 | vec4 row3= texture2DRect(texSplineRowZ,texCoordMatrix); 70 | 71 | float r = angle + twist * a_rot; 72 | float cos_a = cos(r); 73 | float sin_a = sin(r); 74 | 75 | mat4 rot_mat; 76 | rot_mat[0] = vec4 (cos_a,-sin_a,0.0,0.0); 77 | rot_mat[1] = vec4 (sin_a,cos_a,0.0,0.0); 78 | rot_mat[2] = vec4 (0.0,0.0,1.0,0.0); 79 | rot_mat[3] = vec4 (0.0,0.0,0.0,1.0); 80 | 81 | bind_mat[0] = row1; 82 | bind_mat[1] = row2; 83 | bind_mat[2] = row3; 84 | bind_mat[3] = vec4(0.0,0.0,0.0,1.0); 85 | 86 | /* 87 | spline_mat[0].w = spline_mat[0].w - dot( spline_mat[0].xyz, n2.x ); 88 | spline_mat[1].w = spline_mat[1].w - dot( spline_mat[1].xyz, n2.y ); 89 | spline_mat[2].w = spline_mat[2].w - dot( spline_mat[2].xyz, n2.z ); 90 | */ 91 | // mat4 final_mat = bind_mat * rot_mat * spline_mat; 92 | mat4 final_mat = rot_mat * spline_mat; 93 | 94 | //vec4 n2_xf = final_mat * vec4(n2.xyz,0.0); 95 | 96 | gl_FragData[0] = final_mat[0] ; 97 | gl_FragData[1] = final_mat[1] ; 98 | gl_FragData[2] = final_mat[2] ; 99 | } 100 | 101 | -------------------------------------------------------------------------------- /Demo2-Cuboid/shaders/matrices.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Demo2-Cuboid/shaders/matrices2.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2DRect texBindRowX; 2 | uniform sampler2DRect texBindRowY; 3 | uniform sampler2DRect texBindRowZ; 4 | 5 | uniform sampler2DRect texSplineRowX; 6 | uniform sampler2DRect texSplineRowY; 7 | uniform sampler2DRect texSplineRowZ; 8 | 9 | varying vec2 texCoordMatrix; 10 | 11 | void main(void) 12 | { 13 | mat4 bind; 14 | mat4 spline; 15 | bind[0]= texture2DRect(texBindRowX,texCoordMatrix); 16 | bind[1]= texture2DRect(texBindRowY,texCoordMatrix); 17 | bind[2]= texture2DRect(texBindRowZ,texCoordMatrix); 18 | bind[3]= vec4 (0.0,0.0,0.0,1.0); 19 | 20 | spline[0]= texture2DRect(texSplineRowX,texCoordMatrix); 21 | spline[1]= texture2DRect(texSplineRowY,texCoordMatrix); 22 | spline[2]= texture2DRect(texSplineRowZ,texCoordMatrix); 23 | spline[3]= vec4 (0.0,0.0,0.0,1.0); 24 | 25 | mat4 final_mat = bind * spline; 26 | 27 | gl_FragData[0] = final_mat[0] ; 28 | gl_FragData[1] = final_mat[1] ; 29 | gl_FragData[2] = final_mat[2] ; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Demo2-Cuboid/shaders/matrices2.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Demo2-Cuboid/shaders/normal.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D texLight; 2 | uniform sampler2D texDecal; 3 | uniform sampler2DShadow texDepth; 4 | 5 | uniform vec3 camPos; 6 | uniform vec3 lightPos; 7 | uniform vec4 ambient; 8 | uniform vec4 diffuse; 9 | uniform vec4 specular; 10 | 11 | varying vec3 normal; 12 | varying vec3 vertex; 13 | 14 | void main(void) 15 | { 16 | vec3 normalVec = normal; 17 | vec3 lightVec = vec3( normalize(lightPos-vertex) ); 18 | vec3 camVec = vec3( normalize(camPos-vertex) ); 19 | 20 | float l = clamp ( dot ( lightVec , normalVec ) ,0.0,1.0 ); 21 | vec3 r = reflect ( -camVec, normalVec ); 22 | float m = clamp ( dot ( r , lightVec ) ,0.0,1.0); 23 | float q = m*m; q=q*q; 24 | 25 | // gl_FragColor = vec4(normal,1.0) + 0.001 * (diffuse * l * 1.3 + specular * q + ambient); 26 | gl_FragColor = diffuse * l * 1.3 + specular * q + ambient; 27 | } -------------------------------------------------------------------------------- /Demo2-Cuboid/shaders/normal.vert: -------------------------------------------------------------------------------- 1 | 2 | varying vec3 normal; 3 | varying vec3 vertex; 4 | 5 | void main(void) 6 | { 7 | normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 8 | //normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)); 9 | //normal = gl_Normal;//frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 10 | vertex = gl_Vertex.xyz; 11 | gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz,1.0); 12 | } -------------------------------------------------------------------------------- /Demo2-Cuboid/shaders/shadow.frag: -------------------------------------------------------------------------------- 1 | 2 | void main(void) 3 | { 4 | gl_FragColor = vec4 (1.0,1.0,1.0,1.0); 5 | } -------------------------------------------------------------------------------- /Demo2-Cuboid/shaders/shadow.vert: -------------------------------------------------------------------------------- 1 | uniform float angle; 2 | uniform float twist; 3 | uniform vec3 spline_p; 4 | uniform vec3 spline_d1; 5 | uniform vec3 spline_d2; 6 | uniform vec3 spline_normal; 7 | 8 | uniform float arm_angle; 9 | uniform float arm_twist; 10 | uniform vec3 arm_spline_p; 11 | uniform vec3 arm_spline_d1; 12 | uniform vec3 arm_spline_d2; 13 | uniform vec3 arm_spline_normal; 14 | 15 | uniform float elbow_angle; 16 | uniform float elbow_twist; 17 | uniform vec3 elbow_spline_p; 18 | uniform vec3 elbow_spline_d1; 19 | uniform vec3 elbow_spline_d2; 20 | uniform vec3 elbow_spline_normal; 21 | 22 | uniform float body_angle; 23 | uniform float body_twist; 24 | uniform vec3 body_spline_p; 25 | uniform vec3 body_spline_d1; 26 | uniform vec3 body_spline_d2; 27 | uniform vec3 body_spline_normal; 28 | /* 29 | void eval_spline ( 30 | in float a, 31 | in twist, 32 | in angle, 33 | in vec3 spline_p, 34 | in vec3 spline_d1, 35 | in vec3 spline_d2, 36 | in vec3 spline_normal 37 | in p 38 | out) 39 | { 40 | 41 | } 42 | */ 43 | 44 | void main(void) 45 | { 46 | vec3 pos; 47 | vec3 n1; // x 48 | vec3 n2; // y 49 | vec3 n3; // z 50 | 51 | vec3 p = spline_p; 52 | vec3 d1= spline_d1; 53 | vec3 d2= spline_d2; 54 | 55 | float a = gl_MultiTexCoord1.x; 56 | float b = gl_MultiTexCoord1.y; 57 | float c = gl_MultiTexCoord1.z; 58 | float c01 = clamp ( c , 0.0 , 1.0 ); 59 | float alpha = 0.5 * 3.14159265358979323846 * c01; 60 | float cos_c = cos ( alpha ); 61 | float sin_c = sin ( alpha ); 62 | float min0 = min(c,0.0); 63 | float max1 = max(c,1.0); 64 | pos = p + d1 * sin_c + d2 * (1.0-cos_c) + d1 * min0 + d2 * max1; 65 | n3 = normalize(d1 * cos_c + d2 * sin_c); 66 | n1 = spline_normal; 67 | n2 = cross( n1,n3 ); 68 | 69 | float r = angle + twist*c01; 70 | float sin_r = sin ( r ); 71 | float cos_r = cos ( r ); 72 | float aa = cos_r * b + sin_r * a; 73 | float bb = cos_r * a - sin_r * b; 74 | 75 | vec3 result_pos = n1 * aa + n2 * bb + pos; 76 | 77 | gl_Position = gl_ModelViewProjectionMatrix * vec4 ( result_pos.xyz , 1 ) ; 78 | } -------------------------------------------------------------------------------- /Demo3-Arm/Char1-Demo.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/Demo3-Arm/Char1-Demo.exe -------------------------------------------------------------------------------- /Demo3-Arm/Char2-Demo.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/Demo3-Arm/Char2-Demo.exe -------------------------------------------------------------------------------- /Demo3-Arm/glut32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/Demo3-Arm/glut32.dll -------------------------------------------------------------------------------- /Demo3-Arm/shaders/deform.vert: -------------------------------------------------------------------------------- 1 | //uniform sampler2D tex_points; 2 | 3 | varying vec3 normal; 4 | varying vec3 vertex; 5 | varying vec2 textureCoord; 6 | varying vec2 textureCoord1; 7 | varying vec2 textureCoord2; 8 | varying vec2 textureCoord3; 9 | varying vec2 textureCoord4; 10 | 11 | //uniform mat4 light2shadow; 12 | //uniform vec3 spline1_p1; 13 | 14 | void main(void) 15 | { 16 | //normal = gl_Color.xyz * vec3( 2.0,2.0,2.0 ) - vec3 (1.0,1.0,1.0); 17 | //vertex = gl_Vertex.xyz; 18 | 19 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 20 | textureCoord = gl_MultiTexCoord0.xy; 21 | textureCoord1 = gl_MultiTexCoord0.xy; 22 | textureCoord2 = gl_MultiTexCoord0.xy; 23 | textureCoord3 = gl_MultiTexCoord0.xy; 24 | textureCoord4 = gl_MultiTexCoord0.xy; 25 | 26 | textureCoord1.x = gl_MultiTexCoord0.x*4; 27 | textureCoord2.x = gl_MultiTexCoord0.x*4+1; 28 | textureCoord3.x = gl_MultiTexCoord0.x*4+2; 29 | textureCoord4.x = gl_MultiTexCoord0.x*4+3; 30 | } -------------------------------------------------------------------------------- /Demo3-Arm/shaders/matrices.frag: -------------------------------------------------------------------------------- 1 | 2 | uniform sampler2DRect texSplineRowX; 3 | uniform sampler2DRect texSplineRowY; 4 | uniform sampler2DRect texSplineRowZ; 5 | uniform sampler2DRect texSplineParams; 6 | //uniform float adjust_pos; 7 | //uniform float adjust_rot; 8 | //uniform float pose_ofs; 9 | 10 | varying vec2 texCoordMatrix; 11 | varying vec2 texCoordParams; 12 | 13 | varying float a; 14 | 15 | void main(void) 16 | { 17 | float pi = 3.14159265358979323846; 18 | 19 | vec4 param1 = texture2DRect(texSplineParams,texCoordParams); 20 | vec4 param2 = texture2DRect(texSplineParams,texCoordParams+vec2(1,0)); 21 | vec4 param3 = texture2DRect(texSplineParams,texCoordParams+vec2(2,0)); 22 | vec4 param4 = texture2DRect(texSplineParams,texCoordParams+vec2(3,0)); 23 | vec4 param5 = texture2DRect(texSplineParams,texCoordParams+vec2(5,0)); 24 | //.x:deformation_style 25 | //.y:spline_hardness 26 | //.z:spline_twist_adjust 27 | //.w:center_distort 28 | 29 | vec3 spline_p1 = param1.xyz; 30 | vec3 spline_d1 = param2.xyz; 31 | vec3 spline_d2 = param3.xyz; 32 | vec3 spline_normal = param4.xyz; 33 | float angle = param1.w; 34 | float twist = param2.w; 35 | float hardness = param5.y; 36 | float twist_adjust = param5.z; 37 | 38 | float a01 = clamp(a,0,1); 39 | 40 | float a_21 = a*2-1; 41 | float a_rot = sign(a_21) * (1-pow(1-abs(a_21),twist_adjust)) * 0.5 +0.5; 42 | 43 | float p = hardness; 44 | float pow_a = pow(a01 ,p); 45 | float pow_1a = pow(1-a01,p); 46 | float f2_a = a *pow_a; 47 | float f1_a = 1-(1-a)*pow_1a; 48 | float f2_da = pow_a; 49 | float f1_da = pow_1a; 50 | 51 | //vec4 pose= texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x,pose_ofs)); 52 | //vec4 pose_d = texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x+5,pose_ofs))-pose; 53 | 54 | vec3 pos= spline_p1 + spline_d1 * f1_a + spline_d2 * f2_a; 55 | vec3 n1 = spline_normal;// * pose.y; 56 | vec3 n3 = normalize (spline_d1 * f1_da + spline_d2 * f2_da); 57 | vec3 n2 = normalize (cross( n3,n1 )); 58 | 59 | //pos = pos - n2; 60 | 61 | //pos = pos + n2 * (pose.z-1)*1.5; 62 | //n2 = n2 * pose.x; 63 | 64 | mat4 bind_mat; 65 | mat4 spline_mat; 66 | 67 | spline_mat[0] = vec4(n1,0.0); 68 | spline_mat[1] = vec4(n2,0.0); 69 | spline_mat[2] = vec4(n3,0.0); 70 | spline_mat[3] = vec4(pos,1.0); 71 | 72 | spline_mat = transpose(spline_mat); 73 | 74 | vec4 row1= texture2DRect(texSplineRowX,texCoordMatrix); 75 | vec4 row2= texture2DRect(texSplineRowY,texCoordMatrix); 76 | vec4 row3= texture2DRect(texSplineRowZ,texCoordMatrix); 77 | 78 | float r = angle + twist * a_rot; 79 | float cos_a = cos(r); 80 | float sin_a = sin(r); 81 | 82 | mat4 rot_mat; 83 | rot_mat[0] = vec4 (cos_a,-sin_a,0.0,0.0); 84 | rot_mat[1] = vec4 (sin_a,cos_a,0.0,0.0); 85 | rot_mat[2] = vec4 (0.0,0.0,1.0,0.0); 86 | rot_mat[3] = vec4 (0.0,0.0,0.0,1.0); 87 | 88 | bind_mat[0] = row1; 89 | bind_mat[1] = row2; 90 | bind_mat[2] = row3; 91 | bind_mat[3] = vec4(0.0,0.0,0.0,1.0); 92 | 93 | /* 94 | spline_mat[0].w = spline_mat[0].w - dot( spline_mat[0].xyz, n2.x ); 95 | spline_mat[1].w = spline_mat[1].w - dot( spline_mat[1].xyz, n2.y ); 96 | spline_mat[2].w = spline_mat[2].w - dot( spline_mat[2].xyz, n2.z ); 97 | */ 98 | // mat4 final_mat = bind_mat * rot_mat * spline_mat; 99 | mat4 final_mat = rot_mat * spline_mat; 100 | 101 | //vec4 n2_xf = final_mat * vec4(n2.xyz,0.0); 102 | 103 | gl_FragData[0] = final_mat[0] ; 104 | gl_FragData[1] = final_mat[1] ; 105 | gl_FragData[2] = final_mat[2] ; 106 | } 107 | 108 | -------------------------------------------------------------------------------- /Demo3-Arm/shaders/matrices.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Demo3-Arm/shaders/matrices2.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2DRect texBindRowX; 2 | uniform sampler2DRect texBindRowY; 3 | uniform sampler2DRect texBindRowZ; 4 | 5 | uniform sampler2DRect texSplineRowX; 6 | uniform sampler2DRect texSplineRowY; 7 | uniform sampler2DRect texSplineRowZ; 8 | 9 | varying vec2 texCoordMatrix; 10 | 11 | void main(void) 12 | { 13 | mat4 bind; 14 | mat4 spline; 15 | bind[0]= texture2DRect(texBindRowX,texCoordMatrix); 16 | bind[1]= texture2DRect(texBindRowY,texCoordMatrix); 17 | bind[2]= texture2DRect(texBindRowZ,texCoordMatrix); 18 | bind[3]= vec4 (0.0,0.0,0.0,1.0); 19 | 20 | spline[0]= texture2DRect(texSplineRowX,texCoordMatrix); 21 | spline[1]= texture2DRect(texSplineRowY,texCoordMatrix); 22 | spline[2]= texture2DRect(texSplineRowZ,texCoordMatrix); 23 | spline[3]= vec4 (0.0,0.0,0.0,1.0); 24 | 25 | mat4 final_mat = bind * spline; 26 | 27 | gl_FragData[0] = final_mat[0] ; 28 | gl_FragData[1] = final_mat[1] ; 29 | gl_FragData[2] = final_mat[2] ; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Demo3-Arm/shaders/matrices2.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Demo3-Arm/shaders/normal.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D texLight; 2 | uniform sampler2D texDecal; 3 | uniform sampler2DShadow texDepth; 4 | 5 | uniform vec3 camPos; 6 | uniform vec3 lightPos; 7 | uniform vec4 ambient; 8 | uniform vec4 diffuse; 9 | uniform vec4 specular; 10 | 11 | varying vec3 normal; 12 | varying vec3 vertex; 13 | 14 | void main(void) 15 | { 16 | vec3 normalVec = normal; 17 | vec3 lightVec = vec3( normalize(lightPos-vertex) ); 18 | vec3 camVec = vec3( normalize(camPos-vertex) ); 19 | 20 | float l = clamp ( dot ( lightVec , normalVec ) ,0.0,1.0 ); 21 | vec3 r = reflect ( -camVec, normalVec ); 22 | float m = clamp ( dot ( r , lightVec ) ,0.0,1.0); 23 | float q = m*m; q=q*q; 24 | 25 | // gl_FragColor = vec4(normal,1.0) + 0.001 * (diffuse * l * 1.3 + specular * q + ambient); 26 | gl_FragColor = diffuse * l * 1.3 + specular * q + ambient; 27 | } -------------------------------------------------------------------------------- /Demo3-Arm/shaders/normal.vert: -------------------------------------------------------------------------------- 1 | 2 | varying vec3 normal; 3 | varying vec3 vertex; 4 | 5 | void main(void) 6 | { 7 | normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 8 | //normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)); 9 | //normal = gl_Normal;//frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 10 | vertex = gl_Vertex.xyz; 11 | gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz,1.0); 12 | } -------------------------------------------------------------------------------- /Demo3-Arm/shaders/shadow.frag: -------------------------------------------------------------------------------- 1 | 2 | void main(void) 3 | { 4 | gl_FragColor = vec4 (1.0,1.0,1.0,1.0); 5 | } -------------------------------------------------------------------------------- /Demo3-Arm/shaders/shadow.vert: -------------------------------------------------------------------------------- 1 | uniform float angle; 2 | uniform float twist; 3 | uniform vec3 spline_p; 4 | uniform vec3 spline_d1; 5 | uniform vec3 spline_d2; 6 | uniform vec3 spline_normal; 7 | 8 | uniform float arm_angle; 9 | uniform float arm_twist; 10 | uniform vec3 arm_spline_p; 11 | uniform vec3 arm_spline_d1; 12 | uniform vec3 arm_spline_d2; 13 | uniform vec3 arm_spline_normal; 14 | 15 | uniform float elbow_angle; 16 | uniform float elbow_twist; 17 | uniform vec3 elbow_spline_p; 18 | uniform vec3 elbow_spline_d1; 19 | uniform vec3 elbow_spline_d2; 20 | uniform vec3 elbow_spline_normal; 21 | 22 | uniform float body_angle; 23 | uniform float body_twist; 24 | uniform vec3 body_spline_p; 25 | uniform vec3 body_spline_d1; 26 | uniform vec3 body_spline_d2; 27 | uniform vec3 body_spline_normal; 28 | /* 29 | void eval_spline ( 30 | in float a, 31 | in twist, 32 | in angle, 33 | in vec3 spline_p, 34 | in vec3 spline_d1, 35 | in vec3 spline_d2, 36 | in vec3 spline_normal 37 | in p 38 | out) 39 | { 40 | 41 | } 42 | */ 43 | 44 | void main(void) 45 | { 46 | vec3 pos; 47 | vec3 n1; // x 48 | vec3 n2; // y 49 | vec3 n3; // z 50 | 51 | vec3 p = spline_p; 52 | vec3 d1= spline_d1; 53 | vec3 d2= spline_d2; 54 | 55 | float a = gl_MultiTexCoord1.x; 56 | float b = gl_MultiTexCoord1.y; 57 | float c = gl_MultiTexCoord1.z; 58 | float c01 = clamp ( c , 0.0 , 1.0 ); 59 | float alpha = 0.5 * 3.14159265358979323846 * c01; 60 | float cos_c = cos ( alpha ); 61 | float sin_c = sin ( alpha ); 62 | float min0 = min(c,0.0); 63 | float max1 = max(c,1.0); 64 | pos = p + d1 * sin_c + d2 * (1.0-cos_c) + d1 * min0 + d2 * max1; 65 | n3 = normalize(d1 * cos_c + d2 * sin_c); 66 | n1 = spline_normal; 67 | n2 = cross( n1,n3 ); 68 | 69 | float r = angle + twist*c01; 70 | float sin_r = sin ( r ); 71 | float cos_r = cos ( r ); 72 | float aa = cos_r * b + sin_r * a; 73 | float bb = cos_r * a - sin_r * b; 74 | 75 | vec3 result_pos = n1 * aa + n2 * bb + pos; 76 | 77 | gl_Position = gl_ModelViewProjectionMatrix * vec4 ( result_pos.xyz , 1 ) ; 78 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Spacerat 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deformation-Styles-using-Spline-Skinning 2 | 3 | [![Deformation Styles using Spline Skinning](http://i.imgur.com/wfgSRcN.png)](http://dl.acm.org/citation.cfm?id=1272690.1272710) 4 | 5 | Youtube Vid below 6 | 7 | 8 | [![Deformation Styles using Spline Skinning](http://img.youtube.com/vi/QwTMAn7faW4/0.jpg)](http://www.youtube.com/watch?v=QwTMAn7faW4) 9 | 10 | [PDF](https://github.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/blob/master/SCA-Deformation-Styles-Paper.pdf) 11 | -------------------------------------------------------------------------------- /SCA-Deformation-Styles-Paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/SCA-Deformation-Styles-Paper.pdf -------------------------------------------------------------------------------- /Source.Arm/Bmp.h: -------------------------------------------------------------------------------- 1 | #ifndef _Bmp_class 2 | #define _Bmp_class 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "VecMath.h" 9 | 10 | class Bmp 11 | { 12 | public: 13 | 14 | Bmp(); 15 | Bmp(int x,int y,int bpp,unsigned char*data); 16 | Bmp(const char*filename); 17 | ~Bmp(); 18 | 19 | bool load(const char*filename, 20 | bool checktransparency=false, 21 | int check_r=0, 22 | int check_g=0, 23 | int check_b=0); 24 | 25 | bool save(const char*filename); 26 | 27 | vec3f getSxSyT(float x); 28 | int sampleByte(int x,int y); 29 | bool set(int x,int y,int bpp,unsigned char*data); 30 | bool set3d(int x,int y,int z,int bpp,unsigned char*buffer); 31 | void crop(int x,int y); 32 | bool scale(int x,int y); 33 | bool blur(int count); 34 | bool hblur(int count); 35 | bool vblur(int count); 36 | bool addalpha(unsigned char r,unsigned char g,unsigned char b); 37 | bool normalize(void); 38 | bool normalMap(void); 39 | vec3f getPixel(float x,float y); 40 | vec3f get_f_fdx_fdy(float x,float y); 41 | 42 | private: 43 | 44 | int sampleMap(int i,int j); 45 | 46 | public: 47 | 48 | unsigned char*data; 49 | int width; 50 | int height; 51 | int depth; 52 | int bpp; 53 | 54 | private: 55 | 56 | unsigned char bmp[54]; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /Source.Arm/Deformer.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------- // 2 | class Deformer { 3 | 4 | public: 5 | 6 | std::string name ; 7 | Geometry geo; 8 | 9 | Deformer(){ init (); } 10 | ~Deformer() 11 | { 12 | clear(); 13 | } 14 | void init() 15 | { 16 | name = "empty"; 17 | } 18 | 19 | void clear () 20 | { 21 | geo.clear(); 22 | } 23 | void set_geometry ( Geometry geo ) 24 | { 25 | this->geo = geo; 26 | this->name = geo.name; 27 | geo.init(); 28 | } 29 | 30 | void draw (Material *materials, Spline* spline) 31 | { 32 | if ( spline ) 33 | { 34 | geo.draw( materials , spline ); 35 | //spline->draw(); 36 | } 37 | else 38 | geo.draw( materials ); 39 | } 40 | }; 41 | // ---------------------------------------- // 42 | 43 | -------------------------------------------------------------------------------- /Source.Arm/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = sample x_wing teapot 2 | 3 | sample_SOURCES = sample.cpp 4 | x_wing_SOURCES = x_wing.cpp 5 | teapot_SOURCES = teapot.cpp 6 | 7 | CPPFLAGS = @CPPFLAGS@ 8 | 9 | LDADD = ../libsolid/libFreeSOLID.la 10 | 11 | 12 | -------------------------------------------------------------------------------- /Source.Arm/MouseKeyboard.h: -------------------------------------------------------------------------------- 1 | 2 | //vec3f pos(-75,-29,12); 3 | vec3f pos(-15,-7,13.3); 4 | vec3f rot(19,-129,0); 5 | 6 | void mouse_keyboard() 7 | { 8 | /*glPushMatrix(); 9 | glLoadIdentity(); // Reset The View 10 | glRotatef(rot.x,1,0,0); // Move Left 1.5 Units And Into The Screen 6.0 11 | glRotatef(rot.y,0,1,0); // Move Left 1.5 Units And Into The Screen 6.0 12 | float m[16]; 13 | glGetFloatv (GL_MODELVIEW_MATRIX, m); 14 | glPopMatrix();*/ 15 | 16 | static int time = timeGetTime (); 17 | int timeNew = timeGetTime (); 18 | float deltaTime = timeNew-time; time =timeNew; 19 | bool* key = GFX::keyPressed; 20 | 21 | vec3f movX = vec3f ( 1,0,0 ); 22 | vec3f movY = vec3f ( 0,1,0 ); 23 | vec3f movZ = vec3f ( 0,0,1 ); 24 | 25 | movZ.rot_x ( rot.x * 2*M_PI / 360 ); 26 | movX.rot_x ( rot.x * 2*M_PI / 360 ); 27 | 28 | movZ.rot_y ( rot.y * 2*M_PI / 360 ); 29 | movX.rot_y ( rot.y * 2*M_PI / 360 ); 30 | 31 | if ( key[GLUT_KEY_UP ] ) pos=pos+movZ * (0.01 * deltaTime); 32 | if ( key[GLUT_KEY_DOWN ] ) pos=pos-movZ * (0.01 * deltaTime); 33 | if ( key[GLUT_KEY_LEFT ] ) pos=pos+movX * (0.01 * deltaTime); 34 | if ( key[GLUT_KEY_RIGHT] ) pos=pos-movX * (0.01 * deltaTime); 35 | 36 | //printf("p %f %f %f\n", pos.x, pos.y, pos.z ); 37 | 38 | if ( key[GLUT_KEY_PAGE_UP ] ) rot.y-=0.1 * deltaTime; 39 | if ( key[GLUT_KEY_PAGE_DOWN ] ) rot.y+=0.1 * deltaTime; 40 | 41 | if ( GFX::mousePressed[0] ) 42 | { 43 | rot.y += GFX::mouseDX * 300; 44 | rot.x += GFX::mouseDY * 300; 45 | } 46 | /* 47 | if ( keyPressed[GLUT_KEY_LEFT ] ) rot.x-=0.1; 48 | if ( keyPressed[GLUT_KEY_RIGHT] ) rot.x+=0.1; 49 | */ 50 | } 51 | -------------------------------------------------------------------------------- /Source.Arm/ObjControl.h: -------------------------------------------------------------------------------- 1 | class ObjControl { public: 2 | 3 | Deformer* obj_ref; 4 | Deformer* obj_copy; 5 | std::string name; 6 | 7 | Spline spline; 8 | 9 | vec3f pos,scale,axis;float angle; 10 | 11 | ObjControl(){ init(); } 12 | 13 | ~ObjControl(){ 14 | clear(); 15 | } 16 | 17 | void init(){ 18 | this->name = "empty"; 19 | this->obj_ref=NULL; 20 | this->obj_copy=NULL; 21 | this->pos = vec3f (0,0,0); 22 | this->scale = vec3f (1,1,1); 23 | this->axis = vec3f (1,0,0); 24 | this->angle = 0; 25 | } 26 | void clear() 27 | { 28 | if ( obj_copy ) 29 | { 30 | delete(obj_copy); 31 | } 32 | } 33 | void set_object( Deformer* obj ) 34 | { 35 | obj_ref = obj; 36 | init_name(); 37 | /* 38 | vec3f bbmin = obj->geo.bb_min; 39 | vec3f bbmax = obj->geo.bb_max; 40 | vec3f bbmid = (bbmin + bbmax)/2; 41 | 42 | vec3f p1 = vec3f( bbmid.x,bbmid.y,bbmin.z ); 43 | vec3f d = vec3f( 0,0,(bbmax.z-bbmin.z)/2 ); 44 | set_spline( p1,(p1+d),(p1+d+d),0,0 ); 45 | */ 46 | //printf("assigned %s,%d points\n",obj.name.c_str(),obj.geo.points.size()); 47 | } 48 | void draw(Material *mats) 49 | { 50 | if (!obj_ref) return; 51 | 52 | glPushMatrix(); 53 | glTranslatef( pos.x,pos.y,pos.z ); 54 | glRotatef( angle, axis.x,axis.y,axis.z); 55 | glScalef( scale.x,scale.y,scale.z ); 56 | 57 | obj_ref->draw(mats,&spline); 58 | 59 | glPopMatrix(); 60 | } 61 | void init_name(int i=-1) 62 | { 63 | if (!obj_ref){ this->name = "empty";return; } 64 | if ( i== -1 ) 65 | this->name = obj_ref->name; 66 | else 67 | { 68 | this->name = int_to_str(i) + std::string("-") + obj_ref->name; 69 | } 70 | } 71 | }; 72 | -------------------------------------------------------------------------------- /Source.Arm/PBuffer.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////////// 2 | // PBUFFER.h 3 | // class to setup pBuffer 4 | // You may use this code however you wish, but if you do, please credit me and 5 | // provide a link to my website in a readme file or similar 6 | // Downloaded from: www.paulsprojects.net 7 | // Created: 9th September 2002 8 | ////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | #ifndef PBUFFER_H 11 | #define PBUFFER_H 12 | 13 | class PBUFFER 14 | { 15 | public: 16 | HGLRC hRC; //rendering context 17 | HDC hDC; //device context 18 | HPBUFFERARB hBuffer; //buffer handle 19 | 20 | HDC tmp_hDC; // Tmp - context 21 | HGLRC tmp_hRC; 22 | 23 | int tmp_viewport[4]; 24 | 25 | unsigned int pbufferTexture; 26 | 27 | bool useMipmapFilter; 28 | int currentAnisotropy,maxAnisotropy; 29 | 30 | int width, height; //window size 31 | int colorBits, depthBits, stencilBits; //window bpp 32 | 33 | bool Init( int newWidth, int newHeight ); 34 | bool begin(void); 35 | bool end(void); 36 | 37 | void Shutdown(void); 38 | }; 39 | 40 | #endif //PBUFFER_H -------------------------------------------------------------------------------- /Source.Arm/Tools.h: -------------------------------------------------------------------------------- 1 | std::string int_to_str(const int& x) 2 | { 3 | std::ostringstream o; 4 | if (!(o << x)) return "ERROR"; 5 | return o.str(); 6 | } 7 | /* 8 | void Line ( vec3f p1 , vec3f p2 , vec3f color=vec3f(1,1,0) ){ 9 | glBegin(GL_LINES); 10 | glColor3f(color.x ,color.y ,color.z ); 11 | glVertex3f( p1.x,p1.y,p1.z ); 12 | glVertex3f( p2.x,p2.y,p2.z ); 13 | glEnd(); 14 | } 15 | */ 16 | void Box ( vec3f pos , vec3f size ){ 17 | 18 | float xyz[3][4]={{-1,1,1,-1},{1,1,-1,-1},{1,1,1,1}}; 19 | int xchg[6][3]={{1,2,0},{0,1,2},{2,0,1},{0,1,2},{1,2,0},{2,0,1}}; 20 | int mult[6][3]={{0,0,0},{0,0,0},{0,0,0},{1,0,1},{1,1,0},{1,0,1}}; 21 | float tex_x[4]={0,1,1,0}; 22 | float tex_y[4]={1,1,0,0}; 23 | 24 | // draw a triangle 25 | glBegin(GL_QUADS); // start drawing a polygon 26 | for (int j=0;j<6;j++) 27 | { 28 | for (int i=0;i<4;i++) 29 | { 30 | glColor3f(1,1,1); 31 | float x = xyz[xchg[j][0]][i]; if(mult[j][0]) x=-x; 32 | float y = xyz[xchg[j][1]][i]; if(mult[j][1]) y=-y; 33 | float z = xyz[xchg[j][2]][i]; if(mult[j][2]) z=-z; 34 | 35 | glTexCoord2f( tex_x[i], tex_y[i] ); 36 | 37 | glNormal3f( x,y,z ); 38 | glVertex3f( 39 | pos.x+x*size.x, 40 | pos.y+y*size.y, 41 | pos.z+z*size.z ); 42 | } 43 | } 44 | glEnd(); // we're done with the polygon 45 | } 46 | -------------------------------------------------------------------------------- /Source.Arm/VecMath.cpp: -------------------------------------------------------------------------------- 1 | #include "VecMath.h" 2 | 3 | int vec3f::random_number = 3457734; 4 | 5 | void vec3f::random_init() 6 | { 7 | random_number = 3457734; 8 | } 9 | 10 | float vec3f::random_float(){ 11 | int t = random_number; 12 | t = (t * 2345633 + t*1245 + t*356 + t*35 + t/34 + t/325 - 8647445); 13 | random_number = t; 14 | 15 | return ( float (abs(t)%10000)/10000); 16 | } 17 | 18 | vec3f vec3f::random(){ 19 | static vec3f rnd; 20 | rnd.x=random_float()*2-1; 21 | rnd.y=random_float()*2-1; 22 | rnd.z=random_float()*2-1; 23 | rnd.normalize(); 24 | return rnd; 25 | } 26 | 27 | vec3f vec3f::normalize( vec3f a ) 28 | { 29 | float square = a.x*a.x + a.y*a.y + a.z*a.z; 30 | if (square <= 0.00001f ) 31 | { 32 | a.x=1;a.y=0;a.z=0; 33 | return a; 34 | } 35 | float len = 1.0f / (float)sqrt(square); 36 | a.x*=len;a.y*=len;a.z*=len; 37 | return a; 38 | } 39 | 40 | 41 | /* 42 | bool lines_intersect ( vec3f line1[2] ,vec3f line2[2] , vec3f* intersection = NULL) 43 | { 44 | // BBox 45 | 46 | if ( line1[0].x < line2[0].x ) if ( line1[0].x < line2[1].x ) if ( line1[1].x < line2[0].x ) if ( line1[1].x < line2[1].x ) return false; 47 | if ( line1[0].x > line2[0].x ) if ( line1[0].x > line2[1].x ) if ( line1[1].x > line2[0].x ) if ( line1[1].x > line2[1].x ) return false; 48 | if ( line1[0].y > line2[0].y ) if ( line1[0].y > line2[1].y ) if ( line1[1].y > line2[0].y ) if ( line1[1].y > line2[1].y ) return false; 49 | if ( line1[0].y < line2[0].y ) if ( line1[0].y < line2[1].y ) if ( line1[1].y < line2[0].y ) if ( line1[1].y < line2[1].y ) return false; 50 | 51 | // intersect 52 | 53 | 54 | //a x + b = c y + d 55 | //a x - c y = d - b 56 | 57 | //- a2 a1 x + a2 c1 y =-a2 d1 + a2 b1 58 | // a1 a2 x - a1 c2 y = a1 d2 - a1 b2 59 | 60 | // y = ( a1 d2 - a1 b2 - a2 d1 + a2 b1 ) / ( a2 c1 - a1 c2 ) 61 | 62 | 63 | vec3f delta1 = line1[1] - line1[0]; 64 | vec3f delta2 = line2[1] - line2[0]; 65 | vec3f point1 = line1[0]; 66 | vec3f point2 = line2[0]; 67 | 68 | float div1 = delta1.y*delta2.x - delta1.x*delta2.y; 69 | float div2 = delta2.y*delta1.x - delta2.x*delta1.y; 70 | 71 | float a = 2; 72 | 73 | if ( div1 != 0) 74 | { 75 | a = ( delta1.x*point2.y - 76 | delta1.x*point1.y - 77 | delta1.y*point2.x + 78 | delta1.y*point1.x ) / div1; 79 | }else 80 | if ( div2 != 0) 81 | { 82 | a = ( delta2.x*point1.y - 83 | delta2.x*point2.y - 84 | delta2.y*point1.x + 85 | delta2.y*point2.x ) / div2; 86 | } 87 | if ( a <= 1 ) 88 | if ( a >= 0 ) 89 | { 90 | if (intersection) 91 | { 92 | if ( div1 != 0) 93 | *intersection = delta2 * a + point2; 94 | else 95 | *intersection = delta1 * a + point1; 96 | } 97 | return true; 98 | } 99 | 100 | return false; 101 | }; 102 | */ 103 | -------------------------------------------------------------------------------- /Source.Arm/glut32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/Source.Arm/glut32.dll -------------------------------------------------------------------------------- /Source.Arm/render_matrices.h: -------------------------------------------------------------------------------- 1 | void render_matrices(void) 2 | { 3 | static bool init=true; 4 | static GLuint fb; 5 | static GLuint fbo_points[4]; 6 | GLuint fb_type = GL_TEXTURE_RECTANGLE_ARB; 7 | GLuint type = GL_TEXTURE_RECTANGLE_ARB; 8 | 9 | static int fb_width = spline_tex.width; 10 | static int fb_height = spline_tex.height; 11 | 12 | if(init) 13 | { 14 | glGenFramebuffersEXT(1,&fb); 15 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb); 16 | 17 | fbo_points[0] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 18 | fbo_points[1] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 19 | fbo_points[2] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 20 | 21 | spline_tex.handle_nbtpx_out = fbo_points[0]; 22 | spline_tex.handle_nbtpy_out = fbo_points[1]; 23 | spline_tex.handle_nbtpz_out = fbo_points[2]; 24 | 25 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 26 | GL_COLOR_ATTACHMENT0_EXT, fb_type, 27 | fbo_points[0], 0); 28 | get_GL_error(); 29 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 30 | GL_COLOR_ATTACHMENT1_EXT, fb_type, 31 | fbo_points[1], 0); 32 | get_GL_error(); 33 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 34 | GL_COLOR_ATTACHMENT2_EXT, fb_type, 35 | fbo_points[2], 0); 36 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); 37 | get_GL_error(); 38 | 39 | init = false; 40 | } 41 | 42 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb); 43 | get_GL_error(); 44 | 45 | GLenum dbuffers[] = { 46 | GL_COLOR_ATTACHMENT0_EXT, 47 | GL_COLOR_ATTACHMENT1_EXT, 48 | GL_COLOR_ATTACHMENT2_EXT 49 | }; 50 | glDrawBuffers(3, dbuffers);get_GL_error(); 51 | 52 | int viewport[4]; 53 | glGetIntegerv(GL_VIEWPORT, viewport); 54 | glViewport(0,0,fb_width,fb_height); get_GL_error(); 55 | glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); 56 | glMatrixMode(GL_PROJECTION);glPushMatrix(); glLoadIdentity(); 57 | gluOrtho2D(0.0,fb_width,0.0,fb_height); get_GL_error(); 58 | glMatrixMode(GL_MODELVIEW); 59 | glDisable(GL_CULL_FACE); 60 | glDisable(GL_DEPTH_TEST); 61 | glDepthMask(GL_FALSE); 62 | 63 | // Matrix 64 | glActiveTextureARB( GL_TEXTURE0 ); 65 | glBindTexture(type, spline_tex.handle_nbtpx); 66 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 67 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 68 | glActiveTextureARB( GL_TEXTURE1 ); 69 | glBindTexture(type, spline_tex.handle_nbtpy); 70 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 71 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 72 | glActiveTextureARB( GL_TEXTURE2 ); 73 | glBindTexture(type, spline_tex.handle_nbtpz); 74 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 75 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 76 | 77 | // Params 78 | glActiveTextureARB( GL_TEXTURE3 ); 79 | glBindTexture(type, spline_tex.handle_params); 80 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 81 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 82 | 83 | glActiveTextureARB( GL_TEXTURE0 ); 84 | 85 | //glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE);get_GL_error(); 86 | 87 | glMatrixMode(GL_MODELVIEW); 88 | shader_matrices->begin(); 89 | // shader_matrices->setUniform1i("texSplineRowX",0); 90 | // shader_matrices->setUniform1i("texSplineRowY",1); 91 | // shader_matrices->setUniform1i("texSplineRowZ",2); 92 | shader_matrices->setUniform1i("texSplineParams",3); 93 | shader_matrices->setUniform1f("resolution",float(spline_tex.width)); 94 | //shader_matrices->setUniform1f("adjust_rot",2);//float(1+GFX::mouseX*4)); 95 | //shader_matrices->setUniform1f("adjust_pos",global_bend_adjust);//float(1+GFX::mouseY*5)); 96 | //shader_matrices->setUniform1f("pose_ofs",float(spline_tex.height)); 97 | 98 | glBegin(GL_QUADS); 99 | glColor3f(1,1,1); 100 | glMultiTexCoord2f( GL_TEXTURE0, 0.0, 0.0); 101 | glVertex2f(0, 0); 102 | glMultiTexCoord2f( GL_TEXTURE0, fb_width, 0.0); 103 | glVertex2f(fb_width,0); 104 | glMultiTexCoord2f( GL_TEXTURE0, fb_width, fb_height); 105 | glVertex2f(fb_width, fb_height); 106 | glMultiTexCoord2f( GL_TEXTURE0, 0.0, fb_height); 107 | glVertex2f(0, fb_height); 108 | glEnd(); 109 | 110 | shader_matrices->end(); 111 | get_GL_error(); 112 | 113 | glBindTexture(GL_TEXTURE_2D,0); 114 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); 115 | get_GL_error(); 116 | 117 | glEnable(GL_CULL_FACE); 118 | glEnable(GL_DEPTH_TEST); 119 | glDepthMask(GL_TRUE); 120 | 121 | glMatrixMode(GL_PROJECTION);glPopMatrix(); 122 | glMatrixMode(GL_MODELVIEW); glPopMatrix(); 123 | glViewport(viewport[0],viewport[1],viewport[2],viewport[3]); 124 | glDrawBuffer(GL_BACK); 125 | } 126 | -------------------------------------------------------------------------------- /Source.Arm/render_matrices_2.h: -------------------------------------------------------------------------------- 1 | void render_matrices_2(void) 2 | { 3 | static bool init=true; 4 | static GLuint fb; 5 | static GLuint fbo_points[4]; 6 | GLuint fb_type = GL_TEXTURE_RECTANGLE_ARB; 7 | GLuint type = GL_TEXTURE_RECTANGLE_ARB; 8 | 9 | static int fb_width = spline_tex.width; 10 | static int fb_height = spline_tex.height; 11 | 12 | if(init) 13 | { 14 | glGenFramebuffersEXT(1,&fb); 15 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb); 16 | 17 | fbo_points[0] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 18 | fbo_points[1] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 19 | fbo_points[2] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 20 | 21 | spline_tex.handle_nbtpx_out2 = fbo_points[0]; 22 | spline_tex.handle_nbtpy_out2 = fbo_points[1]; 23 | spline_tex.handle_nbtpz_out2 = fbo_points[2]; 24 | 25 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 26 | GL_COLOR_ATTACHMENT0_EXT, fb_type, 27 | fbo_points[0], 0); 28 | get_GL_error(); 29 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 30 | GL_COLOR_ATTACHMENT1_EXT, fb_type, 31 | fbo_points[1], 0); 32 | get_GL_error(); 33 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 34 | GL_COLOR_ATTACHMENT2_EXT, fb_type, 35 | fbo_points[2], 0); 36 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); 37 | get_GL_error(); 38 | 39 | init = false; 40 | } 41 | 42 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb); 43 | get_GL_error(); 44 | 45 | GLenum dbuffers[] = { 46 | GL_COLOR_ATTACHMENT0_EXT, 47 | GL_COLOR_ATTACHMENT1_EXT, 48 | GL_COLOR_ATTACHMENT2_EXT 49 | }; 50 | glDrawBuffers(3, dbuffers);get_GL_error(); 51 | 52 | int viewport[4]; 53 | glGetIntegerv(GL_VIEWPORT, viewport); 54 | glViewport(0,0,fb_width,fb_height); get_GL_error(); 55 | glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); 56 | glMatrixMode(GL_PROJECTION);glPushMatrix(); glLoadIdentity(); 57 | gluOrtho2D(0.0,fb_width,0.0,fb_height); get_GL_error(); 58 | glMatrixMode(GL_MODELVIEW); 59 | glDisable(GL_CULL_FACE); 60 | glDisable(GL_DEPTH_TEST); 61 | glDepthMask(GL_FALSE); 62 | 63 | // Bind Matrix 64 | glActiveTextureARB( GL_TEXTURE0 ); 65 | glBindTexture(type, spline_tex.handle_nbtpx); 66 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 67 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 68 | glActiveTextureARB( GL_TEXTURE1 ); 69 | glBindTexture(type, spline_tex.handle_nbtpy); 70 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 71 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 72 | glActiveTextureARB( GL_TEXTURE2 ); 73 | glBindTexture(type, spline_tex.handle_nbtpz); 74 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 75 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 76 | 77 | // Spline Matrix 78 | glActiveTextureARB( GL_TEXTURE3 ); 79 | glBindTexture(type, spline_tex.handle_nbtpx_out); 80 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 81 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 82 | glActiveTextureARB( GL_TEXTURE4 ); 83 | glBindTexture(type, spline_tex.handle_nbtpy_out); 84 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 85 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 86 | glActiveTextureARB( GL_TEXTURE5 ); 87 | glBindTexture(type, spline_tex.handle_nbtpz_out); 88 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 89 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 90 | 91 | 92 | glActiveTextureARB( GL_TEXTURE0 ); 93 | 94 | //glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE);get_GL_error(); 95 | 96 | glMatrixMode(GL_MODELVIEW); 97 | shader_matrices2->begin(); 98 | 99 | shader_matrices2->setUniform1i("texBindRowX",0); 100 | shader_matrices2->setUniform1i("texBindRowY",1); 101 | shader_matrices2->setUniform1i("texBindRowZ",2); 102 | 103 | shader_matrices2->setUniform1i("texSplineRowX",3); 104 | shader_matrices2->setUniform1i("texSplineRowY",4); 105 | shader_matrices2->setUniform1i("texSplineRowZ",5); 106 | 107 | glBegin(GL_QUADS); 108 | glColor3f(1,1,1); 109 | glMultiTexCoord2f( GL_TEXTURE0, 0.0, 0.0); 110 | glVertex2f(0, 0); 111 | glMultiTexCoord2f( GL_TEXTURE0, fb_width, 0.0); 112 | glVertex2f(fb_width,0); 113 | glMultiTexCoord2f( GL_TEXTURE0, fb_width, fb_height); 114 | glVertex2f(fb_width, fb_height); 115 | glMultiTexCoord2f( GL_TEXTURE0, 0.0, fb_height); 116 | glVertex2f(0, fb_height); 117 | glEnd(); 118 | 119 | shader_matrices2->end(); 120 | get_GL_error(); 121 | 122 | glBindTexture(GL_TEXTURE_2D,0); 123 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); 124 | get_GL_error(); 125 | 126 | glEnable(GL_CULL_FACE); 127 | glEnable(GL_DEPTH_TEST); 128 | glDepthMask(GL_TRUE); 129 | 130 | glMatrixMode(GL_PROJECTION);glPopMatrix(); 131 | glMatrixMode(GL_MODELVIEW); glPopMatrix(); 132 | glViewport(viewport[0],viewport[1],viewport[2],viewport[3]); 133 | glDrawBuffer(GL_BACK); 134 | } 135 | -------------------------------------------------------------------------------- /Source.Arm/shaders/deform.vert: -------------------------------------------------------------------------------- 1 | //uniform sampler2D tex_points; 2 | 3 | varying vec3 normal; 4 | varying vec3 vertex; 5 | varying vec2 textureCoord; 6 | varying vec2 textureCoord1; 7 | varying vec2 textureCoord2; 8 | varying vec2 textureCoord3; 9 | varying vec2 textureCoord4; 10 | 11 | //uniform mat4 light2shadow; 12 | //uniform vec3 spline1_p1; 13 | 14 | void main(void) 15 | { 16 | //normal = gl_Color.xyz * vec3( 2.0,2.0,2.0 ) - vec3 (1.0,1.0,1.0); 17 | //vertex = gl_Vertex.xyz; 18 | 19 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 20 | textureCoord = gl_MultiTexCoord0.xy; 21 | textureCoord1 = gl_MultiTexCoord0.xy; 22 | textureCoord2 = gl_MultiTexCoord0.xy; 23 | textureCoord3 = gl_MultiTexCoord0.xy; 24 | textureCoord4 = gl_MultiTexCoord0.xy; 25 | 26 | textureCoord1.x = gl_MultiTexCoord0.x*4; 27 | textureCoord2.x = gl_MultiTexCoord0.x*4+1; 28 | textureCoord3.x = gl_MultiTexCoord0.x*4+2; 29 | textureCoord4.x = gl_MultiTexCoord0.x*4+3; 30 | } -------------------------------------------------------------------------------- /Source.Arm/shaders/matrices.frag: -------------------------------------------------------------------------------- 1 | 2 | uniform sampler2DRect texSplineRowX; 3 | uniform sampler2DRect texSplineRowY; 4 | uniform sampler2DRect texSplineRowZ; 5 | uniform sampler2DRect texSplineParams; 6 | //uniform float adjust_pos; 7 | //uniform float adjust_rot; 8 | //uniform float pose_ofs; 9 | 10 | varying vec2 texCoordMatrix; 11 | varying vec2 texCoordParams; 12 | 13 | varying float a; 14 | 15 | void main(void) 16 | { 17 | float pi = 3.14159265358979323846; 18 | 19 | vec4 param1 = texture2DRect(texSplineParams,texCoordParams); 20 | vec4 param2 = texture2DRect(texSplineParams,texCoordParams+vec2(1,0)); 21 | vec4 param3 = texture2DRect(texSplineParams,texCoordParams+vec2(2,0)); 22 | vec4 param4 = texture2DRect(texSplineParams,texCoordParams+vec2(3,0)); 23 | vec4 param5 = texture2DRect(texSplineParams,texCoordParams+vec2(5,0)); 24 | //.x:deformation_style 25 | //.y:spline_hardness 26 | //.z:spline_twist_adjust 27 | //.w:center_distort 28 | 29 | vec3 spline_p1 = param1.xyz; 30 | vec3 spline_d1 = param2.xyz; 31 | vec3 spline_d2 = param3.xyz; 32 | vec3 spline_normal = param4.xyz; 33 | float angle = param1.w; 34 | float twist = param2.w; 35 | float hardness = param5.y; 36 | float twist_adjust = param5.z; 37 | 38 | float a01 = clamp(a,0,1); 39 | 40 | float a_21 = a*2-1; 41 | float a_rot = sign(a_21) * (1-pow(1-abs(a_21),twist_adjust)) * 0.5 +0.5; 42 | 43 | float p = hardness; 44 | float pow_a = pow(a01 ,p); 45 | float pow_1a = pow(1-a01,p); 46 | float f2_a = a *pow_a; 47 | float f1_a = 1-(1-a)*pow_1a; 48 | float f2_da = pow_a; 49 | float f1_da = pow_1a; 50 | 51 | //vec4 pose= texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x,pose_ofs)); 52 | //vec4 pose_d = texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x+5,pose_ofs))-pose; 53 | 54 | vec3 pos= spline_p1 + spline_d1 * f1_a + spline_d2 * f2_a; 55 | vec3 n1 = spline_normal;// * pose.y; 56 | vec3 n3 = normalize (spline_d1 * f1_da + spline_d2 * f2_da); 57 | vec3 n2 = normalize (cross( n3,n1 )); 58 | 59 | //pos = pos - n2; 60 | 61 | //pos = pos + n2 * (pose.z-1)*1.5; 62 | //n2 = n2 * pose.x; 63 | 64 | mat4 bind_mat; 65 | mat4 spline_mat; 66 | 67 | spline_mat[0] = vec4(n1,0.0); 68 | spline_mat[1] = vec4(n2,0.0); 69 | spline_mat[2] = vec4(n3,0.0); 70 | spline_mat[3] = vec4(pos,1.0); 71 | 72 | spline_mat = transpose(spline_mat); 73 | 74 | vec4 row1= texture2DRect(texSplineRowX,texCoordMatrix); 75 | vec4 row2= texture2DRect(texSplineRowY,texCoordMatrix); 76 | vec4 row3= texture2DRect(texSplineRowZ,texCoordMatrix); 77 | 78 | float r = angle + twist * a_rot; 79 | float cos_a = cos(r); 80 | float sin_a = sin(r); 81 | 82 | mat4 rot_mat; 83 | rot_mat[0] = vec4 (cos_a,-sin_a,0.0,0.0); 84 | rot_mat[1] = vec4 (sin_a,cos_a,0.0,0.0); 85 | rot_mat[2] = vec4 (0.0,0.0,1.0,0.0); 86 | rot_mat[3] = vec4 (0.0,0.0,0.0,1.0); 87 | 88 | bind_mat[0] = row1; 89 | bind_mat[1] = row2; 90 | bind_mat[2] = row3; 91 | bind_mat[3] = vec4(0.0,0.0,0.0,1.0); 92 | 93 | /* 94 | spline_mat[0].w = spline_mat[0].w - dot( spline_mat[0].xyz, n2.x ); 95 | spline_mat[1].w = spline_mat[1].w - dot( spline_mat[1].xyz, n2.y ); 96 | spline_mat[2].w = spline_mat[2].w - dot( spline_mat[2].xyz, n2.z ); 97 | */ 98 | // mat4 final_mat = bind_mat * rot_mat * spline_mat; 99 | mat4 final_mat = rot_mat * spline_mat; 100 | 101 | //vec4 n2_xf = final_mat * vec4(n2.xyz,0.0); 102 | 103 | gl_FragData[0] = final_mat[0] ; 104 | gl_FragData[1] = final_mat[1] ; 105 | gl_FragData[2] = final_mat[2] ; 106 | } 107 | 108 | -------------------------------------------------------------------------------- /Source.Arm/shaders/matrices.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Source.Arm/shaders/matrices2.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2DRect texBindRowX; 2 | uniform sampler2DRect texBindRowY; 3 | uniform sampler2DRect texBindRowZ; 4 | 5 | uniform sampler2DRect texSplineRowX; 6 | uniform sampler2DRect texSplineRowY; 7 | uniform sampler2DRect texSplineRowZ; 8 | 9 | varying vec2 texCoordMatrix; 10 | 11 | void main(void) 12 | { 13 | mat4 bind; 14 | mat4 spline; 15 | bind[0]= texture2DRect(texBindRowX,texCoordMatrix); 16 | bind[1]= texture2DRect(texBindRowY,texCoordMatrix); 17 | bind[2]= texture2DRect(texBindRowZ,texCoordMatrix); 18 | bind[3]= vec4 (0.0,0.0,0.0,1.0); 19 | 20 | spline[0]= texture2DRect(texSplineRowX,texCoordMatrix); 21 | spline[1]= texture2DRect(texSplineRowY,texCoordMatrix); 22 | spline[2]= texture2DRect(texSplineRowZ,texCoordMatrix); 23 | spline[3]= vec4 (0.0,0.0,0.0,1.0); 24 | 25 | mat4 final_mat = bind * spline; 26 | 27 | gl_FragData[0] = final_mat[0] ; 28 | gl_FragData[1] = final_mat[1] ; 29 | gl_FragData[2] = final_mat[2] ; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Source.Arm/shaders/matrices2.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Source.Arm/shaders/normal.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D texLight; 2 | uniform sampler2D texDecal; 3 | uniform sampler2DShadow texDepth; 4 | 5 | uniform vec3 camPos; 6 | uniform vec3 lightPos; 7 | uniform vec4 ambient; 8 | uniform vec4 diffuse; 9 | uniform vec4 specular; 10 | 11 | varying vec3 normal; 12 | varying vec3 vertex; 13 | 14 | void main(void) 15 | { 16 | vec3 normalVec = normal; 17 | vec3 lightVec = vec3( normalize(lightPos-vertex) ); 18 | vec3 camVec = vec3( normalize(camPos-vertex) ); 19 | 20 | float l = clamp ( dot ( lightVec , normalVec ) ,0.0,1.0 ); 21 | vec3 r = reflect ( -camVec, normalVec ); 22 | float m = clamp ( dot ( r , lightVec ) ,0.0,1.0); 23 | float q = m*m; q=q*q; 24 | 25 | // gl_FragColor = vec4(normal,1.0) + 0.001 * (diffuse * l * 1.3 + specular * q + ambient); 26 | gl_FragColor = diffuse * l * 1.3 + specular * q + ambient; 27 | } -------------------------------------------------------------------------------- /Source.Arm/shaders/normal.vert: -------------------------------------------------------------------------------- 1 | 2 | varying vec3 normal; 3 | varying vec3 vertex; 4 | 5 | void main(void) 6 | { 7 | normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 8 | //normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)); 9 | //normal = gl_Normal;//frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 10 | vertex = gl_Vertex.xyz; 11 | gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz,1.0); 12 | } -------------------------------------------------------------------------------- /Source.Arm/shaders/shadow.frag: -------------------------------------------------------------------------------- 1 | 2 | void main(void) 3 | { 4 | gl_FragColor = vec4 (1.0,1.0,1.0,1.0); 5 | } -------------------------------------------------------------------------------- /Source.Arm/shaders/shadow.vert: -------------------------------------------------------------------------------- 1 | uniform float angle; 2 | uniform float twist; 3 | uniform vec3 spline_p; 4 | uniform vec3 spline_d1; 5 | uniform vec3 spline_d2; 6 | uniform vec3 spline_normal; 7 | 8 | uniform float arm_angle; 9 | uniform float arm_twist; 10 | uniform vec3 arm_spline_p; 11 | uniform vec3 arm_spline_d1; 12 | uniform vec3 arm_spline_d2; 13 | uniform vec3 arm_spline_normal; 14 | 15 | uniform float elbow_angle; 16 | uniform float elbow_twist; 17 | uniform vec3 elbow_spline_p; 18 | uniform vec3 elbow_spline_d1; 19 | uniform vec3 elbow_spline_d2; 20 | uniform vec3 elbow_spline_normal; 21 | 22 | uniform float body_angle; 23 | uniform float body_twist; 24 | uniform vec3 body_spline_p; 25 | uniform vec3 body_spline_d1; 26 | uniform vec3 body_spline_d2; 27 | uniform vec3 body_spline_normal; 28 | /* 29 | void eval_spline ( 30 | in float a, 31 | in twist, 32 | in angle, 33 | in vec3 spline_p, 34 | in vec3 spline_d1, 35 | in vec3 spline_d2, 36 | in vec3 spline_normal 37 | in p 38 | out) 39 | { 40 | 41 | } 42 | */ 43 | 44 | void main(void) 45 | { 46 | vec3 pos; 47 | vec3 n1; // x 48 | vec3 n2; // y 49 | vec3 n3; // z 50 | 51 | vec3 p = spline_p; 52 | vec3 d1= spline_d1; 53 | vec3 d2= spline_d2; 54 | 55 | float a = gl_MultiTexCoord1.x; 56 | float b = gl_MultiTexCoord1.y; 57 | float c = gl_MultiTexCoord1.z; 58 | float c01 = clamp ( c , 0.0 , 1.0 ); 59 | float alpha = 0.5 * 3.14159265358979323846 * c01; 60 | float cos_c = cos ( alpha ); 61 | float sin_c = sin ( alpha ); 62 | float min0 = min(c,0.0); 63 | float max1 = max(c,1.0); 64 | pos = p + d1 * sin_c + d2 * (1.0-cos_c) + d1 * min0 + d2 * max1; 65 | n3 = normalize(d1 * cos_c + d2 * sin_c); 66 | n1 = spline_normal; 67 | n2 = cross( n1,n3 ); 68 | 69 | float r = angle + twist*c01; 70 | float sin_r = sin ( r ); 71 | float cos_r = cos ( r ); 72 | float aa = cos_r * b + sin_r * a; 73 | float bb = cos_r * a - sin_r * b; 74 | 75 | vec3 result_pos = n1 * aa + n2 * bb + pos; 76 | 77 | gl_Position = gl_ModelViewProjectionMatrix * vec4 ( result_pos.xyz , 1 ) ; 78 | } -------------------------------------------------------------------------------- /Source.Cuboid/Bmp.h: -------------------------------------------------------------------------------- 1 | #ifndef _Bmp_class 2 | #define _Bmp_class 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "VecMath.h" 9 | 10 | class Bmp 11 | { 12 | public: 13 | 14 | Bmp(); 15 | Bmp(int x,int y,int bpp,unsigned char*data); 16 | Bmp(const char*filename); 17 | ~Bmp(); 18 | 19 | bool load(const char*filename, 20 | bool checktransparency=false, 21 | int check_r=0, 22 | int check_g=0, 23 | int check_b=0); 24 | 25 | bool save(const char*filename); 26 | 27 | vec3f getSxSyT(float x); 28 | int sampleByte(int x,int y); 29 | bool set(int x,int y,int bpp,unsigned char*data); 30 | bool set3d(int x,int y,int z,int bpp,unsigned char*buffer); 31 | void crop(int x,int y); 32 | bool scale(int x,int y); 33 | bool blur(int count); 34 | bool hblur(int count); 35 | bool vblur(int count); 36 | bool addalpha(unsigned char r,unsigned char g,unsigned char b); 37 | bool normalize(void); 38 | bool normalMap(void); 39 | vec3f getPixel(float x,float y); 40 | vec3f get_f_fdx_fdy(float x,float y); 41 | 42 | private: 43 | 44 | int sampleMap(int i,int j); 45 | 46 | public: 47 | 48 | unsigned char*data; 49 | int width; 50 | int height; 51 | int depth; 52 | int bpp; 53 | 54 | private: 55 | 56 | unsigned char bmp[54]; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /Source.Cuboid/Deformer.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------- // 2 | class Deformer { 3 | 4 | public: 5 | 6 | std::string name ; 7 | Geometry geo; 8 | 9 | Deformer(){ init (); } 10 | ~Deformer() 11 | { 12 | clear(); 13 | } 14 | void init() 15 | { 16 | name = "empty"; 17 | } 18 | 19 | void clear () 20 | { 21 | geo.clear(); 22 | } 23 | void set_geometry ( Geometry geo ) 24 | { 25 | this->geo = geo; 26 | this->name = geo.name; 27 | geo.init(); 28 | } 29 | 30 | void draw (Material *materials, Spline* spline) 31 | { 32 | if ( spline ) 33 | { 34 | geo.draw( materials , spline ); 35 | //spline->draw(); 36 | } 37 | else 38 | geo.draw( materials ); 39 | } 40 | }; 41 | // ---------------------------------------- // 42 | 43 | -------------------------------------------------------------------------------- /Source.Cuboid/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = sample x_wing teapot 2 | 3 | sample_SOURCES = sample.cpp 4 | x_wing_SOURCES = x_wing.cpp 5 | teapot_SOURCES = teapot.cpp 6 | 7 | CPPFLAGS = @CPPFLAGS@ 8 | 9 | LDADD = ../libsolid/libFreeSOLID.la 10 | 11 | 12 | -------------------------------------------------------------------------------- /Source.Cuboid/MouseKeyboard.h: -------------------------------------------------------------------------------- 1 | //vec3f pos(-75,-29,12); 2 | vec3f pos(-2.1,-6.1,6.8); 3 | vec3f rot(-9.5,-161,0); 4 | 5 | void mouse_keyboard() 6 | { 7 | /*glPushMatrix(); 8 | glLoadIdentity(); // Reset The View 9 | glRotatef(rot.x,1,0,0); // Move Left 1.5 Units And Into The Screen 6.0 10 | glRotatef(rot.y,0,1,0); // Move Left 1.5 Units And Into The Screen 6.0 11 | float m[16]; 12 | glGetFloatv (GL_MODELVIEW_MATRIX, m); 13 | glPopMatrix();*/ 14 | 15 | static int time = timeGetTime (); 16 | int timeNew = timeGetTime (); 17 | float deltaTime = timeNew-time; time =timeNew; 18 | bool* key = GFX::keyPressed; 19 | 20 | vec3f movX = vec3f ( 1,0,0 ); 21 | vec3f movY = vec3f ( 0,1,0 ); 22 | vec3f movZ = vec3f ( 0,0,1 ); 23 | 24 | movZ.rot_x ( rot.x * 2*M_PI / 360 ); 25 | movX.rot_x ( rot.x * 2*M_PI / 360 ); 26 | 27 | movZ.rot_y ( rot.y * 2*M_PI / 360 ); 28 | movX.rot_y ( rot.y * 2*M_PI / 360 ); 29 | 30 | if ( key[GLUT_KEY_UP ] ) pos=pos+movZ * (0.01 * deltaTime); 31 | if ( key[GLUT_KEY_DOWN ] ) pos=pos-movZ * (0.01 * deltaTime); 32 | if ( key[GLUT_KEY_LEFT ] ) pos=pos+movX * (0.01 * deltaTime); 33 | if ( key[GLUT_KEY_RIGHT] ) pos=pos-movX * (0.01 * deltaTime); 34 | 35 | //printf("p %f %f %f\n", pos.x, pos.y, pos.z ); 36 | 37 | if ( key[GLUT_KEY_PAGE_UP ] ) rot.y-=0.1 * deltaTime; 38 | if ( key[GLUT_KEY_PAGE_DOWN ] ) rot.y+=0.1 * deltaTime; 39 | 40 | if ( GFX::mousePressed[0] ) 41 | { 42 | rot.y += GFX::mouseDX * 300; 43 | rot.x += GFX::mouseDY * 300; 44 | } 45 | /* 46 | if ( keyPressed[GLUT_KEY_LEFT ] ) rot.x-=0.1; 47 | if ( keyPressed[GLUT_KEY_RIGHT] ) rot.x+=0.1; 48 | */ 49 | } 50 | -------------------------------------------------------------------------------- /Source.Cuboid/ObjControl.h: -------------------------------------------------------------------------------- 1 | class ObjControl { public: 2 | 3 | Deformer* obj_ref; 4 | Deformer* obj_copy; 5 | std::string name; 6 | 7 | Spline spline; 8 | 9 | vec3f pos,scale,axis;float angle; 10 | 11 | ObjControl(){ init(); } 12 | 13 | ~ObjControl(){ 14 | clear(); 15 | } 16 | 17 | void init(){ 18 | this->name = "empty"; 19 | this->obj_ref=NULL; 20 | this->obj_copy=NULL; 21 | this->pos = vec3f (0,0,0); 22 | this->scale = vec3f (1,1,1); 23 | this->axis = vec3f (1,0,0); 24 | this->angle = 0; 25 | } 26 | void clear() 27 | { 28 | if ( obj_copy ) 29 | { 30 | delete(obj_copy); 31 | } 32 | } 33 | void set_object( Deformer* obj ) 34 | { 35 | obj_ref = obj; 36 | init_name(); 37 | /* 38 | vec3f bbmin = obj->geo.bb_min; 39 | vec3f bbmax = obj->geo.bb_max; 40 | vec3f bbmid = (bbmin + bbmax)/2; 41 | 42 | vec3f p1 = vec3f( bbmid.x,bbmid.y,bbmin.z ); 43 | vec3f d = vec3f( 0,0,(bbmax.z-bbmin.z)/2 ); 44 | set_spline( p1,(p1+d),(p1+d+d),0,0 ); 45 | */ 46 | //printf("assigned %s,%d points\n",obj.name.c_str(),obj.geo.points.size()); 47 | } 48 | void draw(Material *mats) 49 | { 50 | if (!obj_ref) return; 51 | 52 | glPushMatrix(); 53 | glTranslatef( pos.x,pos.y,pos.z ); 54 | glRotatef( angle, axis.x,axis.y,axis.z); 55 | glScalef( scale.x,scale.y,scale.z ); 56 | 57 | obj_ref->draw(mats,&spline); 58 | 59 | glPopMatrix(); 60 | } 61 | void init_name(int i=-1) 62 | { 63 | if (!obj_ref){ this->name = "empty";return; } 64 | if ( i== -1 ) 65 | this->name = obj_ref->name; 66 | else 67 | { 68 | this->name = int_to_str(i) + std::string("-") + obj_ref->name; 69 | } 70 | } 71 | }; 72 | -------------------------------------------------------------------------------- /Source.Cuboid/PBuffer.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////////// 2 | // PBUFFER.h 3 | // class to setup pBuffer 4 | // You may use this code however you wish, but if you do, please credit me and 5 | // provide a link to my website in a readme file or similar 6 | // Downloaded from: www.paulsprojects.net 7 | // Created: 9th September 2002 8 | ////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | #ifndef PBUFFER_H 11 | #define PBUFFER_H 12 | 13 | class PBUFFER 14 | { 15 | public: 16 | HGLRC hRC; //rendering context 17 | HDC hDC; //device context 18 | HPBUFFERARB hBuffer; //buffer handle 19 | 20 | HDC tmp_hDC; // Tmp - context 21 | HGLRC tmp_hRC; 22 | 23 | int tmp_viewport[4]; 24 | 25 | unsigned int pbufferTexture; 26 | 27 | bool useMipmapFilter; 28 | int currentAnisotropy,maxAnisotropy; 29 | 30 | int width, height; //window size 31 | int colorBits, depthBits, stencilBits; //window bpp 32 | 33 | bool Init( int newWidth, int newHeight ); 34 | bool begin(void); 35 | bool end(void); 36 | 37 | void Shutdown(void); 38 | }; 39 | 40 | #endif //PBUFFER_H -------------------------------------------------------------------------------- /Source.Cuboid/Tools.h: -------------------------------------------------------------------------------- 1 | std::string int_to_str(const int& x) 2 | { 3 | std::ostringstream o; 4 | if (!(o << x)) return "ERROR"; 5 | return o.str(); 6 | } 7 | /* 8 | void Line ( vec3f p1 , vec3f p2 , vec3f color=vec3f(1,1,0) ){ 9 | glBegin(GL_LINES); 10 | glColor3f(color.x ,color.y ,color.z ); 11 | glVertex3f( p1.x,p1.y,p1.z ); 12 | glVertex3f( p2.x,p2.y,p2.z ); 13 | glEnd(); 14 | } 15 | */ 16 | void Box ( vec3f pos , vec3f size ){ 17 | 18 | float xyz[3][4]={{-1,1,1,-1},{1,1,-1,-1},{1,1,1,1}}; 19 | int xchg[6][3]={{1,2,0},{0,1,2},{2,0,1},{0,1,2},{1,2,0},{2,0,1}}; 20 | int mult[6][3]={{0,0,0},{0,0,0},{0,0,0},{1,0,1},{1,1,0},{1,0,1}}; 21 | float tex_x[4]={0,1,1,0}; 22 | float tex_y[4]={1,1,0,0}; 23 | 24 | // draw a triangle 25 | glBegin(GL_QUADS); // start drawing a polygon 26 | for (int j=0;j<6;j++) 27 | { 28 | for (int i=0;i<4;i++) 29 | { 30 | glColor3f(1,1,1); 31 | float x = xyz[xchg[j][0]][i]; if(mult[j][0]) x=-x; 32 | float y = xyz[xchg[j][1]][i]; if(mult[j][1]) y=-y; 33 | float z = xyz[xchg[j][2]][i]; if(mult[j][2]) z=-z; 34 | 35 | glTexCoord2f( tex_x[i], tex_y[i] ); 36 | 37 | glNormal3f( x,y,z ); 38 | glVertex3f( 39 | pos.x+x*size.x, 40 | pos.y+y*size.y, 41 | pos.z+z*size.z ); 42 | } 43 | } 44 | glEnd(); // we're done with the polygon 45 | } 46 | -------------------------------------------------------------------------------- /Source.Cuboid/VecMath.cpp: -------------------------------------------------------------------------------- 1 | #include "VecMath.h" 2 | 3 | int vec3f::random_number = 3457734; 4 | 5 | void vec3f::random_init() 6 | { 7 | random_number = 3457734; 8 | } 9 | 10 | float vec3f::random_float(){ 11 | int t = random_number; 12 | t = (t * 2345633 + t*1245 + t*356 + t*35 + t/34 + t/325 - 8647445); 13 | random_number = t; 14 | 15 | return ( float (abs(t)%10000)/10000); 16 | } 17 | 18 | vec3f vec3f::random(){ 19 | static vec3f rnd; 20 | rnd.x=random_float()*2-1; 21 | rnd.y=random_float()*2-1; 22 | rnd.z=random_float()*2-1; 23 | rnd.normalize(); 24 | return rnd; 25 | } 26 | 27 | vec3f vec3f::normalize( vec3f a ) 28 | { 29 | float square = a.x*a.x + a.y*a.y + a.z*a.z; 30 | if (square <= 0.00001f ) 31 | { 32 | a.x=1;a.y=0;a.z=0; 33 | return a; 34 | } 35 | float len = 1.0f / (float)sqrt(square); 36 | a.x*=len;a.y*=len;a.z*=len; 37 | return a; 38 | } 39 | 40 | 41 | /* 42 | bool lines_intersect ( vec3f line1[2] ,vec3f line2[2] , vec3f* intersection = NULL) 43 | { 44 | // BBox 45 | 46 | if ( line1[0].x < line2[0].x ) if ( line1[0].x < line2[1].x ) if ( line1[1].x < line2[0].x ) if ( line1[1].x < line2[1].x ) return false; 47 | if ( line1[0].x > line2[0].x ) if ( line1[0].x > line2[1].x ) if ( line1[1].x > line2[0].x ) if ( line1[1].x > line2[1].x ) return false; 48 | if ( line1[0].y > line2[0].y ) if ( line1[0].y > line2[1].y ) if ( line1[1].y > line2[0].y ) if ( line1[1].y > line2[1].y ) return false; 49 | if ( line1[0].y < line2[0].y ) if ( line1[0].y < line2[1].y ) if ( line1[1].y < line2[0].y ) if ( line1[1].y < line2[1].y ) return false; 50 | 51 | // intersect 52 | 53 | 54 | //a x + b = c y + d 55 | //a x - c y = d - b 56 | 57 | //- a2 a1 x + a2 c1 y =-a2 d1 + a2 b1 58 | // a1 a2 x - a1 c2 y = a1 d2 - a1 b2 59 | 60 | // y = ( a1 d2 - a1 b2 - a2 d1 + a2 b1 ) / ( a2 c1 - a1 c2 ) 61 | 62 | 63 | vec3f delta1 = line1[1] - line1[0]; 64 | vec3f delta2 = line2[1] - line2[0]; 65 | vec3f point1 = line1[0]; 66 | vec3f point2 = line2[0]; 67 | 68 | float div1 = delta1.y*delta2.x - delta1.x*delta2.y; 69 | float div2 = delta2.y*delta1.x - delta2.x*delta1.y; 70 | 71 | float a = 2; 72 | 73 | if ( div1 != 0) 74 | { 75 | a = ( delta1.x*point2.y - 76 | delta1.x*point1.y - 77 | delta1.y*point2.x + 78 | delta1.y*point1.x ) / div1; 79 | }else 80 | if ( div2 != 0) 81 | { 82 | a = ( delta2.x*point1.y - 83 | delta2.x*point2.y - 84 | delta2.y*point1.x + 85 | delta2.y*point2.x ) / div2; 86 | } 87 | if ( a <= 1 ) 88 | if ( a >= 0 ) 89 | { 90 | if (intersection) 91 | { 92 | if ( div1 != 0) 93 | *intersection = delta2 * a + point2; 94 | else 95 | *intersection = delta1 * a + point1; 96 | } 97 | return true; 98 | } 99 | 100 | return false; 101 | }; 102 | */ 103 | -------------------------------------------------------------------------------- /Source.Cuboid/glut32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/Source.Cuboid/glut32.dll -------------------------------------------------------------------------------- /Source.Cuboid/render_matrices.h: -------------------------------------------------------------------------------- 1 | void render_matrices(void) 2 | { 3 | static bool init=true; 4 | static GLuint fb; 5 | static GLuint fbo_points[4]; 6 | GLuint fb_type = GL_TEXTURE_RECTANGLE_ARB; 7 | GLuint type = GL_TEXTURE_RECTANGLE_ARB; 8 | 9 | static int fb_width = spline_tex.width; 10 | static int fb_height = spline_tex.height; 11 | 12 | if(init) 13 | { 14 | glGenFramebuffersEXT(1,&fb); 15 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb); 16 | 17 | fbo_points[0] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 18 | fbo_points[1] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 19 | fbo_points[2] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 20 | 21 | spline_tex.handle_nbtpx_out = fbo_points[0]; 22 | spline_tex.handle_nbtpy_out = fbo_points[1]; 23 | spline_tex.handle_nbtpz_out = fbo_points[2]; 24 | 25 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 26 | GL_COLOR_ATTACHMENT0_EXT, fb_type, 27 | fbo_points[0], 0); 28 | get_GL_error(); 29 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 30 | GL_COLOR_ATTACHMENT1_EXT, fb_type, 31 | fbo_points[1], 0); 32 | get_GL_error(); 33 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 34 | GL_COLOR_ATTACHMENT2_EXT, fb_type, 35 | fbo_points[2], 0); 36 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); 37 | get_GL_error(); 38 | 39 | init = false; 40 | } 41 | 42 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb); 43 | get_GL_error(); 44 | 45 | GLenum dbuffers[] = { 46 | GL_COLOR_ATTACHMENT0_EXT, 47 | GL_COLOR_ATTACHMENT1_EXT, 48 | GL_COLOR_ATTACHMENT2_EXT 49 | }; 50 | glDrawBuffers(3, dbuffers);get_GL_error(); 51 | 52 | int viewport[4]; 53 | glGetIntegerv(GL_VIEWPORT, viewport); 54 | glViewport(0,0,fb_width,fb_height); get_GL_error(); 55 | glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); 56 | glMatrixMode(GL_PROJECTION);glPushMatrix(); glLoadIdentity(); 57 | gluOrtho2D(0.0,fb_width,0.0,fb_height); get_GL_error(); 58 | glMatrixMode(GL_MODELVIEW); 59 | glDisable(GL_CULL_FACE); 60 | glDisable(GL_DEPTH_TEST); 61 | glDepthMask(GL_FALSE); 62 | 63 | // Matrix 64 | glActiveTextureARB( GL_TEXTURE0 ); 65 | glBindTexture(type, spline_tex.handle_nbtpx); 66 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 67 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 68 | glActiveTextureARB( GL_TEXTURE1 ); 69 | glBindTexture(type, spline_tex.handle_nbtpy); 70 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 71 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 72 | glActiveTextureARB( GL_TEXTURE2 ); 73 | glBindTexture(type, spline_tex.handle_nbtpz); 74 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 75 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 76 | 77 | // Params 78 | glActiveTextureARB( GL_TEXTURE3 ); 79 | glBindTexture(type, spline_tex.handle_params); 80 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 81 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 82 | 83 | glActiveTextureARB( GL_TEXTURE0 ); 84 | 85 | //glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE);get_GL_error(); 86 | 87 | glMatrixMode(GL_MODELVIEW); 88 | shader_matrices->begin(); 89 | // shader_matrices->setUniform1i("texSplineRowX",0); 90 | // shader_matrices->setUniform1i("texSplineRowY",1); 91 | // shader_matrices->setUniform1i("texSplineRowZ",2); 92 | shader_matrices->setUniform1i("texSplineParams",3); 93 | shader_matrices->setUniform1f("resolution",float(spline_tex.width)); 94 | shader_matrices->setUniform1f("adjust_rot",2);//float(1+GFX::mouseX*4)); 95 | shader_matrices->setUniform1f("adjust_pos",global_bend_adjust);//float(1+GFX::mouseY*5)); 96 | //shader_matrices->setUniform1f("pose_ofs",float(spline_tex.height)); 97 | 98 | 99 | 100 | glBegin(GL_QUADS); 101 | glColor3f(1,1,1); 102 | glMultiTexCoord2f( GL_TEXTURE0, 0.0, 0.0); 103 | glVertex2f(0, 0); 104 | glMultiTexCoord2f( GL_TEXTURE0, fb_width, 0.0); 105 | glVertex2f(fb_width,0); 106 | glMultiTexCoord2f( GL_TEXTURE0, fb_width, fb_height); 107 | glVertex2f(fb_width, fb_height); 108 | glMultiTexCoord2f( GL_TEXTURE0, 0.0, fb_height); 109 | glVertex2f(0, fb_height); 110 | glEnd(); 111 | 112 | shader_matrices->end(); 113 | get_GL_error(); 114 | 115 | glBindTexture(GL_TEXTURE_2D,0); 116 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); 117 | get_GL_error(); 118 | 119 | glEnable(GL_CULL_FACE); 120 | glEnable(GL_DEPTH_TEST); 121 | glDepthMask(GL_TRUE); 122 | 123 | glMatrixMode(GL_PROJECTION);glPopMatrix(); 124 | glMatrixMode(GL_MODELVIEW); glPopMatrix(); 125 | glViewport(viewport[0],viewport[1],viewport[2],viewport[3]); 126 | glDrawBuffer(GL_BACK); 127 | } 128 | -------------------------------------------------------------------------------- /Source.Cuboid/render_matrices_2.h: -------------------------------------------------------------------------------- 1 | void render_matrices_2(void) 2 | { 3 | static bool init=true; 4 | static GLuint fb; 5 | static GLuint fbo_points[4]; 6 | GLuint fb_type = GL_TEXTURE_RECTANGLE_ARB; 7 | GLuint type = GL_TEXTURE_RECTANGLE_ARB; 8 | 9 | static int fb_width = spline_tex.width; 10 | static int fb_height = spline_tex.height; 11 | 12 | if(init) 13 | { 14 | glGenFramebuffersEXT(1,&fb); 15 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb); 16 | 17 | fbo_points[0] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 18 | fbo_points[1] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 19 | fbo_points[2] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 20 | 21 | spline_tex.handle_nbtpx_out2 = fbo_points[0]; 22 | spline_tex.handle_nbtpy_out2 = fbo_points[1]; 23 | spline_tex.handle_nbtpz_out2 = fbo_points[2]; 24 | 25 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 26 | GL_COLOR_ATTACHMENT0_EXT, fb_type, 27 | fbo_points[0], 0); 28 | get_GL_error(); 29 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 30 | GL_COLOR_ATTACHMENT1_EXT, fb_type, 31 | fbo_points[1], 0); 32 | get_GL_error(); 33 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 34 | GL_COLOR_ATTACHMENT2_EXT, fb_type, 35 | fbo_points[2], 0); 36 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); 37 | get_GL_error(); 38 | 39 | init = false; 40 | } 41 | 42 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb); 43 | get_GL_error(); 44 | 45 | GLenum dbuffers[] = { 46 | GL_COLOR_ATTACHMENT0_EXT, 47 | GL_COLOR_ATTACHMENT1_EXT, 48 | GL_COLOR_ATTACHMENT2_EXT 49 | }; 50 | glDrawBuffers(3, dbuffers);get_GL_error(); 51 | 52 | int viewport[4]; 53 | glGetIntegerv(GL_VIEWPORT, viewport); 54 | glViewport(0,0,fb_width,fb_height); get_GL_error(); 55 | glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); 56 | glMatrixMode(GL_PROJECTION);glPushMatrix(); glLoadIdentity(); 57 | gluOrtho2D(0.0,fb_width,0.0,fb_height); get_GL_error(); 58 | glMatrixMode(GL_MODELVIEW); 59 | glDisable(GL_CULL_FACE); 60 | glDisable(GL_DEPTH_TEST); 61 | glDepthMask(GL_FALSE); 62 | 63 | // Bind Matrix 64 | glActiveTextureARB( GL_TEXTURE0 ); 65 | glBindTexture(type, spline_tex.handle_nbtpx); 66 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 67 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 68 | glActiveTextureARB( GL_TEXTURE1 ); 69 | glBindTexture(type, spline_tex.handle_nbtpy); 70 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 71 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 72 | glActiveTextureARB( GL_TEXTURE2 ); 73 | glBindTexture(type, spline_tex.handle_nbtpz); 74 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 75 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 76 | 77 | // Spline Matrix 78 | glActiveTextureARB( GL_TEXTURE3 ); 79 | glBindTexture(type, spline_tex.handle_nbtpx_out); 80 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 81 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 82 | glActiveTextureARB( GL_TEXTURE4 ); 83 | glBindTexture(type, spline_tex.handle_nbtpy_out); 84 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 85 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 86 | glActiveTextureARB( GL_TEXTURE5 ); 87 | glBindTexture(type, spline_tex.handle_nbtpz_out); 88 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 89 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 90 | 91 | 92 | glActiveTextureARB( GL_TEXTURE0 ); 93 | 94 | //glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE);get_GL_error(); 95 | 96 | glMatrixMode(GL_MODELVIEW); 97 | shader_matrices2->begin(); 98 | 99 | shader_matrices2->setUniform1i("texBindRowX",0); 100 | shader_matrices2->setUniform1i("texBindRowY",1); 101 | shader_matrices2->setUniform1i("texBindRowZ",2); 102 | 103 | shader_matrices2->setUniform1i("texSplineRowX",3); 104 | shader_matrices2->setUniform1i("texSplineRowY",4); 105 | shader_matrices2->setUniform1i("texSplineRowZ",5); 106 | 107 | glBegin(GL_QUADS); 108 | glColor3f(1,1,1); 109 | glMultiTexCoord2f( GL_TEXTURE0, 0.0, 0.0); 110 | glVertex2f(0, 0); 111 | glMultiTexCoord2f( GL_TEXTURE0, fb_width, 0.0); 112 | glVertex2f(fb_width,0); 113 | glMultiTexCoord2f( GL_TEXTURE0, fb_width, fb_height); 114 | glVertex2f(fb_width, fb_height); 115 | glMultiTexCoord2f( GL_TEXTURE0, 0.0, fb_height); 116 | glVertex2f(0, fb_height); 117 | glEnd(); 118 | 119 | shader_matrices2->end(); 120 | get_GL_error(); 121 | 122 | glBindTexture(GL_TEXTURE_2D,0); 123 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); 124 | get_GL_error(); 125 | 126 | glEnable(GL_CULL_FACE); 127 | glEnable(GL_DEPTH_TEST); 128 | glDepthMask(GL_TRUE); 129 | 130 | glMatrixMode(GL_PROJECTION);glPopMatrix(); 131 | glMatrixMode(GL_MODELVIEW); glPopMatrix(); 132 | glViewport(viewport[0],viewport[1],viewport[2],viewport[3]); 133 | glDrawBuffer(GL_BACK); 134 | } 135 | -------------------------------------------------------------------------------- /Source.Cuboid/shaders/deform.vert: -------------------------------------------------------------------------------- 1 | //uniform sampler2D tex_points; 2 | 3 | varying vec3 normal; 4 | varying vec3 vertex; 5 | varying vec2 textureCoord; 6 | varying vec2 textureCoord1; 7 | varying vec2 textureCoord2; 8 | varying vec2 textureCoord3; 9 | varying vec2 textureCoord4; 10 | 11 | //uniform mat4 light2shadow; 12 | //uniform vec3 spline1_p1; 13 | 14 | void main(void) 15 | { 16 | //normal = gl_Color.xyz * vec3( 2.0,2.0,2.0 ) - vec3 (1.0,1.0,1.0); 17 | //vertex = gl_Vertex.xyz; 18 | 19 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 20 | textureCoord = gl_MultiTexCoord0.xy; 21 | textureCoord1 = gl_MultiTexCoord0.xy; 22 | textureCoord2 = gl_MultiTexCoord0.xy; 23 | textureCoord3 = gl_MultiTexCoord0.xy; 24 | textureCoord4 = gl_MultiTexCoord0.xy; 25 | 26 | textureCoord1.x = gl_MultiTexCoord0.x*4; 27 | textureCoord2.x = gl_MultiTexCoord0.x*4+1; 28 | textureCoord3.x = gl_MultiTexCoord0.x*4+2; 29 | textureCoord4.x = gl_MultiTexCoord0.x*4+3; 30 | } -------------------------------------------------------------------------------- /Source.Cuboid/shaders/matrices.frag: -------------------------------------------------------------------------------- 1 | 2 | uniform sampler2DRect texSplineRowX; 3 | uniform sampler2DRect texSplineRowY; 4 | uniform sampler2DRect texSplineRowZ; 5 | uniform sampler2DRect texSplineParams; 6 | uniform float adjust_pos; 7 | uniform float adjust_rot; 8 | //uniform float pose_ofs; 9 | 10 | varying vec2 texCoordMatrix; 11 | varying vec2 texCoordParams; 12 | 13 | varying float a; 14 | 15 | void main(void) 16 | { 17 | float pi = 3.14159265358979323846; 18 | 19 | vec4 param1 = texture2DRect(texSplineParams,texCoordParams); 20 | vec4 param2 = texture2DRect(texSplineParams,texCoordParams+vec2(1,0)); 21 | vec4 param3 = texture2DRect(texSplineParams,texCoordParams+vec2(2,0)); 22 | vec4 param4 = texture2DRect(texSplineParams,texCoordParams+vec2(3,0)); 23 | 24 | vec3 spline_p1 = param1.xyz; 25 | vec3 spline_d1 = param2.xyz; 26 | vec3 spline_d2 = param3.xyz; 27 | vec3 spline_normal = param4.xyz; 28 | float angle = param1.w; 29 | float twist = param2.w; 30 | 31 | float a01 = clamp(a,0,1); 32 | 33 | float a_21 = a*2-1; 34 | float a_rot = sign(a_21) * (1-pow(1-abs(a_21),adjust_rot)) * 0.5 +0.5; 35 | 36 | float p = adjust_pos; 37 | float pow_a = pow(a01 ,p); 38 | float pow_1a = pow(1-a01,p); 39 | float f2_a = a *pow_a; 40 | float f1_a = 1-(1-a)*pow_1a; 41 | float f2_da = pow_a; 42 | float f1_da = pow_1a; 43 | 44 | //vec4 pose= texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x,pose_ofs)); 45 | //vec4 pose_d = texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x+5,pose_ofs))-pose; 46 | 47 | vec3 pos= spline_p1 + spline_d1 * f1_a + spline_d2 * f2_a; 48 | vec3 n1 = spline_normal;// * pose.y; 49 | vec3 n3 = normalize (spline_d1 * f1_da + spline_d2 * f2_da); 50 | vec3 n2 = normalize (cross( n3,n1 )); 51 | 52 | //pos = pos - n2; 53 | 54 | //pos = pos + n2 * (pose.z-1)*1.5; 55 | //n2 = n2 * pose.x; 56 | 57 | mat4 bind_mat; 58 | mat4 spline_mat; 59 | 60 | spline_mat[0] = vec4(n1,0.0); 61 | spline_mat[1] = vec4(n2,0.0); 62 | spline_mat[2] = vec4(n3,0.0); 63 | spline_mat[3] = vec4(pos,1.0); 64 | 65 | spline_mat = transpose(spline_mat); 66 | 67 | vec4 row1= texture2DRect(texSplineRowX,texCoordMatrix); 68 | vec4 row2= texture2DRect(texSplineRowY,texCoordMatrix); 69 | vec4 row3= texture2DRect(texSplineRowZ,texCoordMatrix); 70 | 71 | float r = angle + twist * a_rot; 72 | float cos_a = cos(r); 73 | float sin_a = sin(r); 74 | 75 | mat4 rot_mat; 76 | rot_mat[0] = vec4 (cos_a,-sin_a,0.0,0.0); 77 | rot_mat[1] = vec4 (sin_a,cos_a,0.0,0.0); 78 | rot_mat[2] = vec4 (0.0,0.0,1.0,0.0); 79 | rot_mat[3] = vec4 (0.0,0.0,0.0,1.0); 80 | 81 | bind_mat[0] = row1; 82 | bind_mat[1] = row2; 83 | bind_mat[2] = row3; 84 | bind_mat[3] = vec4(0.0,0.0,0.0,1.0); 85 | 86 | /* 87 | spline_mat[0].w = spline_mat[0].w - dot( spline_mat[0].xyz, n2.x ); 88 | spline_mat[1].w = spline_mat[1].w - dot( spline_mat[1].xyz, n2.y ); 89 | spline_mat[2].w = spline_mat[2].w - dot( spline_mat[2].xyz, n2.z ); 90 | */ 91 | // mat4 final_mat = bind_mat * rot_mat * spline_mat; 92 | mat4 final_mat = rot_mat * spline_mat; 93 | 94 | //vec4 n2_xf = final_mat * vec4(n2.xyz,0.0); 95 | 96 | gl_FragData[0] = final_mat[0] ; 97 | gl_FragData[1] = final_mat[1] ; 98 | gl_FragData[2] = final_mat[2] ; 99 | } 100 | 101 | -------------------------------------------------------------------------------- /Source.Cuboid/shaders/matrices.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Source.Cuboid/shaders/matrices2.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2DRect texBindRowX; 2 | uniform sampler2DRect texBindRowY; 3 | uniform sampler2DRect texBindRowZ; 4 | 5 | uniform sampler2DRect texSplineRowX; 6 | uniform sampler2DRect texSplineRowY; 7 | uniform sampler2DRect texSplineRowZ; 8 | 9 | varying vec2 texCoordMatrix; 10 | 11 | void main(void) 12 | { 13 | mat4 bind; 14 | mat4 spline; 15 | bind[0]= texture2DRect(texBindRowX,texCoordMatrix); 16 | bind[1]= texture2DRect(texBindRowY,texCoordMatrix); 17 | bind[2]= texture2DRect(texBindRowZ,texCoordMatrix); 18 | bind[3]= vec4 (0.0,0.0,0.0,1.0); 19 | 20 | spline[0]= texture2DRect(texSplineRowX,texCoordMatrix); 21 | spline[1]= texture2DRect(texSplineRowY,texCoordMatrix); 22 | spline[2]= texture2DRect(texSplineRowZ,texCoordMatrix); 23 | spline[3]= vec4 (0.0,0.0,0.0,1.0); 24 | 25 | mat4 final_mat = bind * spline; 26 | 27 | gl_FragData[0] = final_mat[0] ; 28 | gl_FragData[1] = final_mat[1] ; 29 | gl_FragData[2] = final_mat[2] ; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Source.Cuboid/shaders/matrices2.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Source.Cuboid/shaders/normal.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D texLight; 2 | uniform sampler2D texDecal; 3 | uniform sampler2DShadow texDepth; 4 | 5 | uniform vec3 camPos; 6 | uniform vec3 lightPos; 7 | uniform vec4 ambient; 8 | uniform vec4 diffuse; 9 | uniform vec4 specular; 10 | 11 | varying vec3 normal; 12 | varying vec3 vertex; 13 | 14 | void main(void) 15 | { 16 | vec3 normalVec = normal; 17 | vec3 lightVec = vec3( normalize(lightPos-vertex) ); 18 | vec3 camVec = vec3( normalize(camPos-vertex) ); 19 | 20 | float l = clamp ( dot ( lightVec , normalVec ) ,0.0,1.0 ); 21 | vec3 r = reflect ( -camVec, normalVec ); 22 | float m = clamp ( dot ( r , lightVec ) ,0.0,1.0); 23 | float q = m*m; q=q*q; 24 | 25 | // gl_FragColor = vec4(normal,1.0) + 0.001 * (diffuse * l * 1.3 + specular * q + ambient); 26 | gl_FragColor = diffuse * l * 1.3 + specular * q + ambient; 27 | } -------------------------------------------------------------------------------- /Source.Cuboid/shaders/normal.vert: -------------------------------------------------------------------------------- 1 | 2 | varying vec3 normal; 3 | varying vec3 vertex; 4 | 5 | void main(void) 6 | { 7 | normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 8 | //normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)); 9 | //normal = gl_Normal;//frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 10 | vertex = gl_Vertex.xyz; 11 | gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz,1.0); 12 | } -------------------------------------------------------------------------------- /Source.Cuboid/shaders/shadow.frag: -------------------------------------------------------------------------------- 1 | 2 | void main(void) 3 | { 4 | gl_FragColor = vec4 (1.0,1.0,1.0,1.0); 5 | } -------------------------------------------------------------------------------- /Source.Cuboid/shaders/shadow.vert: -------------------------------------------------------------------------------- 1 | uniform float angle; 2 | uniform float twist; 3 | uniform vec3 spline_p; 4 | uniform vec3 spline_d1; 5 | uniform vec3 spline_d2; 6 | uniform vec3 spline_normal; 7 | 8 | uniform float arm_angle; 9 | uniform float arm_twist; 10 | uniform vec3 arm_spline_p; 11 | uniform vec3 arm_spline_d1; 12 | uniform vec3 arm_spline_d2; 13 | uniform vec3 arm_spline_normal; 14 | 15 | uniform float elbow_angle; 16 | uniform float elbow_twist; 17 | uniform vec3 elbow_spline_p; 18 | uniform vec3 elbow_spline_d1; 19 | uniform vec3 elbow_spline_d2; 20 | uniform vec3 elbow_spline_normal; 21 | 22 | uniform float body_angle; 23 | uniform float body_twist; 24 | uniform vec3 body_spline_p; 25 | uniform vec3 body_spline_d1; 26 | uniform vec3 body_spline_d2; 27 | uniform vec3 body_spline_normal; 28 | /* 29 | void eval_spline ( 30 | in float a, 31 | in twist, 32 | in angle, 33 | in vec3 spline_p, 34 | in vec3 spline_d1, 35 | in vec3 spline_d2, 36 | in vec3 spline_normal 37 | in p 38 | out) 39 | { 40 | 41 | } 42 | */ 43 | 44 | void main(void) 45 | { 46 | vec3 pos; 47 | vec3 n1; // x 48 | vec3 n2; // y 49 | vec3 n3; // z 50 | 51 | vec3 p = spline_p; 52 | vec3 d1= spline_d1; 53 | vec3 d2= spline_d2; 54 | 55 | float a = gl_MultiTexCoord1.x; 56 | float b = gl_MultiTexCoord1.y; 57 | float c = gl_MultiTexCoord1.z; 58 | float c01 = clamp ( c , 0.0 , 1.0 ); 59 | float alpha = 0.5 * 3.14159265358979323846 * c01; 60 | float cos_c = cos ( alpha ); 61 | float sin_c = sin ( alpha ); 62 | float min0 = min(c,0.0); 63 | float max1 = max(c,1.0); 64 | pos = p + d1 * sin_c + d2 * (1.0-cos_c) + d1 * min0 + d2 * max1; 65 | n3 = normalize(d1 * cos_c + d2 * sin_c); 66 | n1 = spline_normal; 67 | n2 = cross( n1,n3 ); 68 | 69 | float r = angle + twist*c01; 70 | float sin_r = sin ( r ); 71 | float cos_r = cos ( r ); 72 | float aa = cos_r * b + sin_r * a; 73 | float bb = cos_r * a - sin_r * b; 74 | 75 | vec3 result_pos = n1 * aa + n2 * bb + pos; 76 | 77 | gl_Position = gl_ModelViewProjectionMatrix * vec4 ( result_pos.xyz , 1 ) ; 78 | } -------------------------------------------------------------------------------- /Source.LegBench/Bmp.h: -------------------------------------------------------------------------------- 1 | #ifndef _Bmp_class 2 | #define _Bmp_class 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "VecMath.h" 9 | 10 | class Bmp 11 | { 12 | public: 13 | 14 | Bmp(); 15 | Bmp(int x,int y,int bpp,unsigned char*data); 16 | Bmp(const char*filename); 17 | ~Bmp(); 18 | 19 | bool load(const char*filename, 20 | bool checktransparency=false, 21 | int check_r=0, 22 | int check_g=0, 23 | int check_b=0); 24 | 25 | bool save(const char*filename); 26 | 27 | vec3f getSxSyT(float x); 28 | int sampleByte(int x,int y); 29 | bool set(int x,int y,int bpp,unsigned char*data); 30 | bool set3d(int x,int y,int z,int bpp,unsigned char*buffer); 31 | void crop(int x,int y); 32 | bool scale(int x,int y); 33 | bool blur(int count); 34 | bool hblur(int count); 35 | bool vblur(int count); 36 | bool addalpha(unsigned char r,unsigned char g,unsigned char b); 37 | bool normalize(void); 38 | bool normalMap(void); 39 | vec3f getPixel(float x,float y); 40 | vec3f get_f_fdx_fdy(float x,float y); 41 | 42 | private: 43 | 44 | int sampleMap(int i,int j); 45 | 46 | public: 47 | 48 | unsigned char*data; 49 | int width; 50 | int height; 51 | int depth; 52 | int bpp; 53 | 54 | private: 55 | 56 | unsigned char bmp[54]; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /Source.LegBench/Deformer.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------- // 2 | class Deformer { 3 | 4 | public: 5 | 6 | std::string name ; 7 | Geometry geo; 8 | 9 | Deformer(){ init (); } 10 | ~Deformer() 11 | { 12 | clear(); 13 | } 14 | void init() 15 | { 16 | name = "empty"; 17 | } 18 | 19 | void clear () 20 | { 21 | geo.clear(); 22 | } 23 | void set_geometry ( Geometry geo ) 24 | { 25 | this->geo = geo; 26 | this->name = geo.name; 27 | geo.init(); 28 | } 29 | 30 | void draw (Material *materials, Spline* spline) 31 | { 32 | if ( spline ) 33 | { 34 | geo.draw( materials , spline ); 35 | //spline->draw(); 36 | } 37 | else 38 | geo.draw( materials ); 39 | } 40 | }; 41 | // ---------------------------------------- // 42 | 43 | -------------------------------------------------------------------------------- /Source.LegBench/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = sample x_wing teapot 2 | 3 | sample_SOURCES = sample.cpp 4 | x_wing_SOURCES = x_wing.cpp 5 | teapot_SOURCES = teapot.cpp 6 | 7 | CPPFLAGS = @CPPFLAGS@ 8 | 9 | LDADD = ../libsolid/libFreeSOLID.la 10 | 11 | 12 | -------------------------------------------------------------------------------- /Source.LegBench/MouseKeyboard.h: -------------------------------------------------------------------------------- 1 | 2 | //vec3f pos(-75,-29,12); 3 | vec3f pos(-24.5,-9.2,19.0); 4 | vec3f rot(18,-116,0); 5 | 6 | void mouse_keyboard() 7 | { 8 | /*glPushMatrix(); 9 | glLoadIdentity(); // Reset The View 10 | glRotatef(rot.x,1,0,0); // Move Left 1.5 Units And Into The Screen 6.0 11 | glRotatef(rot.y,0,1,0); // Move Left 1.5 Units And Into The Screen 6.0 12 | float m[16]; 13 | glGetFloatv (GL_MODELVIEW_MATRIX, m); 14 | glPopMatrix();*/ 15 | 16 | static int time = timeGetTime (); 17 | int timeNew = timeGetTime (); 18 | float deltaTime = timeNew-time; time =timeNew; 19 | bool* key = GFX::keyPressed; 20 | 21 | vec3f movX = vec3f ( 1,0,0 ); 22 | vec3f movY = vec3f ( 0,1,0 ); 23 | vec3f movZ = vec3f ( 0,0,1 ); 24 | 25 | movZ.rot_x ( rot.x * 2*M_PI / 360 ); 26 | movX.rot_x ( rot.x * 2*M_PI / 360 ); 27 | 28 | movZ.rot_y ( rot.y * 2*M_PI / 360 ); 29 | movX.rot_y ( rot.y * 2*M_PI / 360 ); 30 | 31 | if ( key[GLUT_KEY_UP ] ) pos=pos+movZ * (0.01 * deltaTime); 32 | if ( key[GLUT_KEY_DOWN ] ) pos=pos-movZ * (0.01 * deltaTime); 33 | if ( key[GLUT_KEY_LEFT ] ) pos=pos+movX * (0.01 * deltaTime); 34 | if ( key[GLUT_KEY_RIGHT] ) pos=pos-movX * (0.01 * deltaTime); 35 | 36 | //printf("p %f %f %f\n", pos.x, pos.y, pos.z ); 37 | 38 | if ( key[GLUT_KEY_PAGE_UP ] ) rot.y-=0.1 * deltaTime; 39 | if ( key[GLUT_KEY_PAGE_DOWN ] ) rot.y+=0.1 * deltaTime; 40 | 41 | if ( GFX::mousePressed[0] ) 42 | { 43 | rot.y += GFX::mouseDX * 300; 44 | rot.x += GFX::mouseDY * 300; 45 | } 46 | /* 47 | if ( keyPressed[GLUT_KEY_LEFT ] ) rot.x-=0.1; 48 | if ( keyPressed[GLUT_KEY_RIGHT] ) rot.x+=0.1; 49 | */ 50 | } 51 | -------------------------------------------------------------------------------- /Source.LegBench/ObjControl.h: -------------------------------------------------------------------------------- 1 | class ObjControl { public: 2 | 3 | Deformer* obj_ref; 4 | Deformer* obj_copy; 5 | std::string name; 6 | 7 | Spline spline; 8 | 9 | vec3f pos,scale,axis;float angle; 10 | 11 | ObjControl(){ init(); } 12 | 13 | ~ObjControl(){ 14 | clear(); 15 | } 16 | 17 | void init(){ 18 | this->name = "empty"; 19 | this->obj_ref=NULL; 20 | this->obj_copy=NULL; 21 | this->pos = vec3f (0,0,0); 22 | this->scale = vec3f (1,1,1); 23 | this->axis = vec3f (1,0,0); 24 | this->angle = 0; 25 | } 26 | void clear() 27 | { 28 | if ( obj_copy ) 29 | { 30 | delete(obj_copy); 31 | } 32 | } 33 | void set_object( Deformer* obj ) 34 | { 35 | obj_ref = obj; 36 | init_name(); 37 | /* 38 | vec3f bbmin = obj->geo.bb_min; 39 | vec3f bbmax = obj->geo.bb_max; 40 | vec3f bbmid = (bbmin + bbmax)/2; 41 | 42 | vec3f p1 = vec3f( bbmid.x,bbmid.y,bbmin.z ); 43 | vec3f d = vec3f( 0,0,(bbmax.z-bbmin.z)/2 ); 44 | set_spline( p1,(p1+d),(p1+d+d),0,0 ); 45 | */ 46 | //printf("assigned %s,%d points\n",obj.name.c_str(),obj.geo.points.size()); 47 | } 48 | void draw(Material *mats) 49 | { 50 | if (!obj_ref) return; 51 | 52 | glPushMatrix(); 53 | glTranslatef( pos.x,pos.y,pos.z ); 54 | glRotatef( angle, axis.x,axis.y,axis.z); 55 | glScalef( scale.x,scale.y,scale.z ); 56 | 57 | obj_ref->draw(mats,&spline); 58 | 59 | glPopMatrix(); 60 | } 61 | void init_name(int i=-1) 62 | { 63 | if (!obj_ref){ this->name = "empty";return; } 64 | if ( i== -1 ) 65 | this->name = obj_ref->name; 66 | else 67 | { 68 | this->name = int_to_str(i) + std::string("-") + obj_ref->name; 69 | } 70 | } 71 | }; 72 | -------------------------------------------------------------------------------- /Source.LegBench/PBuffer.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////////// 2 | // PBUFFER.h 3 | // class to setup pBuffer 4 | // You may use this code however you wish, but if you do, please credit me and 5 | // provide a link to my website in a readme file or similar 6 | // Downloaded from: www.paulsprojects.net 7 | // Created: 9th September 2002 8 | ////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | #ifndef PBUFFER_H 11 | #define PBUFFER_H 12 | 13 | class PBUFFER 14 | { 15 | public: 16 | HGLRC hRC; //rendering context 17 | HDC hDC; //device context 18 | HPBUFFERARB hBuffer; //buffer handle 19 | 20 | HDC tmp_hDC; // Tmp - context 21 | HGLRC tmp_hRC; 22 | 23 | int tmp_viewport[4]; 24 | 25 | unsigned int pbufferTexture; 26 | 27 | bool useMipmapFilter; 28 | int currentAnisotropy,maxAnisotropy; 29 | 30 | int width, height; //window size 31 | int colorBits, depthBits, stencilBits; //window bpp 32 | 33 | bool Init( int newWidth, int newHeight ); 34 | bool begin(void); 35 | bool end(void); 36 | 37 | void Shutdown(void); 38 | }; 39 | 40 | #endif //PBUFFER_H -------------------------------------------------------------------------------- /Source.LegBench/Tools.h: -------------------------------------------------------------------------------- 1 | std::string int_to_str(const int& x) 2 | { 3 | std::ostringstream o; 4 | if (!(o << x)) return "ERROR"; 5 | return o.str(); 6 | } 7 | /* 8 | void Line ( vec3f p1 , vec3f p2 , vec3f color=vec3f(1,1,0) ){ 9 | glBegin(GL_LINES); 10 | glColor3f(color.x ,color.y ,color.z ); 11 | glVertex3f( p1.x,p1.y,p1.z ); 12 | glVertex3f( p2.x,p2.y,p2.z ); 13 | glEnd(); 14 | } 15 | */ 16 | void Box ( vec3f pos , vec3f size ){ 17 | 18 | float xyz[3][4]={{-1,1,1,-1},{1,1,-1,-1},{1,1,1,1}}; 19 | int xchg[6][3]={{1,2,0},{0,1,2},{2,0,1},{0,1,2},{1,2,0},{2,0,1}}; 20 | int mult[6][3]={{0,0,0},{0,0,0},{0,0,0},{1,0,1},{1,1,0},{1,0,1}}; 21 | float tex_x[4]={0,1,1,0}; 22 | float tex_y[4]={1,1,0,0}; 23 | 24 | // draw a triangle 25 | glBegin(GL_QUADS); // start drawing a polygon 26 | for (int j=0;j<6;j++) 27 | { 28 | for (int i=0;i<4;i++) 29 | { 30 | glColor3f(1,1,1); 31 | float x = xyz[xchg[j][0]][i]; if(mult[j][0]) x=-x; 32 | float y = xyz[xchg[j][1]][i]; if(mult[j][1]) y=-y; 33 | float z = xyz[xchg[j][2]][i]; if(mult[j][2]) z=-z; 34 | 35 | glTexCoord2f( tex_x[i], tex_y[i] ); 36 | 37 | glNormal3f( x,y,z ); 38 | glVertex3f( 39 | pos.x+x*size.x, 40 | pos.y+y*size.y, 41 | pos.z+z*size.z ); 42 | } 43 | } 44 | glEnd(); // we're done with the polygon 45 | } 46 | -------------------------------------------------------------------------------- /Source.LegBench/VecMath.cpp: -------------------------------------------------------------------------------- 1 | #include "VecMath.h" 2 | 3 | int vec3f::random_number = 3457734; 4 | 5 | void vec3f::random_init() 6 | { 7 | random_number = 3457734; 8 | } 9 | 10 | float vec3f::random_float(){ 11 | int t = random_number; 12 | t = (t * 2345633 + t*1245 + t*356 + t*35 + t/34 + t/325 - 8647445); 13 | random_number = t; 14 | 15 | return ( float (abs(t)%10000)/10000); 16 | } 17 | 18 | vec3f vec3f::random(){ 19 | static vec3f rnd; 20 | rnd.x=random_float()*2-1; 21 | rnd.y=random_float()*2-1; 22 | rnd.z=random_float()*2-1; 23 | rnd.normalize(); 24 | return rnd; 25 | } 26 | 27 | vec3f vec3f::normalize( vec3f a ) 28 | { 29 | float square = a.x*a.x + a.y*a.y + a.z*a.z; 30 | if (square <= 0.00001f ) 31 | { 32 | a.x=1;a.y=0;a.z=0; 33 | return a; 34 | } 35 | float len = 1.0f / (float)sqrt(square); 36 | a.x*=len;a.y*=len;a.z*=len; 37 | return a; 38 | } 39 | 40 | 41 | /* 42 | bool lines_intersect ( vec3f line1[2] ,vec3f line2[2] , vec3f* intersection = NULL) 43 | { 44 | // BBox 45 | 46 | if ( line1[0].x < line2[0].x ) if ( line1[0].x < line2[1].x ) if ( line1[1].x < line2[0].x ) if ( line1[1].x < line2[1].x ) return false; 47 | if ( line1[0].x > line2[0].x ) if ( line1[0].x > line2[1].x ) if ( line1[1].x > line2[0].x ) if ( line1[1].x > line2[1].x ) return false; 48 | if ( line1[0].y > line2[0].y ) if ( line1[0].y > line2[1].y ) if ( line1[1].y > line2[0].y ) if ( line1[1].y > line2[1].y ) return false; 49 | if ( line1[0].y < line2[0].y ) if ( line1[0].y < line2[1].y ) if ( line1[1].y < line2[0].y ) if ( line1[1].y < line2[1].y ) return false; 50 | 51 | // intersect 52 | 53 | 54 | //a x + b = c y + d 55 | //a x - c y = d - b 56 | 57 | //- a2 a1 x + a2 c1 y =-a2 d1 + a2 b1 58 | // a1 a2 x - a1 c2 y = a1 d2 - a1 b2 59 | 60 | // y = ( a1 d2 - a1 b2 - a2 d1 + a2 b1 ) / ( a2 c1 - a1 c2 ) 61 | 62 | 63 | vec3f delta1 = line1[1] - line1[0]; 64 | vec3f delta2 = line2[1] - line2[0]; 65 | vec3f point1 = line1[0]; 66 | vec3f point2 = line2[0]; 67 | 68 | float div1 = delta1.y*delta2.x - delta1.x*delta2.y; 69 | float div2 = delta2.y*delta1.x - delta2.x*delta1.y; 70 | 71 | float a = 2; 72 | 73 | if ( div1 != 0) 74 | { 75 | a = ( delta1.x*point2.y - 76 | delta1.x*point1.y - 77 | delta1.y*point2.x + 78 | delta1.y*point1.x ) / div1; 79 | }else 80 | if ( div2 != 0) 81 | { 82 | a = ( delta2.x*point1.y - 83 | delta2.x*point2.y - 84 | delta2.y*point1.x + 85 | delta2.y*point2.x ) / div2; 86 | } 87 | if ( a <= 1 ) 88 | if ( a >= 0 ) 89 | { 90 | if (intersection) 91 | { 92 | if ( div1 != 0) 93 | *intersection = delta2 * a + point2; 94 | else 95 | *intersection = delta1 * a + point1; 96 | } 97 | return true; 98 | } 99 | 100 | return false; 101 | }; 102 | */ 103 | -------------------------------------------------------------------------------- /Source.LegBench/glut32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/Source.LegBench/glut32.dll -------------------------------------------------------------------------------- /Source.LegBench/render_matrices.h: -------------------------------------------------------------------------------- 1 | void render_matrices(void) 2 | { 3 | static bool init=true; 4 | static GLuint fb; 5 | static GLuint fbo_points[4]; 6 | GLuint fb_type = GL_TEXTURE_RECTANGLE_ARB; 7 | GLuint type = GL_TEXTURE_RECTANGLE_ARB; 8 | 9 | static int fb_width = spline_tex.width; 10 | static int fb_height = spline_tex.height; 11 | 12 | if(init) 13 | { 14 | glGenFramebuffersEXT(1,&fb); 15 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb); 16 | 17 | fbo_points[0] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 18 | fbo_points[1] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 19 | fbo_points[2] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 20 | 21 | spline_tex.handle_nbtpx_out = fbo_points[0]; 22 | spline_tex.handle_nbtpy_out = fbo_points[1]; 23 | spline_tex.handle_nbtpz_out = fbo_points[2]; 24 | 25 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 26 | GL_COLOR_ATTACHMENT0_EXT, fb_type, 27 | fbo_points[0], 0); 28 | get_GL_error(); 29 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 30 | GL_COLOR_ATTACHMENT1_EXT, fb_type, 31 | fbo_points[1], 0); 32 | get_GL_error(); 33 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 34 | GL_COLOR_ATTACHMENT2_EXT, fb_type, 35 | fbo_points[2], 0); 36 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); 37 | get_GL_error(); 38 | 39 | init = false; 40 | } 41 | 42 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb); 43 | get_GL_error(); 44 | 45 | GLenum dbuffers[] = { 46 | GL_COLOR_ATTACHMENT0_EXT, 47 | GL_COLOR_ATTACHMENT1_EXT, 48 | GL_COLOR_ATTACHMENT2_EXT 49 | }; 50 | glDrawBuffers(3, dbuffers);get_GL_error(); 51 | 52 | int viewport[4]; 53 | glGetIntegerv(GL_VIEWPORT, viewport); 54 | glViewport(0,0,fb_width,fb_height); get_GL_error(); 55 | glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); 56 | glMatrixMode(GL_PROJECTION);glPushMatrix(); glLoadIdentity(); 57 | gluOrtho2D(0.0,fb_width,0.0,fb_height); get_GL_error(); 58 | glMatrixMode(GL_MODELVIEW); 59 | glDisable(GL_CULL_FACE); 60 | glDisable(GL_DEPTH_TEST); 61 | glDepthMask(GL_FALSE); 62 | 63 | // Matrix 64 | glActiveTextureARB( GL_TEXTURE0 ); 65 | glBindTexture(type, spline_tex.handle_nbtpx); 66 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 67 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 68 | glActiveTextureARB( GL_TEXTURE1 ); 69 | glBindTexture(type, spline_tex.handle_nbtpy); 70 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 71 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 72 | glActiveTextureARB( GL_TEXTURE2 ); 73 | glBindTexture(type, spline_tex.handle_nbtpz); 74 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 75 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 76 | 77 | // Params 78 | glActiveTextureARB( GL_TEXTURE3 ); 79 | glBindTexture(type, spline_tex.handle_params); 80 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 81 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 82 | 83 | glActiveTextureARB( GL_TEXTURE0 ); 84 | 85 | //glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE);get_GL_error(); 86 | 87 | glMatrixMode(GL_MODELVIEW); 88 | shader_matrices->begin(); 89 | // shader_matrices->setUniform1i("texSplineRowX",0); 90 | // shader_matrices->setUniform1i("texSplineRowY",1); 91 | // shader_matrices->setUniform1i("texSplineRowZ",2); 92 | shader_matrices->setUniform1i("texSplineParams",3); 93 | shader_matrices->setUniform1f("resolution",float(spline_tex.width)); 94 | //shader_matrices->setUniform1f("adjust_rot",2);//float(1+GFX::mouseX*4)); 95 | //shader_matrices->setUniform1f("adjust_pos",global_bend_adjust);//float(1+GFX::mouseY*5)); 96 | //shader_matrices->setUniform1f("pose_ofs",float(spline_tex.height)); 97 | 98 | 99 | 100 | glBegin(GL_QUADS); 101 | glColor3f(1,1,1); 102 | glMultiTexCoord2f( GL_TEXTURE0, 0.0, 0.0); 103 | glVertex2f(0, 0); 104 | glMultiTexCoord2f( GL_TEXTURE0, fb_width, 0.0); 105 | glVertex2f(fb_width,0); 106 | glMultiTexCoord2f( GL_TEXTURE0, fb_width, fb_height); 107 | glVertex2f(fb_width, fb_height); 108 | glMultiTexCoord2f( GL_TEXTURE0, 0.0, fb_height); 109 | glVertex2f(0, fb_height); 110 | glEnd(); 111 | 112 | shader_matrices->end(); 113 | get_GL_error(); 114 | 115 | glBindTexture(GL_TEXTURE_2D,0); 116 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); 117 | get_GL_error(); 118 | 119 | glEnable(GL_CULL_FACE); 120 | glEnable(GL_DEPTH_TEST); 121 | glDepthMask(GL_TRUE); 122 | 123 | glMatrixMode(GL_PROJECTION);glPopMatrix(); 124 | glMatrixMode(GL_MODELVIEW); glPopMatrix(); 125 | glViewport(viewport[0],viewport[1],viewport[2],viewport[3]); 126 | glDrawBuffer(GL_BACK); 127 | } 128 | -------------------------------------------------------------------------------- /Source.LegBench/render_matrices_2.h: -------------------------------------------------------------------------------- 1 | void render_matrices_2(void) 2 | { 3 | static bool init=true; 4 | static GLuint fb; 5 | static GLuint fbo_points[4]; 6 | GLuint fb_type = GL_TEXTURE_RECTANGLE_ARB; 7 | GLuint type = GL_TEXTURE_RECTANGLE_ARB; 8 | 9 | static int fb_width = spline_tex.width; 10 | static int fb_height = spline_tex.height; 11 | 12 | if(init) 13 | { 14 | glGenFramebuffersEXT(1,&fb); 15 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb); 16 | 17 | fbo_points[0] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 18 | fbo_points[1] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 19 | fbo_points[2] = GFX::NewFloat16Tex(fb_width,fb_height,0,true); 20 | 21 | spline_tex.handle_nbtpx_out2 = fbo_points[0]; 22 | spline_tex.handle_nbtpy_out2 = fbo_points[1]; 23 | spline_tex.handle_nbtpz_out2 = fbo_points[2]; 24 | 25 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 26 | GL_COLOR_ATTACHMENT0_EXT, fb_type, 27 | fbo_points[0], 0); 28 | get_GL_error(); 29 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 30 | GL_COLOR_ATTACHMENT1_EXT, fb_type, 31 | fbo_points[1], 0); 32 | get_GL_error(); 33 | glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 34 | GL_COLOR_ATTACHMENT2_EXT, fb_type, 35 | fbo_points[2], 0); 36 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); 37 | get_GL_error(); 38 | 39 | init = false; 40 | } 41 | 42 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb); 43 | get_GL_error(); 44 | 45 | GLenum dbuffers[] = { 46 | GL_COLOR_ATTACHMENT0_EXT, 47 | GL_COLOR_ATTACHMENT1_EXT, 48 | GL_COLOR_ATTACHMENT2_EXT 49 | }; 50 | glDrawBuffers(3, dbuffers);get_GL_error(); 51 | 52 | int viewport[4]; 53 | glGetIntegerv(GL_VIEWPORT, viewport); 54 | glViewport(0,0,fb_width,fb_height); get_GL_error(); 55 | glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); 56 | glMatrixMode(GL_PROJECTION);glPushMatrix(); glLoadIdentity(); 57 | gluOrtho2D(0.0,fb_width,0.0,fb_height); get_GL_error(); 58 | glMatrixMode(GL_MODELVIEW); 59 | glDisable(GL_CULL_FACE); 60 | glDisable(GL_DEPTH_TEST); 61 | glDepthMask(GL_FALSE); 62 | 63 | // Bind Matrix 64 | glActiveTextureARB( GL_TEXTURE0 ); 65 | glBindTexture(type, spline_tex.handle_nbtpx); 66 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 67 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 68 | glActiveTextureARB( GL_TEXTURE1 ); 69 | glBindTexture(type, spline_tex.handle_nbtpy); 70 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 71 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 72 | glActiveTextureARB( GL_TEXTURE2 ); 73 | glBindTexture(type, spline_tex.handle_nbtpz); 74 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 75 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 76 | 77 | // Spline Matrix 78 | glActiveTextureARB( GL_TEXTURE3 ); 79 | glBindTexture(type, spline_tex.handle_nbtpx_out); 80 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 81 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 82 | glActiveTextureARB( GL_TEXTURE4 ); 83 | glBindTexture(type, spline_tex.handle_nbtpy_out); 84 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 85 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 86 | glActiveTextureARB( GL_TEXTURE5 ); 87 | glBindTexture(type, spline_tex.handle_nbtpz_out); 88 | glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 89 | glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 90 | 91 | 92 | glActiveTextureARB( GL_TEXTURE0 ); 93 | 94 | //glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE);get_GL_error(); 95 | 96 | glMatrixMode(GL_MODELVIEW); 97 | shader_matrices2->begin(); 98 | 99 | shader_matrices2->setUniform1i("texBindRowX",0); 100 | shader_matrices2->setUniform1i("texBindRowY",1); 101 | shader_matrices2->setUniform1i("texBindRowZ",2); 102 | 103 | shader_matrices2->setUniform1i("texSplineRowX",3); 104 | shader_matrices2->setUniform1i("texSplineRowY",4); 105 | shader_matrices2->setUniform1i("texSplineRowZ",5); 106 | 107 | glBegin(GL_QUADS); 108 | glColor3f(1,1,1); 109 | glMultiTexCoord2f( GL_TEXTURE0, 0.0, 0.0); 110 | glVertex2f(0, 0); 111 | glMultiTexCoord2f( GL_TEXTURE0, fb_width, 0.0); 112 | glVertex2f(fb_width,0); 113 | glMultiTexCoord2f( GL_TEXTURE0, fb_width, fb_height); 114 | glVertex2f(fb_width, fb_height); 115 | glMultiTexCoord2f( GL_TEXTURE0, 0.0, fb_height); 116 | glVertex2f(0, fb_height); 117 | glEnd(); 118 | 119 | shader_matrices2->end(); 120 | get_GL_error(); 121 | 122 | glBindTexture(GL_TEXTURE_2D,0); 123 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); 124 | get_GL_error(); 125 | 126 | glEnable(GL_CULL_FACE); 127 | glEnable(GL_DEPTH_TEST); 128 | glDepthMask(GL_TRUE); 129 | 130 | glMatrixMode(GL_PROJECTION);glPopMatrix(); 131 | glMatrixMode(GL_MODELVIEW); glPopMatrix(); 132 | glViewport(viewport[0],viewport[1],viewport[2],viewport[3]); 133 | glDrawBuffer(GL_BACK); 134 | } 135 | -------------------------------------------------------------------------------- /Source.LegBench/shaders/deform.vert: -------------------------------------------------------------------------------- 1 | //uniform sampler2D tex_points; 2 | 3 | varying vec3 normal; 4 | varying vec3 vertex; 5 | varying vec2 textureCoord; 6 | varying vec2 textureCoord1; 7 | varying vec2 textureCoord2; 8 | varying vec2 textureCoord3; 9 | varying vec2 textureCoord4; 10 | 11 | //uniform mat4 light2shadow; 12 | //uniform vec3 spline1_p1; 13 | 14 | void main(void) 15 | { 16 | //normal = gl_Color.xyz * vec3( 2.0,2.0,2.0 ) - vec3 (1.0,1.0,1.0); 17 | //vertex = gl_Vertex.xyz; 18 | 19 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 20 | textureCoord = gl_MultiTexCoord0.xy; 21 | textureCoord1 = gl_MultiTexCoord0.xy; 22 | textureCoord2 = gl_MultiTexCoord0.xy; 23 | textureCoord3 = gl_MultiTexCoord0.xy; 24 | textureCoord4 = gl_MultiTexCoord0.xy; 25 | 26 | textureCoord1.x = gl_MultiTexCoord0.x*4; 27 | textureCoord2.x = gl_MultiTexCoord0.x*4+1; 28 | textureCoord3.x = gl_MultiTexCoord0.x*4+2; 29 | textureCoord4.x = gl_MultiTexCoord0.x*4+3; 30 | } -------------------------------------------------------------------------------- /Source.LegBench/shaders/matrices.frag: -------------------------------------------------------------------------------- 1 | 2 | uniform sampler2DRect texSplineRowX; 3 | uniform sampler2DRect texSplineRowY; 4 | uniform sampler2DRect texSplineRowZ; 5 | uniform sampler2DRect texSplineParams; 6 | //uniform float adjust_pos; 7 | //uniform float adjust_rot; 8 | //uniform float pose_ofs; 9 | 10 | varying vec2 texCoordMatrix; 11 | varying vec2 texCoordParams; 12 | 13 | varying float a; 14 | 15 | void main(void) 16 | { 17 | float pi = 3.14159265358979323846; 18 | 19 | vec4 param1 = texture2DRect(texSplineParams,texCoordParams); 20 | vec4 param2 = texture2DRect(texSplineParams,texCoordParams+vec2(1,0)); 21 | vec4 param3 = texture2DRect(texSplineParams,texCoordParams+vec2(2,0)); 22 | vec4 param4 = texture2DRect(texSplineParams,texCoordParams+vec2(3,0)); 23 | vec4 param5 = texture2DRect(texSplineParams,texCoordParams+vec2(5,0)); 24 | //.x:deformation_style 25 | //.y:spline_hardness 26 | //.z:spline_twist_adjust 27 | //.w:center_distort 28 | 29 | vec3 spline_p1 = param1.xyz; 30 | vec3 spline_d1 = param2.xyz; 31 | vec3 spline_d2 = param3.xyz; 32 | vec3 spline_normal = param4.xyz; 33 | float angle = param1.w; 34 | float twist = param2.w; 35 | float hardness = param5.y; 36 | float twist_adjust = param5.z; 37 | 38 | float a01 = clamp(a,0,1); 39 | 40 | float a_21 = a*2-1; 41 | float a_rot = sign(a_21) * (1-pow(1-abs(a_21),twist_adjust)) * 0.5 +0.5; 42 | 43 | float p = hardness; 44 | float pow_a = pow(a01 ,p); 45 | float pow_1a = pow(1-a01,p); 46 | float f2_a = a *pow_a; 47 | float f1_a = 1-(1-a)*pow_1a; 48 | float f2_da = pow_a; 49 | float f1_da = pow_1a; 50 | 51 | //vec4 pose= texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x,pose_ofs)); 52 | //vec4 pose_d = texture2DRect(texSplineRowZ,vec2(texCoordMatrix.x+5,pose_ofs))-pose; 53 | 54 | vec3 pos= spline_p1 + spline_d1 * f1_a + spline_d2 * f2_a; 55 | vec3 n1 = spline_normal;// * pose.y; 56 | vec3 n3 = normalize (spline_d1 * f1_da + spline_d2 * f2_da); 57 | vec3 n2 = normalize (cross( n3,n1 )); 58 | 59 | //pos = pos - n2; 60 | 61 | //pos = pos + n2 * (pose.z-1)*1.5; 62 | //n2 = n2 * pose.x; 63 | 64 | mat4 bind_mat; 65 | mat4 spline_mat; 66 | 67 | spline_mat[0] = vec4(n1,0.0); 68 | spline_mat[1] = vec4(n2,0.0); 69 | spline_mat[2] = vec4(n3,0.0); 70 | spline_mat[3] = vec4(pos,1.0); 71 | 72 | spline_mat = transpose(spline_mat); 73 | 74 | vec4 row1= texture2DRect(texSplineRowX,texCoordMatrix); 75 | vec4 row2= texture2DRect(texSplineRowY,texCoordMatrix); 76 | vec4 row3= texture2DRect(texSplineRowZ,texCoordMatrix); 77 | 78 | float r = angle + twist * a_rot; 79 | float cos_a = cos(r); 80 | float sin_a = sin(r); 81 | 82 | mat4 rot_mat; 83 | rot_mat[0] = vec4 (cos_a,-sin_a,0.0,0.0); 84 | rot_mat[1] = vec4 (sin_a,cos_a,0.0,0.0); 85 | rot_mat[2] = vec4 (0.0,0.0,1.0,0.0); 86 | rot_mat[3] = vec4 (0.0,0.0,0.0,1.0); 87 | 88 | bind_mat[0] = row1; 89 | bind_mat[1] = row2; 90 | bind_mat[2] = row3; 91 | bind_mat[3] = vec4(0.0,0.0,0.0,1.0); 92 | 93 | /* 94 | spline_mat[0].w = spline_mat[0].w - dot( spline_mat[0].xyz, n2.x ); 95 | spline_mat[1].w = spline_mat[1].w - dot( spline_mat[1].xyz, n2.y ); 96 | spline_mat[2].w = spline_mat[2].w - dot( spline_mat[2].xyz, n2.z ); 97 | */ 98 | // mat4 final_mat = bind_mat * rot_mat * spline_mat; 99 | mat4 final_mat = rot_mat * spline_mat; 100 | 101 | //vec4 n2_xf = final_mat * vec4(n2.xyz,0.0); 102 | 103 | gl_FragData[0] = final_mat[0] ; 104 | gl_FragData[1] = final_mat[1] ; 105 | gl_FragData[2] = final_mat[2] ; 106 | } 107 | 108 | -------------------------------------------------------------------------------- /Source.LegBench/shaders/matrices.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Source.LegBench/shaders/matrices2.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2DRect texBindRowX; 2 | uniform sampler2DRect texBindRowY; 3 | uniform sampler2DRect texBindRowZ; 4 | 5 | uniform sampler2DRect texSplineRowX; 6 | uniform sampler2DRect texSplineRowY; 7 | uniform sampler2DRect texSplineRowZ; 8 | 9 | varying vec2 texCoordMatrix; 10 | 11 | void main(void) 12 | { 13 | mat4 bind; 14 | mat4 spline; 15 | bind[0]= texture2DRect(texBindRowX,texCoordMatrix); 16 | bind[1]= texture2DRect(texBindRowY,texCoordMatrix); 17 | bind[2]= texture2DRect(texBindRowZ,texCoordMatrix); 18 | bind[3]= vec4 (0.0,0.0,0.0,1.0); 19 | 20 | spline[0]= texture2DRect(texSplineRowX,texCoordMatrix); 21 | spline[1]= texture2DRect(texSplineRowY,texCoordMatrix); 22 | spline[2]= texture2DRect(texSplineRowZ,texCoordMatrix); 23 | spline[3]= vec4 (0.0,0.0,0.0,1.0); 24 | 25 | mat4 final_mat = bind * spline; 26 | 27 | gl_FragData[0] = final_mat[0] ; 28 | gl_FragData[1] = final_mat[1] ; 29 | gl_FragData[2] = final_mat[2] ; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Source.LegBench/shaders/matrices2.vert: -------------------------------------------------------------------------------- 1 | uniform float resolution; 2 | 3 | varying vec2 texCoordMatrix; 4 | varying vec2 texCoordParams; 5 | 6 | varying float a; 7 | 8 | void main(void) 9 | { 10 | //float resolution = 32.0; 11 | a = (gl_MultiTexCoord0.x-0.5) / resolution; 12 | 13 | texCoordMatrix = gl_MultiTexCoord0.xy; 14 | texCoordParams = vec2(0,gl_MultiTexCoord0.y); 15 | 16 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 17 | } 18 | -------------------------------------------------------------------------------- /Source.LegBench/shaders/normal.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D texLight; 2 | uniform sampler2D texDecal; 3 | uniform sampler2DShadow texDepth; 4 | 5 | uniform vec3 camPos; 6 | uniform vec3 lightPos; 7 | uniform vec4 ambient; 8 | uniform vec4 diffuse; 9 | uniform vec4 specular; 10 | 11 | varying vec3 normal; 12 | varying vec3 vertex; 13 | 14 | void main(void) 15 | { 16 | vec3 normalVec = normal; 17 | vec3 lightVec = vec3( normalize(lightPos-vertex) ); 18 | vec3 camVec = vec3( normalize(camPos-vertex) ); 19 | 20 | float l = clamp ( dot ( lightVec , normalVec ) ,0.0,1.0 ); 21 | vec3 r = reflect ( -camVec, normalVec ); 22 | float m = clamp ( dot ( r , lightVec ) ,0.0,1.0); 23 | float q = m*m; q=q*q; 24 | 25 | // gl_FragColor = vec4(normal,1.0) + 0.001 * (diffuse * l * 1.3 + specular * q + ambient); 26 | gl_FragColor = diffuse * l * 1.3 + specular * q + ambient; 27 | } -------------------------------------------------------------------------------- /Source.LegBench/shaders/normal.vert: -------------------------------------------------------------------------------- 1 | 2 | varying vec3 normal; 3 | varying vec3 vertex; 4 | 5 | void main(void) 6 | { 7 | normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 8 | //normal = frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)); 9 | //normal = gl_Normal;//frac(gl_Vertex.w * vec3(1, 1 / 256.0, 1 / 65536.0)) * 2 - 1; 10 | vertex = gl_Vertex.xyz; 11 | gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz,1.0); 12 | } -------------------------------------------------------------------------------- /Source.LegBench/shaders/shadow.frag: -------------------------------------------------------------------------------- 1 | 2 | void main(void) 3 | { 4 | gl_FragColor = vec4 (1.0,1.0,1.0,1.0); 5 | } -------------------------------------------------------------------------------- /Source.LegBench/shaders/shadow.vert: -------------------------------------------------------------------------------- 1 | uniform float angle; 2 | uniform float twist; 3 | uniform vec3 spline_p; 4 | uniform vec3 spline_d1; 5 | uniform vec3 spline_d2; 6 | uniform vec3 spline_normal; 7 | 8 | uniform float arm_angle; 9 | uniform float arm_twist; 10 | uniform vec3 arm_spline_p; 11 | uniform vec3 arm_spline_d1; 12 | uniform vec3 arm_spline_d2; 13 | uniform vec3 arm_spline_normal; 14 | 15 | uniform float elbow_angle; 16 | uniform float elbow_twist; 17 | uniform vec3 elbow_spline_p; 18 | uniform vec3 elbow_spline_d1; 19 | uniform vec3 elbow_spline_d2; 20 | uniform vec3 elbow_spline_normal; 21 | 22 | uniform float body_angle; 23 | uniform float body_twist; 24 | uniform vec3 body_spline_p; 25 | uniform vec3 body_spline_d1; 26 | uniform vec3 body_spline_d2; 27 | uniform vec3 body_spline_normal; 28 | /* 29 | void eval_spline ( 30 | in float a, 31 | in twist, 32 | in angle, 33 | in vec3 spline_p, 34 | in vec3 spline_d1, 35 | in vec3 spline_d2, 36 | in vec3 spline_normal 37 | in p 38 | out) 39 | { 40 | 41 | } 42 | */ 43 | 44 | void main(void) 45 | { 46 | vec3 pos; 47 | vec3 n1; // x 48 | vec3 n2; // y 49 | vec3 n3; // z 50 | 51 | vec3 p = spline_p; 52 | vec3 d1= spline_d1; 53 | vec3 d2= spline_d2; 54 | 55 | float a = gl_MultiTexCoord1.x; 56 | float b = gl_MultiTexCoord1.y; 57 | float c = gl_MultiTexCoord1.z; 58 | float c01 = clamp ( c , 0.0 , 1.0 ); 59 | float alpha = 0.5 * 3.14159265358979323846 * c01; 60 | float cos_c = cos ( alpha ); 61 | float sin_c = sin ( alpha ); 62 | float min0 = min(c,0.0); 63 | float max1 = max(c,1.0); 64 | pos = p + d1 * sin_c + d2 * (1.0-cos_c) + d1 * min0 + d2 * max1; 65 | n3 = normalize(d1 * cos_c + d2 * sin_c); 66 | n1 = spline_normal; 67 | n2 = cross( n1,n3 ); 68 | 69 | float r = angle + twist*c01; 70 | float sin_r = sin ( r ); 71 | float cos_r = cos ( r ); 72 | float aa = cos_r * b + sin_r * a; 73 | float bb = cos_r * a - sin_r * b; 74 | 75 | vec3 result_pos = n1 * aa + n2 * bb + pos; 76 | 77 | gl_Position = gl_ModelViewProjectionMatrix * vec4 ( result_pos.xyz , 1 ) ; 78 | } -------------------------------------------------------------------------------- /include/3D/Point.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3D - C++ Class Library for 3D Transformations 3 | Copyright (C) 1996-1998 Gino van den Bergen 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | Please send remarks, questions and bug reports to gino@win.tue.nl, 20 | or write to: 21 | Gino van den Bergen 22 | Department of Mathematics and Computing Science 23 | Eindhoven University of Technology 24 | P.O. Box 513, 5600 MB Eindhoven, The Netherlands 25 | */ 26 | 27 | #ifndef _POINT_H_ 28 | #define _POINT_H_ 29 | 30 | #include 31 | 32 | #include "Vector.h" 33 | 34 | class Point : public Vector { 35 | public: 36 | Point() {} 37 | Point(const float p[3]) : Vector(p) {} 38 | Point(const double p[3]) : Vector(p) {} 39 | Point(Scalar x, Scalar y, Scalar z) : Vector(x, y, z) {} 40 | 41 | Point& operator+=(const Vector& v); 42 | Point& operator-=(const Vector& v); 43 | Point& operator=(const Vector& v); 44 | 45 | void setInf(const Point& p); 46 | void setSup(const Point& p); 47 | }; 48 | 49 | Point operator+(const Point& p, const Vector& v); 50 | Point operator-(const Point& p, const Vector& v); 51 | 52 | Vector operator-(const Point& p1, const Point& p2); 53 | 54 | bool operator<(const Point& p1, const Point& p2); 55 | 56 | Point inf(const Point& p1, const Point& p2); 57 | Point sup(const Point& p1, const Point& p2); 58 | 59 | Point affine(const Point& p1, const Point& p2, Scalar t); 60 | 61 | Scalar distance(const Point& p1, const Point& p2); 62 | Scalar distance2(const Point& p1, const Point& p2); 63 | 64 | 65 | inline Point& Point::operator+=(const Vector& v) { 66 | comp[X] += v[X]; comp[Y] += v[Y]; comp[Z] += v[Z]; 67 | return *this; 68 | } 69 | 70 | inline Point& Point::operator-=(const Vector& v) { 71 | comp[X] -= v[X]; comp[Y] -= v[Y]; comp[Z] -= v[Z]; 72 | return *this; 73 | } 74 | 75 | inline Point& Point::operator=(const Vector& v) { 76 | comp[X] = v[X]; comp[Y] = v[Y]; comp[Z] = v[Z]; 77 | return *this; 78 | } 79 | 80 | inline void Point::setInf(const Point& p) { 81 | set_min(comp[X], p[X]); set_min(comp[Y], p[Y]); set_min(comp[Z], p[Z]); 82 | } 83 | 84 | inline void Point::setSup(const Point& p) { 85 | set_max(comp[X], p[X]); set_max(comp[Y], p[Y]); set_max(comp[Z], p[Z]); 86 | } 87 | 88 | inline Point operator+(const Point& p, const Vector& v) { 89 | return Point(p[X] + v[X], p[Y] + v[Y], p[Z] + v[Z]); 90 | } 91 | 92 | inline Point operator-(const Point& p, const Vector& v) { 93 | return Point(p[X] - v[X], p[Y] - v[Y], p[Z] - v[Z]); 94 | } 95 | 96 | inline Vector operator-(const Point& p1, const Point& p2) { 97 | return Vector(p1[X] - p2[X], p1[Y] - p2[Y], p1[Z] - p2[Z]); 98 | } 99 | 100 | inline bool operator<(const Point& p1, const Point& p2) { 101 | return p1[X] < p2[X] && p1[Y] < p2[Y] && p1[Z] < p2[Z]; 102 | } 103 | 104 | inline Point inf(const Point& p1, const Point& p2) { 105 | return Point(min(p1[X], p2[X]), min(p1[Y], p2[Y]), min(p1[Z], p2[Z])); 106 | } 107 | 108 | inline Point sup(const Point& p1, const Point& p2) { 109 | return Point(max(p1[X], p2[X]), max(p1[Y], p2[Y]), max(p1[Z], p2[Z])); 110 | } 111 | 112 | inline Point affine(const Point& p1, const Point& p2, Scalar t) { 113 | return Point(p1[X] + (p2[X] - p1[X]) * t, 114 | p1[Y] + (p2[Y] - p1[Y]) * t, 115 | p1[Z] + (p2[Z] - p1[Z]) * t); 116 | } 117 | 118 | inline Scalar distance(const Point& p1, const Point& p2) { 119 | return length(p1 - p2); 120 | } 121 | 122 | inline Scalar distance2(const Point& p1, const Point& p2) { 123 | return length2(p1 - p2); 124 | } 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /include/3D/Tuple3.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3D - C++ Class Library for 3D Transformations 3 | Copyright (C) 1996-1998 Gino van den Bergen 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | Please send remarks, questions and bug reports to gino@win.tue.nl, 20 | or write to: 21 | Gino van den Bergen 22 | Department of Mathematics and Computing Science 23 | Eindhoven University of Technology 24 | P.O. Box 513, 5600 MB Eindhoven, The Netherlands 25 | */ 26 | 27 | #ifndef _TUPLE3_H_ 28 | #define _TUPLE3_H_ 29 | 30 | #include "Basic.h" 31 | 32 | #include 33 | #include 34 | 35 | using namespace std; 36 | 37 | class Tuple3 { 38 | public: 39 | Tuple3() {} 40 | Tuple3(const float v[3]) { setValue(v); } 41 | Tuple3(const double v[3]) { setValue(v); } 42 | Tuple3(Scalar x, Scalar y, Scalar z) { setValue(x, y, z); } 43 | 44 | Scalar& operator[](int i) { return comp[i]; } 45 | const Scalar& operator[](int i) const { return comp[i]; } 46 | 47 | Scalar *getValue() { return comp; } 48 | const Scalar *getValue() const { return comp; } 49 | 50 | void setValue(const float v[3]) { 51 | comp[X] = v[X]; comp[Y] = v[Y]; comp[Z] = v[Z]; 52 | } 53 | 54 | void setValue(const double v[3]) { 55 | comp[X] = v[X]; comp[Y] = v[Y]; comp[Z] = v[Z]; 56 | } 57 | 58 | void setValue(Scalar x, Scalar y, Scalar z) { 59 | comp[X] = x; comp[Y] = y; comp[Z] = z; 60 | } 61 | 62 | protected: 63 | Scalar comp[3]; 64 | }; 65 | 66 | inline bool operator==(const Tuple3& t1, const Tuple3& t2) { 67 | return t1[X] == t2[X] && t1[Y] == t2[Y] && t1[Z] == t2[Z]; 68 | } 69 | 70 | inline ostream& operator<<(ostream& os, const Tuple3& t) { 71 | return os << t[X] << ' ' << t[Y] << ' ' << t[Z]; 72 | } 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /include/3D/Tuple4.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3D - C++ Class Library for 3D Transformations 3 | Copyright (C) 1996-1998 Gino van den Bergen 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | Please send remarks, questions and bug reports to gino@win.tue.nl, 20 | or write to: 21 | Gino van den Bergen 22 | Department of Mathematics and Computing Science 23 | Eindhoven University of Technology 24 | P.O. Box 513, 5600 MB Eindhoven, The Netherlands 25 | */ 26 | 27 | #ifndef _TUPLE4_H_ 28 | #define _TUPLE4_H_ 29 | 30 | #include "Basic.h" 31 | 32 | #include 33 | #include 34 | 35 | using namespace std; 36 | 37 | class Tuple4 { 38 | public: 39 | Tuple4() {} 40 | Tuple4(const float v[4]) { setValue(v); } 41 | Tuple4(const double v[4]) { setValue(v); } 42 | Tuple4(Scalar x, Scalar y, Scalar z, Scalar w) { setValue(x, y, z, w); } 43 | 44 | Scalar& operator[](int i) { return comp[i]; } 45 | const Scalar& operator[](int i) const { return comp[i]; } 46 | 47 | Scalar *getValue() { return comp; } 48 | const Scalar *getValue() const { return comp; } 49 | 50 | void setValue(const float v[4]) { 51 | comp[X] = v[X]; comp[Y] = v[Y]; comp[Z] = v[Z]; comp[W] = v[W]; 52 | } 53 | 54 | void setValue(const double v[4]) { 55 | comp[X] = v[X]; comp[Y] = v[Y]; comp[Z] = v[Z]; comp[W] = v[W]; 56 | } 57 | 58 | void setValue(Scalar x, Scalar y, Scalar z, Scalar w) { 59 | comp[X] = x; comp[Y] = y; comp[Z] = z; comp[W] = w; 60 | } 61 | 62 | protected: 63 | Scalar comp[4]; 64 | }; 65 | 66 | inline bool operator==(const Tuple4& t1, const Tuple4& t2) { 67 | return t1[X] == t2[X] && t1[Y] == t2[Y] && t1[Z] == t2[Z] && t1[W] == t2[W]; 68 | } 69 | 70 | inline ostream& operator<<(ostream& os, const Tuple4& t) { 71 | return os << t[X] << ' ' << t[Y] << ' ' << t[Z] << ' ' << t[W]; 72 | } 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /include/3D/basic.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3D - C++ Class Library for 3D Transformations 3 | Copyright (C) 1996-1998 Gino van den Bergen 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | Please send remarks, questions and bug reports to gino@win.tue.nl, 20 | or write to: 21 | Gino van den Bergen 22 | Department of Mathematics and Computing Science 23 | Eindhoven University of Technology 24 | P.O. Box 513, 5600 MB Eindhoven, The Netherlands 25 | */ 26 | 27 | #ifndef _BASIC_H_ 28 | #define _BASIC_H_ 29 | 30 | #include 31 | #include 32 | #include "config.h" 33 | 34 | typedef double Scalar; 35 | 36 | #if HAVE_FABS 37 | /* If Scalar is changed to a float, use fabsf instead */ 38 | #define abs(dbl) fabs(dbl) 39 | #endif 40 | 41 | const Scalar DEGS_PER_RAD = 57.29577951308232286465; 42 | const Scalar RADS_PER_DEG = 0.01745329251994329547; 43 | const Scalar TWO_PI = 6.28318530717958623200; 44 | const Scalar EPSILON = 1.0e-10; 45 | const Scalar EPSILON2 = 1.0e-20; 46 | const Scalar SOLID_INFINITY = 1.0e50; 47 | 48 | inline Scalar rnd() { return (Scalar(rand()) + 0.5) / (Scalar(RAND_MAX) + 1); } 49 | inline Scalar sabs(Scalar x) { return x < 0 ? -x : x; } 50 | inline int sgn(Scalar x) { return x < 0 ? -1 : x > 0 ? 1 : 0; } 51 | inline bool eqz(Scalar x) { return (sabs(x) <= EPSILON); } 52 | 53 | inline Scalar min(Scalar x, Scalar y) { return x > y ? y : x; } 54 | inline Scalar max(Scalar x, Scalar y) { return x < y ? y : x; } 55 | 56 | inline void set_min(Scalar& x, Scalar y) { if (x > y) x = y; } 57 | inline void set_max(Scalar& x, Scalar y) { if (x < y) x = y; } 58 | 59 | inline Scalar rads(Scalar x) { return x * RADS_PER_DEG; } 60 | inline Scalar degs(Scalar x) { return x * DEGS_PER_RAD; } 61 | 62 | enum { X = 0, Y = 1, Z = 2, W = 3 }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /include/Cg/cgContextManager.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/include/Cg/cgContextManager.h -------------------------------------------------------------------------------- /include/Cg/cgD3D.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/include/Cg/cgD3D.h -------------------------------------------------------------------------------- /include/Cg/cgGL_profiles.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2002, NVIDIA Corporation. 4 | * 5 | * 6 | * 7 | * NVIDIA Corporation("NVIDIA") supplies this software to you in consideration 8 | * of your agreement to the following terms, and your use, installation, 9 | * modification or redistribution of this NVIDIA software constitutes 10 | * acceptance of these terms. If you do not agree with these terms, please do 11 | * not use, install, modify or redistribute this NVIDIA software. 12 | * 13 | * 14 | * 15 | * In consideration of your agreement to abide by the following terms, and 16 | * subject to these terms, NVIDIA grants you a personal, non-exclusive license, 17 | * under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA 18 | * Software"), to use, reproduce, modify and redistribute the NVIDIA 19 | * Software, with or without modifications, in source and/or binary forms; 20 | * provided that if you redistribute the NVIDIA Software, you must retain the 21 | * copyright notice of NVIDIA, this notice and the following text and 22 | * disclaimers in all such redistributions of the NVIDIA Software. Neither the 23 | * name, trademarks, service marks nor logos of NVIDIA Corporation may be used 24 | * to endorse or promote products derived from the NVIDIA Software without 25 | * specific prior written permission from NVIDIA. Except as expressly stated 26 | * in this notice, no other rights or licenses express or implied, are granted 27 | * by NVIDIA herein, including but not limited to any patent rights that may be 28 | * infringed by your derivative works or by other works in which the NVIDIA 29 | * Software may be incorporated. No hardware is licensed hereunder. 30 | * 31 | * 32 | * 33 | * THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT 34 | * WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING 35 | * WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 36 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION 37 | * EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS. 38 | * 39 | * 40 | * 41 | * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, 42 | * EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST 43 | * PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 44 | * PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE, 45 | * REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE, 46 | * HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING 47 | * NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED 48 | * OF THE POSSIBILITY OF SUCH DAMAGE. 49 | * 50 | */ 51 | 52 | 53 | CG_PROFILE_MACRO(Vertex,vp20,VP20,"vp20",6146,1) 54 | CG_PROFILE_MACRO(Fragment20,fp20,FP20,"fp20",6147,0) 55 | CG_PROFILE_MACRO(Vertex30,vp30,VP30,"vp30",6148,1) 56 | CG_PROFILE_MACRO(Fragment,fp30,FP30,"fp30",6149,0) 57 | CG_PROFILE_MACRO(ARBVertex,arbvp1,ARBVP1,"arbvp1",6150,1) 58 | CG_PROFILE_MACRO(Fragment40,fp40,FP40,"fp40",6151,0) 59 | CG_PROFILE_MACRO(ARBFragment,arbfp1,ARBFP1,"arbfp1",7000,0) 60 | CG_PROFILE_MACRO(Vertex40,vp40,VP40,"vp40",7001,1) 61 | CG_PROFILE_MACRO(GLSLVertex,glslv,GLSLV,"glslv",7007,1) 62 | CG_PROFILE_MACRO(GLSLFragment,glslf,GLSLF,"glslf",7008,0) 63 | CG_PROFILE_MACRO(GLSLCombined, glslc, GLSLC, "glslc", 7009, 0) 64 | 65 | #ifndef CG_IN_PROFILES_INCLUDE 66 | # undef CG_PROFILE_MACRO 67 | #endif 68 | -------------------------------------------------------------------------------- /include/Cg/cgProgramManager.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/include/Cg/cgProgramManager.h -------------------------------------------------------------------------------- /include/Cg/cgTemplates.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/include/Cg/cgTemplates.h -------------------------------------------------------------------------------- /include/Cg/cg_enums.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * 4 | * Copyright (c) 2002, NVIDIA Corporation. 5 | * 6 | * 7 | * 8 | * NVIDIA Corporation("NVIDIA") supplies this software to you in consideration 9 | * of your agreement to the following terms, and your use, installation, 10 | * modification or redistribution of this NVIDIA software constitutes 11 | * acceptance of these terms. If you do not agree with these terms, please do 12 | * not use, install, modify or redistribute this NVIDIA software. 13 | * 14 | * 15 | * 16 | * In consideration of your agreement to abide by the following terms, and 17 | * subject to these terms, NVIDIA grants you a personal, non-exclusive license, 18 | * under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA 19 | * Software"), to use, reproduce, modify and redistribute the NVIDIA 20 | * Software, with or without modifications, in source and/or binary forms; 21 | * provided that if you redistribute the NVIDIA Software, you must retain the 22 | * copyright notice of NVIDIA, this notice and the following text and 23 | * disclaimers in all such redistributions of the NVIDIA Software. Neither the 24 | * name, trademarks, service marks nor logos of NVIDIA Corporation may be used 25 | * to endorse or promote products derived from the NVIDIA Software without 26 | * specific prior written permission from NVIDIA. Except as expressly stated 27 | * in this notice, no other rights or licenses express or implied, are granted 28 | * by NVIDIA herein, including but not limited to any patent rights that may be 29 | * infringed by your derivative works or by other works in which the NVIDIA 30 | * Software may be incorporated. No hardware is licensed hereunder. 31 | * 32 | * 33 | * 34 | * THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT 35 | * WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING 36 | * WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 37 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION 38 | * EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS. 39 | * 40 | * 41 | * 42 | * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, 43 | * EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST 44 | * PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 45 | * PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE, 46 | * REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE, 47 | * HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING 48 | * NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED 49 | * OF THE POSSIBILITY OF SUCH DAMAGE. 50 | * 51 | */ 52 | 53 | 54 | /* 55 | * The following macro invocations define the supported CG basic data types. 56 | * 57 | * The macros have the form : 58 | * 59 | * CG_ENUM_MACRO(enum_name, enum_val) 60 | * 61 | * enum_name : The C enumerant name. 62 | * enum_val : The enumerant value. 63 | * 64 | */ 65 | 66 | 67 | 68 | CG_ENUM_MACRO(CG_UNKNOWN, 4096) 69 | CG_ENUM_MACRO(CG_IN, 4097) 70 | CG_ENUM_MACRO(CG_OUT, 4098) 71 | CG_ENUM_MACRO(CG_INOUT, 4099) 72 | CG_ENUM_MACRO(CG_MIXED, 4100) 73 | CG_ENUM_MACRO(CG_VARYING, 4101) 74 | CG_ENUM_MACRO(CG_UNIFORM, 4102) 75 | CG_ENUM_MACRO(CG_CONSTANT, 4103) 76 | CG_ENUM_MACRO(CG_PROGRAM_SOURCE, 4104) 77 | CG_ENUM_MACRO(CG_PROGRAM_ENTRY, 4105) 78 | CG_ENUM_MACRO(CG_COMPILED_PROGRAM, 4106) 79 | CG_ENUM_MACRO(CG_PROGRAM_PROFILE, 4107) 80 | CG_ENUM_MACRO(CG_GLOBAL, 4108) 81 | CG_ENUM_MACRO(CG_PROGRAM, 4109) 82 | CG_ENUM_MACRO(CG_DEFAULT, 4110) 83 | CG_ENUM_MACRO(CG_ERROR, 4111) 84 | CG_ENUM_MACRO(CG_SOURCE, 4112) 85 | CG_ENUM_MACRO(CG_OBJECT, 4113) 86 | CG_ENUM_MACRO(CG_COMPILE_MANUAL, 4114) 87 | CG_ENUM_MACRO(CG_COMPILE_IMMEDIATE, 4115) 88 | CG_ENUM_MACRO(CG_COMPILE_LAZY, 4116) 89 | CG_ENUM_MACRO(CG_CURRENT, 4117) 90 | CG_ENUM_MACRO(CG_LITERAL, 4118) 91 | CG_ENUM_MACRO(CG_VERSION, 4119) 92 | CG_ENUM_MACRO(CG_ROW_MAJOR, 4120) 93 | CG_ENUM_MACRO(CG_COLUMN_MAJOR, 4121) 94 | #undef CG_ENUM_MACRO 95 | 96 | 97 | -------------------------------------------------------------------------------- /include/Cg/cg_profiles.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2002, NVIDIA Corporation. 4 | * 5 | * 6 | * 7 | * NVIDIA Corporation("NVIDIA") supplies this software to you in consideration 8 | * of your agreement to the following terms, and your use, installation, 9 | * modification or redistribution of this NVIDIA software constitutes 10 | * acceptance of these terms. If you do not agree with these terms, please do 11 | * not use, install, modify or redistribute this NVIDIA software. 12 | * 13 | * 14 | * 15 | * In consideration of your agreement to abide by the following terms, and 16 | * subject to these terms, NVIDIA grants you a personal, non-exclusive license, 17 | * under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA 18 | * Software"), to use, reproduce, modify and redistribute the NVIDIA 19 | * Software, with or without modifications, in source and/or binary forms; 20 | * provided that if you redistribute the NVIDIA Software, you must retain the 21 | * copyright notice of NVIDIA, this notice and the following text and 22 | * disclaimers in all such redistributions of the NVIDIA Software. Neither the 23 | * name, trademarks, service marks nor logos of NVIDIA Corporation may be used 24 | * to endorse or promote products derived from the NVIDIA Software without 25 | * specific prior written permission from NVIDIA. Except as expressly stated 26 | * in this notice, no other rights or licenses express or implied, are granted 27 | * by NVIDIA herein, including but not limited to any patent rights that may be 28 | * infringed by your derivative works or by other works in which the NVIDIA 29 | * Software may be incorporated. No hardware is licensed hereunder. 30 | * 31 | * 32 | * 33 | * THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT 34 | * WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING 35 | * WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 36 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION 37 | * EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS. 38 | * 39 | * 40 | * 41 | * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, 42 | * EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST 43 | * PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 44 | * PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE, 45 | * REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE, 46 | * HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING 47 | * NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED 48 | * OF THE POSSIBILITY OF SUCH DAMAGE. 49 | * 50 | */ 51 | 52 | /* 53 | * The following macro invocations define the supported CG profiles. 54 | * 55 | * The macros have the form : 56 | * 57 | * CG_PROFILE_MACRO(name, compiler_id, compiler_opt) 58 | * 59 | * name : The name of the profile. Used consistently with the API. 60 | * compiler_id : The identifier string for the profile used by the compiler. 61 | * compiler_id_caps : compiler_id in caps. 62 | * compiler_opt : The command-line switch used to force compilation into 63 | * the profile. 64 | * int_id : Integer enumerant associated with this bind location. 65 | * vertex_profile : Non-zero if this is a vertex profile, otherwise it 66 | * is considered to be a fragment profile. 67 | * 68 | * 69 | */ 70 | 71 | #define CG_IN_PROFILES_INCLUDE 72 | 73 | #include 74 | 75 | 76 | CG_PROFILE_MACRO(DX9Vertex11,vs_1_1,VS_1_1,"vs_1_1",6153,1) 77 | CG_PROFILE_MACRO(DX9Vertex20,vs_2_0,VS_2_0,"vs_2_0",6154,1) 78 | CG_PROFILE_MACRO(DX9Vertex2x,vs_2_x,VS_2_X,"vs_2_x",6155,1) 79 | CG_PROFILE_MACRO(DX9Vertex2sw,vs_2_sw,VS_2_SW,"vs_2_sw",6156,1) 80 | CG_PROFILE_MACRO(DX9Vertex30,vs_3_0,VS_3_0,"vs_3_0",6157,1) 81 | 82 | CG_PROFILE_MACRO(DX9Pixel11,ps_1_1,PS_1_1,"ps_1_1",6159,0) 83 | CG_PROFILE_MACRO(DX9Pixel12,ps_1_2,PS_1_2,"ps_1_2",6160,0) 84 | CG_PROFILE_MACRO(DX9Pixel13,ps_1_3,PS_1_3,"ps_1_3",6161,0) 85 | CG_PROFILE_MACRO(DX9Pixel20,ps_2_0,PS_2_0,"ps_2_0",6162,0) 86 | CG_PROFILE_MACRO(DX9Pixel2x,ps_2_x,PS_2_X,"ps_2_x",6163,0) 87 | CG_PROFILE_MACRO(DX9Pixel2sw,ps_2_sw,PS_2_SW,"ps_2_sw",6164,0) 88 | CG_PROFILE_MACRO(DX9Pixel30,ps_3_0,PS_3_0,"ps_3_0",6165,0) 89 | 90 | CG_PROFILE_MACRO(Generic, generic, GENERIC, "generic", 7002,0) 91 | 92 | #undef CG_PROFILE_MACRO 93 | #undef CG_IN_PROFILES_INCLUDE 94 | -------------------------------------------------------------------------------- /include/GL/glut.def: -------------------------------------------------------------------------------- 1 | DESCRIPTION 'OpenGL Utility Toolkit for Win32' 2 | 3 | VERSION 3.7 4 | 5 | EXPORTS 6 | 7 | glutAddMenuEntry 8 | glutAddSubMenu 9 | glutAttachMenu 10 | glutBitmapCharacter 11 | glutBitmapLength 12 | glutBitmapWidth 13 | glutButtonBoxFunc 14 | glutChangeToMenuEntry 15 | glutChangeToSubMenu 16 | glutCopyColormap 17 | glutCreateMenu 18 | __glutCreateMenuWithExit 19 | glutCreateSubWindow 20 | glutCreateWindow 21 | __glutCreateWindowWithExit 22 | glutDestroyMenu 23 | glutDestroyWindow 24 | glutDetachMenu 25 | glutDeviceGet 26 | glutDialsFunc 27 | glutDisplayFunc 28 | glutEnterGameMode 29 | glutEntryFunc 30 | glutEstablishOverlay 31 | glutExtensionSupported 32 | glutForceJoystickFunc 33 | glutFullScreen 34 | glutGameModeGet 35 | glutGameModeString 36 | glutGet 37 | glutGetColor 38 | glutGetMenu 39 | glutGetModifiers 40 | glutGetWindow 41 | glutHideOverlay 42 | glutHideWindow 43 | glutIconifyWindow 44 | glutIdleFunc 45 | glutIgnoreKeyRepeat 46 | glutInit 47 | __glutInitWithExit 48 | glutInitDisplayMode 49 | glutInitDisplayString 50 | glutInitWindowPosition 51 | glutInitWindowSize 52 | glutJoystickFunc 53 | glutKeyboardFunc 54 | glutKeyboardUpFunc 55 | glutLayerGet 56 | glutLeaveGameMode 57 | glutMainLoop 58 | glutMenuStateFunc 59 | glutMenuStatusFunc 60 | glutMotionFunc 61 | glutMouseFunc 62 | glutOverlayDisplayFunc 63 | glutPassiveMotionFunc 64 | glutPopWindow 65 | glutPositionWindow 66 | glutPostOverlayRedisplay 67 | glutPostRedisplay 68 | glutPostWindowOverlayRedisplay 69 | glutPostWindowRedisplay 70 | glutPushWindow 71 | glutRemoveMenuItem 72 | glutRemoveOverlay 73 | glutReportErrors 74 | glutReshapeFunc 75 | glutReshapeWindow 76 | glutSetColor 77 | glutSetCursor 78 | glutSetIconTitle 79 | glutSetKeyRepeat 80 | glutSetMenu 81 | glutSetWindow 82 | glutSetWindowTitle 83 | glutSetupVideoResizing 84 | glutShowOverlay 85 | glutShowWindow 86 | glutSolidCone 87 | glutSolidCube 88 | glutSolidDodecahedron 89 | glutSolidIcosahedron 90 | glutSolidOctahedron 91 | glutSolidSphere 92 | glutSolidTeapot 93 | glutSolidTetrahedron 94 | glutSolidTorus 95 | glutSpaceballButtonFunc 96 | glutSpaceballMotionFunc 97 | glutSpaceballRotateFunc 98 | glutSpecialFunc 99 | glutSpecialUpFunc 100 | glutStopVideoResizing 101 | glutStrokeCharacter 102 | glutStrokeLength 103 | glutStrokeWidth 104 | glutSwapBuffers 105 | glutTabletButtonFunc 106 | glutTabletMotionFunc 107 | glutTimerFunc 108 | glutUseLayer 109 | glutVideoPan 110 | glutVideoResize 111 | glutVideoResizeGet 112 | glutVisibilityFunc 113 | glutWarpPointer 114 | glutWindowStatusFunc 115 | glutWireCone 116 | glutWireCube 117 | glutWireDodecahedron 118 | glutWireIcosahedron 119 | glutWireOctahedron 120 | glutWireSphere 121 | glutWireTeapot 122 | glutWireTetrahedron 123 | glutWireTorus 124 | ; __glutSetFCB 125 | ; __glutGetFCB 126 | 127 | -------------------------------------------------------------------------------- /include/GL/glut32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/include/GL/glut32.dll -------------------------------------------------------------------------------- /include/GL/glut32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/include/GL/glut32.lib -------------------------------------------------------------------------------- /include/config.h: -------------------------------------------------------------------------------- 1 | /* include/config.h.in. Generated from configure.in by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DLFCN_H 5 | 6 | /* Define to 1 if you have the `fabs' function. */ 7 | #undef HAVE_FABS 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_INTTYPES_H 11 | 12 | /* Define to 1 if you have the `m' library (-lm). */ 13 | #undef HAVE_LIBM 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_LIMITS_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_MEMORY_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_QHULL_QHULL_A_H 23 | 24 | /* Define to 1 if you have the `sqrt' function. */ 25 | #undef HAVE_SQRT 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_STDINT_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_STDLIB_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_STRINGS_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_STRING_H 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_SYS_STAT_H 41 | 42 | /* Define to 1 if you have the header file. */ 43 | #undef HAVE_SYS_TYPES_H 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #undef HAVE_UNISTD_H 47 | 48 | /* Name of package */ 49 | #undef PACKAGE 50 | 51 | /* Define to the address where bug reports for this package should be sent. */ 52 | #undef PACKAGE_BUGREPORT 53 | 54 | /* Define to the full name of this package. */ 55 | #undef PACKAGE_NAME 56 | 57 | /* Define to the full name and version of this package. */ 58 | #undef PACKAGE_STRING 59 | 60 | /* Define to the one symbol short name of this package. */ 61 | #undef PACKAGE_TARNAME 62 | 63 | /* Define to the version of this package. */ 64 | #undef PACKAGE_VERSION 65 | 66 | /* Define to 1 if you have the ANSI C header files. */ 67 | #undef STDC_HEADERS 68 | 69 | /* Version number of package */ 70 | #undef VERSION 71 | 72 | /* Define to empty if `const' does not conform to ANSI C. */ 73 | #undef const 74 | 75 | /* Define to `__inline__' or `__inline' if that's what the C compiler 76 | calls it, or to nothing if 'inline' is not supported under any name. */ 77 | #ifndef __cplusplus 78 | #undef inline 79 | #endif 80 | -------------------------------------------------------------------------------- /include/mathlib/CVS/Entries: -------------------------------------------------------------------------------- 1 | /_matrix33.h/1.5/Mon Sep 20 17:14:36 2004// 2 | /_matrix33_sse.h/1.4/Mon Sep 20 17:14:36 2004// 3 | /_matrix44_sse.h/1.5/Mon Sep 20 17:14:36 2004// 4 | /_vector2.h/1.8/Wed Oct 13 08:25:53 2004// 5 | /_vector3.h/1.13/Mon Sep 20 17:14:36 2004// 6 | /_vector3_sse.h/1.6/Mon Sep 20 17:14:36 2004// 7 | /_vector4.h/1.11/Mon Sep 20 17:14:36 2004// 8 | /_vector4_sse.h/1.6/Mon Sep 20 17:14:36 2004// 9 | /envelopecurve.h/1.13/Mon Sep 20 17:14:36 2004// 10 | /euler.h/1.1/Thu Jan 23 14:48:29 2003// 11 | /eulerangles.h/1.4/Mon Sep 20 17:14:36 2004// 12 | /line.h/1.6/Thu Dec 2 12:32:32 2004// 13 | /matrix.h/1.4/Fri Jun 4 13:17:32 2004// 14 | /matrixdefs.h/1.1/Thu Jan 23 14:48:29 2003// 15 | /noise.h/1.2/Mon Sep 20 17:14:36 2004// 16 | /pknorm.h/1.4/Mon Sep 20 17:14:36 2004// 17 | /plane.h/1.5/Mon Sep 20 17:14:36 2004// 18 | /polar.h/1.4/Mon Sep 20 17:14:36 2004// 19 | /quaternion.h/1.4/Mon Sep 20 17:14:36 2004// 20 | /rectangle.h/1.5/Mon Sep 20 17:14:36 2004// 21 | /transform33.h/1.2/Mon Sep 20 17:14:36 2004// 22 | /triangle.h/1.4/Mon Sep 20 17:14:36 2004// 23 | /vector.h/1.3/Fri Jun 4 13:17:32 2004// 24 | /vector3envelopecurve.h/1.3/Mon Sep 20 17:14:36 2004// 25 | /transform44.h/1.5/Mon Jan 24 11:25:48 2005// 26 | /nmath.h/1.13/Mon Feb 7 10:12:23 2005// 27 | /_matrix44.h/1.11/Fri Mar 18 11:28:29 2005// 28 | /bbox.h/1.17/Fri Mar 18 11:28:29 2005// 29 | /sphere.h/1.6/Fri Mar 18 11:28:29 2005// 30 | D 31 | -------------------------------------------------------------------------------- /include/mathlib/CVS/Entries.Extra: -------------------------------------------------------------------------------- 1 | /_matrix33.h/////// 2 | /_matrix33_sse.h/////// 3 | /_matrix44_sse.h/////// 4 | /_vector2.h/////// 5 | /_vector3.h/////// 6 | /_vector3_sse.h/////// 7 | /_vector4.h/////// 8 | /_vector4_sse.h/////// 9 | /envelopecurve.h/////// 10 | /euler.h/////// 11 | /eulerangles.h/////// 12 | /line.h/////// 13 | /matrix.h/////// 14 | /matrixdefs.h/////// 15 | /noise.h/////// 16 | /pknorm.h/////// 17 | /plane.h/////// 18 | /polar.h/////// 19 | /quaternion.h/////// 20 | /rectangle.h/////// 21 | /transform33.h/////// 22 | /triangle.h/////// 23 | /vector.h/////// 24 | /vector3envelopecurve.h/////// 25 | /transform44.h/////// 26 | /nmath.h/////// 27 | /_matrix44.h/////// 28 | /bbox.h/////// 29 | /sphere.h/////// 30 | -------------------------------------------------------------------------------- /include/mathlib/CVS/Entries.Extra.Old: -------------------------------------------------------------------------------- 1 | /_matrix33.h//// 2 | /_matrix33_sse.h//// 3 | /_matrix44.h//// 4 | /_matrix44_sse.h//// 5 | /_vector2.h//// 6 | /_vector3.h//// 7 | /_vector3_sse.h//// 8 | /_vector4.h//// 9 | /_vector4_sse.h//// 10 | /bbox.h//// 11 | /envelopecurve.h//// 12 | /euler.h//// 13 | /eulerangles.h//// 14 | /line.h//// 15 | /matrix.h//// 16 | /matrixdefs.h//// 17 | /noise.h//// 18 | /pknorm.h//// 19 | /plane.h//// 20 | /polar.h//// 21 | /quaternion.h//// 22 | /rectangle.h//// 23 | /sphere.h//// 24 | /transform33.h//// 25 | /triangle.h//// 26 | /vector.h//// 27 | /vector3envelopecurve.h//// 28 | /transform44.h//// 29 | /nmath.h//// 30 | -------------------------------------------------------------------------------- /include/mathlib/CVS/Entries.Old: -------------------------------------------------------------------------------- 1 | /_matrix33.h/1.5/Mon Sep 20 17:14:36 2004// 2 | /_matrix33_sse.h/1.4/Mon Sep 20 17:14:36 2004// 3 | /_matrix44.h/1.10/Mon Sep 20 17:14:36 2004// 4 | /_matrix44_sse.h/1.5/Mon Sep 20 17:14:36 2004// 5 | /_vector2.h/1.8/Wed Oct 13 08:25:53 2004// 6 | /_vector3.h/1.13/Mon Sep 20 17:14:36 2004// 7 | /_vector3_sse.h/1.6/Mon Sep 20 17:14:36 2004// 8 | /_vector4.h/1.11/Mon Sep 20 17:14:36 2004// 9 | /_vector4_sse.h/1.6/Mon Sep 20 17:14:36 2004// 10 | /bbox.h/1.16/Fri Oct 8 20:06:42 2004// 11 | /envelopecurve.h/1.13/Mon Sep 20 17:14:36 2004// 12 | /euler.h/1.1/Thu Jan 23 14:48:29 2003// 13 | /eulerangles.h/1.4/Mon Sep 20 17:14:36 2004// 14 | /line.h/1.6/Thu Dec 2 12:32:32 2004// 15 | /matrix.h/1.4/Fri Jun 4 13:17:32 2004// 16 | /matrixdefs.h/1.1/Thu Jan 23 14:48:29 2003// 17 | /noise.h/1.2/Mon Sep 20 17:14:36 2004// 18 | /pknorm.h/1.4/Mon Sep 20 17:14:36 2004// 19 | /plane.h/1.5/Mon Sep 20 17:14:36 2004// 20 | /polar.h/1.4/Mon Sep 20 17:14:36 2004// 21 | /quaternion.h/1.4/Mon Sep 20 17:14:36 2004// 22 | /rectangle.h/1.5/Mon Sep 20 17:14:36 2004// 23 | /sphere.h/1.5/Mon Sep 20 17:14:36 2004// 24 | /transform33.h/1.2/Mon Sep 20 17:14:36 2004// 25 | /triangle.h/1.4/Mon Sep 20 17:14:36 2004// 26 | /vector.h/1.3/Fri Jun 4 13:17:32 2004// 27 | /vector3envelopecurve.h/1.3/Mon Sep 20 17:14:36 2004// 28 | /transform44.h/1.5/Mon Jan 24 11:25:48 2005// 29 | /nmath.h/1.13/Mon Feb 7 10:12:23 2005// 30 | D 31 | -------------------------------------------------------------------------------- /include/mathlib/CVS/Repository: -------------------------------------------------------------------------------- 1 | radonlabs/code/nebula2/inc/mathlib 2 | -------------------------------------------------------------------------------- /include/mathlib/CVS/Root: -------------------------------------------------------------------------------- 1 | :pserver:sven3@192.168.0.90:/mnt/hdc/cvsroot 2 | -------------------------------------------------------------------------------- /include/mathlib/euler.h: -------------------------------------------------------------------------------- 1 | /**** EulerAngles.h - Support for 24 angle schemes ****/ 2 | /* Ken Shoemake, 1993 */ 3 | #ifndef _H_EulerAngles 4 | #define _H_EulerAngles 5 | 6 | /*** Definitions ***/ 7 | typedef struct {float x, y, z, w;} QuatX; /* Quaternion */ 8 | //enum QuatPart {X, Y, Z, W}; 9 | typedef float HMatrix[4][4]; /* Right-handed, for column vectors */ 10 | typedef QuatX EulerAngles; /* (x,y,z)=ang 1,2,3, w=order code */ 11 | 12 | /*** Order type constants, constructors, extractors ***/ 13 | /* There are 24 possible conventions, designated by: */ 14 | /* o EulAxI = axis used initially */ 15 | /* o EulPar = parity of axis permutation */ 16 | /* o EulRep = repetition of initial axis as last */ 17 | /* o EulFrm = frame from which axes are taken */ 18 | /* Axes I,J,K will be a permutation of X,Y,Z. */ 19 | /* Axis H will be either I or K, depending on EulRep. */ 20 | /* Frame S takes axes from initial static frame. */ 21 | /* If ord = (AxI=X, Par=Even, Rep=No, Frm=S), then */ 22 | /* {a,b,c,ord} means Rz(c)Ry(b)Rx(a), where Rz(c)v */ 23 | /* rotates v around Z by c radians. */ 24 | #define EulFrmS 0 25 | #define EulFrmR 1 26 | #define EulFrm(ord) ((unsigned)(ord)&1) 27 | #define EulRepNo 0 28 | #define EulRepYes 1 29 | #define EulRep(ord) (((unsigned)(ord)>>1)&1) 30 | #define EulParEven 0 31 | #define EulParOdd 1 32 | #define EulPar(ord) (((unsigned)(ord)>>2)&1) 33 | #define EulSafe "\000\001\002\000" 34 | #define EulNext "\001\002\000\001" 35 | #define EulAxI(ord) ((int)(EulSafe[(((unsigned)(ord)>>3)&3)])) 36 | #define EulAxJ(ord) ((int)(EulNext[EulAxI(ord)+(EulPar(ord)==EulParOdd)])) 37 | #define EulAxK(ord) ((int)(EulNext[EulAxI(ord)+(EulPar(ord)!=EulParOdd)])) 38 | #define EulAxH(ord) ((EulRep(ord)==EulRepNo)?EulAxK(ord):EulAxI(ord)) 39 | /* EulGetOrd unpacks all useful information about order simultaneously. */ 40 | #define EulGetOrd(ord,i,j,k,h,n,s,f) {unsigned o=ord;f=o&1;o>>=1;s=o&1;o>>=1;\ 41 | n=o&1;o>>=1;i=EulSafe[o&3];j=EulNext[i+n];k=EulNext[i+1-n];h=s?k:i;} 42 | /* EulOrd creates an order value between 0 and 23 from 4-tuple choices. */ 43 | #define EulOrd(i,p,r,f) (((((((i)<<1)+(p))<<1)+(r))<<1)+(f)) 44 | /* Static axes */ 45 | enum xx_yy_zz_ww 46 | { 47 | XX = (1<<0), 48 | YY = (1<<1), 49 | ZZ = (1<<2), 50 | WW = (1<<3), 51 | }; 52 | 53 | #define EulOrdXYZs EulOrd(XX,EulParEven,EulRepNo,EulFrmS) 54 | #define EulOrdXYXs EulOrd(XX,EulParEven,EulRepYes,EulFrmS) 55 | #define EulOrdXZYs EulOrd(XX,EulParOdd,EulRepNo,EulFrmS) 56 | #define EulOrdXZXs EulOrd(XX,EulParOdd,EulRepYes,EulFrmS) 57 | #define EulOrdYZXs EulOrd(YY,EulParEven,EulRepNo,EulFrmS) 58 | #define EulOrdYZYs EulOrd(YY,EulParEven,EulRepYes,EulFrmS) 59 | #define EulOrdYXZs EulOrd(YY,EulParOdd,EulRepNo,EulFrmS) 60 | #define EulOrdYXYs EulOrd(YY,EulParOdd,EulRepYes,EulFrmS) 61 | #define EulOrdZXYs EulOrd(ZZ,EulParEven,EulRepNo,EulFrmS) 62 | #define EulOrdZXZs EulOrd(ZZ,EulParEven,EulRepYes,EulFrmS) 63 | #define EulOrdZYXs EulOrd(ZZ,EulParOdd,EulRepNo,EulFrmS) 64 | #define EulOrdZYZs EulOrd(ZZ,EulParOdd,EulRepYes,EulFrmS) 65 | /* Rotating axes */ 66 | #define EulOrdZYXr EulOrd(XX,EulParEven,EulRepNo,EulFrmR) 67 | #define EulOrdXYXr EulOrd(XX,EulParEven,EulRepYes,EulFrmR) 68 | #define EulOrdYZXr EulOrd(XX,EulParOdd,EulRepNo,EulFrmR) 69 | #define EulOrdXZXr EulOrd(XX,EulParOdd,EulRepYes,EulFrmR) 70 | #define EulOrdXZYr EulOrd(YY,EulParEven,EulRepNo,EulFrmR) 71 | #define EulOrdYZYr EulOrd(YY,EulParEven,EulRepYes,EulFrmR) 72 | #define EulOrdZXYr EulOrd(YY,EulParOdd,EulRepNo,EulFrmR) 73 | #define EulOrdYXYr EulOrd(YY,EulParOdd,EulRepYes,EulFrmR) 74 | #define EulOrdYXZr EulOrd(ZZ,EulParEven,EulRepNo,EulFrmR) 75 | #define EulOrdZXZr EulOrd(ZZ,EulParEven,EulRepYes,EulFrmR) 76 | #define EulOrdXYZr EulOrd(ZZ,EulParOdd,EulRepNo,EulFrmR) 77 | #define EulOrdZYZr EulOrd(ZZ,EulParOdd,EulRepYes,EulFrmR) 78 | 79 | EulerAngles Eul_(float ai, float aj, float ah, int order); 80 | QuatX Eul_ToQuat(EulerAngles ea); 81 | void Eul_ToHMatrix(EulerAngles ea, HMatrix M); 82 | EulerAngles Eul_FromHMatrix(HMatrix M, int order); 83 | EulerAngles Eul_FromQuat(QuatX q, int order); 84 | #endif 85 | -------------------------------------------------------------------------------- /include/mathlib/eulerangles.h: -------------------------------------------------------------------------------- 1 | #ifndef N_EULERANGLES_H 2 | #define N_EULERANGLES_H 3 | //------------------------------------------------------------------------------ 4 | /** 5 | @class nEulerAngles 6 | @ingroup Math 7 | 8 | A class representing a rotation using 3 euler angles. 9 | 10 | (C) 2004 RadonLabs GmbH 11 | */ 12 | #include 13 | #include 14 | #include "mathlib/matrix.h" 15 | #include "mathlib/euler.h" 16 | 17 | //------------------------------------------------------------------- 18 | /** 19 | @class nEulerAngles 20 | @ingroup NebulaMathDataTypes 21 | */ 22 | //------------------------------------------------------------------- 23 | class nEulerAngles { 24 | public: 25 | float x,y,z; 26 | 27 | //-- constructors ----------------------------------------------- 28 | nEulerAngles() 29 | : x(0.0f), 30 | y(0.0f), 31 | z(0.0f) 32 | {}; 33 | nEulerAngles(float _x, float _y, float _z) 34 | : x(_x), 35 | y(_y), 36 | z(_z) 37 | {}; 38 | nEulerAngles(const nEulerAngles& e) 39 | : x(e.x), 40 | y(e.y), 41 | z(e.z) 42 | {}; 43 | nEulerAngles(const matrix33& m) 44 | { 45 | Set(m); 46 | } 47 | 48 | //-- setting elements ------------------------------------------- 49 | void Set(float _x, float _y, float _z) 50 | { 51 | x = _x; 52 | y = _y; 53 | z = _z; 54 | }; 55 | void Set(const nEulerAngles& e) 56 | { 57 | x = e.x; 58 | y = e.y; 59 | z = e.z; 60 | }; 61 | void Set(const matrix33& m) 62 | { 63 | int i,j,k,h,n,s,f; 64 | EulGetOrd(EulOrdXYZs,i,j,k,h,n,s,f); 65 | if (s == EulRepYes) 66 | { 67 | double sy = (float) sqrt(m.m[0][1]*m.m[0][1] + m.m[0][2]*m.m[0][2]); 68 | if (sy > 16*FLT_EPSILON) 69 | { 70 | this->x = (float) atan2(m.m[0][1], m.m[0][2]); 71 | this->y = (float) atan2(sy, m.m[0][0]); 72 | this->z = (float) atan2(m.m[1][0], -m.m[2][0]); 73 | } 74 | else 75 | { 76 | this->x = (float) atan2(-m.m[1][2], m.m[1][1]); 77 | this->y = (float) atan2(sy, m.m[0][0]); 78 | this->z = 0; 79 | } 80 | } 81 | else 82 | { 83 | double cy = sqrt(m.m[0][0]*m.m[0][0] + m.m[1][0]*m.m[1][0]); 84 | if (cy > 16*FLT_EPSILON) 85 | { 86 | this->x = (float) atan2(m.m[2][1], m.m[2][2]); 87 | this->y = (float) atan2(-m.m[2][0], cy); 88 | this->z = (float) atan2(m.m[1][0], m.m[0][0]); 89 | } 90 | else 91 | { 92 | this->x = (float) atan2(-m.m[1][2], m.m[1][1]); 93 | this->y = (float) atan2(-m.m[2][0], cy); 94 | this->z = 0; 95 | } 96 | } 97 | if (n==EulParOdd) 98 | { 99 | this->x = -this->x; 100 | this->y = -this->y; 101 | this->z = -this->z; 102 | } 103 | if (f==EulFrmR) 104 | { 105 | float t = this->x; 106 | this->x = this->z; 107 | this->z = t; 108 | } 109 | } 110 | 111 | matrix33 GetMatrix() 112 | { 113 | matrix33 mat; 114 | 115 | double ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss; 116 | int i,j,k,h,n,s,f; 117 | EulGetOrd(EulOrdXYZs,i,j,k,h,n,s,f); 118 | if (f==EulFrmR) {float t = x; x = z; z = t;} 119 | if (n==EulParOdd) {x = -x; y = -y; z = -z;} 120 | ti = x; tj = y; th = z; 121 | ci = cos(ti); cj = cos(tj); ch = cos(th); 122 | si = sin(ti); sj = sin(tj); sh = sin(th); 123 | cc = ci*ch; cs = ci*sh; sc = si*ch; ss = si*sh; 124 | if (s==EulRepYes) { 125 | mat.M11 = (float)(cj); mat.M12 = (float)( sj*si); mat.M13 = (float)( sj*ci); 126 | mat.M21 = (float)(sj*sh); mat.M22 = (float)(-cj*ss+cc); mat.M23 = (float)(-cj*cs-sc); 127 | mat.M31 = (float)(-sj*ch); mat.M23 = (float)( cj*sc+cs); mat.M33 = (float)( cj*cc-ss); 128 | } else { 129 | mat.M11 = (float)(cj*ch); mat.M12 = (float)(sj*sc-cs); mat.M13 = (float)(sj*cc+ss); 130 | mat.M21 = (float)(cj*sh); mat.M22 = (float)(sj*ss+cc); mat.M23 = (float)(sj*cs-sc); 131 | mat.M31 = (float)(-sj); mat.M32 = (float)(cj*si); mat.M33 = (float)(cj*ci); 132 | } 133 | 134 | return mat; 135 | } 136 | 137 | //-- operators -------------------------------------------------- 138 | bool operator== (const nEulerAngles& e) 139 | { 140 | return ((x == e.x) && (y == e.y) && (z == e.z)) ? true : false; 141 | } 142 | 143 | bool operator!= (const nEulerAngles& e) 144 | { 145 | return ((x != e.x) || (y != e.y) || (z != e.z)) ? true : false; 146 | } 147 | }; 148 | 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /include/mathlib/matrix.h: -------------------------------------------------------------------------------- 1 | #ifndef N_MATRIX_H 2 | #define N_MATRIX_H 3 | //------------------------------------------------------------------- 4 | // CLASSES 5 | // matrix33 -- 3x3 matrix 6 | // matrix34 -- 3x4 matrix 7 | // matrix44 -- 4x4 matrix 8 | //------------------------------------------------------------------- 9 | #include "mathlib/ntypes.h" 10 | 11 | #ifndef __USE_SSE__ 12 | #include "mathlib/_matrix33.h" 13 | #include "mathlib/_matrix44.h" 14 | typedef _matrix33 matrix33; 15 | typedef _matrix44 matrix44; 16 | #else 17 | #include "mathlib/_matrix33_sse.h" 18 | #include "mathlib/_matrix44_sse.h" 19 | typedef _matrix33_sse matrix33; 20 | typedef _matrix44_sse matrix44; 21 | #endif 22 | 23 | //------------------------------------------------------------------- 24 | #endif 25 | -------------------------------------------------------------------------------- /include/mathlib/matrixdefs.h: -------------------------------------------------------------------------------- 1 | #ifndef N_MATRIXDEFS_H 2 | #define N_MATRIXDEFS_H 3 | //------------------------------------------------------------------------------ 4 | /** 5 | Common defines for matrix classes. 6 | 7 | (C) 2002 RadonLabs GmbH 8 | */ 9 | #define M11 m[0][0] 10 | #define M12 m[0][1] 11 | #define M13 m[0][2] 12 | #define M14 m[0][3] 13 | #define M21 m[1][0] 14 | #define M22 m[1][1] 15 | #define M23 m[1][2] 16 | #define M24 m[1][3] 17 | #define M31 m[2][0] 18 | #define M32 m[2][1] 19 | #define M33 m[2][2] 20 | #define M34 m[2][3] 21 | #define M41 m[3][0] 22 | #define M42 m[3][1] 23 | #define M43 m[3][2] 24 | #define M44 m[3][3] 25 | 26 | //------------------------------------------------------------------------------ 27 | #endif 28 | -------------------------------------------------------------------------------- /include/mathlib/noise.h: -------------------------------------------------------------------------------- 1 | #ifndef N_PERLIN_H 2 | #define N_PERLIN_H 3 | //------------------------------------------------------------------------------ 4 | /** 5 | @class noise 6 | @ingroup Math 7 | 8 | Perlin noise class. 9 | 10 | See http://mrl.nyu.edu/~perlin/noise/ for details. 11 | 12 | (C) 2004 RadonLabs GmbH 13 | */ 14 | #include "kernel/ntypes.h" 15 | #include "math.h" 16 | 17 | //------------------------------------------------------------------------------ 18 | class noise 19 | { 20 | public: 21 | /// generate noise value 22 | static float gen(float x, float y, float z); 23 | 24 | private: 25 | /// compute fade curve 26 | static float fade(float t); 27 | /// lerp between a and b 28 | static float lerp(float t, float a, float b); 29 | /// convert into gradient direction 30 | static float grad(int hash, float x, float y, float z); 31 | 32 | static int perm[512]; 33 | }; 34 | 35 | //------------------------------------------------------------------------------ 36 | /** 37 | */ 38 | inline 39 | float 40 | noise::fade(float t) 41 | { 42 | return t * t * t * (t * (t * 6.0f - 15.0f) + 10.0f); 43 | } 44 | 45 | //------------------------------------------------------------------------------ 46 | /** 47 | */ 48 | inline 49 | float 50 | noise::lerp(float t, float a, float b) 51 | { 52 | return a + t * (b - a); 53 | } 54 | 55 | //------------------------------------------------------------------------------ 56 | /** 57 | */ 58 | inline 59 | float 60 | noise::grad(int hash, float x, float y, float z) 61 | { 62 | int h = hash & 15; 63 | float u = h < 8 ? x : y; 64 | float v = h < 4 ? y : ((h == 12) || (h==14)) ? x : z; 65 | return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v); 66 | } 67 | 68 | //------------------------------------------------------------------------------ 69 | /** 70 | */ 71 | inline 72 | float 73 | noise::gen(float x, float y, float z) 74 | { 75 | float floorX = floorf(x); 76 | float floorY = floorf(y); 77 | float floorZ = floorf(z); 78 | 79 | // find unit cube that contains point 80 | int X = int(floorX) & 255; 81 | int Y = int(floorY) & 255; 82 | int Z = int(floorZ) & 255; 83 | 84 | // find relative x,y,z of point in cube 85 | x -= floorX; 86 | y -= floorY; 87 | z -= floorZ; 88 | 89 | // compute fade curves for x, y, z 90 | float u = fade(x); 91 | float v = fade(y); 92 | float w = fade(z); 93 | 94 | // hash coords of 8 cube corners 95 | int A = perm[X] + Y; 96 | int AA = perm[A] + Z; 97 | int AB = perm[A+1] + Z; 98 | int B = perm[X+1] + Y; 99 | int BA = perm[B] + Z; 100 | int BB = perm[B+1] + Z; 101 | 102 | // add blended results from 8 corners of cube 103 | return lerp(w, lerp(v, lerp(u, grad(perm[AA ], x , y , z ), 104 | grad(perm[BA ], x-1, y , z )), 105 | lerp(u, grad(perm[AB ], x , y-1, z ), 106 | grad(perm[BB ], x-1, y-1, z ))), 107 | lerp(v, lerp(u, grad(perm[AA+1], x , y , z-1 ), 108 | grad(perm[BA+1], x-1, y , z-1 )), 109 | lerp(u, grad(perm[AB+1], x , y-1, z-1 ), 110 | grad(perm[BB+1], x-1, y-1, z-1 )))); 111 | } 112 | 113 | //------------------------------------------------------------------------------ 114 | #endif -------------------------------------------------------------------------------- /include/mathlib/pknorm.h: -------------------------------------------------------------------------------- 1 | #ifndef N_PKNORM_H 2 | #define N_PKNORM_H 3 | //------------------------------------------------------------------- 4 | /** 5 | @class pknorm3 6 | @ingroup Math 7 | 8 | A normal packed into 16 bits 9 | 10 | (C) 2004 RadonLabs GmbH 11 | */ 12 | #include "mathlib/vector.h" 13 | 14 | //------------------------------------------------------------------- 15 | class pknorm3 { 16 | ushort n; 17 | 18 | public: 19 | //--- pack each component into 5 bits --------------------------- 20 | void pack(vector3& v) { 21 | const float r = 31.999f; 22 | unsigned int ix = (unsigned int) (r * (v.x+1.0f)*0.5f); 23 | unsigned int iy = (unsigned int)(r * (v.y+1.0f)*0.5f); 24 | unsigned int iz = (unsigned int) (r * (v.z+1.0f)*0.5f); 25 | n = ((ix&31)<<10) | ((iy&31)<<5) | (iz&31); 26 | }; 27 | 28 | //--- unpack into vector3 --------------------------------------- 29 | vector3 unpack(void) { 30 | const float r = 31.999f; 31 | float ix = float((n>>10) & 31); 32 | float iy = float((n>>5) & 31); 33 | float iz = float(n & 31); 34 | vector3 v((((ix/r)*2.0f)-1.0f), 35 | (((iy/r)*2.0f)-1.0f), 36 | (((iz/r)*2.0f)-1.0f)); 37 | return v; 38 | }; 39 | 40 | //-- constructors ----------------------------------------------- 41 | pknorm3() : n(0) {}; 42 | pknorm3(vector3& v) { 43 | pack(v); 44 | }; 45 | 46 | //-- get/set packed representation ------------------------------ 47 | ushort getpacked(void) { 48 | return n; 49 | }; 50 | void setpacked(ushort _n) { 51 | n = _n; 52 | }; 53 | }; 54 | //------------------------------------------------------------------- 55 | #endif 56 | -------------------------------------------------------------------------------- /include/mathlib/rectangle.h: -------------------------------------------------------------------------------- 1 | #ifndef N_RECTANGLE_H 2 | #define N_RECTANGLE_H 3 | //------------------------------------------------------------------------------ 4 | /** 5 | @class rectangle 6 | @ingroup Math 7 | 8 | A 2d rectangle class. 9 | 10 | (C) 2003 RadonLabs GmbH 11 | */ 12 | #include "mathlib/vector.h" 13 | 14 | //------------------------------------------------------------------------------ 15 | class rectangle 16 | { 17 | public: 18 | /// default constructor 19 | rectangle(); 20 | /// constructor 1 21 | rectangle(const vector2& topLeft, const vector2& bottomRight); 22 | /// set content 23 | void set(const vector2& topLeft, const vector2& bottomRight); 24 | /// return true if point is inside 25 | bool inside(const vector2& p) const; 26 | /// return midpoint 27 | vector2 midpoint() const; 28 | /// return width 29 | float width() const; 30 | /// return height 31 | float height() const; 32 | /// return size 33 | vector2 size() const; 34 | 35 | vector2 v0; 36 | vector2 v1; 37 | }; 38 | 39 | //------------------------------------------------------------------------------ 40 | /** 41 | */ 42 | inline 43 | rectangle::rectangle() 44 | { 45 | // empty 46 | } 47 | 48 | //------------------------------------------------------------------------------ 49 | /** 50 | */ 51 | inline 52 | rectangle::rectangle(const vector2& topLeft, const vector2& bottomRight) : 53 | v0(topLeft), 54 | v1(bottomRight) 55 | { 56 | // empty 57 | } 58 | 59 | //------------------------------------------------------------------------------ 60 | /** 61 | */ 62 | inline 63 | void 64 | rectangle::set(const vector2& topLeft, const vector2& bottomRight) 65 | { 66 | this->v0 = topLeft; 67 | this->v1 = bottomRight; 68 | } 69 | 70 | //------------------------------------------------------------------------------ 71 | /** 72 | */ 73 | inline 74 | bool 75 | rectangle::inside(const vector2& p) const 76 | { 77 | return ((this->v0.x <= p.x) && (p.x <= this->v1.x) && 78 | (this->v0.y <= p.y) && (p.y <= this->v1.y)); 79 | } 80 | 81 | //------------------------------------------------------------------------------ 82 | /** 83 | */ 84 | inline 85 | vector2 86 | rectangle::midpoint() const 87 | { 88 | return (this->v0 + this->v1) * 0.5f; 89 | } 90 | 91 | //------------------------------------------------------------------------------ 92 | /** 93 | */ 94 | inline 95 | float 96 | rectangle::width() const 97 | { 98 | return this->v1.x - this->v0.x; 99 | } 100 | 101 | //------------------------------------------------------------------------------ 102 | /** 103 | */ 104 | inline 105 | float 106 | rectangle::height() const 107 | { 108 | return this->v1.y - this->v0.y; 109 | } 110 | 111 | //------------------------------------------------------------------------------ 112 | /** 113 | */ 114 | inline 115 | vector2 116 | rectangle::size() const 117 | { 118 | return this->v1 - this->v0; 119 | } 120 | 121 | //------------------------------------------------------------------------------ 122 | #endif 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /include/mathlib/transform33.h: -------------------------------------------------------------------------------- 1 | #ifndef N_TRANSFORM33_H 2 | #define N_TRANSFORM33_H 3 | //------------------------------------------------------------------------------ 4 | /** 5 | @class transform33 6 | @ingroup Math 7 | 8 | A 3x3 matrix which is described by 2D translation, rotation and scale. 9 | 10 | (C) 2004 RadonLabs GmbH 11 | */ 12 | #include "mathlib/matrix.h" 13 | #include "mathlib/vector.h" 14 | 15 | //------------------------------------------------------------------------------ 16 | class transform33 17 | { 18 | public: 19 | /// constructor 20 | transform33(); 21 | /// set translation 22 | void settranslation(const vector2& v); 23 | /// get translation 24 | const vector2& gettranslation() const; 25 | /// set euler rotation 26 | void seteulerrotation(const vector2& v); 27 | /// get euler rotation 28 | const vector2& geteulerrotation() const; 29 | /// return true if the transformation matrix is dirty 30 | bool isdirty() const; 31 | /// set scale 32 | void setscale(const vector2& v); 33 | /// get scale 34 | const vector2& getscale() const; 35 | /// get resulting 3x3 matrix 36 | const matrix33& getmatrix33(); 37 | /// get resulting 4x4 matrix, with 3x3 matrix cast to the upper-left corner 38 | void getmatrix44(matrix44& out); 39 | 40 | private: 41 | /// update internal matrix 42 | void update(); 43 | 44 | enum 45 | { 46 | Dirty = (1<<0), 47 | }; 48 | vector2 translation; 49 | vector2 euler; 50 | vector2 scale; 51 | matrix33 matrix; 52 | uchar flags; 53 | }; 54 | 55 | //------------------------------------------------------------------------------ 56 | /** 57 | */ 58 | inline 59 | transform33::transform33() : 60 | scale(1.0f, 1.0f), 61 | flags(0) 62 | { 63 | // empty 64 | } 65 | 66 | //------------------------------------------------------------------------------ 67 | /** 68 | */ 69 | inline 70 | void 71 | transform33::settranslation(const vector2& v) 72 | { 73 | this->translation = v; 74 | this->flags |= Dirty; 75 | } 76 | 77 | //------------------------------------------------------------------------------ 78 | /** 79 | */ 80 | inline 81 | const vector2& 82 | transform33::gettranslation() const 83 | { 84 | return this->translation; 85 | } 86 | 87 | //------------------------------------------------------------------------------ 88 | /** 89 | */ 90 | inline 91 | void 92 | transform33::seteulerrotation(const vector2& v) 93 | { 94 | this->euler = v; 95 | this->flags |= Dirty; 96 | } 97 | 98 | //------------------------------------------------------------------------------ 99 | /** 100 | */ 101 | inline 102 | const vector2& 103 | transform33::geteulerrotation() const 104 | { 105 | return this->euler; 106 | } 107 | 108 | //------------------------------------------------------------------------------ 109 | /** 110 | */ 111 | inline 112 | void 113 | transform33::setscale(const vector2& v) 114 | { 115 | this->scale = v; 116 | this->flags |= Dirty; 117 | } 118 | 119 | //------------------------------------------------------------------------------ 120 | /** 121 | */ 122 | inline 123 | const vector2& 124 | transform33::getscale() const 125 | { 126 | return this->scale; 127 | } 128 | 129 | //------------------------------------------------------------------------------ 130 | /** 131 | */ 132 | inline 133 | void 134 | transform33::update() 135 | { 136 | if (this->flags & Dirty) 137 | { 138 | this->matrix.ident(); 139 | this->matrix.scale(vector3(this->scale.x, this->scale.y, 1.0f)); 140 | this->matrix.rotate_x(this->euler.x); 141 | this->matrix.rotate_y(this->euler.y); 142 | this->matrix.translate(this->translation); 143 | this->flags &= ~Dirty; 144 | } 145 | } 146 | 147 | //------------------------------------------------------------------------------ 148 | /** 149 | */ 150 | inline 151 | const matrix33& 152 | transform33::getmatrix33() 153 | { 154 | this->update(); 155 | return this->matrix; 156 | } 157 | 158 | //------------------------------------------------------------------------------ 159 | /** 160 | */ 161 | inline 162 | void 163 | transform33::getmatrix44(matrix44& out) 164 | { 165 | this->update(); 166 | out.set(this->matrix.M11, this->matrix.M12, this->matrix.M13, 0.0f, 167 | this->matrix.M21, this->matrix.M22, this->matrix.M23, 0.0f, 168 | this->matrix.M31, this->matrix.M32, this->matrix.M33, 0.0f, 169 | 0.0f, 0.0f, 0.0f, 1.0f); 170 | } 171 | 172 | //------------------------------------------------------------------------------ 173 | /** 174 | */ 175 | inline 176 | bool 177 | transform33::isdirty() const 178 | { 179 | return (0 != (this->flags & Dirty)); 180 | } 181 | 182 | //------------------------------------------------------------------------------ 183 | #endif 184 | 185 | 186 | -------------------------------------------------------------------------------- /include/mathlib/vector.h: -------------------------------------------------------------------------------- 1 | #ifndef N_VECTOR_H 2 | #define N_VECTOR_H 3 | //------------------------------------------------------------------------------ 4 | /** 5 | Implement 2, 3 and 4-dimensional vector classes. 6 | 7 | (C) 2002 RadonLabs GmbH 8 | */ 9 | #include "ntypes.h" 10 | 11 | #ifndef __USE_SSE__ 12 | // generic vector classes 13 | #include "mathlib/_vector2.h" 14 | #include "mathlib/_vector3.h" 15 | #include "mathlib/_vector4.h" 16 | typedef _vector2 vector2; 17 | typedef _vector3 vector3; 18 | typedef _vector4 vector4; 19 | #else 20 | // sse vector classes 21 | #include "mathlib/_vector2.h" 22 | #include "mathlib/_vector3_sse.h" 23 | #include "mathlib/_vector4_sse.h" 24 | typedef _vector2 vector2; 25 | typedef _vector3_sse vector3; 26 | typedef _vector4_sse vector4; 27 | #endif 28 | 29 | //------------------------------------------------------------------------------ 30 | #endif 31 | -------------------------------------------------------------------------------- /lib/cg.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/lib/cg.lib -------------------------------------------------------------------------------- /lib/cgD3D8.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/lib/cgD3D8.lib -------------------------------------------------------------------------------- /lib/cgD3D8d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/lib/cgD3D8d.lib -------------------------------------------------------------------------------- /lib/cgD3D9.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/lib/cgD3D9.lib -------------------------------------------------------------------------------- /lib/cgD3D9d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/lib/cgD3D9d.lib -------------------------------------------------------------------------------- /lib/cgGL.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/lib/cgGL.lib -------------------------------------------------------------------------------- /lib/glut32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/lib/glut32.lib -------------------------------------------------------------------------------- /lib/glutstatic.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/lib/glutstatic.lib -------------------------------------------------------------------------------- /lib/libGlee.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/lib/libGlee.lib -------------------------------------------------------------------------------- /libGlee/libglee.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="libmoto" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** NICHT BEARBEITEN ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=libmoto - Win32 Debug 8 | !MESSAGE Dies ist kein gultiges Makefile. Zum Erstellen dieses Projekts mit NMAKE 9 | !MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fuhren Sie den Befehl 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "libmoto.mak". 12 | !MESSAGE 13 | !MESSAGE Sie konnen beim Ausfuhren von NMAKE eine Konfiguration angeben 14 | !MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "libmoto.mak" CFG="libmoto - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Fur die Konfiguration stehen zur Auswahl: 19 | !MESSAGE 20 | !MESSAGE "libmoto - Win32 Release" (basierend auf "Win32 (x86) Static Library") 21 | !MESSAGE "libmoto - Win32 Debug" (basierend auf "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "libmoto - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 | # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 45 | # ADD BASE RSC /l 0x411 /d "NDEBUG" 46 | # ADD RSC /l 0x411 /d "NDEBUG" 47 | BSC32=bscmake.exe 48 | # ADD BASE BSC32 /nologo 49 | # ADD BSC32 /nologo 50 | LIB32=link.exe -lib 51 | # ADD BASE LIB32 /nologo 52 | # ADD LIB32 /nologo 53 | 54 | !ELSEIF "$(CFG)" == "libmoto - Win32 Debug" 55 | 56 | # PROP BASE Use_MFC 0 57 | # PROP BASE Use_Debug_Libraries 1 58 | # PROP BASE Output_Dir "Debug" 59 | # PROP BASE Intermediate_Dir "Debug" 60 | # PROP BASE Target_Dir "" 61 | # PROP Use_MFC 0 62 | # PROP Use_Debug_Libraries 1 63 | # PROP Output_Dir "Debug" 64 | # PROP Intermediate_Dir "Debug" 65 | # PROP Target_Dir "" 66 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 67 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 | # ADD BASE RSC /l 0x411 /d "_DEBUG" 69 | # ADD RSC /l 0x411 /d "_DEBUG" 70 | BSC32=bscmake.exe 71 | # ADD BASE BSC32 /nologo 72 | # ADD BSC32 /nologo 73 | LIB32=link.exe -lib 74 | # ADD BASE LIB32 /nologo 75 | # ADD LIB32 /nologo 76 | 77 | !ENDIF 78 | 79 | # Begin Target 80 | 81 | # Name "libmoto - Win32 Release" 82 | # Name "libmoto - Win32 Debug" 83 | # Begin Group "Quellcodedateien" 84 | 85 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 86 | # Begin Source File 87 | 88 | SOURCE=.\GEN_random.cpp 89 | # End Source File 90 | # Begin Source File 91 | 92 | SOURCE=.\MT_Matrix3x3.cpp 93 | # End Source File 94 | # Begin Source File 95 | 96 | SOURCE=.\MT_Point2.cpp 97 | # End Source File 98 | # Begin Source File 99 | 100 | SOURCE=.\MT_Point3.cpp 101 | # End Source File 102 | # Begin Source File 103 | 104 | SOURCE=.\MT_Quaternion.cpp 105 | # End Source File 106 | # Begin Source File 107 | 108 | SOURCE=.\MT_Transform.cpp 109 | # End Source File 110 | # Begin Source File 111 | 112 | SOURCE=.\MT_Vector2.cpp 113 | # End Source File 114 | # Begin Source File 115 | 116 | SOURCE=.\MT_Vector3.cpp 117 | # End Source File 118 | # Begin Source File 119 | 120 | SOURCE=.\MT_Vector4.cpp 121 | # End Source File 122 | # End Group 123 | # Begin Group "Header-Dateien" 124 | 125 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 126 | # End Group 127 | # End Target 128 | # End Project 129 | -------------------------------------------------------------------------------- /libGlee/libglee.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 27 | 30 | 33 | 36 | 39 | 42 | 58 | 61 | 66 | 69 | 72 | 75 | 78 | 81 | 84 | 87 | 88 | 98 | 101 | 104 | 107 | 110 | 113 | 129 | 132 | 137 | 140 | 144 | 147 | 150 | 153 | 156 | 159 | 160 | 161 | 162 | 163 | 164 | 168 | 171 | 172 | 173 | 177 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /libGlee/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/libGlee/readme.txt -------------------------------------------------------------------------------- /media/bindleg2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/media/bindleg2.bmp -------------------------------------------------------------------------------- /media/box2.mtl: -------------------------------------------------------------------------------- 1 | newmtl initialShadingGroup1 2 | illum 4 3 | Kd 0.90 0.70 0.30 4 | Ka 0.00 0.00 0.00 5 | Tf 1.00 1.00 1.00 6 | map_Kd bindleg2.bmp 7 | Ni 1.00 8 | Ks 0.30 0.30 0.30 9 | Ns 0.06 10 | -------------------------------------------------------------------------------- /media/char3.mtl: -------------------------------------------------------------------------------- 1 | newmtl blinn3SG 2 | illum 4 3 | Kd 0.00 0.51 1.00 4 | Ka 0.33 0.33 0.33 5 | Tf 1.00 1.00 1.00 6 | Ni 1.00 7 | Ks 1.00 1.00 1.00 8 | newmtl blinn6SG 9 | illum 4 10 | Kd 0.90 0.70 0.30 11 | Ka 0.00 0.00 0.00 12 | Tf 1.00 1.00 1.00 13 | map_Kd female-bind.bmp 14 | Ni 1.00 15 | Ks 0.50 0.50 0.50 16 | newmtl female_blinn2SG 17 | illum 4 18 | Kd 1.00 0.00 0.04 19 | Ka 0.26 0.00 0.01 20 | Tf 1.00 1.00 1.00 21 | Ni 1.00 22 | Ks 0.50 0.50 0.50 23 | -------------------------------------------------------------------------------- /media/female-bind.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/media/female-bind.bmp -------------------------------------------------------------------------------- /media/female-bind2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/media/female-bind2.bmp -------------------------------------------------------------------------------- /media/female-legs.mtl: -------------------------------------------------------------------------------- 1 | newmtl blinn3SG 2 | illum 4 3 | Kd 0.90 0.70 0.30 4 | Ka 0.33 0.33 0.33 5 | Tf 1.00 1.00 1.00 6 | Ni 1.00 7 | Ks 1.00 1.00 1.00 8 | newmtl blinn6SG 9 | illum 4 10 | Kd 0.90 0.70 0.300 11 | Ka 0.00 0.00 0.00 12 | Tf 0.68 0.68 0.68 13 | map_Kd female-bind2.bmp 14 | Ni 1.00 15 | Ks 0.50 0.50 0.50 16 | -------------------------------------------------------------------------------- /media/female-weights.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/media/female-weights.bmp -------------------------------------------------------------------------------- /media/female3.mtl: -------------------------------------------------------------------------------- 1 | newmtl blinn3SG 2 | illum 4 3 | Kd 0.00 0.51 1.00 4 | Ka 0.33 0.33 0.33 5 | Tf 1.00 1.00 1.00 6 | Ni 1.00 7 | Ks 1.00 1.00 1.00 8 | newmtl blinn6SG 9 | illum 4 10 | Kd 0.90 0.70 0.30 11 | Ka 0.00 0.00 0.00 12 | Tf 1.00 1.00 1.00 13 | map_Kd female-bind.bmp 14 | Ni 1.00 15 | Ks 0.50 0.50 0.50 16 | -------------------------------------------------------------------------------- /media/style0/displacement_back.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/media/style0/displacement_back.bmp -------------------------------------------------------------------------------- /media/style0/displacement_front.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/media/style0/displacement_front.bmp -------------------------------------------------------------------------------- /media/style0/displacement_side.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/media/style0/displacement_side.bmp -------------------------------------------------------------------------------- /media/style1/displacement_back.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/media/style1/displacement_back.bmp -------------------------------------------------------------------------------- /media/style1/displacement_front.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/media/style1/displacement_front.bmp -------------------------------------------------------------------------------- /media/style1/displacement_left_right.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/media/style1/displacement_left_right.bmp -------------------------------------------------------------------------------- /media/textures/deform1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/media/textures/deform1.bmp -------------------------------------------------------------------------------- /media/textures/white.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/media/textures/white.bmp -------------------------------------------------------------------------------- /sample.vc8.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 9.00 2 | # Visual Studio 2005 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cuboid Example", "Source.Cuboid\cuboid.vcproj", "{3487CA45-D525-4C10-951E-C314BCB0C154}" 4 | ProjectSection(ProjectDependencies) = postProject 5 | {CFC6FCD9-7419-4A2C-BF83-44D54F1D6EA2} = {CFC6FCD9-7419-4A2C-BF83-44D54F1D6EA2} 6 | EndProjectSection 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGlee", "libGlee\libglee.vcproj", "{CFC6FCD9-7419-4A2C-BF83-44D54F1D6EA2}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Arm Example", "Source.Arm\Arm.vcproj", "{61AA28F6-14D9-4010-9EA9-B95D8DD99A6F}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | {CFC6FCD9-7419-4A2C-BF83-44D54F1D6EA2} = {CFC6FCD9-7419-4A2C-BF83-44D54F1D6EA2} 13 | EndProjectSection 14 | EndProject 15 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LegBench", "Source.LegBench\LegBench.vcproj", "{E3ED6CC3-57FA-4D9A-993E-75C72A3C7F02}" 16 | ProjectSection(ProjectDependencies) = postProject 17 | {CFC6FCD9-7419-4A2C-BF83-44D54F1D6EA2} = {CFC6FCD9-7419-4A2C-BF83-44D54F1D6EA2} 18 | EndProjectSection 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Win32 = Debug|Win32 23 | Release|Win32 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {3487CA45-D525-4C10-951E-C314BCB0C154}.Debug|Win32.ActiveCfg = Debug|Win32 27 | {3487CA45-D525-4C10-951E-C314BCB0C154}.Debug|Win32.Build.0 = Debug|Win32 28 | {3487CA45-D525-4C10-951E-C314BCB0C154}.Release|Win32.ActiveCfg = Release|Win32 29 | {3487CA45-D525-4C10-951E-C314BCB0C154}.Release|Win32.Build.0 = Release|Win32 30 | {CFC6FCD9-7419-4A2C-BF83-44D54F1D6EA2}.Debug|Win32.ActiveCfg = Debug|Win32 31 | {CFC6FCD9-7419-4A2C-BF83-44D54F1D6EA2}.Debug|Win32.Build.0 = Debug|Win32 32 | {CFC6FCD9-7419-4A2C-BF83-44D54F1D6EA2}.Release|Win32.ActiveCfg = Release|Win32 33 | {CFC6FCD9-7419-4A2C-BF83-44D54F1D6EA2}.Release|Win32.Build.0 = Release|Win32 34 | {61AA28F6-14D9-4010-9EA9-B95D8DD99A6F}.Debug|Win32.ActiveCfg = Debug|Win32 35 | {61AA28F6-14D9-4010-9EA9-B95D8DD99A6F}.Debug|Win32.Build.0 = Debug|Win32 36 | {61AA28F6-14D9-4010-9EA9-B95D8DD99A6F}.Release|Win32.ActiveCfg = Release|Win32 37 | {61AA28F6-14D9-4010-9EA9-B95D8DD99A6F}.Release|Win32.Build.0 = Release|Win32 38 | {E3ED6CC3-57FA-4D9A-993E-75C72A3C7F02}.Debug|Win32.ActiveCfg = Debug|Win32 39 | {E3ED6CC3-57FA-4D9A-993E-75C72A3C7F02}.Debug|Win32.Build.0 = Debug|Win32 40 | {E3ED6CC3-57FA-4D9A-993E-75C72A3C7F02}.Release|Win32.ActiveCfg = Release|Win32 41 | {E3ED6CC3-57FA-4D9A-993E-75C72A3C7F02}.Release|Win32.Build.0 = Release|Win32 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | EndGlobal 47 | -------------------------------------------------------------------------------- /sample/release/libGlee.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sp4cerat/Deformation-Styles-using-Spline-Skinning/2e9e9b5b0629cdad91d335434e1f4fb54a48a0a2/sample/release/libGlee.lib --------------------------------------------------------------------------------