#include #include #include #include #include #include DirectTexture::DirectTexture(const Vector3D &dstPoints,Bitmap &textureBitmap,DrawingSurface &drawingSurface,Device3D &displayDevice) : mEdgeMap(&mLeftEdge,&mRightEdge) { mDstPoints3D=dstPoints; displayDevice.translatePoint(mDstPoints3D,mDstPoints2D); mLeftEdge.numVertexes(Vector3D::VectorPoints); mRightEdge.numVertexes(Vector3D::VectorPoints); mTexturePoints[0]=Point(0,0); mTexturePoints[1]=Point(textureBitmap.width()-1,0); mTexturePoints[2]=Point(textureBitmap.width()-1,textureBitmap.height()-1); mTexturePoints[3]=Point(0,textureBitmap.height()-1); mLeftEdge.setSrcPoints((Point*)&mTexturePoints); mLeftEdge.setDstPoints((Point*)&mDstPoints2D); mRightEdge.setSrcPoints((Point*)&mTexturePoints); mRightEdge.setDstPoints((Point*)&mDstPoints2D); ::directSetSrcBitmapInfo(textureBitmap.width(),textureBitmap.height(),textureBitmap.getDataPtr()); ::directSetDstBitmapInfo(drawingSurface.width(),drawingSurface.height(),drawingSurface.pitch(),(unsigned char*)drawingSurface.ptrSurface()); } DirectTexture::DirectTexture(const Vector2D &dstPoints,Bitmap &textureBitmap,DrawingSurface &drawingSurface) : mEdgeMap(&mLeftEdge,&mRightEdge) { mDstPoints2D=dstPoints; mLeftEdge.numVertexes(Vector3D::VectorPoints); mRightEdge.numVertexes(Vector3D::VectorPoints); mTexturePoints[0]=Point(0,0); mTexturePoints[1]=Point(textureBitmap.width()-1,0); mTexturePoints[2]=Point(textureBitmap.width()-1,textureBitmap.height()-1); mTexturePoints[3]=Point(0,textureBitmap.height()-1); mLeftEdge.setSrcPoints((Point*)&mTexturePoints); mLeftEdge.setDstPoints((Point*)&mDstPoints2D); mRightEdge.setSrcPoints((Point*)&mTexturePoints); mRightEdge.setDstPoints((Point*)&mDstPoints2D); ::directSetSrcBitmapInfo(textureBitmap.width(),textureBitmap.height(),textureBitmap.getDataPtr()); ::directSetDstBitmapInfo(drawingSurface.width(),drawingSurface.height(),drawingSurface.pitch(),(unsigned char*)drawingSurface.ptrSurface()); } DirectTexture::DirectTexture(const Triangle3D &angle3D,Bitmap &textureBitmap,DrawingSurface &drawingSurface,Device3D &displayDevice,TriMap triMap) : mEdgeMap(&mLeftEdge,&mRightEdge) { Triangle angle2D; displayDevice.mapCoordinates((Triangle3D&)angle3D,angle2D); mDstPoints2D[0]=angle2D[0]; mDstPoints2D[1]=angle2D[1]; mDstPoints2D[2]=angle2D[2]; mLeftEdge.numVertexes(Triangle::VectorPoints); mRightEdge.numVertexes(Triangle::VectorPoints); switch(triMap) { case MapCenter : mTexturePoints[0]=Point(0,textureBitmap.height()-1); mTexturePoints[1]=Point(textureBitmap.width()/2,0); mTexturePoints[2]=Point(textureBitmap.width()-1,textureBitmap.height()-1); break; case MapUpperRight : mTexturePoints[0]=Point(0,0); mTexturePoints[1]=Point(textureBitmap.width()-1,0); mTexturePoints[2]=Point(textureBitmap.width()-1,textureBitmap.height()-1); break; case MapLowerLeft : mTexturePoints[0]=Point(0,0); mTexturePoints[1]=Point(textureBitmap.width()-1,textureBitmap.height()-1); mTexturePoints[2]=Point(0,textureBitmap.height()-1); break; } mLeftEdge.setSrcPoints((Point*)&mTexturePoints); mLeftEdge.setDstPoints((Point*)&mDstPoints2D); mRightEdge.setSrcPoints((Point*)&mTexturePoints); mRightEdge.setDstPoints((Point*)&mDstPoints2D); ::directSetSrcBitmapInfo(textureBitmap.width(),textureBitmap.height(),textureBitmap.getDataPtr()); ::directSetDstBitmapInfo(drawingSurface.width(),drawingSurface.height(),drawingSurface.pitch(),(unsigned char*)drawingSurface.ptrSurface()); }