Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
19 May, 2013, 17:55:16 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1] 2 3 ... 7   Go Down
  Print  
Author Topic: Texture drawing -  (Read 4007 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
ben_g
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: Today at 14:09:15
Date Registered: 08 May, 2011, 21:03:27
Location: (ix+$43)
Posts: 645


Topic starter
Total Post Ratings: +74

View Profile
« on: 13 June, 2011, 22:29:29 »
0

Does anybody knows how to draw repeated textures? It would help a lot at my 3D engine, which now can only render wireframe.

I only need to know how it's done, so I can write my own routine.

What I mean with textures: this is a wire frame rectangle rendered by my 3D Engine:

I want to draw a sprite between those 4 points. Could someone explain the principle behind this please?
Logged

Spoiler for completely unimportant stuff:
My projects
 - A base converter that also supports signed and fixed-point numbers.
 - A first person shooter with a polygon-based 3d engine.
Spoiler for latest screenshot:
- A java MORPG.
Spoiler for screenshot:
- a minecraft game in axe
Spoiler for Only open this spoiler if you want to read what's inside:
What's inside.
From when I saw this image, I never lost the game again!
Spoiler for This is [Edit:
not[/Edit] my contest entry. I hope you like it.]
thepenguin77
z80 Assembly Master
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Yesterday at 21:48:33
Date Registered: 14 December, 2009, 04:21:52
Location: Purdue
Posts: 1483


Total Post Ratings: +778

View Profile
« Reply #1 on: 13 June, 2011, 23:35:20 »
0

There's only one person I can think of that has ever done that, he made Gemini. Looking through the source of that, you could probably figure out how he did it.

At the moment, I can think of some ways to do it, but I'm not sure they would be fast.
Logged

zStart v1.3.011 4-29-2013  zStart fully works on 83+BE's (except custom font)
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112
Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Online Online

Gender: Male
Last Login: Today at 17:32:31
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Total Post Ratings: +492

View Profile
« Reply #2 on: 14 June, 2011, 00:59:02 »
0

Well Gemini was a raycaster, not a "real" 3D engine. Which I believe is what ben_g wants. Applying textures in raycasting is easy because of the vertical scanline rendering method and the restrictions of the camera.
« Last Edit: 14 June, 2011, 01:00:02 by Runer112 » Logged
leafy
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: 17 May, 2013, 00:26:27
Date Registered: 26 December, 2010, 05:27:03
Location: the ninth circle of hell
Posts: 1545


Total Post Ratings: +371

View Profile WWW
« Reply #3 on: 14 June, 2011, 00:59:59 »
0

So is this just a horizontal engine? No looking up or down?
Logged

In-progress: Blastlabs, TMJO, qb?, VVVVVV?
Finished: Tag, Tap, MFQT, Nyan
Dead: Graviter
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 16:06:21
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50202


Total Post Ratings: +2611

View Profile WWW
« Reply #4 on: 14 June, 2011, 02:10:42 »
0

Hmm I haven't seen any 3d polygon game with textures on calculators yet. I wonder if it would achieve sustainable speed like in Runer112's raycaster?
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
leafy
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: 17 May, 2013, 00:26:27
Date Registered: 26 December, 2010, 05:27:03
Location: the ninth circle of hell
Posts: 1545


Total Post Ratings: +371

View Profile WWW
« Reply #5 on: 14 June, 2011, 02:12:29 »
0

Look for wolfenstein castle.

EDIT: http://www.ticalc.org/archives/files/fileinfo/277/27767.html

Hella awesome.
Logged

In-progress: Blastlabs, TMJO, qb?, VVVVVV?
Finished: Tag, Tap, MFQT, Nyan
Dead: Graviter
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 16:06:21
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50202


Total Post Ratings: +2611

View Profile WWW
« Reply #6 on: 14 June, 2011, 02:16:37 »
0

That's a raycaster too actually, like Gemini.
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
leafy
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: 17 May, 2013, 00:26:27
Date Registered: 26 December, 2010, 05:27:03
Location: the ninth circle of hell
Posts: 1545


Total Post Ratings: +371

View Profile WWW
« Reply #7 on: 14 June, 2011, 02:18:17 »
0

Oh you said polygon. Never mind.
Logged

In-progress: Blastlabs, TMJO, qb?, VVVVVV?
Finished: Tag, Tap, MFQT, Nyan
Dead: Graviter
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 11:51:23
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Total Post Ratings: +589

View Profile
« Reply #8 on: 14 June, 2011, 08:25:37 »
0

The only project I have ever seen that used linear interpolation across polygons was a space shooter thingy from maxcoders but it was limited, and that was in asm.  The method used is called linear interpolation, and I have a really good website that explains it, but it's on my other computer, so i will have to post it later.  Let me say though, that this is not an easy task, and even the most optimized engines will take lots of memory and barely be able to handle too many polygons.
Logged

ben_g
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: Today at 14:09:15
Date Registered: 08 May, 2011, 21:03:27
Location: (ix+$43)
Posts: 645


Topic starter
Total Post Ratings: +74

View Profile
« Reply #9 on: 14 June, 2011, 13:27:37 »
0

Well Gemini was a raycaster, not a "real" 3D engine. Which I believe is what ben_g wants. Applying textures in raycasting is easy because of the vertical scanline rendering method and the restrictions of the camera.
Yes, It's a "real" 3D engine, and it supports both vertical and horizontal rotation, as well as letting the camera rotate along it's axis using the up vector. There's no way to use routines from raycasters for this. I've already checked gemini, and it renders by casting rays, not by calculating the location of points and drawing a texture between them.

btw: what would be the easyest? Drawing a texture on the quad or drawing a quad as two textured triangles? (Triangles are used with 3D on a computer, But I don't know which is the fastest)
Logged

Spoiler for completely unimportant stuff:
My projects
 - A base converter that also supports signed and fixed-point numbers.
 - A first person shooter with a polygon-based 3d engine.
Spoiler for latest screenshot:
- A java MORPG.
Spoiler for screenshot:
- a minecraft game in axe
Spoiler for Only open this spoiler if you want to read what's inside:
What's inside.
From when I saw this image, I never lost the game again!
Spoiler for This is [Edit:
not[/Edit] my contest entry. I hope you like it.]
Hayleia
Programming Absol
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Last Login: Yesterday at 09:26:23
Date Registered: 01 June, 2011, 20:12:47
Location: ud-ud ?
Posts: 2043


Total Post Ratings: +254

View Profile
« Reply #10 on: 14 June, 2011, 13:32:50 »
0

[offtopic] Congrats ben_g: 100th post !
Logged





Spoiler for what I am according to...:
me: useless
Pokemon Test: an Absol
turiqwalrus: an eggplant
p2: A HUMAN BEING !
Blackpilar and p2: iplantonlyplantwantplanttoplantknowplantifplantyouplantareplantaplantboyplantorplantaplantgirlplant
click here to know where you got your last +1s
thepenguin77
z80 Assembly Master
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Yesterday at 21:48:33
Date Registered: 14 December, 2009, 04:21:52
Location: Purdue
Posts: 1483


Total Post Ratings: +778

View Profile
« Reply #11 on: 14 June, 2011, 17:09:41 »
0

Ok, here is my method. I'm literally making it up as I write this post, but in the end it should work. For this you should use triangles.

1. Convert the 3 corners to xy coordinates.
2. Calculate the relative size of the leftmost point. (3d window distance thing / distance)
3. Now calculate the relative size of each of the other two points and subtract the original from them.
4. (This is where it gets sketchy) You need to figure out the two slopes of (relative distance) / x = a and (relative distance) / y = b. Right now you have two equations: d1 = ax1 + bx1 and d2 = ax2 + bx2. So you need to solve those for a and b. I would divide the first equation by x1, then subtract the the second equation from the first. the ax's will cancel and you can get b. Then just substitute b and get a.
5. Now to apply the texture, we have to base the texture somewhere, so you should probably put the leftmost point on the left side of the texture dead centered vertically.
6. To calculate the pixel in the texture to use for a screen coordinate, here is what you do. X = (1 / (screenOffsetX * a + relativeSizeOfLeft) * screenOffsetX / totalXWidth * textureWidth) and Y is the same.
7. Then, take that pixel out of the texture and put it on the screen.

As far as I can tell, that should work. I'm sure if you actually do it, you'll find lots of optimizations. For instance, the reciprocal I forgot about at the end could probably be calculated earlier.
Logged

zStart v1.3.011 4-29-2013  zStart fully works on 83+BE's (except custom font)
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112
ben_g
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: Today at 14:09:15
Date Registered: 08 May, 2011, 21:03:27
Location: (ix+$43)
Posts: 645


Topic starter
Total Post Ratings: +74

View Profile
« Reply #12 on: 14 June, 2011, 19:33:14 »
0

Ok, here is my method. I'm literally making it up as I write this post, but in the end it should work. For this you should use triangles.
...
2. Calculate the relative size of the leftmost point. (3d window distance thing / distance)
3. Now calculate the relative size of each of the other two points and subtract the original from them.
...
Could you please explain what you mean by the size of a point?

[offtopic] Congrats ben_g: 100th post !
Thanks. 100 post sure goes by fast. I didn't knew I was already there Tongue
Logged

Spoiler for completely unimportant stuff:
My projects
 - A base converter that also supports signed and fixed-point numbers.
 - A first person shooter with a polygon-based 3d engine.
Spoiler for latest screenshot:
- A java MORPG.
Spoiler for screenshot:
- a minecraft game in axe
Spoiler for Only open this spoiler if you want to read what's inside:
What's inside.
From when I saw this image, I never lost the game again!
Spoiler for This is [Edit:
not[/Edit] my contest entry. I hope you like it.]
thepenguin77
z80 Assembly Master
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Yesterday at 21:48:33
Date Registered: 14 December, 2009, 04:21:52
Location: Purdue
Posts: 1483


Total Post Ratings: +778

View Profile
« Reply #13 on: 14 June, 2011, 19:55:25 »
0

Ok, you can use this page and this page for pictures.

What you are trying to do is to figure out how tall the wall should be on the actual screen. The concept we are using here is that an object that is twice as far from you will look half the size. So we can see that the equation would be size = k/distance. Now the question is of course, what is k.

K is the distance to the projection screen. The way you calculate this, you can see in that first link I gave you. It is (screenWidth / 2) / tan(fieldOfView / 2). So assuming you are using a 60 degree field of view on the calculator. 48/tan(30) = 83.

Now go to the second link. What this means, is that a wall on screen that is 83 units away, will be it's actual size. 166 units away it will be half its size, 41.5 units away it will be double size.

So the formula is now (relative size) = 83/distance. Which means if your sprite is supposed to be 50 pixels tall, when it is 120 units away, it will be 83/120 * 50 = 34.5 pixels tall.
Logged

zStart v1.3.011 4-29-2013  zStart fully works on 83+BE's (except custom font)
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112
ben_g
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: Today at 14:09:15
Date Registered: 08 May, 2011, 21:03:27
Location: (ix+$43)
Posts: 645


Topic starter
Total Post Ratings: +74

View Profile
« Reply #14 on: 14 June, 2011, 20:17:33 »
0

Isn't it much easier to calculate how tall the wall is by calculating the distance between the upper point and the lower point? I already convert points from 3D to 2D, so won't it be faster when the textures are calculated to just fit between those points? Triangles have more possibilities, so I think triangles are the best choice, but if I can calculate the slope and size of all 3 sides, isn't that enough to apply a texture?
Logged

Spoiler for completely unimportant stuff:
My projects
 - A base converter that also supports signed and fixed-point numbers.
 - A first person shooter with a polygon-based 3d engine.
Spoiler for latest screenshot:
- A java MORPG.
Spoiler for screenshot:
- a minecraft game in axe
Spoiler for Only open this spoiler if you want to read what's inside:
What's inside.
From when I saw this image, I never lost the game again!
Spoiler for This is [Edit:
not[/Edit] my contest entry. I hope you like it.]
Pages: [1] 2 3 ... 7   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.278 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.