Example #1
0
SpringNetwork::SpringNetwork(int _n) : X(_n), V(_n), F(_n), dV(_n), A(_n), dFdX(_n), dFdV(_n)
{
	assert(SPRING_STRUCT == 0);
	assert(&spring_shear == &spring_struct + SPRING_SHEAR);
	assert(&spring_bend == &spring_struct + SPRING_BEND);
	assert(&spring_struct == &spring_k[SPRING_STRUCT]);
	assert(&spring_shear == &spring_k[SPRING_SHEAR]);
	assert(&spring_bend == &spring_k[SPRING_BEND]);
	//   spring_struct=1000000.0f;
	//  spring_shear=1000000.0f;

	spring_struct = 1000.0f;
	spring_shear = 100.0f;

	spring_bend = 25.0f;
	spring_damp = 5.0f;
	spring_air = 1.0f;
	spring_air = 1.0f;
	cloth_step = 0.25f;  // delta time for cloth
	cloth_gravity = float3(0, -10, 0);
	cloth_sleepthreshold = 0.001f;
	cloth_sleepcount = 100;
	awake = cloth_sleepcount;

	//fix/pin two points in worldspace
	float3Nx3N::Block zero;
	zero.m = float3x3(0, 0, 0, 0, 0, 0, 0, 0, 0);
	zero.c = 0;
	zero.r = 0;
	S.blocks.Add(zero);
	zero.r = numX - 1;
	S.blocks.Add(zero);
}
Example #2
0
inline float3x3 inverse(const float3x3& m) {
	return float3x3(
		       determinant(float2x2(m.t.y, m.t.z, m.u.y, m.u.z)),
		       determinant(float2x2(m.s.z, m.s.y, m.u.z, m.u.y)),
		       determinant(float2x2(m.s.y, m.s.z, m.t.y, m.t.z)),

		       determinant(float2x2(m.t.z, m.t.x, m.u.z, m.u.x)),
		       determinant(float2x2(m.s.x, m.s.z, m.u.x, m.u.z)),
		       determinant(float2x2(m.s.z, m.s.x, m.t.z, m.t.x)),

		       determinant(float2x2(m.t.x, m.t.y, m.u.x, m.u.y)),
		       determinant(float2x2(m.s.y, m.s.x, m.u.y, m.u.x)),
		       determinant(float2x2(m.s.x, m.s.y, m.t.x, m.t.y)))

		   * (1.0f / determinant(m));
}
Example #3
0
inline float3x3 operator *(float f, const float3x3& m)         { return float3x3(m.s * f, m.t * f, m.u * f); }
Example #4
0
inline float3x3 operator *(const float3x3& m1, const float3x3& m2) {
	const float3x3 m3 = transpose(m2);
	return float3x3(float3(dot(m1.s, m3.s), dot(m1.s, m3.t), dot(m1.s, m3.u)),
                  float3(dot(m1.t, m3.s), dot(m1.t, m3.t), dot(m1.t, m3.u)),
                  float3(dot(m1.u, m3.s), dot(m1.u, m3.t), dot(m1.u, m3.u)));
}
Example #5
0
inline float3x3 transpose(const float3x3& m) {
	return float3x3(float3(m.s.x, m.t.x, m.u.x),
	                float3(m.s.y, m.t.y, m.u.y),
                  float3(m.s.z, m.t.z, m.u.z));
}
Example #6
0
File: OBB.cpp Project: Ilikia/naali
void OBB::SetFrom(const AABB &aabb, const Quat &transform)
{
    OBBSetFrom(*this, aabb, float3x3(transform));
}
Example #7
0
    // Test that composing back yields the original float3x3.
    assume(float3x3::FromRS(rotate, scale).Equals(*this, 0.1f));
}

float3x3 float3x3::Mul(const float3x3 &rhs) const { return *this * rhs; }
float3x4 float3x3::Mul(const float3x4 &rhs) const { return *this * rhs; }
float4x4 float3x3::Mul(const float4x4 &rhs) const { return *this * rhs; }
float3x3 float3x3::Mul(const Quat &rhs) const { return *this * rhs; }
float3 float3x3::Mul(const float3 &rhs) const { return *this * rhs; }

float3x3 operator *(const Quat &lhs, const float3x3 &rhs)
{
    float3x3 lhsRot(lhs);
    return lhsRot * rhs;
}

float3 operator *(const float3 &lhs, const float3x3 &rhs)
{
    return rhs.TransformLeft(lhs);
}

float4 operator *(const float4 &lhs, const float3x3 &rhs)
{
    assume(lhs.IsWZeroOrOne());
    return float4(rhs.TransformLeft(lhs.xyz()), lhs.w);
}

