cloth2

changeset 2:b4b8f736332b tip

switched Cloth::transform to match the new vector/matrix multiplication conventions in gmath
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 13 Jan 2016 20:00:37 +0200
parents dc15b741486c
children
files src/cloth.cc src/main.cc
diffstat 2 files changed, 6 insertions(+), 6 deletions(-) [+]
line diff
     1.1 --- a/src/cloth.cc	Mon Jan 11 20:24:13 2016 +0200
     1.2 +++ b/src/cloth.cc	Wed Jan 13 20:00:37 2016 +0200
     1.3 @@ -16,8 +16,8 @@
     1.4  void Cloth::create_rect(int x, int y, float width, float height)
     1.5  {
     1.6  	int num = x * y;
     1.7 -	float dx = width / (float)x;
     1.8 -	float dy = height / (float)y;
     1.9 +	float dx = width / (float)(x - 1);
    1.10 +	float dy = height / (float)(y - 1);
    1.11  
    1.12  	masses.resize(num);
    1.13  	conn.resize(num);
    1.14 @@ -97,7 +97,7 @@
    1.15  void Cloth::transform(const Matrix4x4 &xform)
    1.16  {
    1.17  	for(size_t i=0; i<masses.size(); i++) {
    1.18 -		masses[i].pos = masses[i].pos * xform;
    1.19 +		masses[i].pos = xform * masses[i].pos;
    1.20  	}
    1.21  }
    1.22  
     2.1 --- a/src/main.cc	Mon Jan 11 20:24:13 2016 +0200
     2.2 +++ b/src/main.cc	Wed Jan 13 20:00:37 2016 +0200
     2.3 @@ -55,16 +55,16 @@
     2.4  	//glEnable(GL_LIGHTING);
     2.5  	glEnable(GL_LIGHT0);
     2.6  
     2.7 -	cloth.create_rect(4, 4, 10, 10);
     2.8 +	cloth.create_rect(5, 5, 10, 10);
     2.9  
    2.10  	Matrix4x4 xform = Matrix4x4(1, 0, 0, 0,
    2.11  								0, 1, 0, 0,
    2.12  								0, 0, 1, 0,
    2.13 -								0, 1, 1, 1);
    2.14 +								0, 2, 0, 1);
    2.15  	cloth.transform(xform);
    2.16  	cloth.set_mass(0.1);
    2.17  	cloth.set_spring_constant(0.1);
    2.18 -	cloth.set_gravity(Vector3(0, -0.1, 0));
    2.19 +	cloth.set_gravity(Vector3(0, -0.01, 0));
    2.20  	cloth.set_damping(0.1);
    2.21  
    2.22