I Don't Watch 3D Fund, But....

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
curry
Posts: 45
Joined: September 19th, 2017, 9:43 pm

Re: I Don't Watch 3D Fund, But....

Post by curry » May 22nd, 2018, 5:26 pm

Did every one on the forum die?
I may have lost my original account to a half drunk chili, but i'm still better than you, F*ck Off!

User avatar
curry
Posts: 45
Joined: September 19th, 2017, 9:43 pm

Re: I Don't Watch 3D Fund, But....

Post by curry » June 12th, 2018, 2:29 am

Don't read if you like your parents:
Spoiler:
This might sound wrong, but shits finally turning around. My parents are getting divorced, which means my criminal record is being wiped clean (metaphor). All ongoing punishments will be canceled, which means you can expect me back in the community, working on this project in as little as a month. Exited to be back.
I may have lost my original account to a half drunk chili, but i'm still better than you, F*ck Off!

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: I Don't Watch 3D Fund, But....

Post by albinopapa » June 13th, 2018, 8:34 pm

Hmm, sorry to hear about the parents splitting, but glad to hear you're going to get back into coding.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
curry
Posts: 45
Joined: September 19th, 2017, 9:43 pm

Re: I Don't Watch 3D Fund, But....

Post by curry » June 14th, 2018, 6:10 am

Hey, had to star over. New ship and all, but I cant make a star field type thing (like this). My first few attempts, I tried to use the cstdlib and ctime in a class, but the ship just shot them out like a fucking cannon (new idea?). I'll keep trying, but if you come up with any solutions, please tell me. If you want the solution, let me know. I haven't made a repo yet, so you will get a huge ass zip instead.
albinopapa wrote:Hmm, sorry to hear about the parents splitting, but glad to hear you're going to get back into coding.
Do you like your parents?
Attachments
Shit_swizzeler.zip
New Ship Shit.
(146.24 KiB) Downloaded 145 times
I may have lost my original account to a half drunk chili, but i'm still better than you, F*ck Off!

User avatar
curry
Posts: 45
Joined: September 19th, 2017, 9:43 pm

Re: I Don't Watch 3D Fund, But....

Post by curry » June 14th, 2018, 6:15 am

No animation for this ship, to complex. I'm not doing that shit. Someone else can, I'm not. Why can I not left click on the text box? I have to use the arrow keys to go to different parts of the text.
I may have lost my original account to a half drunk chili, but i'm still better than you, F*ck Off!

User avatar
curry
Posts: 45
Joined: September 19th, 2017, 9:43 pm

Re: I Don't Watch 3D Fund, But....

Post by curry » June 14th, 2018, 6:24 am

Oh, I figured out textures and scaling! For textures, it uses the custom getpixel to tell if you are on a specific color. And if you are, it loads the texture to that spot. Then I used some back alley bullshit algorithm to get the angling working. It basically skips pixels of the bitmap. It looks like shit from some angles, but it gets the job done. For scaling, I just draw the thing at double the size, and cut out pixels, or duplicate them based on what size you want.
I may have lost my original account to a half drunk chili, but i'm still better than you, F*ck Off!

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: I Don't Watch 3D Fund, But....

Post by albinopapa » June 14th, 2018, 3:56 pm

I love my parents, but sometimes wish they would get a divorce for both there sake.

I downloaded your demo, looks like you need a few more stars in that star field :p.

There are two algorithms that I have learned to draw triangles. The first is chili's raster algorithm and the second is using barycentric coordinates. Using the method chili uses, there is a lot of linear interpolation. Using the barycentric coordinates requires less steps in my opinion. I'm curious to know what "back ally algorithm" you used.

As for scaling, if you don't need to rotate the sprite or whatever, then simply skipping pixels or sampling the same pixel is pretty much all that is needed. Mathematically, you would just take the width of the texture divided by the width you want on screen and that is the stepping for each pixel in the texture to sample.

If you have a 32x32 texture and a 64x64 on-screen sprite ( scale factor 2x ) for every two pixels on screen, you sample the same texture pixel twice. If you have a 32x32 texture and a 48x48 on-screen sprite ( scale factor 1.5x ) for every 1.5 pixels on screen, you sample the same texture pixel. For best results though, you could blend the neighboring texture pixels using bilinear filtering.

