Jump to content

Recommended Posts

Posted

Is anyone an give me example please: Handling events on click mouse in Model.

 

I want to create the object NPC and do not know where to start.

 

How work RayCasting I know.

 

I do not understand how to determine the name of the object, then to make a [if] operator.

 

Thanks.

Windows 7 Ultimate x64bit / Intel Core 2 Quad Q8400 / 4GB DDR2 SDRAM / GeForce 8800 GTS

Resource War Developer [ dev blog ]

Posted

As with GetEntityKey know Name of the object, such as a firepit model.

 

TPick pick2;

if(MouseHit(1)) {
HideEntity(character);
HideEntity(waycursor);
  if(CameraPick(&pick2,fw.GetMain().GetCamera(),Vec3(MouseX(),MouseY(),1000.0))) {
    string name;
    name=GetEntityKey(pick2.entity,"name");
    PositionEntity(cursor,Vec3(pick2.X,pick2.Y+0.25,pick2.Z));
  }
ShowEntity(waycursor);
ShowEntity(character);
}

...

if (!pick2.entity) {
 DrawText(0,100,"%s",GetEntityKey(pick2.entity,"name"));
}
 DrawText(0,116,"%s",name);

 

Not Worked ;(

 

Please help me!

Windows 7 Ultimate x64bit / Intel Core 2 Quad Q8400 / 4GB DDR2 SDRAM / GeForce 8800 GTS

Resource War Developer [ dev blog ]

Posted

You are picking the mesh, not the model. See gamelib's PlayerShoot() function how to pick models.

A quick hack would be this:

name=GetEntityKey(GetParent(pick2.entity),"name");

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

DrawText(0,116,"%s",name);

 

I click to model and not see name! Return value (null).

 

What?

Windows 7 Ultimate x64bit / Intel Core 2 Quad Q8400 / 4GB DDR2 SDRAM / GeForce 8800 GTS

Resource War Developer [ dev blog ]

Posted

Your name is a C++ object, and not a text. The C++ object of the string class can be converted to text using the c_str() method:

DrawText(0,116,"%s",(str)name.c_str());

  • Upvote 1

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

Thanks!

 

hmm...

 

Model {
path="firepit.gmf"
position=-2.00000000,0.000000000,-6.00000000
rotation=-0.000000000,-0.000000000,0.000000000
scale=1.00000000,1.00000000,1.00000000
id=205114888
"class"="Model"
"intensity"="1.0"
"name"="firepit_1"
}

 

"class"="Model"

 

Return value "Mesh"

 

"name"="firepit_1"

 

Return value "Scene Root"

 

This is because I use CameraPick method?

Windows 7 Ultimate x64bit / Intel Core 2 Quad Q8400 / 4GB DDR2 SDRAM / GeForce 8800 GTS

Resource War Developer [ dev blog ]

Posted

No, it's because you use the quick hack (GetParent()), instead of the correct GetMeshModel() function from gamelib.

  • Upvote 1

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 ■

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