Sorry tabstop, I completed the question and made it better.
-----------------------------------------------------------
I have a class like such:
and a function like such:Code:class Sphere { public: Sphere(){}; ~Sphere() {}; Sphere(string m_name) : name(m_name) {}; void SetValues(float m_posx, float m_posy, float m_posz, float m_sclx, float m_scly, float m_sclz, float m_r, float m_g, float m_b, float m_Ka, float m_Kd, float m_Ks, float m_Kr, float m_n) { Ka = m_Ka; Kd = m_Kd; Ks = m_Ks; Kr = m_Kr; n = m_n; radius = 1.00; center.x = 0.00; center.y = 0.00; center.z = 0.00; sphereColor.r = m_r; sphereColor.g = m_g; sphereColor.b = m_b; SetTranformMatrix(m_posx, m_posy, m_posz, m_sclx, m_scly, m_sclz); }; //set the transfor matrix void SetTranformMatrix( float posx, float posy, float posz, float sclx, float scly, float sclz) { Trans[0][0] = sclx; Trans[0][1] = 0; Trans[0][2] = 0; Trans[0][3] = posx; Trans[1][0] = 0; Trans[1][1] = scly; Trans[1][2] = 0; Trans[1][3] = posy; Trans[2][0] = 0; Trans[2][1] = 0; Trans[2][2] = sclz; Trans[2][3] = posz; Trans[3][0] = 0; Trans[3][1] = 0; Trans[3][2] = 0; Trans[3][3] = 1; }; //should return the depth at which the the ray has intersected otherwise return -1; double intersect(ray &m_ray) { double T_Inverse[4][4]; invert_matrix(Trans, T_Inverse); //buncha lines here } std::string name; double Trans[4][4]; //transition matrix color sphereColor; private: point center; double radius; float Ka, Kd, Ks, Kr; float n; //specular };
and in main I haveCode:float compute_closest_intersection(ray &m_ray, Sphere * m_spheres) { float intersect = -1; float temp_intersect; for(int i=0; i < 3; i++) { temp_intersect = m_spheres[i].intersect(m_ray); //HERE HERE HERE HERE intersect = (temp_intersect >= intersect) ? temp_intersect : intersect; } return intersect; }
- and the problem: Trans[][] doesn't have values,Code:Sphere inputSphere[5]; float testiii = compute_closest_intersection(Thru_Pixel,InputSphere);
(where it was initialized in the SetTranformMatrix() function)
when the intersect is called from compute_closest_intersection function.
in a nutshell
Why doesn't Trans[][] keep the values assigned to it in the SetTranformMatrix() function.
-Thank you



LinkBack URL
About LinkBacks



