void dxRenderSphere(Sphere* sphere, const Color* color, Matrix* ltm) { Vector circleVertex[SPHERE_DETAILS +1]; Line circleLines[SPHERE_DETAILS]; // generate circle in XY plane int i; for( i=0; i<SPHERE_DETAILS + 1; i++) { circleVertex[i].x = cos(i / (SPHERE_DETAILS / 2.0f) * D3DX_PI) * sphere->radius; circleVertex[i].y = sin(i / (SPHERE_DETAILS / 2.0f) * D3DX_PI) * sphere->radius; circleVertex[i].z = 0; } for( i=0; i<SPHERE_DETAILS; i++ ) { circleLines[i].start = circleVertex[i], circleLines[i].end = circleVertex[i+1]; } Matrix m; Vector temp( 1,1,0 ); Vector scale, translation; float transf; for( i=0; i<SPHERE_BELTS; i++ ) { D3DXMatrixIdentity( &m ); dxRotate( &m, &oY, 180.0f / SPHERE_BELTS * i ); dxTranslate( &m, &sphere->center ); dxRenderLines( SPHERE_DETAILS, circleLines, color, &m ); D3DXMatrixIdentity( &m ); transf = 1.0f/(SPHERE_BELTS)*i; scale = temp * sin( acos( transf ) ); dxScale( &m, &scale ); translation = Vector( 0,0, transf * sphere->radius ); dxTranslate( &m, &translation ); dxRotate( &m, &oX, 90 ); dxTranslate( &m, &sphere->center ); dxRenderLines( SPHERE_DETAILS, circleLines, color, &m ); D3DXMatrixIdentity( &m ); dxScale( &m, &scale ); translation = Vector( 0,0, -transf * sphere->radius ); dxTranslate( &m, &translation ); dxRotate( &m, &oX, 90 ); dxTranslate( &m, &sphere->center ); dxRenderLines( SPHERE_DETAILS, circleLines, color, &m ); } }
void Frame::translate(const Vector3f& translation) { dxTranslate( &TransformationMatrix, &wrap( translation ) ); dirty(); }