X-Git-Url: http://git.euphorik.ch/?p=GPU.git;a=blobdiff_plain;f=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F04_RayTracing%2Fmoo%2Fhost%2FRayTracing.cu;fp=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F04_RayTracing%2Fmoo%2Fhost%2FRayTracing.cu;h=503459473dcfad67948bc7107f7aa6f5734e642b;hp=36e3862fb35adaa23a1c69033e0d24cffe467018;hb=f2c6a4fc79746e2d5c6678699bd2ca93ffc49bcc;hpb=ebdad7dc732d4742d09fd72d312175cb07d27a59 diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/host/RayTracing.cu b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/host/RayTracing.cu index 36e3862..5034594 100644 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/host/RayTracing.cu +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/host/RayTracing.cu @@ -8,6 +8,7 @@ using namespace std; #include "RayTracing.h" #include "Device.h" #include "RayTracingDevice.h" +#include "Sphere.h" RayTracing::RayTracing(int w, int h) : w(w), h(h), @@ -18,20 +19,18 @@ RayTracing::RayTracing(int w, int h) Device::assertDim(dg, db); const int nbSpheres = 10; - Sphere* = this->createSpheres(10); - + Sphere* shperes = this->createSpheres(10); // Copie les spheres dans la constant memory. } RayTracing::~RayTracing() { - delete this->ptrDomaineMathInit; } -void RayTracing::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath) +void RayTracing::runGPU(uchar4* ptrDevPixels) { - rayTracing<<>>(ptrDevPixels, this->w, this->h, domaineMath, this->t); + rayTracing<<>>(ptrDevPixels, this->w, this->h, this->t); HANDLE_ERROR(cudaDeviceSynchronize()); // Pour flusher les 'printf' (pour le DEBUG). } @@ -61,19 +60,23 @@ string RayTracing::getTitle() return this->title; } -Sphere* createSpheres(int n) +Sphere* RayTracing::createSpheres(int n) { Sphere* spheres = new Sphere[n]; const float bord = 200; for (int i = 0; i < n; ++i) { - spheres[i].setR(float(AleaTools::uniformeAB(20, this->w / 10 - 1))); - spheres[i].setCentre(float3 { - float(AleaTools::uniformeAB(bord, this->w - bord)), - float(AleaTools::uniformeAB(bord, this->h - bord)), - float(AleaTools::uniformeAB(10, 2.0 * this->w)) - }); - spheres[i].setHue(float(AleaTools::uniformeAB(0, 1)) + spheres[i].setR(float(this->alea.uniformeAB(20, this->w / 10 - 1))); + + cpu::float3 centre + { + float(this->alea.uniformeAB(double(bord), double(this->w - bord))), + float(this->alea.uniformeAB(double(bord), double(this->h - bord))), + float(this->alea.uniformeAB(10.0, 2.0 * this->w)) + }; + + spheres[i].setCentre(centre); + spheres[i].setHueInitial(float(this->alea.uniformeAB(0.0, 1.0))); } }