Now A5 has me stumped.
Now A5 has me stumped.
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.
Thanks for any help.
To strive, to seek, to find, and not to yield.
Re: Now A5 has me stumped.
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
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
Re: Now A5 has me stumped.
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.
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Now A5 has me stumped.
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.
Both are part of the Mat3 class.
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;
}
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
Re: Now A5 has me stumped.
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.
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Now A5 has me stumped.
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
Re: Now A5 has me stumped.
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.