本文整理汇总了C++中Cylinder::setTrasformationMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ Cylinder::setTrasformationMatrix方法的具体用法?C++ Cylinder::setTrasformationMatrix怎么用?C++ Cylinder::setTrasformationMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cylinder
的用法示例。
在下文中一共展示了Cylinder::setTrasformationMatrix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onInitialization
// Inicializacio, a program futasanak kezdeten, az OpenGL kontextus letrehozasa utan hivodik meg (ld. main() fv.)
void onInitialization() {
glViewport(0, 0, screenWidth, screenHeight);
Color ks = Color(0.4, 0.4, 0.4);
Color kd = Color(255, 215, 0) / 255;
Color k = Color(3.1, 2.7, 1.9);
Color k_1 = Color(1.1, 1.7, 0.9);
Color n = Color(0.17, 0.35, 1.5);
Material *material = new Material(ks, Color(255, 200, 50) / 255, n, k,
Color(), 50, false, false);
Material *material_2 = new Material(ks, Color(205, 127, 50) / 255, n, k,
Color(), 50, false, false);
Material *material_3 = new Material(ks, Color(0, 178, 89) / 255, n, k,
Color(), 50, true, false);
Material *material_4 = new Material(ks, Color(0, 144, 244) / 255,
Color(1.5, 1.5, 1.5), Color(), Color(), 50, false, true);
// Sphere implementation----------------------------------------------
Sphere *firstSphere = new Sphere(material_4);
// Ellipsoid implementation-------------------------------------------
Ellipsoid *firstEllipsoid = new Ellipsoid(material);
myMatrix transfom1 = myMatrix(0.3, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.3, 0, 0,
0, 0, 1);
myMatrix transfom3 = myMatrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.2, 0,
0.5, 1);
myMatrix transfom2 = myMatrix(cos(M_PI / 6), sin(M_PI / 6), 0, 0,
-sin(M_PI / 6), cos(M_PI / 6), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
myMatrix transform4 = myMatrix(0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0.3, 0.2,
1, 1);
Vector normal = Vector(-0.529863, 0.253724, 0.80924, 1);
Vector origo = Vector(-0.150579, 0.20029, 0.229974, 0);
Hit hit = Hit();
hit.normalVector = normal;
hit.intersectPoint = origo;
myMatrix tr1 = myMatrix(0.15, 0, 0, 0, 0, 0.25, 0, 0, 0, 0, 0.15, 0, 0, 0,
0, 1);
myMatrix tr3 = myMatrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0.25, 0, 1);
myMatrix tr = getTheNewCoordSys(hit);
Ellipsoid *secondEllipsoid = new Ellipsoid(material);
myMatrix first_connection_matrix = tr1 * tr3 * tr;
firstEllipsoid->setTrasformationMatrix(transfom1);
secondEllipsoid->setTrasformationMatrix(first_connection_matrix);
Vector normal_2 = normal * first_connection_matrix;
Vector origo_2 = origo * first_connection_matrix;
hit.normalVector = normal_2;
hit.intersectPoint = origo_2;
tr1 = myMatrix(0.15 , 0, 0, 0, 0, 0.25 , 0, 0, 0, 0,
0.15 , 0, 0, 0, 0, 1);
tr3 = myMatrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0.25 , 0,
1);
tr = getTheNewCoordSys(hit);
Ellipsoid *thirdEllipsoid = new Ellipsoid(material);
myMatrix second_connection_matrix = first_connection_matrix*tr;
thirdEllipsoid->setTrasformationMatrix(second_connection_matrix);
// Cylinder implementation---------------------------------------------
Cylinder *firstCylinder = new Cylinder(material);
transfom1 = myMatrix(0.2, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 1);
transfom3 = myMatrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.4, 0, -0.6, 1);
transfom2 = myMatrix(cos(M_PI / 2), sin(M_PI / 2), 0, 0, -sin(M_PI / 2),
cos(M_PI / 2), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
firstCylinder->setTrasformationMatrix((transfom1 * transfom2) * transfom3);
// Paraboloid implemenation--------------------------------------------
Paraboloid *firstParaboloid = new Paraboloid(material_4);
transfom1 = myMatrix(0.2, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 1);
transfom3 = myMatrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.4, 0, -0.6, 1);
transfom2 = myMatrix(cos(M_PI / 2), sin(M_PI / 2), 0, 0, -sin(M_PI / 2),
cos(M_PI / 2), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
firstParaboloid->setTrasformationMatrix((transfom1) * transfom3);
// Plane implementation------------------------------------------------
Plane *firstPlane = new Plane(material_2);
Plane2 *secondPlane = new Plane2(material_2);
Scene scene = Scene();
scene.AddObject((Intersectable*) firstPlane);
// scene.AddObject((Intersectable*) firstCylinder);
// scene.AddObject((Intersectable*) firstSphere);
scene.AddObject((Intersectable*) firstEllipsoid);
scene.AddObject((Intersectable*) secondEllipsoid);
// scene.AddObject((Intersectable*) thirdEllipsoid);
// scene.AddObject((Intersectable*) secondPlane);
// scene.AddObject((Intersectable*) firstParaboloid);
scene.SetAmbientColor(Color(77, 199, 253) / 255);
PositionLightSource *light = new PositionLightSource(Vector(-1, 6, 7),
Color(1, 1, 1));
scene.AddLight((LightSource*) light);
//.........这里部分代码省略.........