|
@@ -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
|
|