const float3x3 float3x3::zero     = float3x3(0,0,0, 0,0,0, 0,0,0);
const float3x3 float3x3::identity = float3x3(1,0,0, 0,1,0, 0,0,1);
const float3x3 float3x3::nan = float3x3(FLOAT_NAN, FLOAT_NAN, FLOAT_NAN, FLOAT_NAN, FLOAT_NAN, FLOAT_NAN, FLOAT_NAN, FLOAT_NAN, FLOAT_NAN);
Example #8
0
inline float4x4 inverse(const float4x4& m) {
	return float4x4(
		       determinant(float3x3(m.t.y, m.u.y, m.v.y, m.t.z, m.u.z, m.v.z, m.t.w, m.u.w, m.v.w)),
		      -determinant(float3x3(m.s.y, m.u.y, m.v.y, m.s.z, m.u.z, m.v.z, m.s.w, m.u.w, m.v.w)),
		       determinant(float3x3(m.s.y, m.t.y, m.v.y, m.s.z, m.t.z, m.v.z, m.s.w, m.t.w, m.v.w)),
		      -determinant(float3x3(m.s.y, m.t.y, m.u.y, m.s.z, m.t.z, m.u.z, m.s.w, m.t.w, m.u.w)),

		      -determinant(float3x3(m.t.x, m.u.x, m.v.x, m.t.z, m.u.z, m.v.z, m.t.w, m.u.w, m.v.w)),
		       determinant(float3x3(m.s.x, m.u.x, m.v.x, m.s.z, m.u.z, m.v.z, m.s.w, m.u.w, m.v.w)),
		      -determinant(float3x3(m.s.x, m.t.x, m.v.x, m.s.z, m.t.z, m.v.z, m.s.w, m.t.w, m.v.w)),
		       determinant(float3x3(m.s.x, m.t.x, m.u.x, m.s.z, m.t.z, m.u.z, m.s.w, m.t.w, m.u.w)),

		       determinant(float3x3(m.t.x, m.u.x, m.v.x, m.t.y, m.u.y, m.v.y, m.t.w, m.u.w, m.v.w)),
		      -determinant(float3x3(m.s.x, m.u.x, m.v.x, m.s.y, m.u.y, m.v.y, m.s.w, m.u.w, m.v.w)),
		       determinant(float3x3(m.s.x, m.t.x, m.v.x, m.s.y, m.t.y, m.v.y, m.s.w, m.t.w, m.v.w)),
		      -determinant(float3x3(m.s.x, m.t.x, m.u.x, m.s.y, m.t.y, m.u.y, m.s.w, m.t.w, m.u.w)),

		      -determinant(float3x3(m.t.x, m.u.x, m.v.x, m.t.y, m.u.y, m.v.y, m.t.z, m.u.z, m.v.z)),
		       determinant(float3x3(m.s.x, m.u.x, m.v.x, m.s.y, m.u.y, m.v.y, m.s.z, m.u.z, m.v.z)),
		      -determinant(float3x3(m.s.x, m.t.x, m.v.x, m.s.y, m.t.y, m.v.y, m.s.z, m.t.z, m.v.z)),
		       determinant(float3x3(m.s.x, m.t.x, m.u.x, m.s.y, m.t.y, m.u.y, m.s.z, m.t.z, m.u.z)))

		   * (1.0f / determinant(m));
}
Example #9
0
float3x3 float3x3::MakeOrthographicProjectionXY()
{
    assume(false && "Not implemented!");
    return float3x3(); ///\todo
}
Example #10
0
float3x3 float3x3::MakeOrthographicProjection(const Plane &target)
{
    assume(false && "Not implemented!");
    return float3x3(); ///\todo
}
Example #11
0
float3x3 float3x3::MakeOrthographicProjection(float nearPlaneDistance, float farPlaneDistance, float horizontalViewportSize, float verticalViewportSize)
{
    assume(false && "Not implemented!");
    return float3x3(); ///\todo
}
Example #12
0
float3x3 float3x3::Reflect(const Plane &p)
{
    assume(false && "Not implemented!");
    return float3x3(); ///\todo
}
Example #13
0
float3x3 float3x3::ShearZ(float xFactor, float yFactor)
{
    return float3x3(1.f, 0.f, 0.f,
                    0.f, 1.f, 0.f,
                    xFactor, yFactor, 1.f);
}
Example #14
0
float3x3 float3x3::ShearY(float xFactor, float zFactor)
{
    return float3x3(1.f, 0.f, 0.f,
                    xFactor, 1.f, zFactor,
                    0.f, 0.f, 1.f);
}
Example #15
0
float3x3 float3x3::ShearX(float yFactor, float zFactor)
{
    return float3x3(1.f, yFactor, zFactor,
                    0.f, 1.f, 0.f,
                    0.f, 0.f, 1.f);
}
Example #16
0
float3x3 float3x3::operator *(const Quat &rhs) const
{
    return *this * float3x3(rhs);
}
Example #17
0
inline float determinant(const float4x4& m) {
	return m.s.x * determinant(float3x3(m.t.y, m.u.y, m.v.y, m.t.z, m.u.z, m.v.z, m.t.w, m.u.w, m.v.w))
		   - m.s.y * determinant(float3x3(m.t.x, m.u.x, m.v.x, m.t.z, m.u.z, m.v.z, m.t.w, m.u.w, m.v.w))
		   + m.s.z * determinant(float3x3(m.t.x, m.u.x, m.v.x, m.t.y, m.u.y, m.v.y, m.t.w, m.u.w, m.v.w))
		   - m.s.w * determinant(float3x3(m.t.x, m.u.x, m.v.x, m.t.y, m.u.y, m.v.y, m.t.z, m.u.z, m.v.z));
}
Example #18
0
float3x3 float3x3::FromRS(const Quat &rotate, const float3 &scale)
{
    return float3x3(rotate) * float3x3::Scale(scale);
}
Example #19
0
float3x3 MUST_USE_RESULT Quat::ToFloat3x3() const
{
	return float3x3(*this);
}
Example #20
0
CONST_WIN32 float3x3 float3x4::Float3x3Part() const
{
	return float3x3(v[0][0], v[0][1], v[0][2],
					v[1][0], v[1][1], v[1][2],
					v[2][0], v[2][1], v[2][2]);
}