Programmeur C / C++ pour reprendre un code

King Kadelfek Message lu Posté le 25 Jan 2009 à 12:02 Bulle
Explorateur

Messages : 44
GCPoints : 37244
Bonjour, suite à la disparition inexpliquée de MGCaladtogel, je suis à la recherche d'un nouveau programmeur C / C++ pour reprendre son travail.

MGCaladtogel avait commencé une DLL permettant de dessiner des objets en 3D avec textures, pixel par pixel.

Voici ce qu'on peut obtenir en agençant les formes produites avec cette DLL :



Et voici maintenant le code.
Les commentaires qui ont été ajoutés sont le fait d'un autre programmeur, pour qui ce code était trop complexe.

L'est-il vraiment ?

Code :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <math.h>

#define DIVISE(a, b) ((b)!=0?((a)/(b)):(0))
#define MAX(a, b) ((a)>=(b)?(a):(b))
#define MIN(a, b) ((a)<=(b)?(a):(b))

#define EXPORT __declspec(dllexport)
#define IMPORT __declspec(dllimport)

#ifndef M_PI
#define M_PI       3.14159265358979323846
#endif

typedef struct{
 DWORD flags;
 DWORD klass;
 void (*dmark)(void*);
 void (*dfree)(void*);
 double *data;
} RGSSCOLOR;

typedef struct{
 DWORD unk1;
 DWORD unk2;
 BITMAPINFOHEADER *infoheader;
 RGBQUAD *firstRow;
 RGBQUAD *lastRow;
} RGSSBMINFO;

typedef struct{
 DWORD unk1;
 DWORD unk2;
 RGSSBMINFO *bminfo;
} BITMAPSTRUCT;

typedef struct{
 DWORD flags;
 DWORD klass;
 void (*dmark)(void*);
 void (*dfree)(void*);
 BITMAPSTRUCT *bm;
} RGSSBITMAP;

STDAPI DllRegisterServer(void);
STDAPI DllUnregisterServer(void);

// targetObject is the object for rm, sourceTop is the picture, Height should be depth
BOOL EXPORT RectangleWithTexture(LONG targetObject, LONG sourceTop, LONG depth, LONG cosAngle, LONG sinAngle, LONG xCoordinate, LONG yCoordinate){
 int x, y;
 LONG xTarget, yTarget, offsetX, offsetY, center, inScreenX, inScreenY;
 LONG rectWidth, rectHeight;
 LPBYTE firstTargetRow, firstTopRow, firstLeftRow, firstRightRow;
 RGSSBMINFO *targetBitmap = ((RGSSBITMAP*)(targetObject<<1))->bm->bminfo; // targetBitmap will contains all the information of targetObject
 RGSSBMINFO *bitmapTop = ((RGSSBITMAP*)(sourceTop<<1))->bm->bminfo; // bitmapTop will contains all the information of sourceTop
 DWORD targetRowSize, topRowSize, leftRowSize, rightRowSize;
 DWORD targetWidth, targetHeight, topWidth, topHeight;
 LPBYTE thisData;
 if(!targetBitmap)return FALSE; //there is no object for RM
 if(!bitmapTop)return FALSE; //there is no picture loaded
 yCoordinate += depth;
 targetWidth = targetBitmap->infoheader->biWidth;
 targetHeight = targetBitmap->infoheader->biHeight;
 topWidth = bitmapTop->infoheader->biWidth;
 topHeight = bitmapTop->infoheader->biHeight;
 targetRowSize = (targetWidth<<2); // <<2, ca veut dire shifter de deux bits vers la gauche (ou encore, multiplier par 4(2^2))
 topRowSize = (topWidth<<2);
 firstTargetRow = (LPBYTE) targetBitmap->firstRow;
 firstTopRow = (LPBYTE) bitmapTop->firstRow;
 rectWidth = ((LONG) (4096 * sqrt((double) (topWidth * topWidth + topHeight * topHeight))))>>12;
 rectHeight = rectWidth;
 center = rectWidth;
 offsetX = rectWidth - topWidth;
 offsetY = rectHeight - topHeight;
 // gestion des bords du bitmap
 inScreenX = 0;
 if (xCoordinate + rectWidth <= 0) return TRUE;
 if (xCoordinate >= 0) {
	if (xCoordinate + rectWidth > targetWidth) {
		rectWidth = targetWidth - xCoordinate;
	}
 } else {
	if (xCoordinate + rectWidth > targetWidth) {
		rectWidth = targetWidth;
    } else {
		rectWidth = rectWidth + xCoordinate;
	}
	inScreenX = -xCoordinate;
 }
 if (rectWidth <= 0) return TRUE;
 inScreenY = 0;
 if (yCoordinate + rectHeight <= 0) return TRUE;
 if (yCoordinate >= 0) {
	if (yCoordinate + rectHeight > targetHeight) {
		rectHeight = targetHeight - yCoordinate;
	}
 } else {
	if (yCoordinate + rectHeight > targetHeight) {
		rectHeight = targetHeight;
    } else {
		rectHeight = rectHeight + yCoordinate;
	}
	inScreenY = -yCoordinate;
 }
 if (rectHeight <= 0) return TRUE;
 // dessin
 firstTargetRow -= targetRowSize * (yCoordinate + inScreenY);
 for (y = inScreenY; y < rectHeight + inScreenY; y++) {
  firstTargetRow += ((xCoordinate + inScreenX)<<2);
  for (x = inScreenX; x < rectWidth + inScreenX; x++) {
   yTarget = ((center<<12) - (offsetY<<12) + ((1 + (y<<1) - center) * cosAngle - (1 + (x<<1) - center) * sinAngle))>>13;
   xTarget = ((center<<12) - (offsetX<<12) + ((1 + (x<<1) - center) * cosAngle + (1 + (y<<1) - center) * sinAngle))>>13;
   if (xTarget < 0 || yTarget < 0 || xTarget >= topWidth || yTarget >= topHeight) {
    *firstTargetRow++;
    *firstTargetRow++;
    *firstTargetRow++;
    *firstTargetRow++;
   }
   else {
    thisData = firstTopRow - (topRowSize * yTarget) + (xTarget<<2);
    *firstTargetRow++ = thisData[0];
    *firstTargetRow++ = thisData[1];
    *firstTargetRow++ = thisData[2];
    *firstTargetRow++ = thisData[3];
   }
  }
  firstTargetRow -= (targetRowSize + ((rectWidth + xCoordinate + inScreenX)<<2));
 }
 return TRUE;
}

