Skip to content

Commit 588b360

Browse files
committed
Ajoutez des fichiers projet.
1 parent 3d69115 commit 588b360

16 files changed

+903
-0
lines changed

cahier de bord.txt

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
M3D
2+
3+
31/03
4+
Premiere pas :
5+
Découverte de la sdl.
6+
SDL_INIT et les Quit pour eviter les fuites de mémoire.
7+
Logging
8+
Création d'une fenetre simple et initilaisation du renderer (dessins de points et de lignes)
9+
Dans le main
10+
11+
12+
01/04
13+
14+
création des objets vecteur 2d, 3d et matrice 2d 3d
15+
16+
Création de l'objet camera
17+
18+
Création de la méthode normalize3d qui renvoi un vect coll au vecteur passé mais normalizé
19+
20+
Création d'un générateur de vecteur qui forment la caméra avec pour le moment un vecteur par pixel sur un angle de vue (FOV) réglable (70° pour les tests)
21+
22+
Création pour le test d'un matrice de rotation sur Z pour faire bouger la caméra
23+
Test concluant qui a mené a la crétion de la matrice de rotation de la caméra qui est une composition précise de 3 angle permtant d'orienter la caméra.
24+
25+
Création alors de la méthode RotatePointsEcran qui prend un ensemble de vecteur3d et leur applique les rotation sucessive : phi selon Z, theta selon x' et gamma selon y'' représentant phi : regard gauche droit theta regardhaut bas et gamma regard penché.
26+
27+
Test dans le main d'un bout de code permettant de tester le tracé des rayon. La scène ne présente qu'une sphère.
28+
On obitent bien un sphère et un fond noir.
29+
30+
/--------------------------------/
31+
L'idée est maintenant de creer un ensemble d'objet qui composeront une scène et d'être capable d'iterer sur l'ensemble des éléments de la scène. Peut etre instancier les objets de meme type pour leur attribuer une fonction de distance passé par adresse. Ensuite creer des methode pour le renderer afin de cast les rayons et iterer sur chaque éléments de la scène.
32+
33+
Note pourri : ont pourrais caster les rayons en damier et si un rayon (pas cast) est entourer de 4 rayon qui sont aller a une certaine distance (ou trop loin), prendre le minimum comme point de départ (ou ne pas le cast mais c'est moyen comme idée). On risque de perdre u détail lointain
34+
35+
Note importante : Le facteur d ne semble pas impacterle champ de vue ce qui n'est pas normal
36+
37+
On normalise les vecteurs de Rays generer pour l'écran
38+
39+
On améliore le test dans le main en réécrivant les paramètres plus proprement.
40+
41+
Note : Pour le raymarching on poura se passer de la première itération et la faire une fois pour touts les rayons puisqu'ils provienne au premier coup du même point.
42+
43+
Ajout de la fonction dot qui a deux vecteur passé renvoi le produit scalair usuel dans le repère x,y,zp
44+
45+
02/04
46+
47+
Implémentation de la fonction reflect grace à : https://asawicki.info/news_1301_reflect_and_refract_functions.html
48+
Prenant un vect3d incident par adresse et un vect3d normal à la surface et modifie le vecteur incident en vect réflechit.
49+
50+
Introduction des fonctions sphereNormal et planXY normal permettant de faire des vect normaux sans estimateNormal
51+
52+
53+
03/04
54+
55+
Essai d'implémentation de plusieurs technique de shadow, simple ou phong, aucune ne semble fonctionner correctement je pense a un problème sur l'évalutaion de la normale
56+
57+
Effectivement il s'agit bien de la donction normale qui ne marche pas le phong fonctionne bien sur les sphere mais il semble quand même avoir des strates visible dont je ne connais pas l'origine
58+
59+
j'ai ajouté un tableau global spheres qui pourrais techniquement dans le future contenir l'ensemble des sphères de la scéne.
60+
61+
Ajout des fonctions norme et fonction necessaires aux différentes implémentation des shadows.
62+
63+
06/04
64+
65+
Après un week-end où je n'ai pas pu avancer je me lance dans la conception de la fonction de rendering : raymarcheRay qui se vera passer un position et une direction et devra modifier la couleur passer en fonction de ce que le rayon percoit de la scène.
66+
67+
Premièrement on va essayer de déplacer ce qu'il y a dans le main dans cette fonction.
68+
69+
08/04
70+
71+
Le problème était dans le normalize3d on multipliait par le module au lieux de diviser
72+
73+
Il en résult que le phong ne marche plus
74+
75+
Une implémentation plus simple semble marcher mais le test en animation sur une obucle for semble ridiculement lent en terme de fps. Sans delay le temps entre frames on était proche du 4 fps avec une unique sphère dans la scène.
76+
77+
On envosagera l'utilisation de threads on testera avec 16 thread grace au module pthread puisque'il semble impossible d'utiliser le GPU sans openGL ou Cuda.

first results.docx

86.6 KB
Binary file not shown.

m3d.sln

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29920.165
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "m3d", "m3d\m3d.vcxproj", "{737EBDCB-FFF6-46FF-B328-39521ED8AE32}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{737EBDCB-FFF6-46FF-B328-39521ED8AE32}.Debug|x64.ActiveCfg = Debug|x64
17+
{737EBDCB-FFF6-46FF-B328-39521ED8AE32}.Debug|x64.Build.0 = Debug|x64
18+
{737EBDCB-FFF6-46FF-B328-39521ED8AE32}.Debug|x86.ActiveCfg = Debug|Win32
19+
{737EBDCB-FFF6-46FF-B328-39521ED8AE32}.Debug|x86.Build.0 = Debug|Win32
20+
{737EBDCB-FFF6-46FF-B328-39521ED8AE32}.Release|x64.ActiveCfg = Release|x64
21+
{737EBDCB-FFF6-46FF-B328-39521ED8AE32}.Release|x64.Build.0 = Release|x64
22+
{737EBDCB-FFF6-46FF-B328-39521ED8AE32}.Release|x86.ActiveCfg = Release|Win32
23+
{737EBDCB-FFF6-46FF-B328-39521ED8AE32}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {C1668551-B033-41BD-B174-089CF268108A}
30+
EndGlobalSection
31+
EndGlobal

m3d/SDL2.dll

1.16 MB
Binary file not shown.

m3d/camera.c

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <math.h>
2+
#include <stdlib.h>
3+
4+
#include "mathlib.h"
5+
#include "values.h"
6+
#include "camera.h"
7+
8+
void RotatePointsEcran(Vect3d* ecran, float phi, float theta, float gamma)
9+
{
10+
Mat3d rot = matriceRotationCamera(phi, theta, gamma);
11+
for (int i = 0; i < WINDOW_LENGHT * WINDOW_WIDTH; i++)
12+
{
13+
ecran[i] = matriceTvect3d(rot, ecran[i]);
14+
}
15+
}
16+
17+
18+
Vect3d* GeneratePointsEcran(Camera* c)
19+
{
20+
Vect3d* ecran;
21+
int i, j;
22+
float u, v;
23+
float deltaX, deltaZ;
24+
float n;
25+
ecran = malloc(sizeof(Vect3d) * WINDOW_LENGHT * WINDOW_WIDTH);
26+
27+
deltaX = c->d * tanf(FOV / 2) / WINDOW_WIDTH;
28+
deltaZ = deltaX;
29+
//deltaZ = c->d * tanf(FOV / 2) / WINDOW_LENGHT;
30+
31+
for (i = 0; i < WINDOW_LENGHT; i++)
32+
{
33+
u = (i - WINDOW_LENGHT / 2) * deltaX;
34+
for (j = 0; j < WINDOW_WIDTH; j++)
35+
{
36+
v = (j - WINDOW_WIDTH / 2) * deltaZ;
37+
n = 1 / sqrtf(v * v + c->d * c->d + u * u);
38+
ecran[i * WINDOW_WIDTH + j] = (Vect3d){v*n, c->d*n, u*n};
39+
}
40+
}
41+
return ecran;
42+
}

m3d/camera.h

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
typedef struct camera {
4+
float posx;
5+
float posy;
6+
float posz;
7+
float et;
8+
float ep;
9+
float eg;
10+
float d;
11+
}Camera;
12+
13+
Vect3d* GeneratePointsEcran(Camera *c);
14+
void RotatePointsEcran(Vect3d* ecran, float phi, float theta, float gamma);

m3d/m3d.vcxproj

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<ProjectGuid>{737EBDCB-FFF6-46FF-B328-39521ED8AE32}</ProjectGuid>
24+
<RootNamespace>m3d</RootNamespace>
25+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
26+
</PropertyGroup>
27+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
29+
<ConfigurationType>Application</ConfigurationType>
30+
<UseDebugLibraries>true</UseDebugLibraries>
31+
<PlatformToolset>v142</PlatformToolset>
32+
<CharacterSet>Unicode</CharacterSet>
33+
</PropertyGroup>
34+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
35+
<ConfigurationType>Application</ConfigurationType>
36+
<UseDebugLibraries>false</UseDebugLibraries>
37+
<PlatformToolset>v142</PlatformToolset>
38+
<WholeProgramOptimization>true</WholeProgramOptimization>
39+
<CharacterSet>Unicode</CharacterSet>
40+
</PropertyGroup>
41+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
42+
<ConfigurationType>Application</ConfigurationType>
43+
<UseDebugLibraries>true</UseDebugLibraries>
44+
<PlatformToolset>v142</PlatformToolset>
45+
<CharacterSet>Unicode</CharacterSet>
46+
</PropertyGroup>
47+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
48+
<ConfigurationType>Application</ConfigurationType>
49+
<UseDebugLibraries>false</UseDebugLibraries>
50+
<PlatformToolset>v142</PlatformToolset>
51+
<WholeProgramOptimization>true</WholeProgramOptimization>
52+
<CharacterSet>Unicode</CharacterSet>
53+
</PropertyGroup>
54+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
55+
<ImportGroup Label="ExtensionSettings">
56+
</ImportGroup>
57+
<ImportGroup Label="Shared">
58+
</ImportGroup>
59+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
60+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
61+
</ImportGroup>
62+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
63+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
64+
</ImportGroup>
65+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
66+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
67+
</ImportGroup>
68+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
69+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
70+
</ImportGroup>
71+
<PropertyGroup Label="UserMacros" />
72+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
73+
<LinkIncremental>true</LinkIncremental>
74+
</PropertyGroup>
75+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
76+
<LinkIncremental>true</LinkIncremental>
77+
</PropertyGroup>
78+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
79+
<LinkIncremental>false</LinkIncremental>
80+
</PropertyGroup>
81+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
82+
<LinkIncremental>false</LinkIncremental>
83+
</PropertyGroup>
84+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
85+
<ClCompile>
86+
<WarningLevel>Level3</WarningLevel>
87+
<SDLCheck>true</SDLCheck>
88+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
89+
<ConformanceMode>true</ConformanceMode>
90+
<AdditionalIncludeDirectories>C:\Development\SDL2\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
91+
</ClCompile>
92+
<Link>
93+
<SubSystem>Console</SubSystem>
94+
<GenerateDebugInformation>true</GenerateDebugInformation>
95+
<AdditionalLibraryDirectories>C:\Development\SDL2\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
96+
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
97+
</Link>
98+
</ItemDefinitionGroup>
99+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
100+
<ClCompile>
101+
<WarningLevel>Level3</WarningLevel>
102+
<SDLCheck>true</SDLCheck>
103+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
104+
<ConformanceMode>true</ConformanceMode>
105+
</ClCompile>
106+
<Link>
107+
<SubSystem>Console</SubSystem>
108+
<GenerateDebugInformation>true</GenerateDebugInformation>
109+
</Link>
110+
</ItemDefinitionGroup>
111+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
112+
<ClCompile>
113+
<WarningLevel>Level3</WarningLevel>
114+
<FunctionLevelLinking>true</FunctionLevelLinking>
115+
<IntrinsicFunctions>true</IntrinsicFunctions>
116+
<SDLCheck>true</SDLCheck>
117+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
118+
<ConformanceMode>true</ConformanceMode>
119+
<AdditionalIncludeDirectories>C:\Development\SDL2\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
120+
</ClCompile>
121+
<Link>
122+
<SubSystem>Console</SubSystem>
123+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
124+
<OptimizeReferences>true</OptimizeReferences>
125+
<GenerateDebugInformation>true</GenerateDebugInformation>
126+
<AdditionalLibraryDirectories>C:\Development\SDL2\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
127+
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
128+
</Link>
129+
</ItemDefinitionGroup>
130+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
131+
<ClCompile>
132+
<WarningLevel>Level3</WarningLevel>
133+
<FunctionLevelLinking>true</FunctionLevelLinking>
134+
<IntrinsicFunctions>true</IntrinsicFunctions>
135+
<SDLCheck>true</SDLCheck>
136+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
137+
<ConformanceMode>true</ConformanceMode>
138+
</ClCompile>
139+
<Link>
140+
<SubSystem>Console</SubSystem>
141+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
142+
<OptimizeReferences>true</OptimizeReferences>
143+
<GenerateDebugInformation>true</GenerateDebugInformation>
144+
</Link>
145+
</ItemDefinitionGroup>
146+
<ItemGroup>
147+
<ClCompile Include="camera.c" />
148+
<ClCompile Include="main.c" />
149+
<ClCompile Include="mathlib.c" />
150+
<ClCompile Include="objects.c" />
151+
<ClCompile Include="rendering.c" />
152+
</ItemGroup>
153+
<ItemGroup>
154+
<ClInclude Include="camera.h" />
155+
<ClInclude Include="mathlib.h" />
156+
<ClInclude Include="objects.h" />
157+
<ClInclude Include="rendering.h" />
158+
<ClInclude Include="values.h" />
159+
</ItemGroup>
160+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
161+
<ImportGroup Label="ExtensionTargets">
162+
</ImportGroup>
163+
</Project>

m3d/m3d.vcxproj.filters

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Fichiers sources">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Fichiers d%27en-tête">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Fichiers de ressources">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="main.c">
19+
<Filter>Fichiers sources</Filter>
20+
</ClCompile>
21+
<ClCompile Include="objects.c">
22+
<Filter>Fichiers sources</Filter>
23+
</ClCompile>
24+
<ClCompile Include="camera.c">
25+
<Filter>Fichiers sources</Filter>
26+
</ClCompile>
27+
<ClCompile Include="mathlib.c">
28+
<Filter>Fichiers sources</Filter>
29+
</ClCompile>
30+
<ClCompile Include="rendering.c">
31+
<Filter>Fichiers sources</Filter>
32+
</ClCompile>
33+
</ItemGroup>
34+
<ItemGroup>
35+
<ClInclude Include="objects.h">
36+
<Filter>Fichiers d%27en-tête</Filter>
37+
</ClInclude>
38+
<ClInclude Include="camera.h">
39+
<Filter>Fichiers d%27en-tête</Filter>
40+
</ClInclude>
41+
<ClInclude Include="mathlib.h">
42+
<Filter>Fichiers d%27en-tête</Filter>
43+
</ClInclude>
44+
<ClInclude Include="values.h">
45+
<Filter>Fichiers d%27en-tête</Filter>
46+
</ClInclude>
47+
<ClInclude Include="rendering.h">
48+
<Filter>Fichiers d%27en-tête</Filter>
49+
</ClInclude>
50+
</ItemGroup>
51+
</Project>

0 commit comments

Comments
 (0)