This commit is contained in:
Kraton99 2022-02-11 16:04:54 +01:00
parent b85eeca530
commit 739d2b1f3e
55 changed files with 0 additions and 1196 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\Adam\Desktop\graf\grafika\Debug\grk-cw2.exe</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
<SatelliteDlls />
<NonRecipeFileRefs />
</Project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,112 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<None Include="shaders\shader_color.frag" />
<None Include="shaders\shader_color.vert" />
<None Include="shaders\shader_tex.frag" />
<None Include="shaders\shader_tex.vert" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\Box.cpp" />
<ClCompile Include="src\Camera.cpp" />
<ClCompile Include="src\main_2_1a.cpp" />
<ClCompile Include="src\Render_Utils.cpp" />
<ClCompile Include="src\Shader_Loader.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Camera.h" />
<ClInclude Include="src\Render_Utils.h" />
<ClInclude Include="src\Shader_Loader.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B4031E08-6274-4FFD-B41C-F8EA29E977FB}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>grk-cw9</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>grk-cw2</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>false</LinkIncremental>
<LibraryPath>$(SolutionDir)dependencies\freeglut\lib;$(SolutionDir)dependencies\glew-2.0.0\lib\Release\Win32;$(SolutionDir)dependencies\assimp;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)dependencies\freeglut\include\GL;$(SolutionDir)dependencies\glew-2.0.0\include\GL;$(SolutionDir)dependencies\glm;$(SolutionDir)dependencies\assimp\include;$(IncludePath)</IncludePath>
<ExecutablePath>$(ExecutablePath)</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(SolutionDir)dependencies\freeglut\include\GL;$(SolutionDir)dependencies\glew-2.0.0\include\GL;$(SolutionDir)dependencies\glm;$(SolutionDir)dependencies\assimp\include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)dependencies\freeglut\lib;$(SolutionDir)dependencies\glew-2.0.0\lib\Release\Win32;$(SolutionDir)dependencies\assimp\Release;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)dependencies\physx-4.1\include;$(SolutionDir)dependencies\physx-4.1\source\common\include;$(SolutionDir)dependencies\physx-4.1\source\common\src;$(SolutionDir)dependencies\physx-4.1\source\physx\src;$(SolutionDir)dependencies\physx-4.1\source\physx\src\device;$(SolutionDir)dependencies\physx-4.1\source\physx\src\buffering;$(SolutionDir)dependencies\physx-4.1\source\physxgpu\include;$(SolutionDir)dependencies\physx-4.1\source\geomutils\include;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\contact;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\common;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\convex;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\distance;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\sweep;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\gjk;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\intersection;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\mesh;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\hf;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\pcm;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\ccd;$(SolutionDir)dependencies\physx-4.1\source\lowlevel\api\include;$(SolutionDir)dependencies\physx-4.1\source\lowlevel\software\include;$(SolutionDir)dependencies\physx-4.1\source\lowlevel\common\include\pipeline;$(SolutionDir)dependencies\physx-4.1\source\lowlevelaabb\include;$(SolutionDir)dependencies\physx-4.1\source\lowleveldynamics\include;$(SolutionDir)dependencies\physx-4.1\source\simulationcontroller\include;$(SolutionDir)dependencies\physx-4.1\source\simulationcontroller\src;$(SolutionDir)dependencies\physx-4.1\source\physxcooking\src;$(SolutionDir)dependencies\physx-4.1\source\physxcooking\src\mesh;$(SolutionDir)dependencies\physx-4.1\source\physxcooking\src\convex;$(SolutionDir)dependencies\physx-4.1\source\scenequery\include;$(SolutionDir)dependencies\physx-4.1\source\physxmetadata\core\include;$(SolutionDir)dependencies\physx-4.1\source\immediatemode\include;$(SolutionDir)dependencies\physx-4.1\source\pvd\include;$(SolutionDir)dependencies\physx-4.1\source\foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\debug\PhysXExtensions_static_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\debug\PhysX_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\debug\PhysXPvdSDK_static_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\debug\PhysXVehicle_static_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\debug\PhysXCharacterKinematic_static_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\debug\PhysXCooking_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\debug\PhysXCommon_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\debug\SnippetUtils_static_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\debug\SnippetRender_static_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\debug\PhysXFoundation_32.lib;opengl32.lib;freeglut.lib;glew32.lib;zlibd.lib;assimp-vc141-mtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)dependencies\physx-4.1\include;$(SolutionDir)dependencies\physx-4.1\source\common\include;$(SolutionDir)dependencies\physx-4.1\source\common\src;$(SolutionDir)dependencies\physx-4.1\source\physx\src;$(SolutionDir)dependencies\physx-4.1\source\physx\src\device;$(SolutionDir)dependencies\physx-4.1\source\physx\src\buffering;$(SolutionDir)dependencies\physx-4.1\source\physxgpu\include;$(SolutionDir)dependencies\physx-4.1\source\geomutils\include;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\contact;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\common;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\convex;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\distance;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\sweep;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\gjk;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\intersection;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\mesh;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\hf;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\pcm;$(SolutionDir)dependencies\physx-4.1\source\geomutils\src\ccd;$(SolutionDir)dependencies\physx-4.1\source\lowlevel\api\include;$(SolutionDir)dependencies\physx-4.1\source\lowlevel\software\include;$(SolutionDir)dependencies\physx-4.1\source\lowlevel\common\include\pipeline;$(SolutionDir)dependencies\physx-4.1\source\lowlevelaabb\include;$(SolutionDir)dependencies\physx-4.1\source\lowleveldynamics\include;$(SolutionDir)dependencies\physx-4.1\source\simulationcontroller\include;$(SolutionDir)dependencies\physx-4.1\source\simulationcontroller\src;$(SolutionDir)dependencies\physx-4.1\source\physxcooking\src;$(SolutionDir)dependencies\physx-4.1\source\physxcooking\src\mesh;$(SolutionDir)dependencies\physx-4.1\source\physxcooking\src\convex;$(SolutionDir)dependencies\physx-4.1\source\scenequery\include;$(SolutionDir)dependencies\physx-4.1\source\physxmetadata\core\include;$(SolutionDir)dependencies\physx-4.1\source\immediatemode\include;$(SolutionDir)dependencies\physx-4.1\source\pvd\include;$(SolutionDir)dependencies\physx-4.1\source\foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\release\PhysXExtensions_static_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\release\PhysX_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\release\PhysXPvdSDK_static_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\release\PhysXVehicle_static_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\release\PhysXCharacterKinematic_static_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\release\PhysXCooking_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\release\PhysXCommon_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\release\SnippetUtils_static_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\release\SnippetRender_static_32.lib;$(SolutionDir)dependencies\physx-4.1\lib\win.x86_32.vc141.mt\release\PhysXFoundation_32.lib;opengl32.lib;freeglut.lib;glew32.lib;zlib.lib;assimp-vc141-mt.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Shader Files">
<UniqueIdentifier>{0a247bb8-2e8e-4a90-b0ef-17415b0941ba}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="shaders\shader_color.frag">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_color.vert">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_tex.frag">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_tex.vert">
<Filter>Shader Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\Shader_Loader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Box.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Camera.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Render_Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\main_2_1a.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Shader_Loader.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\Camera.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\Render_Utils.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1,7 +0,0 @@
import os
rootdir = './'
for filename in os.listdir(rootdir):
if filename.endswith(".md"):
name = filename[:-3]
os.system(f'pandoc -s -o {name}.html {name}.md --css style.css')

