Now A5 has me stumped.

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
User avatar
jkhippie
Posts: 218
Joined: March 24th, 2014, 5:11 pm

Now A5 has me stumped.

Post by jkhippie » September 7th, 2015, 5:06 pm

This is the second tutorial in a row that's left me with some error I just can't see. All was good until I changed PolyClosed::Draw to use the matrices. After that I just get a blank screen when I run it. I changed Draw back to the way it was and it worked fine.
Thanks for any help.
a5 blank screen.zip
(639.08 KiB) Downloaded 160 times
To strive, to seek, to find, and not to yield.

MrGodin
Posts: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

Re: Now A5 has me stumped.

Post by MrGodin » September 7th, 2015, 6:04 pm

just from a quick glance in PolyClosed::Draw you have..
Mat3 trans = Mat3::Translation ( pos ) * Mat3::Rotation ( angle ) * Mat3::Scaling ( scale );
where as i believe it should be ..
Mat3 trans = Mat3::Rotation ( angle ) * Mat3::Scaling ( scale ) *Mat3::Translation ( pos ) ;
i do believe the translation should be last
hope it helps
Curiosity killed the cat, satisfaction brought him back

User avatar
jkhippie
Posts: 218
Joined: March 24th, 2014, 5:11 pm

Re: Now A5 has me stumped.

Post by jkhippie » September 10th, 2015, 3:51 pm

While trying to track this down, I noticed a couple typos. Typos corrected, problem persists.
To strive, to seek, to find, and not to yield.

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

Re: Now A5 has me stumped.

Post by albinopapa » September 10th, 2015, 9:07 pm

I know you said you found a few typos, but you didn't upload the corrected project. Here are the problems I found so far.

Code: Select all

Vec2::operator*(const _Vec2<T> rhs ) const
{
// 
	_Vec2<T> result;
	result.x = elements [ 0 ][ 0 ] * rhs.x + elements [ 0 ][ 1 ] * rhs.y + elements [ 0 ][ 2 ];
	result.x = elements [ 1 ][ 0 ] * rhs.x + elements [ 1 ][ 1 ] * rhs.y + elements [ 1 ][ 2 ];
	return result;
}

	_Mat3 operator *( const _Mat3& rhs ) const
	{
		_Mat3 result;
		for ( int j = 0; j < 3; ++j )
		{
			for ( int k = 0; k < 3; ++k )
			{
				T sum = ( T )0.0;
				for ( int i = 0; i < 3; ++i )
				{
					// There is a problem here, you are looping through i and j
					// and when you are done with i you increment k, but don't do
					// anything with it here, which means you are looping through the same 
					// rows and colums.
					// should be.
					// sum += elements [ j ][ i ] * rhs.elements [ i ][ k ];
					sum += elements [ j ][ i ] * rhs.elements [ i ][ j ];
				}
				result.elements [ j ][ k ] = sum;
			}
		}
		return result;
	}

Both are part of the Mat3 class.
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
jkhippie
Posts: 218
Joined: March 24th, 2014, 5:11 pm

Re: Now A5 has me stumped.

Post by jkhippie » September 11th, 2015, 10:05 pm

Yeah, ap, those were the two. They had no impact on my blankness of screen. When I had the Draw function using .Rotation(angle)... it was fine, but when I changed it to trans * ... all I got was a blank screen.
To strive, to seek, to find, and not to yield.

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

Re: Now A5 has me stumped.

Post by albinopapa » September 12th, 2015, 3:24 am

It works fine for me with the matrices in draw function

Code: Select all

	void Draw ( Vec2 pos, float angle, float scale, D3DGraphics& gfx ) const
	{
		Mat3 trans = Mat3::Translation ( pos ) * Mat3::Rotation ( angle ) * Mat3::Scaling ( scale );
		for ( auto i = vertices.begin (), end = vertices.end () - 1; i != end; ++i )
		{
			gfx.DrawLineClip(trans * (*i), trans * (*(i + 1)), color);
		}

		gfx.DrawLineClip(trans * vertices.back(), trans * vertices.front(), color);
	}

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
jkhippie
Posts: 218
Joined: March 24th, 2014, 5:11 pm

Re: Now A5 has me stumped.

Post by jkhippie » September 16th, 2015, 3:35 pm

I reset my code to the way it was after A4 and went through A5 again. This time it worked. I can't say where I did anything differently, though I must have done. Anyway, thanks ap.
To strive, to seek, to find, and not to yield.

Post Reply