ソースを参照

몇가지 수정.

- Mesh 샘플의 obj 데이터엔 uv 가 없습니다.
Hongtae Kim 5 年 前
コミット
3a3ffa801e
共有3 個のファイルを変更した19 個の追加14 個の削除を含む
  1. バイナリ
      Samples/Data/textures/koo.jpg
  2. 16
    11
      Samples/Mesh/Mesh.cpp
  3. 3
    3
      Samples/Texture/Texture.cpp

バイナリ
Samples/Data/textures/koo.jpg ファイルの表示


+ 16
- 11
Samples/Mesh/Mesh.cpp ファイルの表示

@@ -88,6 +88,8 @@ public:
88 88
 				}
89 89
 
90 90
 				indices.Add(uniqueVertices.Value(vertex));
91
+
92
+                aabb.Expand(vertex.inPos);
91 93
 			}
92 94
 		}
93 95
 	}
@@ -101,6 +103,7 @@ public:
101 103
 	const uint32_t* GetIndicesData() const { 
102 104
 		return indices; }
103 105
 
106
+    DKAabb aabb;
104 107
 private:
105 108
 	DKArray<Vertex> vertices;
106 109
 	DKArray<uint32_t> indices;
@@ -129,7 +132,8 @@ public:
129 132
 	{
130 133
 		
131 134
 		DKLog("Loading Mesh");
132
-		SampleMesh->LoadFromObjFile("..\\Data\\meshes\\car.obj");
135
+        DKString path = resourcePool.ResourceFilePath("meshes/car.obj");
136
+		SampleMesh->LoadFromObjFile(DKStringU8(path));
133 137
 	}
134 138
 
135 139
     DKObject<DKTexture> LoadTexture2D(DKCommandQueue* queue, DKData* data)
@@ -188,14 +192,14 @@ public:
188 192
         DKObject<DKCommandQueue> queue = device->CreateCommandQueue(DKCommandQueue::Graphics);
189 193
 
190 194
 		// create texture
191
-		DKObject<DKTexture> texture = LoadTexture2D(queue, resourcePool.LoadResourceData("textures/deathstar3.png"));
195
+		DKObject<DKTexture> texture = LoadTexture2D(queue, resourcePool.LoadResourceData("textures/koo.jpg"));
192 196
 		// create sampler
193 197
 		DKSamplerDescriptor samplerDesc = {};
194 198
 		samplerDesc.magFilter = DKSamplerDescriptor::MinMagFilterLinear;
195 199
 		samplerDesc.minFilter = DKSamplerDescriptor::MinMagFilterLinear;
196
-		samplerDesc.addressModeU = DKSamplerDescriptor::AddressModeRepeat;
197
-		samplerDesc.addressModeV = DKSamplerDescriptor::AddressModeRepeat;
198
-		samplerDesc.addressModeW = DKSamplerDescriptor::AddressModeRepeat;
200
+		samplerDesc.addressModeU = DKSamplerDescriptor::AddressModeClampToEdge;
201
+		samplerDesc.addressModeV = DKSamplerDescriptor::AddressModeClampToEdge;
202
+		samplerDesc.addressModeW = DKSamplerDescriptor::AddressModeClampToEdge;
199 203
 		samplerDesc.maxAnisotropy = 16;
200 204
 		
201 205
 		DKObject<DKSamplerState> sampler = device->CreateSamplerState(samplerDesc);
@@ -233,7 +237,7 @@ public:
233 237
 		pipelineDescriptor.fragmentFunction = fragShaderFunction;
234 238
 		pipelineDescriptor.colorAttachments.Resize(1);
235 239
 		pipelineDescriptor.colorAttachments.Value(0).pixelFormat = swapChain->ColorPixelFormat();
236
-        pipelineDescriptor.colorAttachments.Value(0).blendingEnabled = true;
240
+        pipelineDescriptor.colorAttachments.Value(0).blendingEnabled = false;
237 241
         pipelineDescriptor.colorAttachments.Value(0).sourceRGBBlendFactor = DKBlendFactor::SourceAlpha;
238 242
         pipelineDescriptor.colorAttachments.Value(0).destinationRGBBlendFactor = DKBlendFactor::OneMinusSourceAlpha;
239 243
 		pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::Invalid; // no depth buffer
@@ -295,6 +299,10 @@ public:
295 299
                 ubo.modelMatrix = DKMatrix4::identity;
296 300
                 ubo.viewMatrix = DKMatrix4::identity;
297 301
 
302
+                DKAffineTransform3 trans;
303
+                trans.Multiply(DKLinearTransform3().Scale(0.25).Rotate(DKVector3(1,1,1), DKGL_PI * 0.1));
304
+                ubo.modelMatrix.Multiply(trans.Matrix4());
305
+
298 306
                 memcpy(uboBuffer->Contents(), &ubo, sizeof(ubo));
299 307
                 bindSet->SetBuffer(0, uboBuffer, 0, sizeof(ubo));
300 308
                 uboBuffer->Flush();
@@ -333,7 +341,7 @@ public:
333 341
 			else
334 342
 			{
335 343
 			}
336
-			DKThread::Sleep(0.5);
344
+			DKThread::Sleep(0.01);
337 345
 		}
338 346
 		DKLog("RenderThread terminating...");
339 347
 	}
@@ -355,10 +363,7 @@ public:
355 363
                 DKApplication::Instance()->Terminate(0);
356 364
         }), NULL, NULL);
357 365
 
358
-		if (SampleMesh == nullptr)
359
-		{
360
-			SampleMesh = new SampleObjMesh;
361
-		}
366
+        SampleMesh = DKOBJECT_NEW SampleObjMesh();
362 367
 
363 368
 		LoadMesh();
364 369
 

+ 3
- 3
Samples/Texture/Texture.cpp ファイルの表示

@@ -3,7 +3,7 @@
3 3
 #include "util.h"
4 4
 
5 5
 
6
-class MeshDemo : public SampleApp
6
+class TextureDemo : public SampleApp
7 7
 {
8 8
     DKObject<DKWindow> window;
9 9
 	DKObject<DKThread> renderThread;
@@ -239,7 +239,7 @@ public:
239 239
         }), NULL, NULL);
240 240
 
241 241
 		runningRenderThread = 1;
242
-		renderThread = DKThread::Create(DKFunction(this, &MeshDemo::RenderThread)->Invocation());
242
+		renderThread = DKThread::Create(DKFunction(this, &TextureDemo::RenderThread)->Invocation());
243 243
 	}
244 244
 	void OnTerminate(void) override
245 245
 	{
@@ -264,7 +264,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
264 264
 int main(int argc, const char * argv[])
265 265
 #endif
266 266
 {
267
-    MeshDemo app;
267
+    TextureDemo app;
268 268
 	DKPropertySet::SystemConfig().SetValue("AppDelegate", "AppDelegate");
269 269
 	DKPropertySet::SystemConfig().SetValue("GraphicsAPI", "Vulkan");
270 270
 	return app.Run();