BOOL EXPORT RectangleWithColor(LONG targetObject, LONG width, LONG height, LONG depth, LONG cosAngle, LONG sinAngle,
 LONG red, LONG green, LONG blue, LONG alpha, LONG xCoordinate, LONG yCoordinate){
 int x, y;
 LONG xTarget, yTarget, offsetX, offsetY, center, inScreenX, inScreenY;
 LONG rectWidth, rectHeight;
 LPBYTE firstTargetRow;
 RGSSBMINFO *targetBitmap = ((RGSSBITMAP*)(targetObject<<1))->bm->bminfo;
 DWORD targetRowSize;
 DWORD targetWidth, targetHeight;
 LPBYTE thisData;
 if(!targetBitmap)return FALSE;
 yCoordinate += depth; 
 targetWidth = targetBitmap->infoheader->biWidth;
 targetHeight = targetBitmap->infoheader->biHeight;
 targetRowSize = (targetWidth<<2);
 firstTargetRow = (LPBYTE) targetBitmap->firstRow;
 rectWidth = ((LONG) (4096 * sqrt((double) (width * width + height * height))))>>12;
 rectHeight = rectWidth;
 center = rectWidth;
 offsetX = rectWidth - width;
 offsetY = rectHeight - height;
 // gestion des bords du bitmap
 inScreenX = 0;
 if (xCoordinate + rectWidth <= 0) return TRUE;
 if (xCoordinate >= 0) {
	if (xCoordinate + rectWidth > targetWidth) {
		rectWidth = targetWidth - xCoordinate;
	}
 } else {
	if (xCoordinate + rectWidth > targetWidth) {
		rectWidth = targetWidth;
    } else {
		rectWidth = rectWidth + xCoordinate;
	}
	inScreenX = -xCoordinate;
 }
 if (rectWidth <= 0) return TRUE;
 inScreenY = 0;
 if (yCoordinate + rectHeight <= 0) return TRUE;
 if (yCoordinate >= 0) {
	if (yCoordinate + rectHeight > targetHeight) {
		rectHeight = targetHeight - yCoordinate;
	}
 } else {
	if (yCoordinate + rectHeight > targetHeight) {
		rectHeight = targetHeight;
    } else {
		rectHeight = rectHeight + yCoordinate;
	}
	inScreenY = -yCoordinate;
 }
 if (rectHeight <= 0) return TRUE;
 // dessin
 firstTargetRow -= targetRowSize * (yCoordinate + inScreenY);
 for (y = inScreenY; y < rectHeight + inScreenY; y++) {
  firstTargetRow += ((xCoordinate + inScreenX)<<2);
  for (x = inScreenX; x < rectWidth + inScreenX; x++) {
   yTarget = ((center<<12) - (offsetY<<12) + ((1 + (y<<1) - center) * cosAngle - (1 + (x<<1) - center) * sinAngle))>>13;
   xTarget = ((center<<12) - (offsetX<<12) + ((1 + (x<<1) - center) * cosAngle + (1 + (y<<1) - center) * sinAngle))>>13;
   if (xTarget < 0 || yTarget < 0 || xTarget >= width || yTarget >= height) {
    *firstTargetRow++;
    *firstTargetRow++;
    *firstTargetRow++;
    *firstTargetRow++;
   }
   else {
    *firstTargetRow++ = blue;
    *firstTargetRow++ = green;
    *firstTargetRow++ = red;
    *firstTargetRow++ = alpha;
   }
  }
  firstTargetRow -= (targetRowSize + ((rectWidth + xCoordinate + inScreenX)<<2));
 }
 return TRUE;
}

BOOL EXPORT CuboidWithColor(LONG targetObject, LONG width, LONG height, LONG depth, LONG cosAngle, LONG sinAngle,
 LONG red, LONG green, LONG blue, LONG alpha, LONG xCoordinate, LONG yCoordinate){
 int x, y;
 LONG xTarget, yTarget, offsetX, offsetY, center, inScreenX, inScreenY;
 LONG rectWidth, rectHeight, offsetYLeft, offsetXLeft, offsetYRight, offsetXRight, light;
 LPBYTE firstTargetRow;
 RGSSBMINFO *targetBitmap = ((RGSSBITMAP*)(targetObject<<1))->bm->bminfo;
 DWORD targetRowSize;
 DWORD targetWidth, targetHeight;
 LPBYTE thisData;
 if(!targetBitmap)return FALSE;
 targetWidth = targetBitmap->infoheader->biWidth;
 targetHeight = targetBitmap->infoheader->biHeight;
 targetRowSize = (targetWidth<<2);
 firstTargetRow = (LPBYTE) targetBitmap->firstRow;
 rectWidth = ((LONG) (4096 * sqrt((double) (width * width + height * height))))>>12;
 rectHeight = rectWidth + depth;
 center = rectWidth;
 offsetX = rectWidth - width;
 offsetY = rectWidth - height;
 offsetXLeft = (((center<<12) + 1024 + ((offsetX - center) * cosAngle - (offsetY + (height<<1) - center) * sinAngle))>>1) - 512;
 offsetYLeft = ((center<<12) + ((offsetY + (height<<1) - center) * cosAngle + (offsetX - center) * sinAngle))>>1;
 offsetXRight = (((center<<12) + 1024 + ((offsetX + (width<<1) - center) * cosAngle - (offsetY + (height<<1) - center) * sinAngle))>>1) - 512;
 offsetYRight = ((center<<12) + ((offsetY + (height<<1) - center) * cosAngle + (offsetX + (width<<1) - center) * sinAngle))>>1;
 light = (25 * sinAngle)>>12;
 // gestion des bords du bitmap
 inScreenX = 0;
 if (xCoordinate + rectWidth <= 0) return TRUE;
 if (xCoordinate >= 0) {
	if (xCoordinate + rectWidth > targetWidth) {
		rectWidth = targetWidth - xCoordinate;
	}
 } else {
	if (xCoordinate + rectWidth > targetWidth) {
		rectWidth = targetWidth;
    } else {
		rectWidth = rectWidth + xCoordinate;
	}
	inScreenX = -xCoordinate;
 }
 if (rectWidth <= 0) return TRUE;
 inScreenY = 0;
 if (yCoordinate + rectHeight <= 0) return TRUE;
 if (yCoordinate >= 0) {
	if (yCoordinate + rectHeight > targetHeight) {
		rectHeight = targetHeight - yCoordinate;
	}
 } else {
	if (yCoordinate + rectHeight > targetHeight) {
		rectHeight = targetHeight;
    } else {
		rectHeight = rectHeight + yCoordinate;
	}
	inScreenY = -yCoordinate;
 }
 if (rectHeight <= 0) return TRUE;
 // dessin
 firstTargetRow -= targetRowSize * (yCoordinate + inScreenY);
 for (y = inScreenY; y < rectHeight + inScreenY; y++) {
  firstTargetRow += ((xCoordinate + inScreenX)<<2);
  for (x = inScreenX; x < rectWidth + inScreenX; x++) {
   yTarget = ((center<<12) - (offsetY<<12) + ((1 + (y<<1) - center) * cosAngle - (1 + (x<<1) - center) * sinAngle))>>13;
   xTarget = ((center<<12) - (offsetX<<12) + ((1 + (x<<1) - center) * cosAngle + (1 + (y<<1) - center) * sinAngle))>>13;
   if (xTarget < 0 || yTarget < 0 || xTarget >= width || yTarget >= height) {
    xTarget = DIVISE(2048 + (x<<12) - offsetXLeft, cosAngle);
	yTarget = (2048 + (y<<12) - (DIVISE((2048 + (x<<12) - offsetXLeft)* sinAngle, cosAngle)) - offsetYLeft)>>12;
    if (xTarget < 0 || yTarget < 0 || xTarget >= width || yTarget >= depth) {
     xTarget = DIVISE(2048 + (x<<12) - offsetXRight, sinAngle);
	 yTarget = (2048 + (y<<12) + (DIVISE((2048 + (x<<12) - offsetXRight)* cosAngle, sinAngle)) - offsetYRight)>>12;
     if (sinAngle == 0 || xTarget < 0 || yTarget < 0 || xTarget >= height || yTarget >= depth) {
      *firstTargetRow++;
	  *firstTargetRow++;
	  *firstTargetRow++;
	  *firstTargetRow++;
     }
     else {
      *firstTargetRow++ = MAX(blue - 25 - light, 0);
      *firstTargetRow++ = MAX(green - 25 - light, 0);
      *firstTargetRow++ = MAX(red - 25 - light, 0);
      *firstTargetRow++ = alpha;
     }
    }
    else {
     *firstTargetRow++ = MAX(blue - 50 - light, 0);
     *firstTargetRow++ = MAX(green - 50 - light, 0);
     *firstTargetRow++ = MAX(red - 50 - light, 0);
     *firstTargetRow++ = alpha;
    }
   }
   else {
    *firstTargetRow++ = blue;
    *firstTargetRow++ = green;
    *firstTargetRow++ = red;
    *firstTargetRow++ = alpha;
   }
  }
  firstTargetRow -= (targetRowSize + ((rectWidth + xCoordinate + inScreenX)<<2));
 }
 return TRUE;
}

