Recent

Author Topic: Homography & affine transformations  (Read 13564 times)

EmperorOfKeyboard

  • New Member
  • *
  • Posts: 29
  • That is why people who are afraid to look inside t
Re: Homography & affine transformations
« Reply #15 on: December 23, 2021, 01:01:53 am »
Maby I are doing somethink wrong, butt I cannot find download button. :(
Well, I can for separate files, byt there're hundreds! Not to mention folders structure.
Maby I need login GitBug?
I so smart almos smart as you, but i also cute.

Seenkao

  • Sr. Member
  • ****
  • Posts: 399
    • New ZenGL.
Re: Homography & affine transformations
« Reply #16 on: December 23, 2021, 05:24:13 am »
Ты в папку зашёл, выйди и скачай всю библиотеку. Да, забыл, она работает с Delphi, можно с Delphi 7.

Можешь попробовать ещё ZenGL. Просто я не знаю, насколько будет легко тебе с ним работать. Но примеры так же есть для работы с основными примитивами. Смотри пятую демку. А вообще можешь все демки посмотреть.  :) Работать будет и на Lazarus и даже на FPC отдельно (нужен опыт компилирования для FPC, новичкам проще в Lazarus компилировать).

Google translate: You went into the folder, go out and download the entire library. Yes, I forgot, it works with Delphi, you can with Delphi 7.

You can also try ZenGL. I just don't know how easy it will be for you to work with him. But there are also examples for working with basic primitives. See the fifth demo. In general, you can see everything. :) Will work on Lazarus and even on FPC separately (compilation experience for FPC is required).
« Last Edit: December 23, 2021, 05:35:22 am by Seenkao »
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.
Работаю над ZenGL.
Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL. :)

circular

  • Hero Member
  • *****
  • Posts: 3794
    • Personal webpage
Re: Homography & affine transformations
« Reply #17 on: December 23, 2021, 08:38:54 am »
It depends how low level you wanna go.

That can be done directly your program or using libraries. Nowadays most computer support OpenGL so you can get things very much accelerated.

Here are all the steps you need:
- have objects defined in a 3D world, each vertex as (x,y,z) coordinates
- rotate the world around the viewer (lots of sine and cosine or using normalization and vector product to compute all axes)
- projection in 2D : basically dividing horizontal and vertical coordinates by depth. Though it may not be trivial if the polygon is both in front and behind, like as wall on the side, because then you need to split it at a certain distance to avoid dividing by 0.
- filling the texture : this combines regular polygon filling but also interpolating 1/z to get a perspective transform.

If you use a 3D library, basically you only need to take care of defining the 3D objects and define the transform. Programming everything up to the pixels is feasible, I did it in BGRABitmap library, though software rendering is much slower than hardware.

Here is how for example a class that computes a scene (rotating and projecting):
https://github.com/bgrabitmap/bgrabitmap/blob/master/bgrabitmap/bgrascene3d.pas

Here is an example on how to actually render the polygons (it uses software units):
https://github.com/bgrabitmap/bgrabitmap/blob/master/bgrabitmap/bgrarenderer3d.pas

And here using OpenGL (encapsulated in classes):
https://github.com/bgrabitmap/bgrabitmap/blob/master/bgrabitmap/bgraopengl3d.pas

Regards
Conscience is the debugger of the mind

EmperorOfKeyboard

  • New Member
  • *
  • Posts: 29
  • That is why people who are afraid to look inside t
Re: Homography & affine transformations
« Reply #18 on: December 23, 2021, 01:50:54 pm »
Seenkao, same.