View File

@ -1,8 +0,0 @@
#version 430 core
in vec4 color;
void main()
{
gl_FragColor = color;
}

View File

@ -1,14 +0,0 @@
#version 430 core
layout(location = 0) in vec4 vertexPosition;
layout(location = 1) in vec4 vertexColor;
uniform mat4 transformation;
out vec4 color;
void main()
{
color = vertexColor;
gl_Position = transformation * vertexPosition;
}

View File

@ -1,16 +0,0 @@
#version 430 core
out vec4 fragColor;
in float hue;
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main()
{
fragColor = vec4(hsv2rgb(vec3(hue,1,1)), 1.0);
}

View File

@ -1,11 +0,0 @@
#version 430 core
layout(location = 0) in vec4 vertexPosition;
layout(location = 1) in float vertexHue;
out float hue;
void main()
{
hue = vertexHue;
gl_Position = vertexPosition;
}

View File

@ -1,6 +0,0 @@
#version 430 core
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

View File

@ -1,12 +0,0 @@
#version 430 core
layout(location = 0) in vec3 vertexPosition;
layout(location = 1) in vec2 vertexTexCoord;
layout(location = 2) in vec3 vertexNormal;
uniform mat4 transformation;
void main()
{
gl_Position = transformation * vec4(vertexPosition, 1.0);
}

View File

@ -1,6 +0,0 @@
#version 430 core
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

View File

@ -1,13 +0,0 @@
#version 430 core
layout(location = 0) in vec3 vertexPosition;
layout(location = 1) in vec2 vertexTexCoord;
layout(location = 2) in vec3 vertexNormal;
uniform mat4 transformation;
uniform mat4 model;
void main()
{
gl_Position = transformation * model * vec4(vertexPosition, 1.0);
}

View File

