cMatrix3d InputManager::GetCameraTransformations() { cMatrix3d cam; //Col0 has Position cam.setCol0(cVector3d(transforms.xPos, transforms.yPos, transforms.zPos)); //Col1 has Gaze dvec4 gazeCamSpace = dvec4( 0, 0, 1, 1); dvec4 gazeWorldSpace = camToWorld * gazeCamSpace; cam.setCol1(cVector3d(gazeWorldSpace.x, gazeWorldSpace.y, gazeWorldSpace.z)); //Col2 has Up cVector3d up; if(transforms.elevation == 0) { //If Looking straight down, change the up vector to the heading up = cVector3d(cos(d2r(transforms.heading)), 0, sin(d2r(transforms.heading))); } else if(transforms.elevation == 180) { //If looking straight up, change the up vector to the negative heading up = cVector3d(0 - cos(d2r(transforms.heading)), 0, 0 - sin(d2r(transforms.heading))); } else { up = cVector3d(0,1,0); } cam.setCol2(up); return cam; }
cVector3d InputManager::RotateVector(const cVector3d& vec) { dvec4 glmVec = dvec4(vec.x, vec.y, vec.z, 1); dvec4 newVec = rotateToWorld * glmVec; //might need to negate z coordinate return cVector3d(newVec.x, newVec.y, 0 - newVec.z); }
fractFunc::fractFunc( d *params_, int eaa_, int maxiter_, int nThreads_, bool auto_deepen_, bool yflip, bool periodicity_, render_type_t render_type_, int warp_param_, IFractWorker *fw, IImage *im_, IFractalSite *site_) { site = site_; im = im_; ok = true; debug_flags = 0; render_type = render_type_; //printf("render type %d\n", render_type); worker = fw; params = params_; eaa = eaa_; maxiter = maxiter_; nThreads = nThreads_; auto_deepen = auto_deepen_; periodicity = periodicity_; warp_param = warp_param_; set_progress_range(0.0,1.0); /* printf("(%d,%d,%d,%d,%d,%d)\n", im->Xres(), im->Yres(), im->totalXres(), im->totalYres(), im->Xoffset(), im->Yoffset()); */ dvec4 center = dvec4( params[XCENTER],params[YCENTER], params[ZCENTER],params[WCENTER]); rot = rotated_matrix(params); eye_point = center + rot[VZ] * -10.0; // FIXME add eye distance parameter rot = rot/im->totalXres(); // distance to jump for one pixel down or across deltax = rot[VX]; // if yflip, draw Y axis down, otherwise up deltay = yflip ? rot[VY] : -rot[VY]; // half that distance delta_aa_x = deltax / 2.0; delta_aa_y = deltay / 2.0; // topleft is now top left corner of top left pixel... topleft = center - deltax * im->totalXres() / 2.0 - deltay * im->totalYres() / 2.0; // offset to account for tiling, if any topleft += im->Xoffset() * deltax; topleft += im->Yoffset() * deltay; // .. then offset to center of pixel topleft += delta_aa_x + delta_aa_y; // antialias: offset to middle of top left quadrant of pixel aa_topleft = topleft - (delta_aa_y + delta_aa_x) / 2.0; nTotalHalfIters = nTotalDoubleIters = nTotalK = 0; worker->set_fractFunc(this); last_update_y = 0; };
dvec4 DataFormatBase::valueToNormalizedVec4Double(void*) const { return dvec4(0.0); }
dvec4 VolumeVectorSampler::sample(double x, double y, double z, double t) const { return sample(dvec4(x, y, z, t)); }
dvec4 VolumeVectorSampler::sample(const vec4 &pos) const { return sample(dvec4(pos)); }
dvec4 dvec4::operator/(const dvec4& v) { return dvec4(x / v.x, y / v.y, z / v.z, w / v.w); }
dvec4 dvec4::operator*(const dvec4& v) { return dvec4(x * v.x, y * v.y, z * v.z, w * v.w); }
dvec4 dvec4::operator-(const dvec4& v) { return dvec4(x - v.x, y - v.y, z - v.z, w - v.w); }
dvec4 dvec4::operator+(const dvec4& v) { return dvec4(x + v.x, y + v.y, z + v.z, w + v.w); }
dvec4 dvec4::normalize() { double len = 1.0f / length(); return dvec4(x * len, y * len, z * len); }