djoker
04-12-2006, 08:21 PM
HI ppl...
my 2 attached guns draw above the terrain ...with this happens? :cry:
the guns is attached 2 camera ,fps style
http://img159.imageshack.us/img159/4992/probrv6.th.jpg (http://img159.imageshack.us/my.php?image=probrv6.jpg)
http://img159.imageshack.us/img159/1061/prob2pp2.th.jpg (http://img159.imageshack.us/my.php?image=prob2pp2.jpg)
function Convert_2D_To_3D(x,y:integer):TD3DVector;
var
modelM : TMatrix4d;
projectM: TMatrix4d;
bx,ex,ey,ez,
by,
bz: GLdouble;
viewport: TVector4i;
NEAR_Z:gldouble;
RayBegin:TD3DVector;
begin
NEAR_Z:=1.0;
glGetDoublev(GL_PROJECTION_MATRIX, @projectM );
glGetDoublev(GL_MODELVIEW_MATRIX, @modelM);
glGetIntegerv(GL_VIEWPORT, @viewport );
gluUnProject(X, viewport[3]-y ,0.0,modelm, projectm, viewport,@bx,@by,@bz);
raybegin:=Make3DVector(bx,by,bz);
NEAR_Z:=0.965;// dist 2 camera
gluUnProject(X, viewport[3]-y ,NEAR_Z,modelm, projectm, viewport,@ex,@ey,@ez);
result:=Make3DVector(ex,ey,ez);
end;
--------------------------------------------------------
//update camera
DivCamera_Update(0);
DivCamera_MouseLook(0);
// get the ray from screen space to 3D Space
gun1:=Convert_2D_To_3D(800 div 2+280,600 div 2+ 250);
gun2:=Convert_2D_To_3D(800 div 2-280,600 div 2+ 250);
//draw terrain and water
DivTerrain_Render;
DivWaterPlane_Draw(0);
// draw gun 1
DivEntities_Render(0,timegettime/1000);
DivEntities_Yaw(0, 180-DivCamera_GetRX);
DivEntities_Pitch(0,+(DivCamera_GetRY-90));
DivEntities_Position(0,gun2.x,gun2.y,gun2.z);
// draw gun 2
DivEntities_Render(0,timegettime/1000);
DivEntities_Yaw(0, 180-DivCamera_GetRX);
DivEntities_Pitch(0,+(DivCamera_GetRY-90));
DivEntities_Position(0,gun1.x,gun1.y,gun1.z);
my 2 attached guns draw above the terrain ...with this happens? :cry:
the guns is attached 2 camera ,fps style
http://img159.imageshack.us/img159/4992/probrv6.th.jpg (http://img159.imageshack.us/my.php?image=probrv6.jpg)
http://img159.imageshack.us/img159/1061/prob2pp2.th.jpg (http://img159.imageshack.us/my.php?image=prob2pp2.jpg)
function Convert_2D_To_3D(x,y:integer):TD3DVector;
var
modelM : TMatrix4d;
projectM: TMatrix4d;
bx,ex,ey,ez,
by,
bz: GLdouble;
viewport: TVector4i;
NEAR_Z:gldouble;
RayBegin:TD3DVector;
begin
NEAR_Z:=1.0;
glGetDoublev(GL_PROJECTION_MATRIX, @projectM );
glGetDoublev(GL_MODELVIEW_MATRIX, @modelM);
glGetIntegerv(GL_VIEWPORT, @viewport );
gluUnProject(X, viewport[3]-y ,0.0,modelm, projectm, viewport,@bx,@by,@bz);
raybegin:=Make3DVector(bx,by,bz);
NEAR_Z:=0.965;// dist 2 camera
gluUnProject(X, viewport[3]-y ,NEAR_Z,modelm, projectm, viewport,@ex,@ey,@ez);
result:=Make3DVector(ex,ey,ez);
end;
--------------------------------------------------------
//update camera
DivCamera_Update(0);
DivCamera_MouseLook(0);
// get the ray from screen space to 3D Space
gun1:=Convert_2D_To_3D(800 div 2+280,600 div 2+ 250);
gun2:=Convert_2D_To_3D(800 div 2-280,600 div 2+ 250);
//draw terrain and water
DivTerrain_Render;
DivWaterPlane_Draw(0);
// draw gun 1
DivEntities_Render(0,timegettime/1000);
DivEntities_Yaw(0, 180-DivCamera_GetRX);
DivEntities_Pitch(0,+(DivCamera_GetRY-90));
DivEntities_Position(0,gun2.x,gun2.y,gun2.z);
// draw gun 2
DivEntities_Render(0,timegettime/1000);
DivEntities_Yaw(0, 180-DivCamera_GetRX);
DivEntities_Pitch(0,+(DivCamera_GetRY-90));
DivEntities_Position(0,gun1.x,gun1.y,gun1.z);