@ -1,104 +0,0 @@
// dane 36 wierzcholkow i kolorow opisujace model pudelka
const float boxPositions[] = {
0.25f, 0.25f, 0.75f, 1.0f,
0.25f, -0.25f, 0.75f, 1.0f,
-0.25f, 0.25f, 0.75f, 1.0f,
0.25f, -0.25f, 0.75f, 1.0f,
-0.25f, -0.25f, 0.75f, 1.0f,
-0.25f, 0.25f, 0.75f, 1.0f,
0.25f, 0.25f, -0.75f, 1.0f,
-0.25f, 0.25f, -0.75f, 1.0f,
0.25f, -0.25f, -0.75f, 1.0f,
0.25f, -0.25f, -0.75f, 1.0f,
-0.25f, 0.25f, -0.75f, 1.0f,
-0.25f, -0.25f, -0.75f, 1.0f,
-0.25f, 0.25f, 0.75f, 1.0f,
-0.25f, -0.25f, 0.75f, 1.0f,
-0.25f, -0.25f, -0.75f, 1.0f,
-0.25f, 0.25f, 0.75f, 1.0f,
-0.25f, -0.25f, -0.75f, 1.0f,
-0.25f, 0.25f, -0.75f, 1.0f,
0.25f, 0.25f, 0.75f, 1.0f,
0.25f, -0.25f, -0.75f, 1.0f,
0.25f, -0.25f, 0.75f, 1.0f,
0.25f, 0.25f, 0.75f, 1.0f,
0.25f, 0.25f, -0.75f, 1.0f,
0.25f, -0.25f, -0.75f, 1.0f,
0.25f, 0.25f, -0.75f, 1.0f,
0.25f, 0.25f, 0.75f, 1.0f,
-0.25f, 0.25f, 0.75f, 1.0f,
0.25f, 0.25f, -0.75f, 1.0f,
-0.25f, 0.25f, 0.75f, 1.0f,
-0.25f, 0.25f, -0.75f, 1.0f,
0.25f, -0.25f, -0.75f, 1.0f,
-0.25f, -0.25f, 0.75f, 1.0f,
0.25f, -0.25f, 0.75f, 1.0f,
0.25f, -0.25f, -0.75f, 1.0f,
-0.25f, -0.25f, -0.75f, 1.0f,
-0.25f, -0.25f, 0.75f, 1.0f,
};
const float boxColors[] = {
0.0f, 0.0f, 1.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f,
0.8f, 0.8f, 0.8f, 1.0f,
0.8f, 0.8f, 0.8f, 1.0f,
0.8f, 0.8f, 0.8f, 1.0f,
0.8f, 0.8f, 0.8f, 1.0f,
0.8f, 0.8f, 0.8f, 1.0f,
0.8f, 0.8f, 0.8f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f,
0.5f, 0.5f, 0.0f, 1.0f,
0.5f, 0.5f, 0.0f, 1.0f,
0.5f, 0.5f, 0.0f, 1.0f,
0.5f, 0.5f, 0.0f, 1.0f,
0.5f, 0.5f, 0.0f, 1.0f,
0.5f, 0.5f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f, 1.0f, 1.0f,
0.0f, 1.0f, 1.0f, 1.0f,
0.0f, 1.0f, 1.0f, 1.0f,
0.0f, 1.0f, 1.0f, 1.0f,
0.0f, 1.0f, 1.0f, 1.0f,
0.0f, 1.0f, 1.0f, 1.0f,
};

View File

@ -1,32 +0,0 @@
#include "Camera.h"
glm::mat4 Core::createPerspectiveMatrix(float zNear, float zFar)
{
const float frustumScale = 1.0f;
glm::mat4 perspective;
perspective[0][0] = frustumScale;
perspective[1][1] = frustumScale;
perspective[2][2] = (zFar + zNear) / (zNear - zFar);
perspective[3][2] = (2 * zFar * zNear) / (zNear - zFar);
perspective[2][3] = -1;
perspective[3][3] = 0;
return perspective;
}
glm::mat4 Core::createViewMatrix( glm::vec3 position, glm::vec3 forward, glm::vec3 up )
{
glm::vec3 side = glm::cross(forward, up);
// Trzeba pamietac o minusie przy ustawianiu osi Z kamery.
// Wynika to z tego, ze standardowa macierz perspektywiczna zaklada, ze "z przodu" jest ujemna (a nie dodatnia) czesc osi Z.
glm::mat4 cameraRotation;
cameraRotation[0][0] = side.x; cameraRotation[1][0] = side.y; cameraRotation[2][0] = side.z;
cameraRotation[0][1] = up.x; cameraRotation[1][1] = up.y; cameraRotation[2][1] = up.z;
cameraRotation[0][2] = -forward.x; cameraRotation[1][2] = -forward.y; cameraRotation[2][2] = -forward.z;
glm::mat4 cameraTranslation;
cameraTranslation[3] = glm::vec4(-position, 1.0f);
return cameraRotation * cameraTranslation;
}

View File

@ -1,14 +0,0 @@
#pragma once
#include "glm.hpp"
namespace Core
{
glm::mat4 createPerspectiveMatrix(float zNear = 0.1f, float zFar = 100.0f);
// position - pozycja kamery
// forward - wektor "do przodu" kamery (jednostkowy)
// up - wektor "w gore" kamery (jednostkowy)
// up i forward musza byc ortogonalne!
glm::mat4 createViewMatrix(glm::vec3 position, glm::vec3 forward, glm::vec3 up);
}

View File

@ -1,21 +0,0 @@
#include "Render_Utils.h"
#include <algorithm>
#include "glew.h"
#include "freeglut.h"
void Core::DrawContext(Core::RenderContext& context)
{
glBindVertexArray(context.vertexArray);
glDrawElements(
GL_TRIANGLES, // mode
context.size, // count
GL_UNSIGNED_SHORT, // type
(void*)0 // element array buffer offset
);
glBindVertexArray(0);
}

