JFKvoilà le code en question:
MERCI DE TON AIDE





il ya 4 unresolved external pour les 4 fonctions :
init();
hitsphere();
draw();
main();
#include "stdafx.h"
#include "raywin.h"
#include "MainFrm.h"
#include "raywinDoc.h"
#include "raywinView.h"
#include "Raytrace.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRaywinApp
BEGIN_MESSAGE_MAP(CRaywinApp, CWinApp)
//{{AFX_MSG_MAP(CRaywinApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRaywinApp construction
CRaywinApp::CRaywinApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
bool init(char* inputName, scene &myScene) {
int nbMat, nbSphere, nbLight;
int i;
ifstream sceneFile(inputName);
if (!sceneFile)
return false;
sceneFile >> myScene.sizex >> myScene.sizey;
sceneFile >> nbMat >> nbSphere >> nbLight ;
myScene.matTab.resize(nbMat);
myScene.sphTab.resize(nbSphere);
myScene.lgtTab.resize(nbLight);
for (i=0; i<nbMat; ++i)
sceneFile >> myScene.matTab[i];
for (i=0; i<nbSphere; ++i)
sceneFile >> myScene.sphTab[i];
for (i=0; i<nbLight; ++i)
sceneFile >> myScene.lgtTab[i];
return true;
}
bool hitSphere(const ray &r, const sphere& s, float &t) {
// intersection rayon/sphere
vecteur dist = s.pos - r.start;
float B = r.dir * dist;
float D = B*B - dist * dist + s.size * s.size;
if (D < 0.0f) return false;
float t0 = B - sqrtf(D);
float t1 = B + sqrtf(D);
bool retvalue = false;
if ((t0 > 0.1f ) && (t0 < t)) {
t = t0;
retvalue = true;
}
if ((t1 > 0.1f ) && (t1 < t)) {
t = t1;
retvalue = true;
}
return retvalue;
}
bool draw(char* outputName, scene &myScene) {
ofstream imageFile(outputName,ios_base::binary);
if (!imageFile)
return false;
// Ajout du header TGA
imageFile.put(0).put(0);
imageFile.put(2); /* RGB non compresse */
imageFile.put(0).put(0);
imageFile.put(0).put(0);
imageFile.put(0);
imageFile.put(0).put(0); /* origine X */
imageFile.put(0).put(0); /* origine Y */
imageFile.put((myScene.sizex & 0x00FF)).put((myScene.sizex & 0xFF00) / 256);
imageFile.put((myScene.sizey & 0x00FF)).put((myScene.sizey & 0xFF00) / 256);
imageFile.put(24); /* 24 bit bitmap */
imageFile.put(0);
// fin du header TGA
// balayage
for (int y = 0; y < myScene.sizey; ++y) {
for (int x = 0 ; x < myScene.sizex; ++x) {
float red = 0, green = 0, blue = 0;
float coef = 1.0f;
int level = 0;
// lancer de rayon
ray viewRay = { {float(x), float(y), -10000.0f}, { 0.0f, 0.0f, 1.0f}};
do {
// recherche de l'intersection la plus proche
float t = 20000.0f;
int currentSphere=-1;
for (unsigned int i = 0; i < myScene.sphTab.size() ; ++i) {
if (hitSphere(viewRay, myScene.sphTab[i], t)) {
currentSphere = i;
}
}
if (currentSphere == -1)
break;
point newStart = viewRay.start + t * viewRay.dir;
// la normale au point d'intersection
vecteur n = newStart - myScene.sphTab[currentSphere].pos;
float temp = n * n;
if (temp == 0.0f)
break;
temp = 1.0f / sqrtf(temp);
n = temp * n;
material currentMat = myScene.matTab[myScene.sphTab[currentSphere].material];
// calcul de la valeur d'éclairement au point
for (unsigned int j = 0; j < myScene.lgtTab.size() ; ++j) {
light current = myScene.lgtTab[j];
vecteur dist = current.pos - newStart;
if ( n * dist <= 0.0f )
continue;
float t = sqrtf(dist * dist);
if ( t <= 0.0f )
continue;
ray lightRay;
lightRay.start = newStart;
lightRay.dir = (1/t) * dist;
// calcul des ombres
bool inShadow = false;
for (unsigned int i = 0; i < myScene.sphTab.size() ; ++i) {
if (hitSphere(lightRay, myScene.sphTab[i], t)) {
inShadow = true;
break;
}
}
if (!inShadow) {
// lambert
float lambert = (lightRay.dir * n) * coef;
red += lambert * current.red * currentMat.red;
green += lambert * current.green * currentMat.green;
blue += lambert * current.blue * currentMat.blue;
}
}
// on itére sur la prochaine reflexion
coef *= currentMat.reflection;
float reflet = 2.0f * (viewRay.dir * n);
viewRay.start = newStart;
viewRay.dir = viewRay.dir - reflet * n;
level++;
} while ((coef > 0.0f) && (level < 10));
imageFile.put(min(blue*255.0f,255.0f)).put(min(green*255.0f, 255.0f)).put(min(red*255.0f, 255.0f));
}
}
return true;
}
int main(int argc, char* argv[]) {
if (argc < 3)
return -1;
scene myScene;
if (!init(argv[1], myScene))
return -1;
if (!draw(argv[2], myScene))
return -1;
return 0;
}
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CRaywinApp object
CRaywinApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CRaywinApp initialization
BOOL CRaywinApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CRaywinDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CRaywinView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CRaywinApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CRaywinApp message handlers