#include #include #include #include #include #include #include Texture::Texture(const Vector3D &dstPoints,Bitmap &textureBitmap,DIB3D &displayBitmap) : mEdgeMap(&mLeftEdge,&mRightEdge) { mDstPoints3D=dstPoints; displayBitmap.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); ::setSrcBitmapInfo(textureBitmap.width(),textureBitmap.height(),textureBitmap.getDataPtr()); ::setDstBitmapInfo(displayBitmap.width(),displayBitmap.height(),(unsigned char*)displayBitmap.ptrData()); } Texture::Texture(const Vector3D &dstPoints,Bitmap &textureBitmap,Bitmap &displayBitmap,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); ::setSrcBitmapInfo(textureBitmap.width(),textureBitmap.height(),textureBitmap.getDataPtr()); ::setDstBitmapInfo(displayBitmap.width(),displayBitmap.height(),displayBitmap.getDataPtr()); } Texture::Texture(const Vector2D &dstPoints,Bitmap &textureBitmap,DIBitmap &displayBitmap) : 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); ::setSrcBitmapInfo(textureBitmap.width(),textureBitmap.height(),textureBitmap.getDataPtr()); ::setDstBitmapInfo(displayBitmap.width(),displayBitmap.height(),(unsigned char*)displayBitmap.ptrData()); } Texture::Texture(const Vector3D &dstPoints,Bitmap &textureBitmap,DIBitmap &displayBitmap,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); ::setSrcBitmapInfo(textureBitmap.width(),textureBitmap.height(),textureBitmap.getDataPtr()); ::setDstBitmapInfo(displayBitmap.width(),displayBitmap.height(),(unsigned char*)displayBitmap.ptrData()); } Texture::Texture(const Triangle3D &angle3D,Bitmap &textureBitmap,DIBitmap &displayBitmap,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); ::setSrcBitmapInfo(textureBitmap.width(),textureBitmap.height(),textureBitmap.getDataPtr()); ::setDstBitmapInfo(displayBitmap.width(),displayBitmap.height(),(unsigned char*)displayBitmap.ptrData()); }