A couple of friends and I are trying to code a small animated segment. So, we decided that a good and still somewhat simple proyect would be to make some kind of horror house tour, in which the "player" travels in a cart across an abandoned mine.
Since making circles and straight lines is kind of boring, we decided to make a "slightly" more complex motion. We reasoned that we could import a .obj with a simple vertex strip that would act as a path to move along. This object would, of course, not be drawn on screen. So, I created a Trayectory class to handle the importing of this path. Here is the code I use to import the path:
Trayectory::Trayectory(String^ obj)
{
this->vert = gcnew List<Point3D^>();
this->norm = gcnew List<Point3D^>();
StreamReader^ archivo=gcnew StreamReader(obj);
array<String^>^ file = archivo->ReadToEnd()->Split('\n');
archivo->Close();
for each(String^ s in file) {
array<String^>^ str = s->Split(' ');
if(str[0]=="v") {
Point3D^ tmp = gcnew Point3D(Convert::ToSingle(str[1]),Convert::ToSingle(str[2]),Convert::ToSingle(str[3]));
this->vert->Add(tmp);
}
if(str[0]=="vn") {
Point3D^ tmp = gcnew Point3D(Convert::ToSingle(str[1]),Convert::ToSingle(str[2])+1.0,Convert::ToSingle(str[3]));
this->norm->Add(tmp);
}
}
}
I have two small issues, however:
gluLookAt
up
vector using for calculating side
vector: side=forward X up
.