本文整理汇总了C++中Vector4::SetVector4方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector4::SetVector4方法的具体用法?C++ Vector4::SetVector4怎么用?C++ Vector4::SetVector4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector4
的用法示例。
在下文中一共展示了Vector4::SetVector4方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testCrossProduct
void testCrossProduct(){
Vector4 a;
Vector4 b;
a.SetVector4(1,2,0,1);
b.SetVector4(2,1,1,1);
Vector4* c;
c = a.CrossProduct(b,a);
c->DisplayVector4();
delete c;
}
示例2: testVector
void testVector(){
Vector4 a;
Vector4 b;
a.SetVector4(1,0,0,1);
b.SetVector4(2,0,0,2);
Vector4* c;
c = a.Add(b,a);
c->DisplayVector4();
delete c;
}
示例3: findViewDirection
Vector4* findViewDirection(double xS, double yS, double zS){
Vector4* V = new Vector4();
V->SetVector4(eX-xS, eY-yS, eZ-zS,1.0);
V->ConvertToUnit();
return V;
}
示例4: findLightDirection
/**
* Calculates the direction of the light source.
* @param xS
* @param yS
* @param zS
* @return
*/
Vector4* findLightDirection(double xS, double yS, double zS, Light& light){
double xL = light.position[0];
double yL = light.position[1];
double zL = light.position[2];
Vector4* L = new Vector4();
L->SetVector4(xL-xS, yL-yS, zL-zS,1.0);
return L;
}
示例5: findReflectedRayDirection
Vector4* findReflectedRayDirection(Vector4 &N, Vector4& L){
Vector4* R;
Vector4* Rtemp = new Vector4();
Rtemp->SetVector4(0,0,0,1);
Rtemp->GetCopyOf(N);
double N_dot_L = N.DotProduct(N,L);
Rtemp->Elongate(2*N_dot_L);
R = Rtemp->Subtract(*Rtemp,L);
delete Rtemp;
return R;
}
示例6: findNormalToSphere
Vector4* findNormalToSphere(double xS, double yS, double zS, Sphere& sphere){
//Coordinates of the centre of the sphere.
double x_c = sphere.position[0];
double y_c = sphere.position[1];
double z_c = sphere.position[2];
//radius of the sphere.
double S_r = sphere.radius;
Vector4* normal = new Vector4();
normal->SetVector4(xS-x_c, yS-y_c, zS-z_c, 1.0);
normal->ConvertToUnit();
return normal;
}
示例7:
/**
* Finds a cross b.
* a and b must be in dimension 3 represented as 4 length vector in homogeneous coordinates.
* @param a
* @param b
* @return
*/
Vector4* Vector4::CrossProduct(Vector4 &u, Vector4 &v){
u.Homogenize();
v.Homogenize();
double a1 = u.getX();
double a2 = u.getY();
double a3 = u.getZ();
double b1 = v.getX();
double b2 = v.getY();
double b3 = v.getZ();
double x = a2*b3 - a3*b2;
double y = a3*b1 - a1*b3;
double z = a1*b2 - a2*b1;
Vector4* product = new Vector4();
product->SetVector4(x,y,z,1);
return product;
}
示例8: getColor
Color* getColor(Vector4& viewVector, double x, double y, double z, int depth){
Color* color = new Color(0,0,0);
int red = 0;
int green = 0;
int blue = 0;
double ka_red = 0.0;
double ka_green = 0.0;
double ka_blue = 0.0;
double kd_red = 0.0;
double kd_green = 0.0;
double kd_blue = 0.0;
double ks_red = 0.0;
double ks_green= 0.0;
double ks_blue = 0.0;
double shininess = 0.0;
//The view vector from the point of intersection to where the user is standing.
Vector4* V = findViewDirection(x,y,z);
V->ConvertToUnit();
//The normal vector to the surface obtained by interpolating the normals.
Vector4* N = new Vector4();
N->SetVector4(0,0,0,1);
if(iType == SPHERE){
N->GetCopyOf( *findNormalToSphere(x,y,z,spheres[index_sphere]) );
N->ConvertToUnit();
kd_red = spheres[index_sphere].color_diffuse[0];
kd_green = spheres[index_sphere].color_diffuse[1];
kd_blue = spheres[index_sphere].color_diffuse[2];
ks_red = spheres[index_sphere].color_specular[0];
ks_green = spheres[index_sphere].color_specular[1];
ks_blue = spheres[index_sphere].color_specular[2];
shininess = spheres[index_sphere].shininess;
}
if(iType == TRIANGLE){
N->GetCopyOf( *findNormalToTriangle(x,y,z,triangles[index_triangle]) );
N->ConvertToUnit();
Vector4* Kd = interpolateKd(x,y,z, triangles[index_triangle]);
Vector4* Ks = interpolateKs(x,y,z, triangles[index_triangle]);
kd_red = Kd->getX();
kd_green = Kd->getY();
kd_blue = Kd->getZ();
ks_red = Ks->getX();
ks_green = Ks->getY();
ks_blue = Ks->getZ();
shininess = interpolateShininess(x,y,z, triangles[index_triangle]);
delete Kd;
delete Ks;
}
ka_red = kd_red;
ka_green = kd_green;
ka_blue = kd_blue;
color->addMoreRed((int)getAmbientRed(ka_red));
color->addMoreGreen((int)getAmbientGreen(ka_green));
color->addMoreBlue((int)getAmbientBlue(ka_blue));
int i =0;
for(i = 0; i<num_lights; i++){
//Light Vector (From the point of intersection to the light source)
auto_ptr<Vector4> L(findLightDirection(x,y,z,lights[i]));
L->ConvertToUnit();
//Reflected Ray Vector
auto_ptr<Vector4> R(findReflectedRayDirection(*N, *L));
R->ConvertToUnit();
double LN = L->DotProduct(*L, *N);
double RV = R->DotProduct(*R, *V);
// if(isShadowed(x,y,z,lights[i]) and LN>=0){
if(isShadowed(x,y,z,lights[i])){
red = 0;
green = 0;
blue = 0;
}else{
red = getRed(lights[i].color[0], ka_red, kd_red, ks_red, LN, RV, shininess);
green = getGreen(lights[i].color[1], ka_green, kd_green, ks_green, LN, RV, shininess);
blue = getBlue(lights[i].color[2], ka_blue, kd_blue, ks_green, LN, RV, shininess);
}
//.........这里部分代码省略.........