View File

@ -1,68 +0,0 @@
#pragma once
#include "glm.hpp"
#include "glew.h"
//#include "objload.h"
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <vector>
#include <iostream>
#define BUFFER_OFFSET(i) ((void*)(i))
namespace Core
{
struct RenderContext {
GLuint vertexArray;
GLuint vertexBuffer;
GLuint vertexIndexBuffer;
unsigned int size = 0;
void initFromAiMesh(aiMesh* mesh) {
vertexArray = 0;
vertexBuffer = 0;
vertexIndexBuffer = 0;
std::vector<float> textureCoord;
std::vector<unsigned int> indices;
//tex coord must be converted to 2d vecs
for (unsigned int i = 0; i < mesh->mNumVertices; i++)
{
if (mesh->mTextureCoords[0] != nullptr) {
textureCoord.push_back(mesh->mTextureCoords[0][i].x);
textureCoord.push_back(mesh->mTextureCoords[0][i].y);
}
else {
textureCoord.push_back(0.0f);
textureCoord.push_back(0.0f);
}
}
if (mesh->mTextureCoords[0] == nullptr) {
std::cout << "no uv coords\n";
}
for (unsigned int i = 0; i < mesh->mNumFaces; i++)
{
aiFace face = mesh->mFaces[i];
// retrieve all indices of the face and store them in the indices vector
for (unsigned int j = 0; j < face.mNumIndices; j++)
indices.push_back(face.mIndices[j]);
}
unsigned int vertexDataBufferSize = sizeof(float) * mesh->mNumVertices * 3;
unsigned int vertexNormalBufferSize = sizeof(float) * mesh->mNumVertices * 3;
unsigned int vertexTexBufferSize = sizeof(float) * mesh->mNumVertices * 2;
}
~RenderContext() {
glDeleteBuffers(1, &vertexBuffer);
glDeleteBuffers(1, &vertexIndexBuffer);
glDeleteVertexArrays(1, &vertexArray);
}
};
void DrawContext(RenderContext& context);
}

View File

@ -1,102 +0,0 @@
#include "Shader_Loader.h"
#include<iostream>
#include<fstream>
#include<vector>
using namespace Core;
Shader_Loader::Shader_Loader(void){}
Shader_Loader::~Shader_Loader(void){}
std::string Shader_Loader::ReadShader(char *filename)
{
std::string shaderCode;
std::ifstream file(filename, std::ios::in);
if (!file.good())
{
std::cout << "Can't read file " << filename << std::endl;
std::terminate();
}
file.seekg(0, std::ios::end);
shaderCode.resize((unsigned int)file.tellg());
file.seekg(0, std::ios::beg);
file.read(&shaderCode[0], shaderCode.size());
file.close();
return shaderCode;
}
GLuint Shader_Loader::CreateShader(GLenum shaderType, std::string
source, char* shaderName)
{
int compile_result = 0;
GLuint shader = glCreateShader(shaderType);
const char *shader_code_ptr = source.c_str();
const int shader_code_size = source.size();
glShaderSource(shader, 1, &shader_code_ptr, &shader_code_size);
glCompileShader(shader);
glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_result);
//sprawdz bledy
if (compile_result == GL_FALSE)
{
int info_log_length = 0;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &info_log_length);
std::vector<char> shader_log(info_log_length);
glGetShaderInfoLog(shader, info_log_length, NULL, &shader_log[0]);
std::cout << "ERROR compiling shader: " << shaderName << std::endl << &shader_log[0] << std::endl;
return 0;
}
return shader;
}
GLuint Shader_Loader::CreateProgram(char* vertexShaderFilename,
char* fragmentShaderFilename)
{
//wczytaj shadery
std::string vertex_shader_code = ReadShader(vertexShaderFilename);
std::string fragment_shader_code = ReadShader(fragmentShaderFilename);
GLuint vertex_shader = CreateShader(GL_VERTEX_SHADER, vertex_shader_code, "vertex shader");
GLuint fragment_shader = CreateShader(GL_FRAGMENT_SHADER, fragment_shader_code, "fragment shader");
int link_result = 0;
//stworz shader
GLuint program = glCreateProgram();
glAttachShader(program, vertex_shader);
glAttachShader(program, fragment_shader);
glLinkProgram(program);
glGetProgramiv(program, GL_LINK_STATUS, &link_result);
//sprawdz bledy w linkerze
if (link_result == GL_FALSE)
{
int info_log_length = 0;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_log_length);
std::vector<char> program_log(info_log_length);
glGetProgramInfoLog(program, info_log_length, NULL, &program_log[0]);
std::cout << "Shader Loader : LINK ERROR" << std::endl << &program_log[0] << std::endl;
return 0;
}
glDetachShader(program, vertex_shader);
glDetachShader(program, fragment_shader);
glDeleteShader(vertex_shader);
glDeleteShader(fragment_shader);
return program;
}
void Shader_Loader::DeleteProgram( GLuint program )
{
glDeleteProgram(program);
}