To do bilinear filtering, you would blend the two neighboring pixels horizontally on the current row, then the two on the row below the current row. Then interpolate between between those two pixels.

Example:

Code: Select all

		const Color topLeft		= { 255, 255,   0, 0 };
		const Color topRight		= { 255,   0, 255, 0 };
		const Color bottomLeft	= { 255, 128, 128, 0 };
		const Color bottomRight	= { 255,   0, 255, 0 };

		const float xStart = 375.f;
		const float yStart = 275.f;
		const float xPos = 394.5f;
		const float yPos = 294.5f;
		
		// First, you need to determine the percentage of each pixel needs to be sampled
		const float tx = xPos - std::floorf( xPos );
		const float ty = yPos - std::floorf( yPos );

		// These represent the percentages in the range of unsigned ints instead of floats
		// ix and iy are the current pixel averages ( inverse average ) 
		// x and y are the neighboring pixel averages
		const int x = int( tx * 255.f );
		const int ix = 255 - x;
		const int y = int( ty * 255.f );
		const int iy = 255 - y;
		
		// Interpolate the two pixels in the current row
		const int topBlendA = ( ( topLeft.GetA() * ix ) + ( topRight.GetA() * x ) ) >> 8;
		const int topBlendR = ( ( topLeft.GetR() * ix ) + ( topRight.GetR() * x ) ) >> 8;
		const int topBlendG = ( ( topLeft.GetG() * ix ) + ( topRight.GetG() * x ) ) >> 8;
		const int topBlendB = ( ( topLeft.GetB() * ix ) + ( topRight.GetB() * x ) ) >> 8;

		// Interpolate the two pixels in the row below the current row
		const int bottomBlendA = ( ( bottomLeft.GetA()  * ix ) + ( bottomRight.GetA() * x ) ) >> 8;
		const int bottomBlendR = ( ( bottomLeft.GetR()  * ix ) + ( bottomRight.GetR() * x ) ) >> 8;
		const int bottomBlendG = ( ( bottomLeft.GetG()  * ix ) + ( bottomRight.GetG() * x ) ) >> 8;
		const int bottomBlendB = ( ( bottomLeft.GetB()  * ix ) + ( bottomRight.GetB() * x ) ) >> 8;

		// Now interpolate between the two pixels in the vertical direction
		const int resultA = ( ( topBlendA * iy ) + ( bottomBlendA * y ) ) >> 8;
		const int resultR = ( ( topBlendR * iy ) + ( bottomBlendR * y ) ) >> 8;
		const int resultG = ( ( topBlendG * iy ) + ( bottomBlendG * y ) ) >> 8;
		const int resultB = ( ( topBlendB * iy ) + ( bottomBlendB * y ) ) >> 8;

		// Pack result back into a Color object
		const Color result = {
			unsigned char( resultA ),
			unsigned char( resultR ),
			unsigned char( resultG ),
			unsigned char( resultB )
		};

This is done from memory since I've lost all my previous projects that would have had this algorithm in it, so I'm not sure it will work as is. Just look up bilinear filtering in C++ and you should find a stackoverflow.com post on it I believe.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
curry
Posts: 45
Joined: September 19th, 2017, 9:43 pm

Re: I Don't Watch 3D Fund, But....

Post by curry » June 14th, 2018, 4:53 pm

albinopapa wrote:I love my parents
Then why the FUCK did you read my post!? (jk)
albinopapa wrote:I downloaded your demo, looks like you need a few more stars in that star field :p.
There are 1000. C++ is so fast, it initialized all of them in 1 second, so ctime was useless.
I may have lost my original account to a half drunk chili, but i'm still better than you, F*ck Off!

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: I Don't Watch 3D Fund, But....

Post by albinopapa » June 14th, 2018, 7:38 pm

Use the <chrono> library.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: I Don't Watch 3D Fund, But....

Post by chili » June 15th, 2018, 1:33 am

chrono is bae
Chili

Post Reply