Sooshi Posted February 16, 2010 Share Posted February 16, 2010 I have just come from out of town for valentines day and I have decided to do the raycast C++ tutorial(but coding in Lua) and I am having trouble followng it. I feel it isnt being explained properly for me to understand the concept. I have searched the forums and I cant seem to find any examples to help me get started. I was wondering if anyone could offer some help as to giving me a better example with in depth explanations of doing simple raycasting using cubes and the functions provided. Like for instance this bit of code is whats confusing me, the sprintf....is that a function? If anyone could provide a simple workflow(perferably in Lua) with doing simple raycasting that would help me out quite a bit. Thanks... I dont really understand the code below because sprintf is where I got lost.. --Test and display visibility between two points result=PointVisible(Vec3(4,0,0),Vec3(-4,0,0)) sprintf(temp,"Visible: %d",result) DrawText(0,0,result) --Display the tested line point0=CameraUnproject(cam,Vec3(4,0,0)) point1=CameraUnproject(cam,Vec3(-4,0,0)) SetColor(Vec4(1,0,0,1)) DrawLine(4,0,-8,0) SetColor(Vec4(1)) Quote Working on a major RPG project.......will showcase soon. www.kevintillman1.wix.com/tillmansart Link to comment Share on other sites More sharing options...
Josh Posted February 16, 2010 Share Posted February 16, 2010 sprintf is just a weird C++ thing you need to make a string, because C++ can't just say "DrawText(result,0,0)". 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...
Canardia Posted February 16, 2010 Share Posted February 16, 2010 In C++ you can say: DrawText(0,0,"Visible: %d",result); No need for sprintf with DrawText. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Sooshi Posted February 16, 2010 Author Share Posted February 16, 2010 sprintf is just a weird C++ thing you need to make a string, because C++ can't just say "DrawText(result,0,0)". In C++ you can say: DrawText(0,0,"Visible: %d",result);No need for sprintf with DrawText. Oh ok I see, what about CameraUnproject(), what is that doing exactly? Quote Working on a major RPG project.......will showcase soon. www.kevintillman1.wix.com/tillmansart Link to comment Share on other sites More sharing options...
Canardia Posted February 16, 2010 Share Posted February 16, 2010 Couldn't remember it either, but a quick look at the wiki explained it very well: http://www.leadwerks.com/wiki/index.php?title=Cameras#CameraUnproject Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Sooshi Posted February 17, 2010 Author Share Posted February 17, 2010 Couldn't remember it either, but a quick look at the wiki explained it very well: http://www.leadwerks.com/wiki/index.php?title=Cameras#CameraUnproject oh yea wiki...thnx bro Quote Working on a major RPG project.......will showcase soon. www.kevintillman1.wix.com/tillmansart Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted February 17, 2010 Share Posted February 17, 2010 sprintf is just a weird C++ thing you need to make a string, because C++ can't just say "DrawText(result,0,0)". oops... http://www.leadwerks.com/wiki/index.php?title=CameraUnproject TVec3 pos = CameraUnproject(Camera,EntityPosition(cube)) ; DrawText (pos.X,pos.Y,"Cube center position"); if (pos.Z < 0) DrawText (pos.X,pos.Y+15,"Cube behind camera"); DrawText (0,0,"Use the arrow keys to move the cube"); SetBlend (0); Flip (1); Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
Sooshi Posted February 17, 2010 Author Share Posted February 17, 2010 playing around for a few hours, I figured it out, thanks for your help guys.. Quote Working on a major RPG project.......will showcase soon. www.kevintillman1.wix.com/tillmansart 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.