/
Zamar_Terrier
/
TigorEngine
Обзор
Документация
Войти
/
Zamar_Terrier
/
TigorEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
tests/create_object_test.c
140 строк
4 KB
Zamar_Terrier
Запрос на слияние 'feature-12032026' (
#9
) из feature-12032026 в master
08 июн 2026, 11:31
Верифицирован
08 июн 2026, 11:31
2200f38
Код
Авторство
О чём код?
#include <TigorEngine.h> #include <TigorGUI.h> #include <Core/e_camera.h> #include <Core/e_transform.h> #include <Objects/render_texture.h> #include <Objects/primitiveObject.h> #include <Objects/light_object.h> #include "Tools/e_math.h" LightObject* light1, * light2, * light3, * light4; Camera2D cam2D; Camera3D cam3D; PrimitiveObject po; PrimitiveObject light_point; vec3 dir, l_pos; extern TEngine engine; double time = 0; void Update(float dTime) { Camera3DMovementUpdateMain(dTime); Camera3DRotationUpdateMain(dTime); time += dTime * 0.5f; l_pos.x = 3 * cos(time); l_pos.y = 3 * sin(time); l_pos.z = 0;//3 * sin(time); dir.x = cos(time * M_PI / 2 / 10); dir.y = sin(time * M_PI / 2 / 10); dir.z = sin(time * M_PI / 2 / 10); //dir = Camera3DGetRotation(); LightObjectSetDirection(light1, dir.x, dir.y, dir.z); LightObjectSetPosition(light2, l_pos.x, l_pos.y, l_pos.z); LightObjectSetPosition(light3, l_pos.x * -1, l_pos.y * -1, l_pos.z * -1); vec3 s_pos = Camera3DGetPositionMain(); LightObjectSetPosition(light4, s_pos.x, s_pos.y, s_pos.z); vec3 s_dir = v3_muls(Camera3DGetRotationMain(), -1); LightObjectSetDirection(light4, s_dir.x, s_dir.y, s_dir.z); char buff[125]; sprintf(buff, "%0.2f, %0.2f, %0.2f", dir.x, dir.y, dir.z); //GUIAddText(600, 30, vec4_f(0, 0, 0, 1), 7, (const char *)buff); Transform3DSetPosition((GameObject3D*)&light_point, l_pos.x, l_pos.y, l_pos.z); } void Draw(){ GameObjectDraw((GameObject *)&po); GameObjectDraw((GameObject *)&light_point); char buffer[64]; sprintf(buffer, "fps now %i", engine.fpsCounter); GUIAddText(0, 30, vec4_f(0, 0, 0, 1), 7, buffer); TEngineRenderGUI(); } int main() { TEngineInitSystem(800, 600, "Test"); TEngineSetUpdater(Update); TEngineSetDrawer(Draw); printf("Size of Transform buff : %i\n", sizeof(TransformBuffer)); printf("Size of Light buff : %i\n", sizeof(LightBuffer)); TEngineSetFont("res\\arial.ttf"); light1 = LightObjectAdd(TIGOR_LIGHT_OBJECT_TYPE_DIRECTIONAL_LIGHT); light2 = LightObjectAdd(TIGOR_LIGHT_OBJECT_TYPE_POINT_LIGHT); LightObjectSetColor(light2, 0, 1, 0); LightObjectSetRadius(light2, 10.0f); light3 = LightObjectAdd(TIGOR_LIGHT_OBJECT_TYPE_POINT_LIGHT); LightObjectSetColor(light3, 0, 0, 1); LightObjectSetRadius(light3, 10.0f); light4 = LightObjectAdd(TIGOR_LIGHT_OBJECT_TYPE_SPOT_LIGHT); LightObjectSetColor(light4, 1, 0, 0); LightObjectSetRadius(light4, 200.0f); DrawParam dParam; memset(&dParam, 0, sizeof(DrawParam)); dParam.diffuse = "res/texture.jpg"; PrimitiveObjectInit(&po, &dParam, TIGOR_PRIMITIVE3D_CUBE, NULL); Transform3DSetPosition((GameObject3D *)&po, 0, 0, 7); Transform3DSetScale((GameObject3D *)&po, 5, 5, 5); /* uint32_t num_pack = GameObject3DSetShaderSimple((GameObject3D *)&po, "vert.spv", "frag.spv"); BluePrintAddUniformObjectC((BluePrints *)&po.go.graphObj.BluePrints, num_pack, 192, VK_SHADER_STAGE_VERTEX_BIT, 0); BluePrintAddUniformObjectC((BluePrints *)&po.go.graphObj.BluePrints, num_pack, 568, VK_SHADER_STAGE_FRAGMENT_BIT, 1); BluePrintAddTextureC((BluePrints *)&po.go.graphObj.BluePrints, num_pack, VK_SHADER_STAGE_FRAGMENT_BIT, 2); GameObject3DSetDescriptorUpdate((GameObject3D *)&po, num_pack, 0, (UpdateDescriptor)GameObject3DDescriptorModelUpdate); GameObject3DSetDescriptorUpdate((GameObject3D *)&po, num_pack, 1, (UpdateDescriptor)GameObject3DDescriptorLightUpdate); GameObject3DSetDescriptorTextureCreate((GameObject3D *)&po, num_pack, 2, NULL); GameObject3DInitDraw((GameObject3D *)&po);*/ GameObject3DEnableLight((GameObject3D *)&po, true); //GameObjectInit(&po); SphereParam sParam; sParam.radius = 1; sParam.sectorCount = 10; sParam.stackCount = 10; PrimitiveObjectInit(&light_point, &dParam, TIGOR_PRIMITIVE3D_SPHERE, &sParam); Camera3DSetSensitivityMain(10); TEngineStartRender(); GameObjectDestroy((GameObject *)&po); GameObjectDestroy((GameObject *)&light_point); TEngineDeviceWaitIdle(); TEngineCleanUp(); return 0; }