BOOL EXPORT CuboidWithTextures(LONG target_id, LONG width, LONG height, LONG depth, LONG cosAngle, LONG sinAngle,
 LONG xCoordinate, LONG yCoordinate, LONG top_id, LONG side1_id, LONG side2_id, LONG side3_id, LONG side4_id){
 int x, y, val, offsetLight1, offsetLight2;
 LONG xTarget, yTarget, offsetX, offsetY, center, inScreenX, inScreenY;
 LONG rectWidth, rectHeight, offsetYLeft, offsetXLeft, offsetYRight, offsetXRight, light;
 LONG offsetYLeft2, offsetXLeft2, offsetYRight2, offsetXRight2;

 LPBYTE firstTargetRow;
 LPBYTE firstTopRow, firstSide1Row, firstSide2Row, firstSide3Row, firstSide4Row;

 RGSSBMINFO *targetBitmap = ((RGSSBITMAP*)(target_id <<1 ))->bm->bminfo;
 RGSSBMINFO *top = ((RGSSBITMAP*)(top_id << 1))->bm->bminfo;
 RGSSBMINFO *side1 = ((RGSSBITMAP*)(side1_id << 1))->bm->bminfo;
 RGSSBMINFO *side2 = ((RGSSBITMAP*)(side2_id << 1))->bm->bminfo;
 RGSSBMINFO *side3 = ((RGSSBITMAP*)(side3_id << 1))->bm->bminfo;
 RGSSBMINFO *side4 = ((RGSSBITMAP*)(side4_id << 1))->bm->bminfo;

 DWORD targetRowSize;
 DWORD topRowSize, side1RowSize, side2RowSize, side3RowSize, side4RowSize;
 DWORD targetWidth, targetHeight;
 DWORD topWidth, topHeight, side1Width, side1Height, side2Width, side2Height, side3Width, side3Height, side4Width, side4Height;
 LPBYTE thisData;
 targetWidth = targetBitmap->infoheader->biWidth;
 targetHeight = targetBitmap->infoheader->biHeight;
 topWidth = top->infoheader->biWidth;
 topHeight = top->infoheader->biHeight;
 side1Width = side1->infoheader->biWidth;
 side1Height = side1->infoheader->biHeight;
 side2Width = side2->infoheader->biWidth;
 side2Height = side2->infoheader->biHeight;
 side3Width = side3->infoheader->biWidth;
 side3Height = side3->infoheader->biHeight;
 side4Width = side4->infoheader->biWidth;
 side4Height = side4->infoheader->biHeight;
 targetRowSize = targetWidth << 2;
 topRowSize = topWidth << 2;
 side1RowSize = side1Width << 2;
 side2RowSize = side2Width << 2;
 side3RowSize = side3Width << 2;
 side4RowSize = side4Width << 2;
 firstTargetRow = (LPBYTE) targetBitmap->firstRow;
 firstTopRow = (LPBYTE) top->firstRow;
 firstSide1Row = (LPBYTE) side1->firstRow;
 firstSide2Row = (LPBYTE) side2->firstRow;
 firstSide3Row = (LPBYTE) side3->firstRow;
 firstSide4Row = (LPBYTE) side4->firstRow;

 rectWidth = ((LONG) (4096 * sqrt((double) (width * width + height * height)))) >> 12;
 rectHeight = rectWidth + depth;
 center = rectWidth;
 offsetX = rectWidth - width;
 offsetY = rectWidth - height;
 val = (offsetX - center) * cosAngle - (offsetY + (height << 1) - center) * sinAngle;
 offsetXLeft = ((center << 12) + 1024 + val >> 1) - 512;
 offsetXLeft2 = ((center << 12) + 1024 - val >> 1) - 512;
 val = (offsetY + (height << 1) - center) * cosAngle + (offsetX - center) * sinAngle;
 offsetYLeft = (center << 12) + val >>1;
 offsetYLeft2 = (center << 12) - val >>1;
 val = (offsetX + (width << 1) - center) * cosAngle - (offsetY + (height << 1) - center) * sinAngle;
 offsetXRight = ((center << 12) + 1024 + val >> 1) - 512;
 offsetXRight2 = ((center << 12) + 1024 - val >> 1) - 512;
 val = (offsetY + (height << 1) - center) * cosAngle + (offsetX + (width << 1) - center) * sinAngle;
 offsetYRight = (center << 12) + val >> 1;
 offsetYRight2 = (center << 12) - val >> 1;
 if (cosAngle * sinAngle > 0 || sinAngle == 0) {
   light = 25 * abs(sinAngle) >> 12;
   offsetLight1 = 50;
   offsetLight2 = 25;
 } else {
   light = 25 * abs(cosAngle) >> 12;
   offsetLight1 = 25;
   offsetLight2 = 50;
 }
 // gestion des bords du bitmap
 inScreenX = 0;
 if (xCoordinate + rectWidth <= 0) return TRUE;
 if (xCoordinate >= 0) {
	if (xCoordinate + rectWidth > targetWidth) {
		rectWidth = targetWidth - xCoordinate;
	}
 } else {
	if (xCoordinate + rectWidth > targetWidth) {
		rectWidth = targetWidth;
    } else {
		rectWidth = rectWidth + xCoordinate;
	}
	inScreenX = -xCoordinate;
 }
 if (rectWidth <= 0) return TRUE;
 inScreenY = 0;
 if (yCoordinate + rectHeight <= 0) return TRUE;
 if (yCoordinate >= 0) {
	if (yCoordinate + rectHeight > targetHeight) {
		rectHeight = targetHeight - yCoordinate;
	}
 } else {
	if (yCoordinate + rectHeight > targetHeight) {
		rectHeight = targetHeight;
    } else {
		rectHeight = rectHeight + yCoordinate;
	}
	inScreenY = -yCoordinate;
 }
 if (rectHeight <= 0) return TRUE;
 // dessin
 firstTargetRow -= targetRowSize * (yCoordinate + inScreenY);
 for (y = inScreenY; y < rectHeight + inScreenY; y++) {
  firstTargetRow += ((xCoordinate + inScreenX)<<2);
  for (x = inScreenX; x < rectWidth + inScreenX; x++) {
   yTarget = ((center<<12) - (offsetY<<12) + ((1 + (y<<1) - center) * cosAngle - (1 + (x<<1) - center) * sinAngle))>>13;
   xTarget = ((center<<12) - (offsetX<<12) + ((1 + (x<<1) - center) * cosAngle + (1 + (y<<1) - center) * sinAngle))>>13;
   if (xTarget < 0 || yTarget < 0 || xTarget >= width || yTarget >= height) {
    xTarget = DIVISE(2048 + (x<<12) - offsetXLeft, cosAngle);
	yTarget = (2048 + (y<<12) - (DIVISE((2048 + (x<<12) - offsetXLeft)* sinAngle, cosAngle)) - offsetYLeft)>>12;
    if (cosAngle <= 0 || xTarget < 0 || yTarget < 0 || xTarget >= width || yTarget >= depth) {
     xTarget = DIVISE(2048 + (x<<12) - offsetXRight, sinAngle);
	 yTarget = (2048 + (y<<12) + (DIVISE((2048 + (x<<12) - offsetXRight)* cosAngle, sinAngle)) - offsetYRight)>>12;
     if (sinAngle <= 0 || xTarget < 0 || yTarget < 0 || xTarget >= height || yTarget >= depth) {
	  xTarget = -(DIVISE(2048 + (x<<12) - offsetXLeft2, cosAngle));
	  yTarget = (2048 + (y<<12) - (DIVISE((2048 + (x<<12) - offsetXLeft2)* sinAngle, cosAngle)) - offsetYLeft2)>>12;
	  if (cosAngle >= 0 || xTarget < 0 || yTarget < 0 || xTarget >= width || yTarget >= depth) {
	    xTarget = -(DIVISE(2048 + (x<<12) - offsetXRight2, sinAngle));
		yTarget = (2048 + (y<<12) + (DIVISE((2048 + (x<<12) - offsetXRight2)* cosAngle, sinAngle)) - offsetYRight2)>>12;
		if (sinAngle >= 0 || xTarget < 0 || yTarget < 0 || xTarget >= height || yTarget >= depth) {
		  *firstTargetRow++;
		  *firstTargetRow++;
	      *firstTargetRow++;
	      *firstTargetRow++;
		} else {
		  xTarget = (xTarget * side4Width << 12) / height >> 12;
		  yTarget = (yTarget * side4Height << 12) / depth >> 12;
		  thisData = firstSide4Row - (side4RowSize * yTarget) + (xTarget<<2);
		  *firstTargetRow++ = MAX(thisData[0] - offsetLight2 - light, 0);
	      *firstTargetRow++ = MAX(thisData[1] - offsetLight2 - light, 0);
	      *firstTargetRow++ = MAX(thisData[2] - offsetLight2 - light, 0);
		  *firstTargetRow++ = thisData[3];
		}
	  } else {
	    xTarget = (xTarget * side3Width << 12) / width >> 12;
		yTarget = (yTarget * side3Height << 12) / depth >> 12;
		thisData = firstSide3Row - (side3RowSize * yTarget) + (xTarget<<2);
		*firstTargetRow++ = MAX(thisData[0] - offsetLight1 - light, 0);
	    *firstTargetRow++ = MAX(thisData[1] - offsetLight1 - light, 0);
	    *firstTargetRow++ = MAX(thisData[2] - offsetLight1 - light, 0);
		*firstTargetRow++ = thisData[3];
	  }
     }
     else {
      xTarget = (xTarget * side2Width << 12) / height >> 12;
	  yTarget = (yTarget * side2Height << 12) / depth >> 12;
	  thisData = firstSide2Row - (side2RowSize * yTarget) + (xTarget<<2);
	  *firstTargetRow++ = MAX(thisData[0] - offsetLight2 - light, 0);
	  *firstTargetRow++ = MAX(thisData[1] - offsetLight2 - light, 0);
	  *firstTargetRow++ = MAX(thisData[2] - offsetLight2 - light, 0);
	  *firstTargetRow++ = thisData[3];
     }
    }
    else {
     xTarget = (xTarget * side1Width << 12) / width >> 12;
	 yTarget = (yTarget * side1Height << 12) / depth >> 12;
	 thisData = firstSide1Row - (side1RowSize * yTarget) + (xTarget<<2);
	 *firstTargetRow++ = MAX(thisData[0] - offsetLight1 - light, 0);
	 *firstTargetRow++ = MAX(thisData[1] - offsetLight1 - light, 0);
	 *firstTargetRow++ = MAX(thisData[2] - offsetLight1 - light, 0);
	 *firstTargetRow++ = thisData[3];
    }
   }
   else {
	xTarget = (xTarget * topWidth << 12) / width >> 12;
	yTarget = (yTarget * topHeight << 12) / height >> 12;
	thisData = firstTopRow - (topRowSize * yTarget) + (xTarget<<2);
    *firstTargetRow++ = thisData[0];
    *firstTargetRow++ = thisData[1];
    *firstTargetRow++ = thisData[2];
    *firstTargetRow++ = thisData[3];
   }
  }
  firstTargetRow -= (targetRowSize + ((rectWidth + xCoordinate + inScreenX)<<2));
 }
 return TRUE;
}