View File

@ -1,29 +0,0 @@
#pragma once
#include "glew.h"
#include "freeglut.h"
#include <iostream>
namespace Core
{
class Shader_Loader
{
private:
std::string ReadShader(char *filename);
GLuint CreateShader(GLenum shaderType,
std::string source,
char* shaderName);
public:
Shader_Loader(void);
~Shader_Loader(void);
GLuint CreateProgram(char* VertexShaderFilename,
char* FragmentShaderFilename);
void DeleteProgram(GLuint program);
};
}

View File

@ -1,102 +0,0 @@
#include "glew.h"
#include "freeglut.h"
#include "glm.hpp"
#include "ext.hpp"
#include <iostream>
#include <cmath>
#include "Shader_Loader.h"
#include "Render_Utils.h"
#include "Box.cpp"
GLuint program;
Core::Shader_Loader shaderLoader;
unsigned int VAO;
void renderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
// ZADANIE: W zalaczonym wyzej pliku Box.cpp znajduja sie tablice pozycji i kolorow wierzcholkow prostopadloscianu. Przesun go o wektor (0.5, 0.5, -0.2) i wyswietl go.
//
// Do shadera uzytego w tym zadaniu nalezy przeslac nie tylko pozycje, ale rowniez kolory wierzcholkow.
// W funkcji init należy przesłać pozycje i kolory do GPU
glUseProgram(program);
// Powiąż stworzone VAO za pomocą funkcji glBindVertexArray
// wykorzystaj glDrawArrays do narysowania prostopadłościanu
glm::mat4 transformation;
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUseProgram(0);
glutSwapBuffers();
}
void init()
{
glEnable(GL_DEPTH_TEST);
program = shaderLoader.CreateProgram("shaders/shader_2_1.vert", "shaders/shader_2_1.frag");
// Dokładny opis działania funkcji z poniższych punktów można znaleźć na slajdach z wykładu, w dokumentacji https://www.khronos.org/registry/OpenGL-Refpages/gl4/ funkcje są opisane także na stronach https://learnopengl.com/Getting-started/Hello-Triangle oraz https://open.gl/drawing
// Zainicjalizuj VertexArrayObject (VAO) i zapisz w nim atrybuty prostopadłościanu
// I Stwórz VAO
// 1. Stwórz nowy VAO za pomocą glGenVertexArrays i przypisz jego adres do zmiennej globalnej
// 2. Powiąż stworzone VAO za pomocą funkcji glBindVertexArray
// II Zainicjalizuj VBO
// 3. Stwórz VertexBufferObject do przechowywania pozycji wierzchołków za pomocą funkcji glGenBuffers
// 4. Powiąż stworzone VBO za pomocą funkcji glBindBuffer(GLenum target, GLuint )
// 5. Zaalokuj w GPU miejsce na tablice wierzchołków i kolorów za pomocą glBufferData pamiętaj, żeby zaalokować dość miejsca dla punktów i kolorów
// III Prześlij dane do karty graficznej
// A) Prześlij pozycję wierzchołków do karty graficznej
// 6. Aktywuj atrybut powiązany z pozycją wierchołków za pomocą glEnableVertexAttribArray(GLuint index). Indeks jest zapisany w shaderze wierzchołków w 3. lini. Można odpytać shader o indeks za pomocą funkcji glGetAttribLocation(GL uint program, const GLchar *name)
// 7. Przekaż dane za pomocą glBufferSubData
// 8. Zdefiniuj jak OpenGL powinien interpretować dane za pomocą glVertexAttribPointer
// B) powtórz punkty 6-8 by przesłać wartości odpowiadające za kolor
// 9. Uwolnij VAO za pomocą funkcji glBindVertexArray(0)
}
void shutdown()
{
shaderLoader.DeleteProgram(program);
}
void idle()
{
glutPostRedisplay();
}
int main(int argc, char ** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(200, 200);
glutInitWindowSize(600, 600);
glutCreateWindow("OpenGL Pierwszy Program");
glewInit();
init();
glutDisplayFunc(renderScene);
glutIdleFunc(idle);
glutMainLoop();
shutdown();
return 0;
}

View File

