Jump to content

CameraPick


DarthRaff
 Share

Recommended Posts

Hello,

 

Can someone, please, tell me what am i doing wrong ? i'm trying to translate it from lua with no success, thank you very much.

  if (KeyHit(KEY_E)) {
   TPick pick;
   pick = CameraPick(&pick,cam,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,3.0),0,0);
   if (pick) {
 do {
  if (GetEntityKey(pick.entity,"class") == ENTITY_MODEL) {
   break;
  }
  pick.entity = pick.entity.parent;
 } while (!pick.entity);
 if (pick.entity) {
  SendEntityMessage(pick.entity,"use");
 }
   }
  }

Link to comment
Share on other sites

So sorry, very long time no programming.

 

I don't know how to use the two functions to have it working. GetMeshModel() is used by GetPickedEntity() but how to use it, i'm very lost.

 

I tryied this but, of course, it's wrong

  if (KeyHit(KEY_E)) {
   TPick pick;
   pick = CameraPick(&pick,cam,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,3.0),2,0,0);
   SendEntityMessage(GetPickedEntity(pick,3.0f,0),"use");
  }

Link to comment
Share on other sites

You would need to include the function definition as shown below:

 

TModel GetMeshModel(TEntity _Entity)
{
       string strClassname;
       while (_Entity != NULL)
       {
               strClassname = GetEntityKey(_Entity, "class");
               if (strClassname == "Model")
               {
                       return _Entity;
               }
               _Entity = GetParent(_Entity);
       }
       return NULL;
};

 

and then modify your code so that the entity you are looking to pass the message to is obtained from:

 

GetMeshModel(pick.entity)

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...