Skip to content

BobDeng1974/3D-Rendering-Engine-in-C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

3D-Rendering-Engine-in-C

WindowsApi
written in C
I have not cleaned up the code yet!

Contorl

Up : space
Down : shift
Move : w,a,s,d
Rotation : ↑,↓,←,→

ScreenShots

screenshot_1 screenshot_2 screenshot_3

Main&Important Code

Coordinate_axis in this project

Coordinate_axis

Rotation matrix

code_1 Horizontal_rotation * Vertical_rotation

Get Coordinate to output

code_2

Moving Coordinate Calculation

code_3 Let "Horizontal rotation" be "H"and "Distance traveled" be "D"
The player's "Horizontal rotation" value is stored in degree,
So, when calculating, it should be calculated as radian value.
Therefore, H = (Horizontal rotation) * (PI / 180).

When moving forward

player_x += cos(H + (π / 2)) * (-D)
player_z += sin(H + (π / 2)) * D

When moving backward

player_x += cos(H - (π / 2)) * (-D)
player_z += sin(H - (π / 2)) * D

When moving left

player_x += cos(H + π) * D
player_z += sin(H + π) * (-D)

When moving right

player_x += cos(H) * D
player_z += sin(H) * (-D)

About

Rendering 3D in C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published