@ -1,85 +0,0 @@
#include "glew.h"
#include "freeglut.h"
#include "glm.hpp"
#include "ext.hpp"
#include <iostream>
#include <cmath>
#include "Shader_Loader.h"
#include "Render_Utils.h"
#include "Box.cpp"
float points[] = {
0.0f,1.0f,0.f,1.f,
0.7818314824680298f,0.6234898018587336f,0.f,1.f,
0.9749279121818236f,-0.22252093395631434f,0.f,1.f,
0.43388373911755823f,-0.900968867902419f,0.f,1.f,
-0.433883739117558f,-0.9009688679024191f,0.f,1.f,
-0.9749279121818236f,-0.2225209339563146f,0.f,1.f,
-0.7818314824680299f,0.6234898018587334f,0.f,1.f,
};
float hues[] = {
0.0, 0.7142857142857143, 0.42857142857142855, 0.14285714285714285, 0.8571428571428571, 0.5714285714285714, 0.2857142857142857
};
GLuint program;
Core::Shader_Loader shaderLoader;
unsigned int VAO;
void renderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
// ZADANIE: Powyżej w tablicy points znajdują się wierzchołki 7-kąta foremnego, zadanie polega na narysowaniu gwiazdy siedmioramiennej jak na obrazku zad1b.jpg. Do shadera należy przesłać pozycje wierzchołków i ich odcienie z tablicy hues podobnie jak w zadaniu 1a.
// Idealnie rozwiązane zadanie wymaga użycia indeksowania z użyciem Element Buffer Objects oraz trybu rysowania GL_LINE_STRIP
// (dodatkowe) Jedna krawędź przechodzi przez wszystkie odcienie zamiast z czerwonego do magenty. Co to powoduje? W jaki sposób byś to naprawił?
glUseProgram(program);
glUseProgram(0);
glutSwapBuffers();
}
void init()
{
glEnable(GL_DEPTH_TEST);
program = shaderLoader.CreateProgram("shaders/shader_2_1b.vert", "shaders/shader_2_1b.frag");
}
void shutdown()
{
shaderLoader.DeleteProgram(program);
}
void idle()
{
glutPostRedisplay();
}
int main(int argc, char ** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(200, 200);
glutInitWindowSize(600, 600);
glutCreateWindow("OpenGL Pierwszy Program");
glewInit();
init();
glutDisplayFunc(renderScene);
glutIdleFunc(idle);
glutMainLoop();
shutdown();
return 0;
}

View File

@ -1,119 +0,0 @@
#include "glew.h"
#include "freeglut.h"
#include "glm.hpp"
#include "ext.hpp"
#include <iostream>
#include <cmath>
#include "Shader_Loader.h"
#include "Render_Utils.h"
#include "Camera.h"
#include "Box.cpp"
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <string>
GLuint program;
Core::Shader_Loader shaderLoader;
Core::RenderContext shipContext;
Core::RenderContext sphereContext;
float cameraAngle = 0;
glm::vec3 cameraPos = glm::vec3(-5, 0, 0);
glm::vec3 cameraDir;
void keyboard(unsigned char key, int x, int y)
{
float angleSpeed = 0.1f;
float moveSpeed = 0.1f;
switch(key)
{
case 'a': cameraAngle -= angleSpeed; break;
case 'd': cameraAngle += angleSpeed; break;
case 'w': cameraPos += cameraDir * moveSpeed; break;
case 's': cameraPos -= cameraDir * moveSpeed; break;
}
}
glm::mat4 createCameraMatrix()
{
cameraDir = glm::vec3(cosf(cameraAngle), 0.0f, sinf(cameraAngle));
glm::vec3 up = glm::vec3(0,1,0);
return Core::createViewMatrix(cameraPos, cameraDir, up);
}
void renderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
glUseProgram(program);
glm::mat4 camera = createCameraMatrix();
glm::mat4 perspective = Core::createPerspectiveMatrix();
glm::mat4 transformation = perspective * camera;
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUseProgram(0);
glutSwapBuffers();
}
void init()
{
glEnable(GL_DEPTH_TEST);
program = shaderLoader.CreateProgram("shaders/shader_2_2.vert", "shaders/shader_2_2.frag");
}
void shutdown()
{
shaderLoader.DeleteProgram(program);
}
void loadModelToContext(std::string path,Core::RenderContext& context)
{
Assimp::Importer import;
const aiScene* scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_CalcTangentSpace);
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
{
std::cout << "ERROR::ASSIMP::" << import.GetErrorString() << std::endl;
return;
}
}
void idle()
{
glutPostRedisplay();
}
int main(int argc, char ** argv)
{
loadModelToContext(".\\models\\spaceship.obj", sphereContext);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(200, 200);
glutInitWindowSize(600, 600);
glutCreateWindow("OpenGL Pierwszy Program");
glewInit();
init();
glutKeyboardFunc(keyboard);
glutDisplayFunc(renderScene);
glutIdleFunc(idle);
glutMainLoop();
shutdown();
return 0;
}

View File

