Pārlūkot izejas kodu

몇가지 수정.

- Mesh 샘플의 obj 데이터엔 uv 가 없습니다.
Hongtae Kim 5 gadus atpakaļ
vecāks
revīzija
3a3ffa801e
3 mainītis faili ar 19 papildinājumiem un 14 dzēšanām
  1. Binārs
      Samples/Data/textures/koo.jpg
  2. 16
    11
      Samples/Mesh/Mesh.cpp
  3. 3
    3
      Samples/Texture/Texture.cpp

Binārs
Samples/Data/textures/koo.jpg Parādīt failu


+ 16
- 11
Samples/Mesh/Mesh.cpp Parādīt failu

88
 				}
88
 				}
89
 
89
 
90
 				indices.Add(uniqueVertices.Value(vertex));
90
 				indices.Add(uniqueVertices.Value(vertex));
91
+
92
+                aabb.Expand(vertex.inPos);
91
 			}
93
 			}
92
 		}
94
 		}
93
 	}
95
 	}
101
 	const uint32_t* GetIndicesData() const { 
103
 	const uint32_t* GetIndicesData() const { 
102
 		return indices; }
104
 		return indices; }
103
 
105
 
106
+    DKAabb aabb;
104
 private:
107
 private:
105
 	DKArray<Vertex> vertices;
108
 	DKArray<Vertex> vertices;
106
 	DKArray<uint32_t> indices;
109
 	DKArray<uint32_t> indices;
129
 	{
132
 	{
130
 		
133
 		
131
 		DKLog("Loading Mesh");
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
     DKObject<DKTexture> LoadTexture2D(DKCommandQueue* queue, DKData* data)
139
     DKObject<DKTexture> LoadTexture2D(DKCommandQueue* queue, DKData* data)
188
         DKObject<DKCommandQueue> queue = device->CreateCommandQueue(DKCommandQueue::Graphics);
192
         DKObject<DKCommandQueue> queue = device->CreateCommandQueue(DKCommandQueue::Graphics);
189
 
193
 
190
 		// create texture
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
 		// create sampler
196
 		// create sampler
193
 		DKSamplerDescriptor samplerDesc = {};
197
 		DKSamplerDescriptor samplerDesc = {};
194
 		samplerDesc.magFilter = DKSamplerDescriptor::MinMagFilterLinear;
198
 		samplerDesc.magFilter = DKSamplerDescriptor::MinMagFilterLinear;
195
 		samplerDesc.minFilter = DKSamplerDescriptor::MinMagFilterLinear;
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
 		samplerDesc.maxAnisotropy = 16;
203
 		samplerDesc.maxAnisotropy = 16;
200
 		
204
 		
201
 		DKObject<DKSamplerState> sampler = device->CreateSamplerState(samplerDesc);
205
 		DKObject<DKSamplerState> sampler = device->CreateSamplerState(samplerDesc);
233
 		pipelineDescriptor.fragmentFunction = fragShaderFunction;
237
 		pipelineDescriptor.fragmentFunction = fragShaderFunction;
234
 		pipelineDescriptor.colorAttachments.Resize(1);
238
 		pipelineDescriptor.colorAttachments.Resize(1);
235
 		pipelineDescriptor.colorAttachments.Value(0).pixelFormat = swapChain->ColorPixelFormat();
239
 		pipelineDescriptor.colorAttachments.Value(0).pixelFormat = swapChain->ColorPixelFormat();
236
-        pipelineDescriptor.colorAttachments.Value(0).blendingEnabled = true;
240
+        pipelineDescriptor.colorAttachments.Value(0).blendingEnabled = false;
237
         pipelineDescriptor.colorAttachments.Value(0).sourceRGBBlendFactor = DKBlendFactor::SourceAlpha;
241
         pipelineDescriptor.colorAttachments.Value(0).sourceRGBBlendFactor = DKBlendFactor::SourceAlpha;
238
         pipelineDescriptor.colorAttachments.Value(0).destinationRGBBlendFactor = DKBlendFactor::OneMinusSourceAlpha;
242
         pipelineDescriptor.colorAttachments.Value(0).destinationRGBBlendFactor = DKBlendFactor::OneMinusSourceAlpha;
239
 		pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::Invalid; // no depth buffer
243
 		pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::Invalid; // no depth buffer
295
                 ubo.modelMatrix = DKMatrix4::identity;
299
                 ubo.modelMatrix = DKMatrix4::identity;
296
                 ubo.viewMatrix = DKMatrix4::identity;
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
                 memcpy(uboBuffer->Contents(), &ubo, sizeof(ubo));
306
                 memcpy(uboBuffer->Contents(), &ubo, sizeof(ubo));
299
                 bindSet->SetBuffer(0, uboBuffer, 0, sizeof(ubo));
307
                 bindSet->SetBuffer(0, uboBuffer, 0, sizeof(ubo));
300
                 uboBuffer->Flush();
308
                 uboBuffer->Flush();
333
 			else
341
 			else
334
 			{
342
 			{
335
 			}
343
 			}
336
-			DKThread::Sleep(0.5);
344
+			DKThread::Sleep(0.01);
337
 		}
345
 		}
338
 		DKLog("RenderThread terminating...");
346
 		DKLog("RenderThread terminating...");
339
 	}
347
 	}
355
                 DKApplication::Instance()->Terminate(0);
363
                 DKApplication::Instance()->Terminate(0);
356
         }), NULL, NULL);
364
         }), NULL, NULL);
357
 
365
 
358
-		if (SampleMesh == nullptr)
359
-		{
360
-			SampleMesh = new SampleObjMesh;
361
-		}
366
+        SampleMesh = DKOBJECT_NEW SampleObjMesh();
362
 
367
 
363
 		LoadMesh();
368
 		LoadMesh();
364
 
369
 

+ 3
- 3
Samples/Texture/Texture.cpp Parādīt failu

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