circular, division by 0 only if character stands right on the wall, collision test must prevent it. Or mobsters who attack - they should never be placed in came coords as char. Of course char must have "standard" heigth, for what reason i dodnt decide. Maybe if character shall be have 0 height, then it may go throught wall, because walls must have heigth.... I didnt think. I want make somethink as SESMAR, but w/o that ill anime and with right angle. (Scr taken from https://www.polygon.com/2018/2/15/17012102/secret-of-mana-review-remake-ps4-vita-playstation-sony-pc-release-square-enix.)

Why I want own game? Reson is so simple that you'll no laugh because it's getting old (i dont know what that means, but its like "boring"?): i cannot win regular games! So if I'll make own, I be sure i can win or no one can win, haha. (Problem of such way be that no one except me shall want play such game. Too easy.)
I so smart almos smart as you, but i also cute.

circular

  • Hero Member
  • *****
  • Posts: 3794
    • Personal webpage
Re: Homography & affine transformations
« Reply #19 on: December 23, 2021, 03:03:36 pm »
circular, division by 0 only if character stands right on the wall, collision test must prevent it.
I think you missed the point. If there is anything behind you, like the floor or a wall on your left or right, then at some point, the z value is zero. This is generally solved by defining a clip plane, a minimum depth for drawing things. For example, in real life that could be everything at least 1 cm away.

Quote
Why I want own game? Reson is so simple that you'll no laugh because it's getting old (i dont know what that means, but its like "boring"?): i cannot win regular games! So if I'll make own, I be sure i can win or no one can win, haha. (Problem of such way be that no one except me shall want play such game. Too easy.)
That's a good reason enough. You could also try on easy settings.  ;)
Conscience is the debugger of the mind

Seenkao

  • Sr. Member
  • ****
  • Posts: 399
    • New ZenGL.
Re: Homography & affine transformations
« Reply #20 on: December 23, 2021, 06:46:29 pm »
Seenkao, same.
Нет, это не то же самое. Они подобны.
ZenGL кросс платформенный и может работать и на Delphi и на FPC/Lazarus.
GLEngine2D - только для Windows и только для Delphi (для FPC/Lazarus его надо переделывать).

GLEngine2D более понятен для новичка (как моё мнение). Не создаёт сам окно, работает только с VCL (насчёт FMX не знаю).
ZenGL менее понятен в использовании. Позволяет создавать окно как самостоятельно, так и работать с VCL/LCL. Позволяет сделать больше чем GLEngine2D.

Обе библиотеки только для 2D. Но обе можно переделать под 3D, по своему желанию. Для этого надо знать OpenGL.

Есть ещё множество разных библиотек для работы как с OpenGL, так и с DirectX. И тут надо их пересматривать и выбирать что хочется и по мере того что понравилось - выбирать.

Google translate: No, it’s not the same. They are similar.
ZenGL is cross platform and can run on both Delphi and FPC / Lazarus.
GLEngine2D - only for Windows and only for Delphi (for FPC / Lazarus it needs to be redone).

GLEngine2D is more understandable for a beginner (in my opinion). Does not create the window itself, only works with VCL (I don’t know about FMX).
ZenGL is less intuitive to use. Allows you to create a window both independently and work with VCL / LCL. Lets you do more than GLEngine2D.

Both libraries are 2D only. But both can be remade for 3D, as you wish. To do this, you need to know OpenGL.

There are many more different libraries for working with both OpenGL and DirectX. And then you need to revise them and choose what you want and, as you liked it, choose.

Quote
Why I want own game? Reson is so simple that you'll no laugh because it's getting old (i dont know what that means, but its like "boring"?): i cannot win regular games! So if I'll make own, I be sure i can win or no one can win, haha. (Problem of such way be that no one except me shall want play such game. Too easy.)
начинать создавать игры надо с простых вещей, например "Тетрис", "Сокобан", "Пинг-понг" и подобные. Чтоб получить общий опыт с чем можно столкнуться при создании игры. И, если есть желание создавать игры, то надо выбирать сразу полноценный движок, в котором не надо будет всё делать вручную. Который предоставляет необходимый функционал для создания игры.

Хорошо, если есть опыт в написании простых игр, тогда можно приступать и к более сложным проектам. :)

Писать игру с полного нуля, не очень хорошая затея. На это будет потрачено очень много времени. Если оно у тебя есть, то вперёд - дерзай!  ;) Но если не хватит терпения и жалко времени, то просто "забей". Выбирай понравившийся игровой движок.

Google translate:
you need to start creating games with simple things, for example, "Tetris", "Sokoban", "Ping-pong" and the like. To get a general experience with what you can face when creating a game. And, if there is a desire to create games, then you need to choose a full-fledged engine right away, in which you will not have to do everything manually. Which provides the necessary functionality to create a game.

Well, if you have experience in writing simple games, then you can start more complex projects. :)

Writing a game from scratch is not a good idea. A lot of time will be spent on this. If you have this time, then go ahead - go for it! ;) But if you do not have enough patience and feel sorry for the time, then just "forget it." Choose the game engine you like.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.
Работаю над ZenGL.
Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL. :)

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 762
Re: Homography & affine transformations
« Reply #21 on: December 24, 2021, 04:41:01 pm »
Linear algebra - is universal way to convert coordinates. And it's actually easy to understand, if it's explained correctly.

Vector - is coordinate-independent object. We've got used to Euclidean coordinates so much, that we don't even realize, that it's just one of infinite number of possible coordinate systems. Vector coordinates can't be specified without corresponding coordinate system. Coordinate system is specified via set of basis vectors, i.e. unit vectors along axises. There is also another important operation - dot product. It's nothing more, than projection of one vector onto another and multiplying their lengths. Or just projection, if one of vectors is unit vector, as basis vector is. And coordinates - are nothing more, than projections of vector onto basis vectors. I.e. dot products x = v · e.

