CGI of human heads

I am looking at producing CGI displays of human heads via C++ and OpenGL
I have just started to learn C++ and would like to ask for any guidance that could be given.


//Using laser line triangulation scanning of the human head to obtain
//surface co-ordinates computing through CGI for 3D display (OpenGL)
//Step 1 a program for reading xyz co-ordinate values into an array
//and then further dividing into three coloum array's
//Code::Blocks 8.02 in C++ GNC GCC Compiler

[code]
#include <iostream>
using namespace std;

int main()
{

float ax[5];
float ay[5];
float az[5];

float array[5][3]=

// Stream of values 2.9 -105.8 -57.4\n3.0 -104.8 -58.6\n3.1 -103.9 -59.7\n3.1 -103.0 -60.2\n3.1 -102.1 -60.8

// Matrix of values
// X Y Z
//
/ / j0 j1 j2

{ {2.9, -105.8, -57.4}, // i 0
{3.0, -104.8, -58.6}, // i 1
{3.1, -103.9, -59.7}, // i 2
{3.1, -103.0, -60.2}, // i 3
{3.1, -102.1, -60.8}, // i 4
};

int i;
int j;

{
// Loop to populate the array matrix
for(i=0; i<5; i++)
for(j=0; j<3; j++)
{

cout<<array[i][j]<<" \n"; //Check array matrix has formed

// It will work up to here then I am lost


}
//ax[5] = array[5][3]; // Make array ax pull off first coloum
{
// for(j=0;j<1;j++);


//j=0;j<3; gives coloums XYZ
//j=0;j<1; gives coloum X rows 0-4 X values
//j=1;j<2; gives coloum Y rows 0-4 Y values
//j=2;j<3; gives coloum Z rows 0-4 Z values


// for(i=0;i<5;i++);
}
}

//cout<<ax[i]; //Check ax array has formed

return 0;
}
[\code]
Last edited on
[code]
#include <iostream>

using namespace std;

int main()
{
float ax[5];
float ay[5];
float az[5];

float array[5][3]=

// Stream of values 2.9 -105.8 -57.4\n3.0 -104.8 -58.6\n3.1 -103.9 -59.7\n
// 3.1 -103.0 -60.2\n3.1 -102.1 -60.8

// Matrix of values
// X Y Z
//
//j0 j1 j2
{ {2.9, -105.8, -57.4},// i 0
{3.0, -104.8, -58.6},// i 1
{3.1, -103.9, -59.7},// i 2
{3.1, -103.0, -60.2},// i 3
{3.1, -102.1, -60.8},// i 4
};

int i;
int j;
cout.setf(ios_base::fixed,ios_base::floatfield);//Sets floating point
cout.precision(2); //Resets the number of units after . point

for(i=0;i<5;i++) {
for(j=0;j<1;j++) {
ax[i] = array[i][j]; // Loop through 0-1 and pass values to array ax
}
}
for(i=0;i<5;i++) {
for(j=1;j<2;j++) {
ay[i] = array[i][j]; // Loop through 1-2 and pass values to array ay
}
}
for(i=0;i<5;i++) {
for(j=2;j<3;j++) {
az[i] = array[i][j]; // Loop through 2-3 and pass values to array az
}
}
cout<<"ENTERTIES"<<"\n"<<"3DFACES"<<"\n"; //File format for .DXF
for(i=0;i<5;i++) {
cout<<"10"<<"\n"<<ax[i]<<"\n"<<"20"<<"\n"<<ay[i]<<"\n"<<"30"<<"\n"<<az[i]<<"\n";
}
cout<<"EOF";
return 0;
}
[\code]

OUTPUT FROM THE ABOVE CODE

ENTERTIES
3DFACES
10
2.9
20
-105.8
30
-57.4
10
3
20
-104.8
30
-58.6
10
3.1
20
-103.9
30
-59.7
10
3.1
20
-103
30
-60.2
10
3.1
20
-102.1
30
-60.8
EOF
[code]
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
float ax[257];
float ay[257];
float az[257];
float array[257][3];
int i;
int j;

ifstream in_file("c:\\bust\\one_p.txt", ios::in);
if(!in_file.is_open()) {
cout<<"File not opened"<<"\n";
return 1;
}

for(i=0;i<257;i++) {
for(j=0;j<3;j++) {
in_file >> array[i][j];
}
}
for(i=0;i<257;i++) {
for(j=0;j<1;j++) {
ax[i] = array[i][j];
}
}
for(i=0;i<257;i++) {
for(j=1;j<2;j++) {
ay[i] = array[i][j];
}
}
for(i=0;i<257;i++) {
for(j=2;j<3;j++) {
az[i] = array[i][j];
}
}

ofstream fout("c:\\bust\\dxf_files\\one_p.dxf", ios::out); //Create object output file
fout<<"ENTERTIES"<<"\n"<<"3DFACES"<<"\n"; //Output File format for .DXF
for(i=0;i<257;i++) {
fout<<"10"<<"\n"<<ax[i]<<"\n"<<"20"<<"\n"<<ay[i]<<"\n"<<"30"<<"\n"<<az[i]<<"\n";
}
fout<<"EOF";
return 0;
}

[\code]
Please use code tags when posting on the forums, makes your code more readable, and thus in turn helps us help you.

[ code ] stuff goes here [ /code ]

I am looking at producing CGI displays of human heads via C++ and OpenGL


Cool.

I have just started to learn C++ and would like to ask for any guidance that could be given.


RTM and practice practice practice.

Also if you would like to ask a question related to your problem:
http://www.catb.org/esr/faqs/smart-questions.html
Last edited on
Topic archived. No new replies allowed.