Posted by Kozmo.
Hello,
I thought I would share this simple Crosshair. As with FarCry, there is a SDK available for Crysis. This SDK will save you weeks of reversing, so use it!
Google Crytek Crysis SDK
I wont go into on how to get the games struct pointers this time. Unlike FarCry there is no Draw2dLine function. So we have to make our own.
On the 2 draw functions I provided, you may want to check for null pointers before trying to use them. This was just a spliced together example of how
to draw 2d lines /spheres
Code:
Code:
//This Section Should be Inited Just once
int screenx,screeny,width,height;
mySystem = myFramework->GetISystem();
IRenderer *pIRenderer = ( IRenderer *)mySystem->GetIRenderer();
pIRenderer->GetViewport(&screenx,&screeny,&width,&height);
//get dead center
float ScreenCenterX = (float)width / 2 + screenx;
float ScreenCenterY = (float)height / 2 + screeny;
//This section should go in your main game loop (EndScene will work)
pIRenderer->SetMaterialColor( 1, 1, 1, 0.5f );
Vec3 x(ScreenCenterX-10,ScreenCenterY,0);
Vec3 y(ScreenCenterX+10,ScreenCenterY,0);
draw2Dline(x,y);
x(ScreenCenterX,ScreenCenterY-10,0);
y(ScreenCenterX,ScreenCenterY+10,0);
draw2Dline(x,y);
x(ScreenCenterX,ScreenCenterY,0);
drawCircle(x);
//END of CROSSHAIR
//these are the 2d functions
void draw2Dline(Vec3 x,Vec3 y)
{
Vec3 v3x;
Vec3 v3y;
mySystem->GetIRenderer()->UnProjectFromScreen(x.x,x.y,x.z,&v3x.x,&v3x.y,&v3x.z);
mySystem->GetIRenderer()->UnProjectFromScreen(y.x,y.y,y.z,&v3y.x,&v3y.y,&v3y.z);
mySystem->GetIRenderer()->DrawLine(v3x,v3y);
}
void drawCircle(Vec3 x)
{
Vec3 v3x;
mySystem->GetIRenderer()->UnProjectFromScreen(x.x,x.y,x.z,&v3x.x,&v3x.y,&v3x.z);
mySystem->GetIRenderer()->GetIRenderAuxGeom()->DrawSphere(v3x,.01f,ColorB(255,0,0),true);
}
A pic of the crosshair with Red Dot (pic is not good cuz of my resizing/shrinking etc. crosshair is actually equal in height/width)
Credits: Okidoki for his farcry info