This video tutorial demonstrates how to create a simple 3D scene in C using the raylib library, covering essential concepts including camera positioning (position, target, up vector), field of view (FOV) settings, and projection types (perspective vs orthographic). The instructor explains that 3D rendering requires a camera to define viewing angles, unlike 2D graphics, and shows how to implement camera movement, draw 3D cubes, and use mouse controls for navigation. The key insight is that 3D graphics fundamentally differ from 2D because objects must be viewed from specific angles defined by the camera's position and orientation.
深掘り
前提条件
- データがありません。
次のステップ
- データがありません。
深掘り
3D Basics in C追加:
Hello everybody. In today's episode, we're going to try to learn about how to code three-dimensional stuff in C.
In my last 100 or so episodes, I have exclusively coded stuff in two dimensions just because it's simple, it's straightforward, it's visual, and it's fun. Okay? I never really attempted to do anything in 3D. I remember like 1 year ago or maybe even almost 2 years ago by now, uh I started learning about C and the first thing I tried to do in raylib was to to code something in 3D and I completely failed and I freaked out and I canceled the recording and I never uploaded that episode. So, today with >> [laughter and gasps] >> with a history of projects in my backpack, with some experience, I'm going to re-attempt to try to create something ultra simple in three dimensions. Maybe it's just going to be a simple cube that the camera can move around or something like that. So, don't be too harsh on me.
I'm just going to try to get something in raylib running.
I know on the raylib examples page, there is an example of a raylib 3D cube.
Let's just have a look at that. I will try to not do the exact same thing, but maybe something slightly different. For example, this one here is a rotating cube. Okay, that's nice. It has a fixed camera. I don't think I can move around here.
And then I remember, right, there's a basic example here for a cube that we can walk around, I think.
Yeah, this one or this one here.
Can I move?
Yeah, so here I can move the camera with the mouse and I can also slightly tilt something with the arrow keys. Now, okay.
Yeah, so there are examples on the raylib GitHub page or on the raylib page itself. I'm not sure if I will use them. Let's try to do it without first.
So, I'm going to create a new directory 3D cube. I already have one by the way because ah, let's go into that and show you that one. It's or it's also a video that I've recorded sometime ago. That's a video where I That's a project where I coded a 3D cube from scratch using STL. So, this has nothing to do with raylib.
So, I'm going to No, I I won't compile and show you that one >> [laughter] >> because I don't have STL set up right now on my machine.
What I want to do is create a new directory and call it raylib cube. Okay, so make directory raylib cube.
Raylib cube exists.
Raylib cube, how's that possible? What?
Ah, is that maybe sample code? Did I explore something about the raylib cube in the past? I completely forgot.
I think that's just Yeah, okay. Okay, the window is being closed and someone commented de-initialization. That's definitely not my own code.
>> [laughter] [gasps] >> Whenever you see proper cleanup, it's not from me.
So, this project is also occu- Is this Yeah.
Let's figure out a new project name.
>> [gasps] >> Um >> [sighs] >> So, 3D cube and raylib cube are both taken.
Let's just create a directory of 3D world and go into this one, 3D world. Okay.
And I'm going to create a source file called world.c, include raylib.h, and include standard io.h, and then we need a main method here. And that's that's about it. Let's print something here. Oops, that's not what I wanted to paste here. Printf Hello world. That's a good start for a three-dimensional project.
And let's CD into that over here and try to compile it, world, and source file is world.c.
Okay.
And now we have an executable here.
Right there that we can execute. And if I execute it, I get a hello world. Mhm.
Mhm. Mhm. Has nothing to do with 3D yet.
I just wanted to see and if if I I just wanted to see if I can get a quick starting point set up.
Now, because I want to use raylib, I will open the raylib headers right here.
And from here, I'm going to take the init window function and paste it here.
No, paste it up here.
And we're going to initialize a window with a width and a height and a title.
So, width and height height and title. What's the title going to be? 3D cube.
Okay. And then I'm going to need to define width as 900 as always and define height as 600. And now we are set. If I now compile this, this won't work because now we're making Now it's the first time that we make use of a raylib library function, so we need to link raylib here. So, if we compile, we need to append {dash} L raylib. Link raylib.
That's what it means.
And now it's compiled and now we can execute it. And as you can see, there was a quick glimpse of a window opening and closing instantly.
Perfect. So, to keep the window open, we want to create a while loop here. While the window should not close, we keep it open. Wow.
And what do we do here? We begin drawing. That's how raylib um measure this frame per frames per seconds and handles them because we have to begin drawing and end drawing inside this loop and then we can set a frame rate outside of that loop.
Set target FPS is 60 frames per second.
And now we should have a working executable, right? That opens a window.
It has a title 3D cube and it stays open until we close it. Perfect.
>> [gasps] >> But now comes the first detail. Here I'm calling begin drawing and end drawing, but I don't even know if this is the right thing to do right now because I just saw when I typed here begin and auto completed, there was begin mode 2D and begin mode 3D.
So, probably I need to call begin mode 3D.
Do I need to call it only once out here?
Let's have a look. Begin mode.
Here.
So, begin mode 2D does the following. It begins 2D mode with custom camera.
Parenthesis 2D.
And then end mode 2D ends 2D mode with custom camera.
Same for 3D.
Begin 3D mode with custom camera 3D. And then we end the mode 3D. So, is there any reason we need to do this inside the loop or can we just do it outside? End mode 3D.
I'm not so sure, but it definitely has to do with the camera. And when I dealt with 2D projects, I never used the camera because I just created everything in the pixel coordinate space. Never used the camera, which is responsible for panning across the image and zooming in and stuff like that. I never made use of it. Maybe that should have Maybe I should have created a project on that before I started recording this 3D project.
But okay, we will figure it out.
Uh what am I doing here?
Uh visual Okay.
So, now I think we need to look at sample code because in raylib there's no documentation at all.
There's only sample code, and it teaches by example, and it's intended to be used as as a tutorial.
Um before we do it, maybe let's check if um if we're even calling the these functions correctly. So, here we begin mode 3D.
I don't know when to call it. Should we call it outside of the loop or inside of it?
Can we call it outside of begin drawing or should or does it have to be called within?
I don't know.
And begin mode 3D, where is that function defined? Begin mode 3D.
Wait, doesn't it exist? Begin mode 3D, does it not exist? Wait.
Begin mode 2D, begin mode 3D. There it is.
Why doesn't it exist if I search for it here?
What the hell?
I mean, there's begin mode 2D.
Did I just delete it accidentally? Wait.
I'm going to reopen the file.
User include raylib 3D. Let's search for 3D.
>> [gasps] >> There it is.
Did I Maybe I deleted it somehow.
Begin mode 3D. I search for it, now I get the result.
Or I Or there was a typo in my search. I don't know.
Okay, anyways, in begin mode 3D, we have to pass a camera 3D. What's that?
A camera is basically a It's a model that contains information about the Or it's a data structure that contains information about the angle from which you are looking at a at an object and also the distance. As far as I know, it's effectively like a real camera that you point at whatever object. The camera, depending on how you hold it, generates a different image.
And especially in the 3D world, you need to use a camera because if you define objects in three-dimensional space, you can't just render them without a camera camera because it's not defined from where you look at the object. In 2D space, it's not as critical because you can simply draw objects at specific pixel positions.
In 3D, it's not that straightforward because you always look at objects from a specific angle.
And that's what a camera defines.
So, we need to initialize a camera 3D, which this function here takes as input.
Camera 3D, let's have a look at that one.
There it is. So, this is a structure camera 3D. It takes as input the position of the camera, the target, so where does it look which direction does it look at?
Maybe does it help if I draw this? I don't know.
Let's see.
Let's try to visualize it here.
So, this is the camera here.
This one is the camera.
And let's say that this one is the target.
So, these are already two three-dimensional coordinates here that you define. These are three-dimensional coordinates. Yeah, right. Vector 3.
And then there's an another vector that is called up, and it's the it's the camera up vector. And I recall from looking this up some sometime in the past that the camera up vector is a vector that you have to define because you can look at a specific object. For example, let me look at this cup here.
But it's still undefined.
Well, okay, what's what's currently defined?
What we are currently defining is the is the position of the camera position and the target that it's looking at.
Okay.
But it's but the the up vector of the camera, so the angle at which the camera is being held is not defined. So, the camera could actually look at the object like this or like this or like this.
Do you get the point?
So, that's also undefined. You have also have to define the rotation of this camera view angle thingy.
I'm the master of at explaining stuff.
>> [snorts] >> Oh, I hope it is all correct. So, this is the up vector. It's a vector pointing in some direction and then there's some math being done, some matrix multiplication or whatever, cross products.
Completely have no idea.
Um that figures out what's up and what is down.
And then there's a floating point number f o v y. That's the field of view aperture in y degrees in perspective used as a near plane width in orthographic.
What?
Okay, basically it's a field of view. 90 [clears throat] degrees. Let's It's some angle that defines the field of view. Let's not over complicate it.
>> [snorts] >> Then there's another integer projection, camera projection, camera perspective, or orthographic. Oh, let's have a look at those two.
Camera projection, orthographic, and perspective. Right, I recall them. By the way, I when I attended university, I had a course that was called um image processing for engineers.
For those who do not know, I did not study computer science. I studied electrical engineerings and electrical engineering, and it was super important to understand how cameras themselves work.
Of course, I forgot it almost all. But there are different projections that you can use to look at objects.
Essentially, they are different matrices that the camera um that will represent the camera. This might be an okay-ish um visualization here. So, the orthographic projection >> [sighs] >> works in a way as if your eyes were uniformly distributed on a plane, and you look Oh my god, how do I even explain this? This is incredible. Well, imagine rays of light extending from your eyes, or reaching into your eyes, and you have thousands of eyes scattered across a plane here, and they and your eyes can catch all the parallel rays coming uh flying into them, as opposed to having a single eye here for the perspective projection, which >> [sighs] >> I have to draw this, guys.
My my explanation is super So, let's let's say there's uh some object here. Let's Let's just say this is a cube, but I'm just going to represent it using a line.
And then let's say you have one eye.
How do I make this red? So, this is your eye.
Okay. And then light from this object reaches your eye. Let's say your eye is effectively just a single point in in space.
Mhm. So, this eye is of course grossly over represented here. It's just a single point. And your eye knows where the upper corner of this object is by ray casting it like this, okay?
>> [gasps] >> And that's what creates these That's what's the perspective projection is being is doing. It's effectively warping because the rays extend in at angles from your eyes, or rather into your eyes.
What the orthographic pro- Or also it's it's also called a parallel projection, by the way.
What that is doing is you have an object, let's say this is the object here.
And that's what I meant by 1,000 eyes.
You have this eye here, and this eye here, and this eye here, and this eye here. And the light reaches your eyes in parallel rays like this.
And that's why there's no warping, but of course there's That's not how reality looks like.
Because in reality you absorb light from all different directions. But the orthographic projection is used in I think in engineering, especially in civil engineering where you and actually no, in in all kinds of engineering, in mechanical engineering, um where you design machines, buildings, bridges, etc., parts, whatever physical product, and you want to precisely model it such that every part of the object that you're modeling is equally represented, and that's how you can do it.
Let's have a look, for example, at a apartment plan.
Apartment floor plan, for example, is effectively if we look at it in 3D, this should be I don't know about this one. Is this orthographic or perspective? This is perspective.
But, you can have these floor plans in orthographic projection. This one is perspective because you see the inner walls from both sides.
Maybe let's look for orthographic specifically.
Here. Yeah, that's that's a good ex- good example.
Here, for example, that's an orthographic projection. You see that the individual shapes composing the structure that you're interested in, they are not distorted by perspective.
And when I'm looking at that one, I remember The Sims game.
Sims, you probably know it, which also uses a perspective projection. At least Oh, no, the new games don't, but the classic ones I'm too old, guys. The classic ones definitely use a orthographic projection here.
Okay, so that's a that was a small outlook on the different projections. And actually yeah, that's all we need to know about the projections. So, it can be camera perspective or camera orthographic if we deal with classical 3D game engine-ish um 3D worlds, then it's of course going to be the perspective projection.
So, let's define a camera 3D struct camera 3D cam and it's equal to let's have a look. So, position we position the camera Oh, no. Okay. So, I need a couple more variables here. I'm I'm not even sure how it's going to end up in the end.
>> [snorts] >> By the way, I just removed the struct here because it's part of the type definition. So, here the the camera 3D is defined as the the struct camera 3D is defined via type def as camera 3D. That's and that effectively maps this keyword to this.
So, we can omit that.
Same for the vector three as well. So, vector three is a position.
Let's say it's I don't know 10 0 0.
So, we look at an object. Let's assume that we're using meters. If you're from the US, sorry guys. Um sorry, not sorry.
Let's have a look, wait.
Meters versus feet? I don't even know what you guys in the US are using. Feet? Are you using feet to measure distances?
map here.
I'm not going to say anymore anymore than that. Where in the world do people use metric and imperial?
Why are all these maps so pixelated?
metric imperial map Good. Let me have a zip of water.
>> [sighs] >> So, for the rest of this video, I will say 10 m just for >> [clears throat] >> just so we have a common denominator denominator here. And we can think of units [snorts] of distance. I could also say 10 units.
But then we couldn't differentiate between measures of distance and measures of volume and measures of area. But I think in this episode we we are only going to deal with distances, right?
Anyways, let's say the target target is located at the origin point, right at the center of our coordinate system.
>> [sighs] >> Then the up vector is, let's say, oh, I don't know what the coordinate system is in in Real Axis. Is X and Y then the floor plane as in classical mathematics, or is it some some other plane? I will assume that X and Y are this. Let me just draw it just so we are all aligned. Why can't I just choose a color here?
So, I assume that the coordinate system looks somehow like this.
Probably X is this, y is this.
z is that.
And because that because that vector that we have to define now is called up, I assume that the first one is x, y, and we want it to point up. I am not sure if it actually should point up because I recall when I looked this up in the past, the up vector actually defined a vector that when it's when the cross product with some other vector was calculated, then the result should point up.
So, it could also be another vector, but we will just play around with it and see.
You see, I have some fragments of knowledge here in this area, but really it's um not much at all. Not much at all.
>> [gasps] >> Field of view. How What What's my field of view, guys? I'm going to try to figure out my field of view.
I'm going to stop when I can't see either of my hands anymore.
Mhm, I think now I'm approaching the border.
Yeah, okay. That's my field of view.
It's quite large. It's almost It's almost That's definitely a scientific method to determine field of view, guys. That's almost 180°.
But why? Are fields of views really that large in computer games? I don't think so.
Maybe I'm an exception.
Maybe I should create a YouTube channel and speak about my insane field of view.
So, float field of view FOV, uh but it was the field of view in Y degrees in perspective.
>> [gasps] >> Oh, ah, I see. Because in in the orthographic camera projection, there is no field of view because or maybe that's just how I am that's just me trying to figure out this right now.
Um here in the perspective projection, we have a field of view which is yeah, to be precise, this angle here.
In the of orthographic projection, there is no field of view.
This is unlimited. If this object was bigger, well, or is there a field of view?
Well, there's definitely not an opening angle because all the rays are parallel.
Somehow the scene is of course still limited, but there's no angle involved.
>> [sighs] >> So, how is it even determined what the field of view in orthographic projections is?
The field of view as in what fits into the screen image?
Some of you are probably watching this and freaking out because I know nothing here, but >> [sighs and gasps] >> it's really interesting. If you look at these these things without just copying them from some online example, and you really have a look at every individual field here, and you speak about it and think for it, you think about it for a second, it's it's always opening up interesting new questions that I didn't really think about in the past.
So, let's just say that the field of view, Y, whatever that is as compared to some regular field of view. Mm.
Um let's say this field of view is I I think I saw in games before that it's 90.
>> [sighs] >> But I don't know. Let's just set it to 90. I'm I'm sure with 90 degrees I can't go too wrong. Because let's say this is a player in a game. This is some object and then the player has a field of view of 90 degrees. Let's say it's looking like this approximately. It's not too bad. That one looks okay.
But of course, if you are a field of view monster like me, then you can see objects in this entire range.
Yeah.
I should get an award for these scientific drawings here.
Then we define a projection.
But we can define it as part of the camera itself. So, we define we uh we set define a camera that consists of the position, the target, the up vector, the field of view, and the perspective. And the perspective is at the projection, sorry.
The projection is camera perspective.
Oh, there seems to be also the opportunity to uh the possibility to create a custom projection.
Or whatever those are.
Well, first person, third person, orbital.
Interesting.
Let's see if we are going to encounter those later on.
Then let's close this and begin mode 3D with the cam.
And if we compile this, it's compiling.
If I execute it, there's nothing in here.
Okay, there's nothing in there because we probably need to do something else.
For example, we begin the mode 3D. Do we ever end it?
No, we currently don't end it, but I don't even think we need to end it.
We begin the mode 3D.
We set the camera.
But if we want to move, then maybe we need to move this inside the loop.
Maybe we need to do this.
Because if the camera is changing position and the angle it's looking at or the the target coordinate it's looking at, then maybe we're going to have to update it in here.
Inside the loop. Otherwise, we won't be able to move.
Now we begin drawing something. Begin drawing. Let's figure out and see if there's a begin drawing method for 3D.
No, there does not seem to be a method for that.
And how do I now draw anything?
There is probably something for 3D here.
Yeah, basic 3D shapes drawing functions.
Draw a line in 3D.
Draw a point in 3D. Draw a circle in 3D.
Um Okay. It's a circle in 3D.
Draw a triangle strip 3D. Draw cube.
There it is.
Draw cube at a position with a width and a height, a length.
Wait. Which cube has a width, a height, and a length? I thought that cubes are the three-dimensional version of squares.
But it's probably Apparently, it's the three-dimensional version of a rectangle.
Wait, that somehow does not make sense to me. Wait. Cube German is Würfel. Würfel is definitely the word for a three-dimensional square.
Is cube equal cool sided? I know I'm I mean I know what this library function means. I'm just wondering if it's precise or if if my understanding is flawed or if this is a conscious design choice.
Yeah, okay. So, this AI overview here states that yes, a cube is perfectly equal sided.
>> [sighs] >> All edges of a cube are equal in length.
Okay, but then what is a 3D rectangle name called in English?
It's a cuboid or rectangular prism.
Okay.
Never really heard of them.
So, I assume that this is just a conscious design choice because never nobody would ever be able to properly use a function if it's called draw rectangular prism. Because people just don't know what that is is if you're not a native speaker.
So, let's draw a cube in this >> [snorts] >> inside begin drawing and end drawing.
Inside the space delimited by those two functions, draw cube at a position.
And the position is a vector three.
Let's create a vector three that's called origin, and that's a position that is just 000.
And that's the position of the cube.
And then the length is one, the width is one, and the height is one.
And the color is red, as always, guys.
Whenever I try something new with raylib, it's always red.
And this compiles, and now we don't see anything, and the program is crashing.
Great.
What's the error here?
Matrix stack overflow. Oh, no, I can't even figure out regular stack overflows.
Why do you give me a matrix stack overflow now?
Please, don't.
>> [snorts] >> At least it's recognizing my graphics card. That's nice. I really never spent any attention here. Never really paid any attention here.
>> [sighs] >> So, hm, target time per frame is this.
Matrix stack overflow segmentation fault. Okay, now's the point in time where probably figuring things out would take too long. So, let's have a look at the raylib cube example and see what we need to do.
How to properly use those functions here. There it is.
Okay, where's the sample code? There it is.
So, we define a camera.
It's just zero. This is a placeholder for 000 as far as I know. Then, a Ah, no, it's just >> [snorts] >> No, it's it's of course just a placeholder for the entire structure and then the fields of the structure are populated here.
>> [snorts] >> Then, the field of view here is set to 45° only. Then, camera perspective is set. Cube position is zero. Just like in my case and a target frame rate is set.
We update the camera.
Okay, I don't know if the updating of the camera is needed or if it's just needed if it is changed. Probably, it's only needed if it's changed. But, here we already see that we can define the camera outside.
And update its position inside. That's useful. Then, we begin drawing. We clear the background. We begin the 3D mode inside the drawing.
Ah, okay. So, maybe I just need to switch those two functions up. So, we begin drawing first. Then, we begin the 3D mode. Then, probably before we end drawing, we also have to end mode 3D.
And that's probably just the pattern that raylib requires. So, if I compile this, now it works. And if I execute it, oh, yes, there is a small cube and it looks 2D.
Probably, because we are not looking at it from an angle. So, we are essentially looking at it exactly at its side.
>> [gasps] [sighs] >> But, that's already that's already a success. So, we are now in a 3D world, but we're not seeing any 3D effects.
So, we have subtly mastered the art of 3D already.
So, Okay, we can also draw cube wires.
What's cube wires? That's probably the skeleton around the cube, but let's not do that because I first want you to see the effect of the of the current drawing. So, what we currently need to do is we draw it we we create a camera.
And let's not eagerly not use the update camera thing.
What do we need it?
Wait.
Here, begin mode 3D is called using the same camera, and the same camera is updated in every iteration of the loop.
I don't know if this is required.
Why is update Why is update camera required? Because I could just do cam.position.x position.
x is incremented, for example. I could just change the position x.
Compile this. Of course, this doesn't work. Why doesn't it work?
Uh has no member position because, of course, it's it has no member pause.
That's just how I called the variable here. Of course, it's called position.
If I compile this now, that works, and then this does not work.
So, probably Mhm.
Uh I'm not so sure about that.
Maybe the camera is somehow read only.
But that doesn't make sense.
Because I'm passing a fresh camera here, and I'm creating it every single loop iteration.
But I would have expected that I can't change the camera, and if we move begin the 3D mode then and the camera changes in each each iteration and we should already see some movement.
But that's apparently not the case.
Why? Let's have a look at update camera.
Update cam here.
Update camera. We pass a camera and a mode and this updates the camera position for the selected mode.
What is the mode?
Because here in the sample I saw that the camera comes with this attribute camera free.
So maybe my camera is not free and cannot move.
Camera free.
Camera free mode.
Where do we can specify the camera mode?
Camera camera mode.
It's not used anywhere.
Oh, of course, because it's an enum enum and probably it's only referenced in library methods via an integer.
But apparently >> [sighs] >> not so sure.
Update camera. Why is this required?
Is this even required? This is something I don't know.
Because I'm creating a camera here and then I'm just changing its position.
Why do I need to specify a free camera mode?
Really?
Free camera.
>> Hmm.
position.x target up field of view camera perspective camera position.x plus plus that should increment the camera position.
Wait.
Let's just Let me just stupidly print the cam.position.x here.
Just to confirm that it's that it's changing.
Of course this is This is a floating point number.
Compile, execute. Yeah, and it is changing as you can see here. However, there was no movement in the running application.
That's odd.
And if I call update camera and I pass an address here of the camera. Wait. In begin mode 3D, what's the input here?
It's the camera. Ah, it's a pass by value here.
So, the 3D mode does not have a reference to the original camera. And if I change the original camera here I then I I I just I if I change the original camera here and I I have only passed the camera by value into the begin mode 3D, then begin mode 3D of course has no visibility, but of course I'm reiterating every time and passing the new value here.
Mhm.
>> [sighs] >> So, I I really don't get why I need to update the camera.
But let's try to do it and also pass this camera three here. Camera three.
Uh and let's see if this changes anything. And now it does seem to change something because now we see movement.
Uh we see really weird movement. How about we zoom in a bit by setting the position closer to the cube? For example, only 5 m distance.
Now we see a bigger rectangle.
And there's some movement back there. I don't get what that is.
What the hell is that?
>> [sighs] >> What's going on, guys?
Let's close a couple of tabs. Oh, I need the examples tab, of course.
And let's go to the 3D cube here.
And have a look. So, we update the camera.
We pass the address of the camera.
And when does this camera even change? The camera target does change if the Z or Z key is pressed and it's reset to zero.
Else um Wait.
How the hell does the movement here even change? How does the camera even change?
Oh, how's this looking around implemented in the code down there?
I don't see it.
Update camera. Begin drawing. 3D mode.
Draw cube. Draw cube wires. Draw grid.
End mode 3D.
End drawing. Where is the mouse handling even implemented?
Is this something that Oh, wait.
Ah, it's already active by default. So, if I move the mouse now, I see some mouse handling.
Okay.
Mhm, I see It seems to slowly click. So, what you are currently seeing is a cube.
When we move the mouse, we look around.
There's some new drawing happening here, but because the canvas is not cleared between updates, the background is not cleared.
You see this line being drawn.
And now you see I still don't see anything because you I need to compile, of course, and execute.
And now you see moving away from the cube.
Aha, but I was accessing only the X coordinate here. So, why is this moving away from the cube?
So, probably the coordinate system is somehow different here.
I'm looking I'm at Okay, I'm at at position Ah, I get it. I'm at position X5.
X equals 5. If I increase X, then of course, I'm moving away from the cube because I am currently positioned at X equals 5. I'm looking at the cube and I'm moving away from the cube because X is incrementing here.
Aha, okay.
And I can still look around using the mouse because that's what Yeah, the mouse does this panning around here. Does this looking around. Okay, it slowly seems to click. So, if I don't change the mouse position the following happens. Oh.
Ah, there it is. You see the Ah, okay. Somehow I can only move the mouse here and if I move it towards the center of the screen the rectangle already leaves the screen.
That's not very That's not convenient at all.
Oh, and I can already use the arrow keys here. That's already implemented by Raylib by Raylib. I can walk around the circle at the I can walk around the cube. All All these results are making me crazy, guys. So, we do have We do have a working 3D cube. I don't know I don't get why everything's working, but apparently everything is already implemented in Raylib.
And I can move away from the cube and toward it. I'm just using the WASD keys here. Probably the left and right and up and down arrow keys also work. Yeah, they do work, but they are very slow.
>> [sighs] >> And Okay, I get it. Now, the mouse pointer is annoying and that's what disable cursor was for disable cursor.
Now, let's compile this and execute it.
And now I Yeah, I can't even move the window because my cursor is disabled, which is not very useful. Can I somehow move away here?
Where's the application? There it is.
Yeah, okay, that's not very convenient for my use case because I need to be able to move the window so you can see it.
Nah, forgot compiling. Now, let's execute it.
There it is.
And where's the cube?
There it is.
So, now what's left is we have this cube here as you can see in a nice perspective projection.
That's nice.
And then what's missing is we want to draw the wire frame of this cube. Let's search for cube here.
Draw cube.
Draw cube and draw cube wires. There it is.
Let's do that down here as well. Draw cube wires.
And the cube wires are also located at at the same position.
And they have a width and a height and a width and height and length that is equal to the original cube.
And a color and that color is white.
And if we compile this now, we should have a cube here, perfect with a wire frame around it.
How can I move above the cube? I probably have to fly upwards somehow, but the mouse is exiting the screen. Yeah, okay.
Yeah, all right. I guess guys I guess can we call it a day? Is there anything else you want me to do?
>> [sighs and gasps] >> I actually like the result very much.
I preferred to this one here with this ugly coordinate system.
So, this is quite a raw result.
It's apparently if you understand it once how it works, in raylib it's quite simple to create a 3D object and move around it.
That's quite nice. So, that's our result. Now, we could easily extend it if you want in another episode and we could place a new block next to this one and then another block next to this one and then a block on top of this one and then we already have a Minecraft clone that's almost indistinguishable from the original Minecraft. Well, well, well, there's so much stuff that we can do in 3D. Put your ideas in the comments and if you want to learn C from scratch and be able to create these projects yourselves and create real useful C projects that are not boring and um useful actually, then have a look at the No Nonsense C programming course that's linked in the description below the video. It's a course that takes you from zero C skills to quite capable C along with terminal skills and everything that everything that I do here you will be able to do perfectly fine yourselves without boring PowerPoint slides, only practicing.
We We're only only going to explore stuff in the terminal and I give you practice exercises and if you follow them, I promise you the difference from before and after the course will be night and day.
So, I also show a couple of tricks um terminal tricks and mental models that I use on a day-to-day basis. So, it's not just C, it's very very useful computer knowledge in general.
So, have a look at that. It's linked under the video. Aside from that, I hope you guys enjoyed it. It's quite a simple project, I admit it.
But, it's a project that allows us that allowed us to initiate the flame >> [snorts] >> that or to to spark desires for future C 3D projects.
>> [gasps] >> All right, guys. I'm not going to talk >> [laughter] >> anymore and bore you to death. So, see you in the next episode. Bye-bye.
関連おすすめ
resume fixed instantly 😭 Comment “app”andI’ll sendyou the link #parakeetaipartnership #resumetips
Ritcareer
686 views•2026-05-31
Re: 🗣️📍theprophedu📍2026 GST 103 CLASS (E-EXAM REVISION)
theprophedu
636 views•2026-06-04
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
Making Minecraft Clone with C++ & Raylib
PecaCSLive
686 views•2026-06-04
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Instagram accounts got PWNed
EricParker
13K views•2026-06-03
So What's Odin Lang Even Good For
TechOverTea
131 views•2026-06-01
🚀 BCS613C Compiler Design | Module 1 to 5 Schema Evaluation 🔥 | VTU 6th Sem 💯 #VTU #bcs613c #exam
Pranavaa-y4y
104 views•2026-06-02











