Coding Math: Episode 22 - 3D - Postcards in Space

preview_player
Показать описание
Finally, we make it into the realm of the third dimension. Or at least half way into the third dimension.

Рекомендации по теме
Комментарии
Автор

No need to apologise for the lack of coding...your voice is enough to calm anything and everything : ¬ )

johnconley
Автор

I used this formula for computing the odds of hitting a guy with an arrow shot in an RPG I made. The target size get smaller with distance. How much smaller? Well, just use Keith's formula.

if z = 0, you have a 100% chance to hit the target. If z = 600, you have a 33% chance to score a hit. And so on. Makes for interesting dice rolls.

kevnar
Автор

Here's the code for those of you not using canvas translation:

xOffset = width / 2; // sets the vanishing point to center screen
yOffset = height / 2;

perspective = fl / (fl + shapePos.z);

zSize = shapeSize * perspective;
xPos = xOffset + (shapePos.x * perspective) - (zSize / 2);
yPos = yOffset + (shapePos.y * perspective) - (zSize / 2);
G.FillRect(xPos, yPos, zSize, zSize);


shapeSize is the size of the rectangle. Keith set his to 200. You should be able to figure the rest out.

kevnar
Автор

In 3d programming, these are often called billboards or billboard sprites.

jimsmart
Автор

I recently started following these tutorials and for me the best thing about these videos are Keith's sense of humour 🤣🤣. Last video was posted on this channel way back in 2017. I hope you are doing well Keith and also thank you for these amazing tutorials, they have helped me a lot.

khushwantdafre
Автор

Hi, can you explain from where comes the perspective formula please ? Otherwise nice video !

sociamix
Автор

Thanks for the explanation Kieth. Love your tutorials.

thawfeekyahya
Автор

you impressed me with the exampless that was nice 

lucasmachain
Автор

Why do you first translate by x*perspective ans then do the scale ? By doing the scale first, the drawing position will also be scale by perspective, then you just have to draw the object at is original x and y coordinate.

TheGrifdail
Автор

you're tutorials are exactly what I was looking for!!

BlenderGameArtist
Автор

thank you so much for all.
do you have a video about raycasting?

joaquimjesus
Автор

I dont understand why focal length (the diameter of an eye basically) is a number as large as 300 (large relative to distances u use in the world).

alekmoth
Автор

@13:50 You didn't order the blit order of the objects by by z-axis, taking advantage of the painter's algorithm for occlusion? It would take literally a minute to explain.

cygil
Автор

why 'fl', on perspective, is 300?

joaquimjesus
Автор

Are the z-index problems with the last example just because you originally set it up to go away from the camera as opposed to towards?

Revlis
Автор

I find your tutorials a little long winded (perspective -- I get it, get to the formulas already) but others seem to appreciate it so I guess there's a niche for it.

cygil
Автор

It's not just how stuff was rendered in Wolfenstein. It's how every single particle effect is rendered in every single game.

DasAntiNaziBroetchen