This commit is contained in:
2021-05-20 07:47:03 -07:00
parent e2274ea8bf
commit 3a867f9ad6
12 changed files with 434 additions and 4 deletions

View File

@ -50,6 +50,8 @@ typedef struct {
tileset_t *kagamiTileset;
primitive_t *kagamiQuad;
primitive_t *chipPrimitive;
texture_t *chipTexture;
primitive_t *tablePrimitive;
texture_t *tableTexture;

View File

@ -0,0 +1,341 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "pokerchip.h"
primitive_t * pokerChipCreate() {
vertice_t vertices[POKER_CHIP_VERTICE_COUNT] = {
{ .x = 0, .y = 0.015, .z = -0.1, .u = 0.351562, .v = 0.28125 },
{ .x = 0.0309017, .y = -0.015, .z = -0.09510570000000002, .u = 0.273438, .v = 0.21093799999999996 },
{ .x = 0, .y = -0.015, .z = -0.1, .u = 0.273438, .v = 0.28125 },
{ .x = 0.0309017, .y = 0.015, .z = -0.09510570000000002, .u = 0.351562, .v = 0.21093799999999996 },
{ .x = 0.058778500000000004, .y = -0.015, .z = -0.08090170000000001, .u = 0.273438, .v = 0.140625 },
{ .x = 0.058778500000000004, .y = 0.015, .z = -0.08090170000000001, .u = 0.265625, .v = 0.49218799999999996 },
{ .x = 0.08090170000000001, .y = -0.015, .z = -0.058778500000000004, .u = 0.1875, .v = 0.421875 },
{ .x = 0.058778500000000004, .y = -0.015, .z = -0.08090170000000001, .u = 0.1875, .v = 0.49218799999999996 },
{ .x = 0.08090170000000001, .y = 0.015, .z = -0.058778500000000004, .u = 0.265625, .v = 0.421875 },
{ .x = 0.09510570000000002, .y = -0.015, .z = -0.0309017, .u = 0.1875, .v = 0.35156200000000004 },
{ .x = 0.09510570000000002, .y = 0.015, .z = -0.0309017, .u = 0.265625, .v = 0.35156200000000004 },
{ .x = 0.1, .y = -0.015, .z = 0, .u = 0.1875, .v = 0.28125 },
{ .x = 0.1, .y = 0.015, .z = 0, .u = 0.265625, .v = 0.28125 },
{ .x = 0.09510560000000001, .y = -0.015, .z = 0.0309017, .u = 0.1875, .v = 0.21093799999999996 },
{ .x = 0.09510560000000001, .y = 0.015, .z = 0.0309017, .u = 0.265625, .v = 0.21093799999999996 },
{ .x = 0.08090170000000001, .y = -0.015, .z = 0.058778500000000004, .u = 0.1875, .v = 0.140625 },
{ .x = 0.08090170000000001, .y = 0.015, .z = 0.058778500000000004, .u = 0.085938, .v = 0.49218799999999996 },
{ .x = 0.058778500000000004, .y = -0.015, .z = 0.08090170000000001, .u = 0.007812, .v = 0.421875 },
{ .x = 0.08090170000000001, .y = -0.015, .z = 0.058778500000000004, .u = 0.007812, .v = 0.49218799999999996 },
{ .x = 0.058778500000000004, .y = 0.015, .z = 0.08090170000000001, .u = 0.085938, .v = 0.421875 },
{ .x = 0.0309017, .y = -0.015, .z = 0.09510570000000002, .u = 0.007812, .v = 0.35156200000000004 },
{ .x = 0.0309017, .y = 0.015, .z = 0.09510570000000002, .u = 0.085938, .v = 0.35156200000000004 },
{ .x = 0, .y = -0.015, .z = 0.1, .u = 0.007812, .v = 0.28125 },
{ .x = 0, .y = 0.015, .z = 0.1, .u = 0.085938, .v = 0.28125 },
{ .x = -0.0309017, .y = -0.015, .z = 0.09510560000000001, .u = 0.007812, .v = 0.21093799999999996 },
{ .x = -0.0309017, .y = 0.015, .z = 0.09510560000000001, .u = 0.085938, .v = 0.21093799999999996 },
{ .x = -0.05877860000000001, .y = -0.015, .z = 0.08090170000000001, .u = 0.007812, .v = 0.140625 },
{ .x = -0.05877860000000001, .y = 0.015, .z = 0.08090170000000001, .u = 0.171875, .v = 0.49218799999999996 },
{ .x = -0.08090170000000001, .y = -0.015, .z = 0.058778500000000004, .u = 0.09375, .v = 0.421875 },
{ .x = -0.05877860000000001, .y = -0.015, .z = 0.08090170000000001, .u = 0.09375, .v = 0.49218799999999996 },
{ .x = -0.08090170000000001, .y = 0.015, .z = 0.058778500000000004, .u = 0.171875, .v = 0.421875 },
{ .x = -0.09510570000000002, .y = -0.015, .z = 0.0309016, .u = 0.09375, .v = 0.35156200000000004 },
{ .x = -0.09510570000000002, .y = 0.015, .z = 0.0309016, .u = 0.171875, .v = 0.35156200000000004 },
{ .x = -0.1, .y = -0.015, .z = -1e-7, .u = 0.09375, .v = 0.28125 },
{ .x = -0.1, .y = 0.015, .z = -1e-7, .u = 0.171875, .v = 0.28125 },
{ .x = -0.09510560000000001, .y = -0.015, .z = -0.030901800000000004, .u = 0.09375, .v = 0.21093799999999996 },
{ .x = -0.09510560000000001, .y = 0.015, .z = -0.030901800000000004, .u = 0.171875, .v = 0.21093799999999996 },
{ .x = -0.0809016, .y = -0.015, .z = -0.05877860000000001, .u = 0.09375, .v = 0.140625 },
{ .x = -0.0809016, .y = 0.015, .z = -0.05877860000000001, .u = 0.351562, .v = 0.49218799999999996 },
{ .x = -0.0587784, .y = -0.015, .z = -0.08090180000000001, .u = 0.273438, .v = 0.421875 },
{ .x = -0.0809016, .y = -0.015, .z = -0.05877860000000001, .u = 0.273438, .v = 0.49218799999999996 },
{ .x = -0.09510570000000002, .y = 0.015, .z = 0.0309016, .u = 0.421875, .v = 0.929688 },
{ .x = 0, .y = 0.015, .z = 0.1, .u = 0.46875, .v = 0.640625 },
{ .x = 0.09510560000000001, .y = 0.015, .z = 0.0309017, .u = 0.210938, .v = 0.5078119999999999 },
{ .x = -0.0587784, .y = 0.015, .z = -0.08090180000000001, .u = 0.351562, .v = 0.421875 },
{ .x = -0.0309016, .y = -0.015, .z = -0.09510570000000002, .u = 0.273438, .v = 0.35156200000000004 },
{ .x = -0.0309016, .y = 0.015, .z = -0.09510570000000002, .u = 0.351562, .v = 0.35156200000000004 },
{ .x = 0.08090170000000001, .y = -0.015, .z = 0.058778500000000004, .u = 0.789062, .v = 0.992188 },
{ .x = -0.1, .y = -0.015, .z = -1e-7, .u = 0.859375, .v = 0.53125 },
{ .x = -0.0309016, .y = -0.015, .z = -0.09510570000000002, .u = 0.578125, .v = 0.578125 },
{ .x = 0.058778500000000004, .y = 0.015, .z = -0.08090170000000001, .u = 0.351562, .v = 0.140625 },
{ .x = 0.08090170000000001, .y = 0.015, .z = 0.058778500000000004, .u = 0.265625, .v = 0.140625 },
{ .x = -0.05877860000000001, .y = 0.015, .z = 0.08090170000000001, .u = 0.085938, .v = 0.140625 },
{ .x = -0.0809016, .y = 0.015, .z = -0.05877860000000001, .u = 0.171875, .v = 0.140625 },
{ .x = 0.058778500000000004, .y = 0.015, .z = -0.08090170000000001, .u = 0.007812, .v = 0.7109380000000001 },
{ .x = 0.0309017, .y = 0.015, .z = -0.09510570000000002, .u = 0.007812, .v = 0.789062 },
{ .x = 0, .y = 0.015, .z = -0.1, .u = 0.03125, .v = 0.867188 },
{ .x = -0.0309016, .y = 0.015, .z = -0.09510570000000002, .u = 0.078125, .v = 0.921875 },
{ .x = -0.0587784, .y = 0.015, .z = -0.08090180000000001, .u = 0.140625, .v = 0.96875 },
{ .x = -0.0809016, .y = 0.015, .z = -0.05877860000000001, .u = 0.210938, .v = 0.992188 },
{ .x = -0.09510560000000001, .y = 0.015, .z = -0.030901800000000004, .u = 0.289062, .v = 0.992188 },
{ .x = -0.1, .y = 0.015, .z = -1e-7, .u = 0.359375, .v = 0.96875 },
{ .x = -0.08090170000000001, .y = 0.015, .z = 0.058778500000000004, .u = 0.46875, .v = 0.867188 },
{ .x = -0.05877860000000001, .y = 0.015, .z = 0.08090170000000001, .u = 0.492188, .v = 0.789062 },
{ .x = -0.0309017, .y = 0.015, .z = 0.09510560000000001, .u = 0.492188, .v = 0.7109380000000001 },
{ .x = 0.0309017, .y = 0.015, .z = 0.09510570000000002, .u = 0.429688, .v = 0.578125 },
{ .x = 0.058778500000000004, .y = 0.015, .z = 0.08090170000000001, .u = 0.359375, .v = 0.53125 },
{ .x = 0.08090170000000001, .y = 0.015, .z = 0.058778500000000004, .u = 0.289062, .v = 0.5078119999999999 },
{ .x = 0.1, .y = 0.015, .z = 0, .u = 0.140625, .v = 0.53125 },
{ .x = 0.09510570000000002, .y = 0.015, .z = -0.0309017, .u = 0.078125, .v = 0.578125 },
{ .x = 0.08090170000000001, .y = 0.015, .z = -0.058778500000000004, .u = 0.03125, .v = 0.640625 },
{ .x = 0, .y = -0.015, .z = -0.1, .u = 0.53125, .v = 0.640625 },
{ .x = 0.0309017, .y = -0.015, .z = -0.09510570000000002, .u = 0.507812, .v = 0.7109380000000001 },
{ .x = 0.058778500000000004, .y = -0.015, .z = -0.08090170000000001, .u = 0.507812, .v = 0.789062 },
{ .x = 0.08090170000000001, .y = -0.015, .z = -0.058778500000000004, .u = 0.531716, .v = 0.861221 },
{ .x = 0.09510570000000002, .y = -0.015, .z = -0.0309017, .u = 0.570312, .v = 0.921875 },
{ .x = 0.1, .y = -0.015, .z = 0, .u = 0.632812, .v = 0.96875 },
{ .x = 0.09510560000000001, .y = -0.015, .z = 0.0309017, .u = 0.710938, .v = 0.992188 },
{ .x = 0.058778500000000004, .y = -0.015, .z = 0.08090170000000001, .u = 0.867188, .v = 0.96875 },
{ .x = 0.0309017, .y = -0.015, .z = 0.09510570000000002, .u = 0.929688, .v = 0.921875 },
{ .x = 0, .y = -0.015, .z = 0.1, .u = 0.968284, .v = 0.861221 },
{ .x = -0.0309017, .y = -0.015, .z = 0.09510560000000001, .u = 0.992188, .v = 0.789062 },
{ .x = -0.05877860000000001, .y = -0.015, .z = 0.08090170000000001, .u = 0.992188, .v = 0.7109380000000001 },
{ .x = -0.08090170000000001, .y = -0.015, .z = 0.058778500000000004, .u = 0.968284, .v = 0.638779 },
{ .x = -0.09510570000000002, .y = -0.015, .z = 0.0309016, .u = 0.929688, .v = 0.578125 },
{ .x = -0.09510560000000001, .y = -0.015, .z = -0.030901800000000004, .u = 0.789062, .v = 0.5078119999999999 },
{ .x = -0.0809016, .y = -0.015, .z = -0.05877860000000001, .u = 0.710938, .v = 0.5078119999999999 },
{ .x = -0.0587784, .y = -0.015, .z = -0.08090180000000001, .u = 0.640625, .v = 0.53125 }
};
indice_t indices[POKER_CHIP_INDICE_COUNT] = {
0,
1,
2,
3,
4,
1,
5,
6,
7,
8,
9,
6,
10,
11,
9,
12,
13,
11,
14,
15,
13,
16,
17,
18,
19,
20,
17,
21,
22,
20,
23,
24,
22,
25,
26,
24,
27,
28,
29,
30,
31,
28,
32,
33,
31,
34,
35,
33,
36,
37,
35,
38,
39,
40,
41,
42,
43,
44,
45,
39,
46,
2,
45,
47,
48,
49,
0,
3,
1,
3,
50,
4,
5,
8,
6,
8,
10,
9,
10,
12,
11,
12,
14,
13,
14,
51,
15,
16,
19,
17,
19,
21,
20,
21,
23,
22,
23,
25,
24,
25,
52,
26,
27,
30,
28,
30,
32,
31,
32,
34,
33,
34,
36,
35,
36,
53,
37,
38,
44,
39,
54,
55,
56,
56,
57,
58,
58,
59,
60,
60,
61,
41,
41,
62,
63,
63,
64,
41,
64,
42,
41,
42,
65,
43,
65,
66,
43,
66,
67,
43,
43,
68,
69,
69,
70,
43,
70,
54,
43,
54,
56,
58,
58,
60,
41,
54,
58,
43,
58,
41,
43,
44,
46,
45,
46,
0,
2,
49,
71,
72,
72,
73,
49,
73,
74,
49,
74,
75,
47,
75,
76,
47,
76,
77,
47,
47,
78,
79,
79,
80,
81,
81,
82,
83,
83,
84,
48,
48,
85,
86,
86,
87,
49,
47,
79,
81,
81,
83,
48,
48,
86,
49,
49,
74,
47,
47,
81,
48
};
primitive_t *primitive = primitiveCreate(
POKER_CHIP_VERTICE_COUNT,
POKER_CHIP_INDICE_COUNT
);
primitiveBufferVertices(primitive, 0, POKER_CHIP_VERTICE_COUNT, vertices);
primitiveBufferIndices(primitive, 0, POKER_CHIP_INDICE_COUNT, indices);
return primitive;
}

View File

@ -0,0 +1,22 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
#include "../../display/primitive.h"
#define POKER_CHIP_NAME "Poker Chip"
#define POKER_CHIP_VERTICE_COUNT 88
#define POKER_CHIP_INDICE_COUNT 228
#define POKER_CHIP_TRIANGLE_COUNT 76
/**
* Generated Model Poker Chip
* Generated at Wed, 19 May 2021 14:20:06 GMT
* @returns Poker Chip as a primitive.
*/
primitive_t * pokerChipCreate();

View File

@ -40,6 +40,7 @@ bool gameInit() {
holdemRenderWorldInit();
holdemRenderPlayerInit();
holdemRenderCardInit();
holdemRenderChipInit();
// Prepare the action manager
pokerActionInit();

View File

@ -17,6 +17,7 @@
#include "../poker/action/start.h"
#include "../poker/render/player.h"
#include "../poker/render/card.h"
#include "../poker/render/chip.h"
#include "../poker/render/frame.h"
#include "../poker/render/look.h"
#include "../poker/render/world.h"

View File

@ -42,6 +42,9 @@ void actionRoundInit(int32_t index, void *data) {
player->cardCount = 0;
player->currentBet = 0;
player->chips = 1000;
player->currentBet = 1000;
}
// Next action

23
src/poker/render/chip.c Normal file
View File

@ -0,0 +1,23 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "chip.h"
void holdemRenderChipInit() {
GAME_STATE.chipPrimitive = pokerChipCreate();
GAME_STATE.chipTexture = assetTextureLoad("pokerchip.png");
}
void holdemRenderChip() {
shaderUsePositionAndScale(GAME_STATE.shaderWorld,
0, 0.05, -0.6,
0, 0, 0,
0.2, 0.2, 0.2
);
shaderUseTexture(GAME_STATE.shaderWorld, GAME_STATE.chipTexture);
primitiveDraw(GAME_STATE.chipPrimitive, 0, -1);
}

23
src/poker/render/chip.h Normal file
View File

@ -0,0 +1,23 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
#include "../../assets/models/pokerchip.h"
#include "../../file/asset.h"
#include "../../display/shader.h"
#include "../../display/texture.h"
/**
* Init the poker chips renderer for each player.
*/
void holdemRenderChipInit();
/**
* Render the poker chips.
*/
void holdemRenderChip();

View File

@ -61,13 +61,24 @@ void holdemRenderFrameUseLeft() {
void holdemRenderFrameUseRight() {
glClearColor(0.3, 0.3, 0, 1);
frameBufferUse(GAME_STATE.frameRight, true);
cameraPerspective(&GAME_STATE.cameraRight, 45,
// cameraPerspective(&GAME_STATE.cameraRight, 45,
// (
// (float)GAME_STATE.frameRight->texture->width /
// (float)GAME_STATE.frameRight->texture->height
// ), 0.2f, 1000.0f
// );
// cameraLookAt(&GAME_STATE.cameraRight, 0, 3, 3, 0, 0, 0);
cameraPerspective(&GAME_STATE.cameraRight, 15,
(
(float)GAME_STATE.frameRight->texture->width /
(float)GAME_STATE.frameRight->texture->height
), 0.2f, 1000.0f
);
cameraLookAt(&GAME_STATE.cameraRight, 0, 3, 3, 0, 0, 0);
cameraLookAt(&GAME_STATE.cameraRight, 0, 1, -8, 0, 0, 0);
shaderUseCamera(GAME_STATE.shaderWorld, &GAME_STATE.cameraRight);
}

View File

@ -48,4 +48,6 @@ void holdemRenderWorld() {
holdemRenderCardForSeat(seat, player->cards[j], HOLDEM_GAME_CARD_SLOT_HAND0+j);
}
}
holdemRenderChip();
}

View File

@ -9,6 +9,7 @@
#include <dawn/dawn.h>
#include "player.h"
#include "card.h"
#include "chip.h"
#include "../../assets/models/pokertable.h"
/**

View File

@ -6,13 +6,13 @@
const fs = require('fs');
const path = require('path');
const MODEL_NAME = 'Poker Table';
const MODEL_NAME = 'Poker Chip';
const FLIP_TEXTURE_Y = true;
let rawVertices = [];
let faces = [];
let coordinates = [];
const filePath = path.join(__dirname, 'model.obj');
const filePath = path.join(__dirname, '..', '..', 'assets', 'models', 'Chip Single', 'Single Chip.obj');
const data = fs.readFileSync(filePath, 'utf-8');
const scale = 0.1;