And matrix - is nothing more, than just set of new coordinate system basis vectors, specified in old coordinate system. And therefore Mv multiplication is nothing more, than just projection (i.e. dot product) of vector, specified in old coordinate system, onto basis vectors of new coordinate system, also specified in old coordinate system. And therefore matrix multiplication - is nothing more, than just projection of set of basis vectors onto coordinate system, specified by another set of basis vectors. Transposing is needed to coordinate vector/matrix sizes, so they would obey vector/matrix multiplication rule - (n x m)(m x k) = (n x k).

Translation is achieved via adding 4th coordinate and assuming, that it's always 1. So, 4th basis vector is simply added to resulting vector. Matrix is usually padded to 4x4 via adding (0, 0, 0, 1) vector in order to make matrix multiplications easier.

So, only problem, we need to solve - to choose coordinate systems we need and describe them via corresponding basis vector sets, i.e. matrices.

Object coordinates are usually specified via it's local coordinates. It's done to make object transformation easier. Then it's coordinates are converted into world space, so we need local -> world matrix. And then we need to convert coordinates into viewer space, as viewer - is actually point, we are looking from. Therefore we need world -> viewer matrix. Last matrix - is projection matrix, that is little more complex. Projection - is non-linear operation, so it isn't possible via simple vector/matrix multiplications. Perspective projection is done via adding extra operation using that fourth coordinate w, that is usually unused - i.e. perspective division (x/w, y/w, z/w, w/w). Projection matrix is chosen such way, that all coordinates, falling into view frustum, should be converted into specific range, i.e. -1..1 or 0..1. I don't remember exactly.
« Last Edit: December 24, 2021, 05:01:03 pm by Mr.Madguy »
29.12.2021 - migration to DynamicData 4.1 is completed - complete overhaul of data access driver.
My project still requires full Delphi 2009 support to be ported to Lazarus.
It's time to finally do it, because Delphi 2009 is 13 years old.

EmperorOfKeyboard

  • New Member
  • *
  • Posts: 29
  • That is why people who are afraid to look inside t
Re: Homography & affine transformations
« Reply #22 on: December 25, 2021, 04:42:40 pm »
I is greatly sorry gays, i were totally busy with sleeping. Last lime I sleeped 12 hours! 8)

Excuse me for this flood, i just need finish my sleepings and eatings berofe i shall do som.

So, responce to question why i want make bike out of spikes instead of make real things on products which passed test of tymes.

circular, i guess uoy meant that if something segment be on the POV, perspective shall unwind it to infinity + and -. I agree, but visually it chall be no more than column of 2 colors walking throught POV. I mean, if texture is even, it gives 2 pixels of maby different color in centre of its top row. But you're right about checking /0.

Seenkao, I meant same result - i cannot download probably i has obcolete browser, OS or computor, so GitHub show me no download buttons.
I are not beginner! I made about 5 games on God-forsaken Builder 6++ and blasphemous VBA! 2 of them are fault: 1st works but i f****d lose source, 2nd i has sources, but hexes works wrong, so it's not finished. Now I make superior desk game where horse must eat colored balls. It's like another balls game, but with horse. 1st my game was about it too, but w/o chains of moves. And, of course, tanks with sounds!!! Which requires rtl60.bpl. Main probles of my greatest game of all tymes is comception. I mot invented it fully. I has sketches, butt not whole architeckture.

Mr.Madguy, you got the point gut. I really like analytick geometry even i cannot understand how it works (almost). Definitely if we can prematurely calc matrices, it can save recourses and make performance grow. Also (I plan to use it later) if we have fixed angle on whic char can rotate, we may beforehand make a table with all sins and coss, it also speed up. I downloaded some books to read about, because all what i readed before i sucesfully forget.

Thankc google for it good translator. I used it just for only some words. My english (not pronounce) is so good that I can refugee to Great England as migrant! I simply don't want. And not oligarch.

If I shall made something worth, I'll post it on forum, I mean, about perspective. But before it I'll make my little game and maby make video to brag how awesome I is. Rules: on board 8x8 horse eat color balls. It can eat ball only same colors with it. Moves are chess. On easy level you can select 5 moves before ball start falling (it's always new balls added from top, random color, as in many such games), on hard - only 3. After each jump horse can change color ONCE. It's for changing colors to eat all of them and preventing stuck if in this cell in no more horse moves. It sounds great, but since i never tested, i do not know how good balance is. Maby i need more colors or more moves. I already built window!!! With BUTTONS!!!!!!! (Really, programming with mouse is useful if it's not onlu mouse programming.)

Thank you, we'll see each other after maintenance if there shall be anything. :D
I so smart almos smart as you, but i also cute.

 

TinyPortal © 2005-2018