示例#1
0
HW_FORCE_INLINE const mat3x4 scale3x4(const vec3& scale)
{
	mat3x4 m;

	m.rows[0] = vec4(scale.getX(), 0.f,          0.f,          0.f);
	m.rows[1] = vec4(0.f,          scale.getY(), 0.f,          0.f);
	m.rows[2] = vec4(0.f,          0.f,          scale.getZ(), 0.f);

	return m;
}
示例#2
0
HW_FORCE_INLINE const mat3x4 translate3x4(const vec3& v)
{
	mat3x4 m(mat_identity);

	// TODO: Optimize
	m.rows[0].setW(v.getX());
	m.rows[1].setW(v.getY());
	m.rows[2].setW(v.getZ());

	return m;
}
示例#3
0
void renderBillboard(const vec3& pUp, const vec3& pRight, const World3& pWorld, const vec3& pPosition, const vec3& pColor, real pAlpha, real pSize) {
	const vec3 up = pUp * pSize;
	const vec3 right = pRight * pSize;
	const vec3 top = pPosition + up;
	const vec3 bottom = pPosition -up;

	glColor4f(pColor.getX(), pColor.getY(), pColor.getZ(), pAlpha);
	glTexCoord2f(1,1); glVertex(top + right);
	glTexCoord2f(0,1); glVertex(top - right);
	glTexCoord2f(0,0); glVertex(bottom - right);
	glTexCoord2f(1,0); glVertex(bottom + right);
}
示例#4
0
int main()
{
  
  // Test: Cubic Bezier Curve
  {
    const vec3 input[] = { 
      vec3(0.0f), 
      vec3(1.0f, 10.0f, 0.0f), 
      vec3(2.0f, -10.0f, 0.0f), 
      vec3(3.0f, 0.0f, 0.0f) 
    };
    
    for(F32 t = 0.0f; t<=1.0f; t+=0.1f){
      const vec3 vt = bezier_curve(4, input, t);
      const vec3 vd = bezier_curve_der(4, input, t);
      
      if(!_test(vt.getZ(), 0.0f))
        return 1;
      if(!_test(vt.getX(), 3.0f*t))
        return 1;
      if(!_test(vt.getY(), 3.0f*t*(1-t)*(1-2.0f*t)*10.0f))
        return 1;
      if(!_test(vd.getX(), 3.0f))
        return 1;
      if(!_test(vd.getZ(), 0.0f))
        return 1;
      if(!_test(vd.getY(), 30.0f*(1.0f-6.0f*t+6.0f*t*t)))
        return 1;
    }
  }
  
  // Test: Cubic Bezier Patch
  {
    const vec3 input[4][3] = {
      { 
        vec3(0.0f, 0.0f, 0.0f), 
        vec3(0.0f, 1.0f, 0.0f), 
        vec3(0.0f, 2.0f, 0.0f)
      },
      { 
        vec3(1.0f, 0.0f, 0.0f), 
        vec3(1.0f, 1.0f, 0.0f), 
        vec3(1.0f, 2.0f, 0.0f)
      },
      {
        vec3(2.0f, 0.0f, 0.0f), 
        vec3(2.0f, 1.0f, 0.0f), 
        vec3(2.0f, 2.0f, 0.0f)
      },
      {
        vec3(3.0f, 0.0f, 0.0f), 
        vec3(3.0f, 1.0f, 0.0f), 
        vec3(3.0f, 2.0f, 0.0f)
      }
    };
    
    for(F32 u = 0.0f; u<=1.0f; u+=0.1f)
      for(F32 v = 0.0f; v<=1.0f; v+=0.1f){
        const vec3 vt = bezier_patch(4, 3, (vec3*)input, u, v);
        const vec3 vdv = bezier_patch_dv(4, 3, (vec3*)input, u, v);
        const vec3 vdu = bezier_patch_du(4, 3, (vec3*)input, u, v);
        const vec3 normal = normalize(cross(vdu, vdv));
        
        if(!_test(vt.getZ(), 0.0f))
          return 1;
        if(!_test(vt.getX(), u*3.0f))
          return 1;
        if(!_test(vt.getY(), v*2.0f))
          return 1;
        if(!_test(vdv, vec3(0.0f, 2.0f, 0.0f)))
          return 1;
        if(!_test(vdu, vec3(3.0f, 0.0f, 0.0f)))
          return 1;
        if(!_test(normal, vec3(0.0f, 0.0f, 1.0f)))
          return 1;
      }
    
  }

  // 

  return 0;
}
示例#5
0
文件: vec3.hpp 项目: madeso/lolball
	vec3 getCrossProduct(const vec3& r) const { return vec3(getY()*r.getZ() - getZ()*r.getY(),
															getZ()*r.getX() - getX()*r.getZ(),
															getX()*r.getY() - getY()*r.getX()); }
示例#6
0
文件: vec3.hpp 项目: madeso/lolball
	void operator-=(const vec3& vec) { setX(getX()-vec.getX()); setY(getY()-vec.getY()); setZ(getZ()-vec.getZ()); }