BOOL EXPORT SlopeWithColor(LONG targetObject, LONG width, LONG height, LONG depth, LONG cosAngle, LONG sinAngle,
 LONG red, LONG green, LONG blue, LONG alpha, LONG xCoordinate, LONG yCoordinate){
 int x, y, index, index_ref, difference, i;
 BOOL correction;
 LONG xTarget, yTarget, offsetX, offsetY, center, inScreenX, inScreenY;
 LONG rectWidth, rectHeight, offsetYLeft, offsetXLeft, offsetYRight, offsetXRight;
 LONG light, lightSlope, lightTriangle, lightSquare;
 LONG slopeLength, slopeHeight, slopeWidth, rightSlope;
 LONG cosTheta, sinTheta, xInt, yInt;
 LPBYTE firstTargetRow;
 RGSSBMINFO *targetBitmap = ((RGSSBITMAP*)(targetObject<<1))->bm->bminfo;
 DWORD targetRowSize;
 DWORD targetWidth, targetHeight;
 LPBYTE thisData;
 if(!targetBitmap)return FALSE;
 targetWidth = targetBitmap->infoheader->biWidth;
 targetHeight = targetBitmap->infoheader->biHeight;
 targetRowSize = (targetWidth<<2);
 firstTargetRow = (LPBYTE) targetBitmap->firstRow;
 rectWidth = ((LONG) (4096 * sqrt((double) (width * width + height * height))))>>12;
 rectHeight = rectWidth + depth;
 center = rectWidth;
 offsetX = rectWidth - width;
 offsetY = rectWidth - height;
 offsetXLeft = (((center<<12) + 1024 + ((offsetX - center) * cosAngle - (offsetY - center) * sinAngle))>>1) - 512;
 offsetYLeft = ((center<<12) + ((offsetY - center) * cosAngle + (offsetX - center) * sinAngle))>>1;
 if (sinAngle > 0) {
	offsetXRight = (((center<<12) + 1024 + ((offsetX + (width<<1) - center) * cosAngle - (offsetY + (height<<1) - center) * sinAngle))>>1) - 512;
	offsetYRight = ((center<<12) + ((offsetY + (height<<1) - center) * cosAngle + (offsetX + (width<<1) - center) * sinAngle))>>1;
 } else {
	offsetXRight = (((center<<12) + 1024 + ((offsetX - center) * cosAngle - (offsetY + (height<<1) - center) * sinAngle))>>1) - 512;
	offsetYRight = ((center<<12) + ((offsetY + (height<<1) - center) * cosAngle + (offsetX - center) * sinAngle))>>1;
 }
 // gestion de la lumière
 light = (25 * sinAngle)>>12;
 while (TRUE) {
  if (cosAngle >= 0 && sinAngle >= 0) {
   lightSlope = - 50 - light;
   lightTriangle = - 25 - light;
   lightSquare = - 25 - light;
   break;
  }
  if (cosAngle < 0 && sinAngle >= 0) {
   lightSlope = - 100 + light;
   lightTriangle = - 75 + light;
   lightSquare = - 50 + light;
   break;
  }
  if (cosAngle < 0 && sinAngle < 0) {
   lightSlope = light;
   lightTriangle = - 25 + light;
   lightSquare = - 50 + light;
   break;
  }
  if (cosAngle >= 0 && sinAngle < 0) {
   lightSlope = - 50 - light;
   lightTriangle = - 75 - light;
   lightSquare = - 75 - light;
   break;
  }
 }
 // caractéristiques de la pente
 slopeLength = ((LONG) (4096 * sqrt((double) (depth * depth + height * height + ((depth * height * cosAngle)>>11)))))>>12;
 slopeHeight = ((height<<12) + depth * cosAngle)>>12;
 slopeWidth = (depth * sinAngle)>>12;
 rightSlope = DIVISE((depth<<12), height);
 cosTheta = (LONG) (4096 * (((double) slopeHeight) / ((double) slopeLength)));
 sinTheta = (LONG) (4096 * (((double) slopeWidth) / ((double) slopeLength)));
 // gestion des bords du bitmap
 inScreenX = 0;
 if (xCoordinate + rectWidth <= 0) return TRUE;
 if (xCoordinate >= 0) {
	if (xCoordinate + rectWidth > targetWidth) {
		rectWidth = targetWidth - xCoordinate;
	}
 } else {
	if (xCoordinate + rectWidth > targetWidth) {
		rectWidth = targetWidth;
    } else {
		rectWidth = rectWidth + xCoordinate;
	}
	inScreenX = -xCoordinate;
 }
 if (rectWidth <= 0) return TRUE;
 inScreenY = 0;
 if (yCoordinate + rectHeight <= 0) return TRUE;
 if (yCoordinate >= 0) {
	if (yCoordinate + rectHeight > targetHeight) {
		rectHeight = targetHeight - yCoordinate;
	}
 } else {
	if (yCoordinate + rectHeight > targetHeight) {
		rectHeight = targetHeight;
    } else {
		rectHeight = rectHeight + yCoordinate;
	}
	inScreenY = -yCoordinate;
 }
 if (rectHeight <= 0) return TRUE;
 // dessin
 firstTargetRow -= targetRowSize * (yCoordinate + inScreenY);
 for (y = inScreenY; y < rectHeight + inScreenY; y++) {
  firstTargetRow += ((xCoordinate + inScreenX)<<2);
  index = 0;
  index_ref = 0;
  correction = FALSE;
  for (x = inScreenX; x < rectWidth + inScreenX; x++) {
   yInt = ((center<<12) - (offsetY<<12) + ((1 + (y<<1) - center) * cosAngle - (1 + (x<<1) - center) * sinAngle))>>13;
   xInt = ((center<<12) - (offsetX<<12) + ((1 + (x<<1) - center) * cosAngle + (1 + (y<<1) - center) * sinAngle))>>13;
   yTarget = DIVISE((yInt<<12), cosTheta);
   xTarget = (((xInt<<12) - (DIVISE(((yInt<<12))* sinTheta, cosTheta)))>>12);
   if (slopeHeight < 1 || xTarget < 0 || yTarget < 0 || xTarget >= width || yTarget >= slopeLength) {
	xTarget = DIVISE(1024 + (x<<12) - offsetXRight, sinAngle);
	yTarget = (2048 + (y<<12) + (DIVISE((1024 + (x<<12) - offsetXRight)* cosAngle, sinAngle)) - offsetYRight)>>12;
	if (sinAngle == 0 || xTarget < 0 || yTarget < 0 || xTarget >= height || yTarget >= depth || ((yTarget<<12)) + rightSlope * xTarget < (depth<<12)) {
	 xTarget = DIVISE(2048 + (x<<12) - offsetXLeft, cosAngle);
	 yTarget = (2048 + (y<<12) - (DIVISE((2048 + (x<<12) - offsetXLeft)* sinAngle, cosAngle)) - offsetYLeft)>>12;
	 if (cosAngle == 0 || xTarget < 0 || yTarget < 0 || xTarget >= width || yTarget >= depth) {
      *firstTargetRow++;
	  *firstTargetRow++;
	  *firstTargetRow++;
	  *firstTargetRow++;
	  if (index != 0) index_ref++;
     }
     else {
      *firstTargetRow++ = MAX(blue + lightSquare, 0);
      *firstTargetRow++ = MAX(green + lightSquare, 0);
      *firstTargetRow++ = MAX(red + lightSquare, 0);
      *firstTargetRow++ = alpha;
	  index++;
	  index_ref++;
	  if (index != index_ref) correction = TRUE;
     }
    }
    else {
	 *firstTargetRow++ = MAX(blue + lightTriangle, 0);
     *firstTargetRow++ = MAX(green + lightTriangle, 0);
     *firstTargetRow++ = MAX(red + lightTriangle, 0);
     *firstTargetRow++ = alpha;
	 index++;
	 index_ref++;
	 if (index != index_ref) correction = TRUE;
    }
   }
   else {
    *firstTargetRow++ = MAX(blue + lightSlope, 0);
    *firstTargetRow++ = MAX(green + lightSlope, 0);
    *firstTargetRow++ = MAX(red + lightSlope, 0);
    *firstTargetRow++ = alpha;
	index++;
	index_ref++;
	if (index != index_ref) correction = TRUE;
   }
   if (correction) {
	difference = index_ref - index;
	firstTargetRow -= ((difference + 1)<<2);
	for (i = 0; i < difference; i++) {
	 *firstTargetRow++ = MAX(blue + lightSlope, 0);
     *firstTargetRow++ = MAX(green + lightSlope, 0);
     *firstTargetRow++ = MAX(red + lightSlope, 0);
     *firstTargetRow++ = alpha;
	}
	index = index_ref;
	correction = FALSE;
	firstTargetRow += 4;
   }
  }
  firstTargetRow -= (targetRowSize + ((rectWidth + xCoordinate + inScreenX)<<2));
 }
 return TRUE;
}

