ParaToxic Posted May 27, 2011 Share Posted May 27, 2011 Hello,i try to make a bullet class with Raycasting.I made a point1 at the player position and point2 like: point2=Vec3(0,0,30); point2=TFormVector(point2,cam,NULL); LinePick(&pick,point1,point2); this,but when i check the values of point2,its wrong. How can i solve this problem? Thank you Quote Link to comment Share on other sites More sharing options...
Josh Posted May 27, 2011 Share Posted May 27, 2011 How is it wrong? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
ParaToxic Posted May 28, 2011 Author Share Posted May 28, 2011 So i have a little example.Maybe somebody can told me why it is wrong. #include "engine.h" int main(int argc, char** argv) { Initialize(); Graphics(800,600); TCamera cam=CreateCamera(); PositionEntity(cam,Vec3(0,2,-10)); Collisions(1,2,true); TModel scene=LoadModel("scene.gmf"); EntityType(scene,2); TLight light=CreatePointLight(); PositionEntity(light,Vec3(0,5,0)); TBuffer buffer=CreateBuffer(800,600,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); TController player=CreateController(); SetBodyMass(player,6); EntityType(player,1); TVec3 point1=Vec3(0,0,0); TVec3 point2=Vec3(0,0,0); TVec3 a=Vec3(0,0,0); TVec3 b=Vec3(0,0,0); TPick pick; float move=0.0; float strafe=0.0; TVec3 camrotation=Vec3(0); float mx=0; float my=0; HideMouse(); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); while(!KeyHit(KEY_ESCAPE)) { mx=Curve(MouseX()-GraphicsWidth()/2,mx,6); my=Curve(MouseY()-GraphicsHeight()/2,my,6); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); camrotation.X=camrotation.X+my/10.0; camrotation.Y=camrotation.Y-mx/10.0; RotateEntity(cam,camrotation); move=KeyDown(KEY_W)-KeyDown(KEY_S); strafe=KeyDown(KEY_D)-KeyDown(KEY_A); UpdateController(player,camrotation.Y,move,strafe); UpdateWorld(); TVec3 playerpos=EntityPosition(player); TVec3 camerapos=EntityPosition(cam); camerapos.Y=Curve(playerpos.Y+1.75,camerapos.Y,2.0); camerapos=Vec3(playerpos.X,camerapos.Y,playerpos.Z); PositionEntity(cam,camerapos); point1=EntityPosition(cam); point2=Vec3(0,0,4); point2=TFormVector(point2,cam,0); if(LinePick(&pick,point1,point2,0,0)) { a=CameraUnproject(cam,point1); b=CameraUnproject(cam,Vec3(pick.X,pick.Y,pick.Z)); } SetBuffer(buffer); RenderWorld(); SetBuffer(BackBuffer()); RenderLights(buffer); DrawLine(a.X,a.Y,b.X,a.Y); Flip(); } return Terminate(); } Thank you for advanced Quote Link to comment Share on other sites More sharing options...
TylerH Posted June 2, 2011 Share Posted June 2, 2011 As far as I know you don't need to be transforming that vector into camera space. It is technically already in camera space. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.