@ -1,107 +0,0 @@
html { font-size: 100%; overflow-y: scroll; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
body{
color:#444;
font-family:Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman', serif;
font-size:12px;
line-height:1.5em;
padding:1em;
margin:auto;
max-width:42em;
background:#fefefe;
}
a{ color: #0645ad; text-decoration:none;}
a:visited{ color: #0b0080; }
a:hover{ color: #06e; }
a:active{ color:#faa700; }
a:focus{ outline: thin dotted; }
a:hover, a:active{ outline: 0; }
::-moz-selection{background:rgba(255,255,0,0.3);color:#000}
::selection{background:rgba(255,255,0,0.3);color:#000}
a::-moz-selection{background:rgba(255,255,0,0.3);color:#0645ad}
a::selection{background:rgba(255,255,0,0.3);color:#0645ad}
p{
margin:1em 0;
}
img{
max-width:100%;
}
h1,h2,h3,h4,h5,h6{
font-weight:normal;
color:#111;
line-height:1em;
}
h4,h5,h6{ font-weight: bold; }
h1{ font-size:2.5em; }
h2{ font-size:2em; }
h3{ font-size:1.5em; }
h4{ font-size:1.2em; }
h5{ font-size:1em; }
h6{ font-size:0.9em; }
blockquote{
color:#666666;
margin:0;
padding-left: 3em;
border-left: 0.5em #EEE solid;
}
hr { display: block; height: 2px; border: 0; border-top: 1px solid #aaa;border-bottom: 1px solid #eee; margin: 1em 0; padding: 0; }
pre, code, kbd, samp { color: #000; font-family: monospace, monospace; _font-family: 'courier new', monospace; font-size: 0.98em; }
pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; }
b, strong { font-weight: bold; }
dfn { font-style: italic; }
ins { background: #ff9; color: #000; text-decoration: none; }
mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; }
sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
sup { top: -0.5em; }
sub { bottom: -0.25em; }
ul, ol { margin: 1em 0; padding: 0 0 0 2em; }
li p:last-child { margin:0 }
dd { margin: 0 0 0 2em; }
img { border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; }
table {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
}
th { border-bottom: 1px solid black; }
td { vertical-align: top; }
@media only screen and (min-width: 480px) {
body{font-size:14px;}
}
@media only screen and (min-width: 768px) {
body{font-size:16px;}
}
@media print {
* { background: transparent !important; color: black !important; filter:none !important; -ms-filter: none !important; }
body{font-size:12pt; max-width:100%;}
a, a:visited { text-decoration: underline; }
hr { height: 1px; border:0; border-bottom:1px solid black; }
a[href]:after { content: " (" attr(href) ")"; }
abbr[title]:after { content: " (" attr(title) ")"; }
.ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; }
pre, blockquote { border: 1px solid #999; padding-right: 1em; page-break-inside: avoid; }
tr, img { page-break-inside: avoid; }
img { max-width: 100% !important; }
@page :left { margin: 15mm 20mm 15mm 10mm; }
@page :right { margin: 15mm 10mm 15mm 20mm; }
p, h2, h3 { orphans: 3; widows: 3; }
h2, h3 { page-break-after: avoid; }
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

View File

@ -1,103 +0,0 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>zadanie_2_2</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
</style>
<link rel="stylesheet" href="style.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<h1 id="ładowanie-modeli">Ładowanie modeli</h1>
<p>w tym zadaniu przećwiczymy ładowanie modeli z plików, wykorzystamy do tego bibliotekę assimp (The Open Asset Import Library ), która zapewnia wspólny interfejs dla różnych typów plików.</p>
<p>Funkcja <code>loadModelToContext</code> pobiera ścieżkę do pliku z modelem i wczytuje go przy użyciu importera assimp.</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="at">const</span> aiScene* scene = <span class="kw">import</span>.ReadFile(path, aiProcess_TriangulateaiProcess_Triangulate | aiProcess_CalcTangentSpace);</span></code></pre></div>
<p>Importer przyjmuje ścieżkę i flagi preprocesingu, które mówią jakie operacje ma wykonać importer przed przekazaniem nam pliku. W naszym przypadku dokonuje triangularyzacji (zamienia wszystkie wielokąty na trójkąty) i oblicza przestrzeń styczną (o której będzie mowa później).</p>
<blockquote>
<p>Wywołaj funkcję dla ścieżki do statku <strong>./models/spaceship.obj</strong> i zmiennej globalnej <code>Core::RenderContext sphereContext</code>. Dodaj breakpoint po załadowaniu sceny i obejrzyj jak wygląda struktura załadowanego obiektu</p>
</blockquote>
<p>Załadowany obiekt posiada szereg pól jak na przykład tekstury, oświetlenia, materiały, węzły (<em>Node</em>) czy modele. Węzły odpowiadają za hierarchię elementów w modelu, co ułatwia jego animację, wykorzystamy to w późniejszych zajęciach, w trakcie tych zajęć będziemy się skupiać na modelach. Nasze obiekty składają się z tylko jednego modelu, wywołaj <code>context.initFromAiMesh</code> z nim jako argumentem.</p>
<h3 id="zadanie">Zadanie</h3>
<p>Jeśli tego nie zrobiłeś wywołaj metodę <code>context.initFromAiMesh</code> z argumentem<code>scene-&gt;mMeshes[0]</code> po wczytaniu sceny. Metoda nie jest kompletna, uzupełnij ją o ładowanie indeksów, wierzchołków, normalnych i współrzędnych tekstur do bufora. Współrzędne tekstur i indeksy zostały przekonwertowane do odpowiedniego formatu i znajdują się w zmiennych <code>std::vector&lt;float&gt; textureCoord</code> i <code>std::vector&lt;unsigned int&gt; indices</code> odpowiednio. Pozostałe są dostępne jako atrybuty <code>aiMesh</code>, mianowicie <code>mesh-&gt;mVertices</code> zawiera wierzchołki a <code>mesh-&gt;mNormals</code> normalne</p>
<p>Dodatkowo</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode c++"><code class="sourceCode cpp"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="dt">unsigned</span> <span class="dt">int</span> vertexDataBufferSize = <span class="kw">sizeof</span>(<span class="dt">float</span>) * mesh-&gt;mNumVertices * <span class="dv">3</span>;</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="dt">unsigned</span> <span class="dt">int</span> vertexNormalBufferSize = <span class="kw">sizeof</span>(<span class="dt">float</span>) * mesh-&gt;mNumVertices * <span class="dv">3</span>;</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="dt">unsigned</span> <span class="dt">int</span> vertexTexBufferSize = <span class="kw">sizeof</span>(<span class="dt">float</span>) * mesh-&gt;mNumVertices * <span class="dv">2</span>;</span></code></pre></div>
<p>zawierają rozmiary buforów.</p>
<p>Wykorzystaj w <code>renderScene</code> funkcję <code>Core::DrawContext(Core::RenderContext&amp; context)</code></p>
</body>
</html>

View File

@ -1,32 +0,0 @@
# Ładowanie modeli
w tym zadaniu przećwiczymy ładowanie modeli z plików, wykorzystamy do tego bibliotekę assimp (The Open Asset Import Library ), która zapewnia wspólny interfejs dla różnych typów plików.
Funkcja `loadModelToContext` pobiera ścieżkę do pliku z modelem i wczytuje go przy użyciu importera assimp.
```c++
const aiScene* scene = import.ReadFile(path, aiProcess_TriangulateaiProcess_Triangulate | aiProcess_CalcTangentSpace);
```
Importer przyjmuje ścieżkę i flagi preprocesingu, które mówią jakie operacje ma wykonać importer przed przekazaniem nam pliku. W naszym przypadku dokonuje triangularyzacji (zamienia wszystkie wielokąty na trójkąty) i oblicza przestrzeń styczną (o której będzie mowa później).
> Wywołaj funkcję dla ścieżki do statku **./models/spaceship.obj** i zmiennej globalnej `Core::RenderContext sphereContext`. Dodaj breakpoint po załadowaniu sceny i obejrzyj jak wygląda struktura załadowanego obiektu
Załadowany obiekt posiada szereg pól jak na przykład tekstury, oświetlenia, materiały, węzły (*Node*) czy modele. Węzły odpowiadają za hierarchię elementów w modelu, co ułatwia jego animację, wykorzystamy to w późniejszych zajęciach, w trakcie tych zajęć będziemy się skupiać na modelach. Nasze obiekty składają się z tylko jednego modelu, wywołaj `context.initFromAiMesh` z nim jako argumentem.
### Zadanie
Jeśli tego nie zrobiłeś wywołaj metodę `context.initFromAiMesh` z argumentem`scene->mMeshes[0]` po wczytaniu sceny. Metoda nie jest kompletna, uzupełnij ją o ładowanie indeksów, wierzchołków, normalnych i współrzędnych tekstur do bufora. Współrzędne tekstur i indeksy zostały przekonwertowane do odpowiedniego formatu i znajdują się w zmiennych `std::vector<float> textureCoord` i ` std::vector<unsigned int> indices` odpowiednio. Pozostałe są dostępne jako atrybuty `aiMesh`, mianowicie `mesh->mVertices` zawiera wierzchołki a `mesh->mNormals` normalne
Dodatkowo
```C++
unsigned int vertexDataBufferSize = sizeof(float) * mesh->mNumVertices * 3;
unsigned int vertexNormalBufferSize = sizeof(float) * mesh->mNumVertices * 3;
unsigned int vertexTexBufferSize = sizeof(float) * mesh->mNumVertices * 2;
```
zawierają rozmiary buforów.
Wykorzystaj w `renderScene` funkcję `Core::DrawContext(Core::RenderContext& context)`

Binary file not shown.

Binary file not shown.

BIN
cw 6/Release/Bubble.obj Normal file

Binary file not shown.

BIN
cw 6/Release/Camera.obj Normal file

Binary file not shown.

BIN
cw 6/Release/Fish.obj Normal file

Binary file not shown.

BIN
cw 6/Release/KeyPoints.obj Normal file

Binary file not shown.

BIN
cw 6/Release/Model.obj Normal file

Binary file not shown.

BIN
cw 6/Release/Particle.obj Normal file

Binary file not shown.

BIN
cw 6/Release/Physics.obj Normal file

Binary file not shown.

Binary file not shown.

BIN
cw 6/Release/SOIL.obj Normal file

Binary file not shown.

Binary file not shown.

BIN
cw 6/Release/Skybox.obj Normal file

Binary file not shown.

BIN
cw 6/Release/Texture.obj Normal file

Binary file not shown.

BIN
cw 6/Release/image_DXT.obj Normal file

Binary file not shown.

Binary file not shown.

BIN
cw 6/Release/main_6_1.obj Normal file

Binary file not shown.

Binary file not shown.