BOOL EXPORT InvertSlopeWithColor(LONG targetObject, LONG width, LONG height, LONG depth, LONG cosAngle, LONG sinAngle,
 LONG red, LONG green, LONG blue, LONG alpha, LONG xCoordinate, LONG yCoordinate){
 int x, y, index, index_ref, difference, i;
 BOOL correction, condition;
 LONG xTarget, yTarget, offsetX, offsetY, center, inScreenX, inScreenY;
 LONG rectWidth, rectHeight, offsetYLeft, offsetXLeft, offsetYRight, offsetXRight, offsetYLeftSquare, offsetXLeftSquare;
 LONG light, lightSlope, lightTriangle, lightSquare;
 LONG slopeLength, slopeHeight, slopeWidth, rightSlope;
 LONG cosTheta, sinTheta, xInt, yInt;
 LPBYTE firstTargetRow;
 RGSSBMINFO *targetBitmap = ((RGSSBITMAP*)(targetObject<<1))->bm->bminfo;
 DWORD targetRowSize;
 DWORD targetWidth, targetHeight;
 LPBYTE thisData;
 if(!targetBitmap)return FALSE;
 targetWidth = targetBitmap->infoheader->biWidth;
 targetHeight = targetBitmap->infoheader->biHeight;
 targetRowSize = (targetWidth<<2);
 firstTargetRow = (LPBYTE) targetBitmap->firstRow;
 rectWidth = ((LONG) (4096 * sqrt((double) (width * width + height * height))))>>12;
 rectHeight = rectWidth + depth;
 center = rectWidth;
 offsetX = rectWidth - width;
 offsetY = rectWidth - height;
 offsetXLeft = (((center<<12) + 1024 + ((offsetX - center) * cosAngle - (offsetY - center) * sinAngle))>>1) - 512;
 offsetYLeft = ((center<<12) + ((offsetY - center) * cosAngle + (offsetX - center) * sinAngle))>>1;
 offsetXLeftSquare = (((center<<12) + 1024 + ((offsetX - center) * cosAngle - (offsetY + (height<<1) - center) * sinAngle))>>1) - 512;
 offsetYLeftSquare = ((center<<12) + ((offsetY + (height<<1) - center) * cosAngle + (offsetX - center) * sinAngle))>>1;
 if (sinAngle > 0) {
	offsetXRight = (((center<<12) + 1024 + ((offsetX + (width<<1) - center) * cosAngle - (offsetY + (height<<1) - center) * sinAngle))>>1) - 512;
	offsetYRight = ((center<<12) + ((offsetY + (height<<1) - center) * cosAngle + (offsetX + (width<<1) - center) * sinAngle))>>1;
 } else {
	offsetXRight = (((center<<12) + 1024 + ((offsetX - center) * cosAngle - (offsetY + (height<<1) - center) * sinAngle))>>1) - 512;
	offsetYRight = ((center<<12) + ((offsetY + (height<<1) - center) * cosAngle + (offsetX - center) * sinAngle))>>1;
 }
 // gestion de la lumière
 light = (25 * sinAngle)>>12;
 while (TRUE) {
  if (cosAngle >= 0 && sinAngle >= 0) {
   lightSlope = - 50 - light;
   lightTriangle = - 25 - light;
   lightSquare = - 25 - light;
   break;
  }
  if (cosAngle < 0 && sinAngle >= 0) {
   lightSlope = - 100 + light;
   lightTriangle = - 75 + light;
   lightSquare = - 50 + light;
   break;
  }
  if (cosAngle < 0 && sinAngle < 0) {
   lightSlope = light;
   lightTriangle = - 25 + light;
   lightSquare = - 50 + light;
   break;
  }
  if (cosAngle >= 0 && sinAngle < 0) {
   lightSlope = - 50 - light;
   lightTriangle = - 75 - light;
   lightSquare = - 75 - light;
   break;
  }
 }
 if (cosAngle < 0) lightSlope = lightSquare;
 // caractéristiques de la pente
 slopeLength = ((LONG) (4096 * sqrt((double) (depth * depth + height * height + ((depth * height * cosAngle)>>11)))))>>12;
 slopeHeight = ((height<<12) + depth * cosAngle)>>12;
 slopeWidth = (depth * sinAngle)>>12;
 rightSlope = DIVISE((depth<<12), height);
 cosTheta = (LONG) (4096 * (((double) slopeHeight) / ((double) slopeLength)));
 sinTheta = (LONG) (4096 * (((double) slopeWidth) / ((double) slopeLength)));
 // gestion des bords du bitmap
 inScreenX = 0;
 if (xCoordinate + rectWidth <= 0) return TRUE;
 if (xCoordinate >= 0) {
	if (xCoordinate + rectWidth > targetWidth) {
		rectWidth = targetWidth - xCoordinate;
	}
 } else {
	if (xCoordinate + rectWidth > targetWidth) {
		rectWidth = targetWidth;
    } else {
		rectWidth = rectWidth + xCoordinate;
	}
	inScreenX = -xCoordinate;
 }
 if (rectWidth <= 0) return TRUE;
 inScreenY = 0;
 if (yCoordinate + rectHeight <= 0) return TRUE;
 if (yCoordinate >= 0) {
	if (yCoordinate + rectHeight > targetHeight) {
		rectHeight = targetHeight - yCoordinate;
	}
 } else {
	if (yCoordinate + rectHeight > targetHeight) {
		rectHeight = targetHeight;
    } else {
		rectHeight = rectHeight + yCoordinate;
	}
	inScreenY = -yCoordinate;
 }
 if (rectHeight <= 0) return TRUE;
 // dessin
 firstTargetRow -= targetRowSize * (yCoordinate + inScreenY);
 for (y = inScreenY; y < rectHeight + inScreenY; y++) {
  firstTargetRow += ((xCoordinate + inScreenX)<<2);
  index = 0;
  index_ref = 0;
  correction = FALSE;
  for (x = inScreenX; x < rectWidth + inScreenX; x++) {
   while (TRUE) {
    if (cosAngle > 0) {
	 xTarget = DIVISE(2048 + (x<<12) - offsetXLeftSquare, cosAngle);
	 yTarget = (2048 + (y<<12) - (DIVISE((2048 + (x<<12) - offsetXLeftSquare)* sinAngle, cosAngle)) - offsetYLeftSquare)>>12;
	 condition = (xTarget < 0 || yTarget < 0 || xTarget >= width || yTarget >= depth);
	 break;
    }
	if (cosAngle < 0) {
	 yInt = ((center<<12) - (offsetY<<12) + ((1 + (y<<1) - center) * cosAngle - (1 + (x<<1) - center) * sinAngle))>>13;
	 xInt = ((center<<12) - (offsetX<<12) + ((1 + (x<<1) - center) * cosAngle + (1 + (y<<1) - center) * sinAngle))>>13;
	 yTarget = DIVISE((yInt<<12), cosTheta);
	 xTarget = (((xInt<<12) - (DIVISE(((yInt<<12))* sinTheta, cosTheta)))>>12);
	 condition = (slopeHeight >= 0 || xTarget < 0 || yTarget < 0 || xTarget >= width || yTarget >= slopeLength);
	 break;
    }
	condition = TRUE;
	break;
   }
   if (condition) {
	xTarget = DIVISE(1024 + (x<<12) - offsetXRight, sinAngle);
	yTarget = (2048 + (y<<12) + (DIVISE((1024 + (x<<12) - offsetXRight)* cosAngle, sinAngle)) - offsetYRight)>>12;
	if (sinAngle == 0 || xTarget < 0 || yTarget < 0 || xTarget >= height || yTarget >= depth || ((yTarget<<12)) + rightSlope * xTarget > (depth<<12)) {
	 yTarget = ((center<<12) - (offsetY<<12) + ((1 + (y<<1) - center) * cosAngle - (1 + (x<<1) - center) * sinAngle))>>13;
     xTarget = ((center<<12) - (offsetX<<12) + ((1 + (x<<1) - center) * cosAngle + (1 + (y<<1) - center) * sinAngle))>>13;
     if (xTarget < 0 || yTarget < 0 || xTarget >= width || yTarget >= height) {
      *firstTargetRow++;
	  *firstTargetRow++;
	  *firstTargetRow++;
	  *firstTargetRow++;
	  if (index != 0) index_ref++;
     }
     else {
      *firstTargetRow++ = blue;
      *firstTargetRow++ = green;
      *firstTargetRow++ = red;
      *firstTargetRow++ = alpha;
	  index++;
	  index_ref++;
	  if (index != index_ref) correction = TRUE;
     }
    }
    else {
	 *firstTargetRow++ = MAX(blue + lightTriangle, 0);
     *firstTargetRow++ = MAX(green + lightTriangle, 0);
     *firstTargetRow++ = MAX(red + lightTriangle, 0);
     *firstTargetRow++ = alpha;
	 index++;
	 index_ref++;
	 if (index != index_ref) correction = TRUE;
    }
   }
   else {
    *firstTargetRow++ = MAX(blue + lightSlope, 0);
    *firstTargetRow++ = MAX(green + lightSlope, 0);
    *firstTargetRow++ = MAX(red + lightSlope, 0);
    *firstTargetRow++ = alpha;
	index++;
	index_ref++;
	if (index != index_ref) correction = TRUE;
   }
   if (correction) {
	difference = index_ref - index;
	firstTargetRow -= ((difference + 1)<<2);
	for (i = 0; i < difference; i++) {
	 *firstTargetRow++ = MAX(blue + lightSlope, 0);
     *firstTargetRow++ = MAX(green + lightSlope, 0);
     *firstTargetRow++ = MAX(red + lightSlope, 0);
     *firstTargetRow++ = alpha;
	}
	index = index_ref;
	correction = FALSE;
	firstTargetRow += 4;
   }
  }
  firstTargetRow -= (targetRowSize + ((rectWidth + xCoordinate + inScreenX)<<2));
 }
 return TRUE;
}

