Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e1e92ec

Browse files
committed
camera
1 parent 2a90a09 commit e1e92ec

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

cncvis/api.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ int cncvis_init(const char *configFile)
166166
glInit(globalFramebuffer);
167167

168168
// Initialize the camera and Y axis as up
169-
globalCamera = ucncCameraNew(500.0f, 500.0f, 500.0f, 0.0f, 0.0f, 1.0f);
169+
globalCamera = ucncCameraNew(600.0f, 600.0f, 300.0f, 0.0f, 0.0f, 1.0f);
170170

171171
printCameraDetails(globalCamera);
172172
printf("Successfully initialised the global camera.\n");
@@ -179,19 +179,10 @@ int cncvis_init(const char *configFile)
179179
// Enable depth testing and lighting for the scene
180180
glEnable(GL_DEPTH_TEST);
181181

182-
// Set up lighting properties for GL_LIGHT0 to simulate distant sunlight
183-
GLfloat light_position[] = {1000.0, 1000.0, 1000.0, 0.0}; // Directional light pointing from above and to the right
184-
GLfloat light_ambient[] = {0.2, 0.2, 0.2, 1.0}; // Very soft ambient lighting
185-
GLfloat light_diffuse[] = {1.0, 1.0, 1.0, 1.0}; // Full white diffuse lighting
186-
GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; // Full white specular highlights
187-
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
188-
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
189-
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
190-
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
191-
192182
// Enable lighting for the scene
193183
glEnable(GL_LIGHTING);
194184
glEnable(GL_LIGHT0);
185+
glEnable(GL_LIGHT1);
195186

196187
// Enable color material to apply colors from the actor to materials
197188
glEnable(GL_COLOR_MATERIAL);
@@ -207,7 +198,7 @@ int cncvis_init(const char *configFile)
207198
glLoadIdentity();
208199
// Correct aspect ratio calculation for the framebuffer
209200
GLfloat aspectRatio = (GLfloat)globalFramebuffer->xsize / (GLfloat)globalFramebuffer->ysize;
210-
gluPerspective(90.0f, aspectRatio, 1.0f, 5000.0f); // FOV, aspect ratio, near, far planes
201+
gluPerspective(60.0f, aspectRatio, 1.0f, 5000.0f); // FOV, aspect ratio, near, far planes
211202

212203
// Switch to modelview matrix for placing objects in the 3D scene
213204
glMatrixMode(GL_MODELVIEW);
@@ -277,7 +268,7 @@ void cncvis_render(void)
277268
glLoadIdentity();
278269

279270
GLfloat aspectRatio = (GLfloat)globalFramebuffer->xsize / (GLfloat)globalFramebuffer->ysize;
280-
gluPerspective(90.0f, aspectRatio, 1.0f, 5000.0f);
271+
gluPerspective(60.0f, aspectRatio, 1.0f, 5000.0f);
281272

282273
glMatrixMode(GL_MODELVIEW);
283274
glLoadIdentity();

cncvis/assembly.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ void ucncAssemblyRender(const ucncAssembly *assembly) {
164164
// assembly->name, assembly->positionX, assembly->positionY, assembly->positionZ,
165165
// assembly->rotationX, assembly->rotationY, assembly->rotationZ);
166166

167+
extern void drawAxis(float);
168+
drawAxis(500.0f); // Draw a reference axis
169+
167170
// Render all actors in this assembly
168171
for (int i = 0; i < assembly->actorCount; i++) {
169172
ucncActorRender(assembly->actors[i]);

cncvis/camera.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ ucncCamera* ucncCameraNew(float posX, float posY, float posZ, float upX, float u
2020
camera->upX = upX;
2121
camera->upY = upY;
2222
camera->upZ = upZ;
23+
camera->directionX = 0.0f;
24+
camera->directionY = 0.0f;
25+
camera->directionZ = 0.0f;
2326

2427
// Set the initial yaw, pitch, and zoom level
2528
camera->yaw = 0.0f;

0 commit comments

Comments
 (0)