Jump to content

Recommended Posts

Posted

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)) 

Working on a major RPG project.......will showcase soon.

 

www.kevintillman1.wix.com/tillmansart

Posted

sprintf is just a weird C++ thing you need to make a string, because C++ can't just say "DrawText(result,0,0)".

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

In C++ you can say: DrawText(0,0,"Visible: %d",result);

No need for sprintf with DrawText.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Posted

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?

Working on a major RPG project.......will showcase soon.

 

www.kevintillman1.wix.com/tillmansart

Posted

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);

AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD

76561197984667096.png

Posted

playing around for a few hours, I figured it out, thanks for your help guys..

Working on a major RPG project.......will showcase soon.

 

www.kevintillman1.wix.com/tillmansart

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...