BOOL EXPORT CylinderWithColor(int targetObject, int radius, int depth, int red, int green, int blue, int alpha,
							  int xCoordinate, int yCoordinate){
 int x, y, offsetY, yTarget, inScreenX, inScreenY, width, height, light;
 LPBYTE firstTargetRow;
 RGSSBMINFO *targetBitmap = ((RGSSBITMAP*)(targetObject<<1))->bm->bminfo;
 int targetRowSize, targetWidth, targetHeight;
 targetWidth = targetBitmap->infoheader->biWidth;
 targetHeight = targetBitmap->infoheader->biHeight;
 targetRowSize = targetWidth << 2;
 firstTargetRow = (LPBYTE) targetBitmap->firstRow;
 width = radius << 1;
 height = width + depth;
 // gestion des bords du bitmap
 inScreenX = 0;
 if (xCoordinate + width <= 0) return TRUE;
 if (xCoordinate >= 0) {
	if (xCoordinate + width > targetWidth) {
		width = targetWidth - xCoordinate;
	}
 } else {
	if (xCoordinate + width > targetWidth) {
		width = targetWidth;
    } else {
		width = width + xCoordinate;
	}
	inScreenX = -xCoordinate;
 }
 if (width <= 0) return TRUE;
 inScreenY = 0;
 if (yCoordinate + height <= 0) return TRUE;
 if (yCoordinate >= 0) {
	if (yCoordinate + height > targetHeight) {
		height = targetHeight - yCoordinate;
	}
 } else {
	if (yCoordinate + height > targetHeight) {
		height = targetHeight;
    } else {
		height = height + yCoordinate;
	}
	inScreenY = -yCoordinate;
 }
 if (height <= 0) return TRUE;
 // dessin
 firstTargetRow -= targetRowSize * (yCoordinate + inScreenY);
 for (y = inScreenY; y < height + inScreenY; y++) {
  firstTargetRow += (xCoordinate + inScreenX << 2);
  for (x = inScreenX; x < width + inScreenX; x++) {
   if (y >= (radius << 1) || ((y - radius) * (y - radius) + (x - radius) * (x - radius) - radius * radius > 0)) {
	offsetY = sqrt((double) x * ((radius << 1) - x));
	yTarget = y - radius - offsetY;
	if (x >= radius) {
		light = - 25 - (25 * offsetY) / radius;
	} else {
		light = - 75 + (25 * offsetY) / radius;
	}
	if (yTarget < 0 || yTarget >= depth) {
     *firstTargetRow++;
	 *firstTargetRow++;
	 *firstTargetRow++;
	 *firstTargetRow++;
    } else {
     *firstTargetRow++ = MAX(blue + light, 0);
     *firstTargetRow++ = MAX(green + light, 0);
     *firstTargetRow++ = MAX(red + light, 0);
     *firstTargetRow++ = alpha;
    }
   } else {
    *firstTargetRow++ = blue;
    *firstTargetRow++ = green;
    *firstTargetRow++ = red;
    *firstTargetRow++ = alpha;
   }
  }
  firstTargetRow -= (targetRowSize + (width + xCoordinate + inScreenX << 2));
 }
 return TRUE;
}

