VCG Library
space_minimal.cpp
1 #include <stdio.h>
2 #include<vcg/math/base.h>
3 #include<vcg/space/point3.h>
4 #include<vcg/space/point4.h>
5 #include<vcg/space/color4.h>
6 
7 using namespace vcg;
8 // The shortest, simplest, dulliest introduction to the VCG Library
9 int main(int argc, char *argv[])
10 {
11  printf("Hello Library!\n");
12 
13  // classical point types.
14  // Point3f is just a typedef for Point3<float>
15  Point3f pp0(0,1,2);
16  Point3f pp1(2,1,0);
17 
18  // classical overloading of math operators
19  Point3f pp2=pp1+pp0;
20 
21  //you can access to the components of a point with three different access methods
22  // [0] [1] [2] <-- Preferred style
23  // .X() .Y() .Z()
24  // .V(0) .V(1) .V(2)
25  printf("pp2: %f %f %f \n",pp2[0], pp2.Y(),pp2.V(2));
26 
27  // Warning no implicit casts between different types
28  // Conversions are explicit
29  Point3i ppi=Point3i::Construct(pp1+pp0);
30 
31  Point4i size(0,0,1,1);
32 
33  // Colors are specialized Point4<unsigned char>
34  // with a specialized constructor
35 
36  Color4b cb(Color4b::LightBlue);
37  Color4f cf(Color4f::LightBlue);
38 
39  Color4b cbi; cbi.Import(cf);
40  printf("ci %i %i %i %i\n",cbi.V(0),cbi.V(1),cbi.V(2),cbi.V(3));
41  return -1;
42 }