예제 #1
0
파일: mesh.cpp 프로젝트: ipa-nhg/kukadu
void Mesh::setCappedCylinder(double r, double l, uint fineness) {
  uint i;
  setSphere(fineness);
  scale(r, r, r);
  for(i=0; i<V.d0; i++) if(V(i, 2)>0.) V(i, 2)+=l;
  translate(0, 0, -.5*l);
}
예제 #2
0
void Extent::transform ( BaseExtent const * source, Transform const & tform, float scale )
{
    if(!source) return;

    Extent const * sphereSource = safe_cast< Extent const * >(source);

    setSphere( ShapeUtils::transform( sphereSource->getSphere(), tform, scale ) );
}
예제 #3
0
void Extent::copy ( BaseExtent const * source )
{
    if(!source) return;

    Extent const * sphereSource = safe_cast< Extent const * >(source);

    setSphere( sphereSource->getSphere() );
}
예제 #4
0
void Extent::loadSphere( Iff & iff )
{
	iff.enterChunk(TAG_SPHR);

		Vector center = iff.read_floatVector();
		real radius = iff.read_float();

		setSphere( Sphere(center,radius) );

	iff.exitChunk(TAG_SPHR);
}
예제 #5
0
void Extent::loadSphere_old (Iff & iff )
{
	iff.enterChunk(TAG_CNTR);
		const Vector center = iff.read_floatVector();
	iff.exitChunk(TAG_CNTR);

	iff.enterChunk(TAG_RADI);
		const real  radius = iff.read_float();
	iff.exitChunk(TAG_RADI);

	setSphere(Sphere(center, radius));
}
예제 #6
0
// Sets up the scene
void initScene()
{
    // Set the number of ray bounces
    glUniform1i(glGetUniformLocation(shaderProgram, "MAX_BOUNCE"), 4);
    
    //--------------------- Lights
    // Light1
    Vec3 point(-1.0f, 1.0f, 1.0f);
    Vec3 color(1.0f, 1.0f, 1.0f);
    float intensity = 2.0f;
    setLight(shaderProgram, "uLight1", point, color, intensity);

    // Light2
    point = Vec3(1.0f, 2.0f, 0.0f);
    color = Vec3(1.0f, 1.0f, 1.0f);
    intensity = 0.5f;
    setLight(shaderProgram, "uLight2", point, color, intensity);
    
    //--------------------- Spheres
    // Sphere1
    point = Vec3(0.0f, 0.0f, 0.0f);
    //color = Vec3(0.5f, 0.0f, 0.0f);
    color = Vec3(0.0f, 0.0f, 0.0f);
    float radius = 0.3f;
    Material mat;
    mat.ka = 0.0f;
    mat.kd = 0.0f;
    //mat.ks = 1.0f;
    mat.kt = 0.9f;
    mat.color = color;
    mat.matType = 2;
    mat.ior = 1.5;
    setSphere(shaderProgram, "uSphere1", point, radius, mat);

    // Sphere2
    point = Vec3(0.6f, 0.0f, 0.0f);
    sphere2Pos = Vec4(point[0], point[1], point[2], 1.0f);
    color = Vec3(0.35f, 0.3f, 0.2f);
    radius = 0.2f;
    mat.ka = 0.1f;
    mat.kd = 0.8f;
    mat.ks = 0.2f;
    mat.color = color;
    mat.matType = 1;
    setSphere(shaderProgram, "uSphere2", point, radius, mat);
    
    // Sphere3
    point = Vec3(0.0f, 0.61f, 0.0f);
    //color = Vec3(0.5f, 0.0f, 0.0f);
    color = Vec3(0.0f, 0.0f, 0.0f);
    radius = 0.3f;
    mat.ka = 0.0f;
    mat.kd = 0.0f;
    mat.ks = 0.9f;
    mat.color = color;
    mat.matType = 1;
    setSphere(shaderProgram, "uSphere3", point, radius, mat);

    //--------------------- Planes
    // Plane1
    point = Vec3(0.0f, 0.0f, -10.0f);
    Vec3 normal(0.0f, 0.0f, 1.0f);
    color = Vec3(1.0f, 1.0f, 1.0f);
    mat.ka = 0.1f;
    mat.kd = 0.6f;
    mat.ks = 0.4f;
    mat.color = color;
    mat.matType = 0;
    bool checkered = false;
    setPlane(shaderProgram, "uPlane1", point, normal, mat, checkered);

    // Plane2 left
    point = Vec3(-4.0f, 0.0f, 0.0f);
    normal = Vec3(1.0f, 0.0f, 0.0f);
    color = Vec3(0.4f, 0.4f, 0.0f);
    mat.ka = 0.1f;
    mat.kd = 0.6f;
    mat.ks = 0.4f;
    mat.color = color;
    mat.matType = 0;
    checkered = false;            
    setPlane(shaderProgram, "uPlane2", point, normal, mat, checkered);

    // Plane3 right
    point = Vec3(4.0f, 0.0f, 0.0f);
    normal = Vec3(-1.0f, 0.0f, 0.0f);
    color = Vec3(0.0f, 0.7f, 0.0f);
    mat.ka = 0.1f;
    mat.kd = 0.6f;
    mat.ks = 0.4f;
    mat.color = color;
    mat.matType = 0;
    checkered = false;            
    setPlane(shaderProgram, "uPlane3", point, normal, mat, checkered);    
    

    // Plane4 back
    point = Vec3(0.0f, 0.0f, 10.0f);
    normal = Vec3(0.0f, 0.0f, -1.0f);
    color = Vec3(0.0f, 0.0f, 0.4f);
    mat.ka = 0.1f;
    mat.kd = 0.6f;
    mat.ks = 0.4f;
    mat.color = color;
    mat.matType = 0;
    checkered = false;            
    setPlane(shaderProgram, "uPlane4", point, normal, mat, checkered);    
    
    // Plane4 top
    point = Vec3(0.0f, 4.0f, 0.0f);
    normal = Vec3(0.0f, -1.0f, 0.0f);
    color = Vec3(0.4f, 0.0f, 0.0f);
    mat.ka = 0.1f;
    mat.kd = 0.6f;
    mat.ks = 0.4f;
    mat.color = color;
    mat.matType = 0;
    checkered = false;            
    setPlane(shaderProgram, "uPlane5", point, normal, mat, checkered);    
    
    // Plane4 bottom
    point = Vec3(0.0f, -3.0f, 0.0f);
    normal = Vec3(0.0f, 1.0f, 0.0f);
    color = Vec3(1.0f, 1.0f, 1.0f);
    mat.ka = 0.1f;
    mat.kd = 0.6f;
    mat.ks = 0.4f;
    mat.color = color;
    mat.matType = 1;
    checkered = true;            
    setPlane(shaderProgram, "uPlane6", point, normal, mat, checkered);    
}
BOSphereBlocker::BOSphereBlocker(const math::vector3d& c,float r){
	setSphere(c,r);

}
BOSphereBlocker::BOSphereBlocker(){
	setSphere(0,1);

}