BOOL EXPORT CylinderWithTextures(int targetObject, int radius, int depth, int top_id, int side_id,
								 int angle, int cosAngle, int sinAngle, int xCoordinate, int yCoordinate){
 int x, y, offsetY, xTarget, yTarget, inScreenX, inScreenY, width, height, light;
 int perimeter, sideOffset;
 LPBYTE firstTargetRow, firstTopRow, firstSideRow;
 RGSSBMINFO *targetBitmap = ((RGSSBITMAP*)(targetObject<<1))->bm->bminfo;
 RGSSBMINFO *top = ((RGSSBITMAP*)(top_id << 1))->bm->bminfo;
 RGSSBMINFO *side = ((RGSSBITMAP*)(side_id << 1))->bm->bminfo;
 int targetRowSize, topRowSize, sideRowSize;
 int targetWidth, targetHeight, topWidth, topHeight, sideWidth, sideHeight;
 LPBYTE thisData;
 targetWidth = targetBitmap->infoheader->biWidth;
 targetHeight = targetBitmap->infoheader->biHeight;
 topWidth = top->infoheader->biWidth;
 topHeight = top->infoheader->biHeight;
 sideWidth = side->infoheader->biWidth;
 sideHeight = side->infoheader->biHeight;
 targetRowSize = targetWidth << 2;
 topRowSize = topWidth << 2;
 sideRowSize = sideWidth << 2;
 firstTargetRow = (LPBYTE) targetBitmap->firstRow;
 firstTopRow = (LPBYTE) top->firstRow;
 firstSideRow = (LPBYTE) side->firstRow;
 width = radius << 1;
 height = width + depth;
 perimeter = (int) M_PI * radius << 1;
 angle %= 360;
 // gestion des bords du bitmap
 inScreenX = 0;
 if (xCoordinate + width <= 0) return TRUE;
 if (xCoordinate >= 0) {
	if (xCoordinate + width > targetWidth) {
		width = targetWidth - xCoordinate;
	}
 } else {
	if (xCoordinate + width > targetWidth) {
		width = targetWidth;
    } else {
		width = width + xCoordinate;
	}
	inScreenX = -xCoordinate;
 }
 if (width <= 0) return TRUE;
 inScreenY = 0;
 if (yCoordinate + height <= 0) return TRUE;
 if (yCoordinate >= 0) {
	if (yCoordinate + height > targetHeight) {
		height = targetHeight - yCoordinate;
	}
 } else {
	if (yCoordinate + height > targetHeight) {
		height = targetHeight;
    } else {
		height = height + yCoordinate;
	}
	inScreenY = -yCoordinate;
 }
 if (height <= 0) return TRUE;
 // dessin
 firstTargetRow -= targetRowSize * (yCoordinate + inScreenY);
 for (y = inScreenY; y < height + inScreenY; y++) {
  firstTargetRow += (xCoordinate + inScreenX << 2);
  for (x = inScreenX; x < width + inScreenX; x++) {
   if (y >= (radius << 1) || ((y - radius) * (y - radius) + (x - radius) * (x - radius) - radius * radius > 0)) {
	offsetY = sqrt((double) x * ((radius << 1) - x));
	yTarget = y - radius - offsetY;
	if (x >= radius) {
		light = - 25 - (25 * offsetY) / radius;
	} else {
		light = - 75 + (25 * offsetY) / radius;
	}
	if (yTarget < 0 || yTarget >= depth) {
     *firstTargetRow++;
	 *firstTargetRow++;
	 *firstTargetRow++;
	 *firstTargetRow++;
    } else {
	 xTarget = (int) (perimeter >> 1) * acos(((double) (radius - x)) / radius) / M_PI;
     xTarget = (((xTarget * sideWidth << 12) / perimeter >> 12) + (angle * sideWidth) / 360) % sideWidth;
	 yTarget = (yTarget * sideHeight << 12) / depth >> 12;
	 thisData = firstSideRow - (sideRowSize * yTarget) + (xTarget<<2);
	 *firstTargetRow++ = MAX(thisData[0] + light, 0);
     *firstTargetRow++ = MAX(thisData[1] + light, 0);
     *firstTargetRow++ = MAX(thisData[2] + light, 0);
	 *firstTargetRow++ = thisData[3];
    }
   } else {
    yTarget = (radius << 12) + ((y - radius) * cosAngle - ((x - radius) * sinAngle)) >> 12;
	xTarget = (radius << 12) + ((x - radius) * cosAngle + ((y - radius) * sinAngle)) >> 12;
    xTarget = ((xTarget * topWidth << 12) / width >> 12) % topWidth;
	yTarget = ((yTarget * topHeight << 12) / width >> 12) % topHeight;
	thisData = firstTopRow - (topRowSize * yTarget) + (xTarget<<2);
	*firstTargetRow++ = thisData[0];
    *firstTargetRow++ = thisData[1];
    *firstTargetRow++ = thisData[2];
	*firstTargetRow++ = thisData[3];
   }
  }
  firstTargetRow -= (targetRowSize + (width + xCoordinate + inScreenX << 2));
 }
 return TRUE;
}


Je peux fournir toutes les versions précédentes du code, jusqu'à la première version, ainsi qu'un projet RM l'utilisant à chaque fois.
Les tests en sont incroyablement simplifiés.

Un exemple :

Image



Il ne s'agirait pas forcément de "continuer" le travail, mais peut-être seulement de "reprendre" certaines parties.
La DLL gère les faces supérieures du cube, elle gère les cubes entiers, je voudrais qu'elle gère uniquement les faces latérales.
Ce genre de choses.

Une personne capable de travailler sur ce code entrerait directement dans l'équipe (11 membres permanents), et participerait ainsi à cette grande aventure. :)
Mod Message lu Posté le 25 Jan 2009 à 12:49 Bulle
Avatar de Mod
Webmaster

Messages : 4954
GCPoints : 2100823
Je n'ai pas vraiment le temps pour pouvoir aider sur ça, mais à vue de nez, le code n'a pas l'air excessivement complexe. Juste illisible, avec des gros paquets de code condensés.
En revanche, il y a pas mal de trigonométrie là-dedans, mieux vaut donc un programmeur qui soit aussi mathématicophile...
Répondre
GameCorp - Site d'apprentissage et d'entraide à la création de jeux vidéo.
XHTML Valid 1.1 - Page générée en 0.0533 secondes