Umnik Posted February 1, 2010 Posted February 1, 2010 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. Quote Windows 7 Ultimate x64bit / Intel Core 2 Quad Q8400 / 4GB DDR2 SDRAM / GeForce 8800 GTS Resource War Developer [ dev blog ]
Umnik Posted February 3, 2010 Author Posted February 3, 2010 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! Quote Windows 7 Ultimate x64bit / Intel Core 2 Quad Q8400 / 4GB DDR2 SDRAM / GeForce 8800 GTS Resource War Developer [ dev blog ]
Canardia Posted February 3, 2010 Posted February 3, 2010 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"); 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 ■
Umnik Posted February 3, 2010 Author Posted February 3, 2010 DrawText(0,116,"%s",name); I click to model and not see name! Return value (null). What? Quote Windows 7 Ultimate x64bit / Intel Core 2 Quad Q8400 / 4GB DDR2 SDRAM / GeForce 8800 GTS Resource War Developer [ dev blog ]
Canardia Posted February 3, 2010 Posted February 3, 2010 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()); 1 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 ■
Umnik Posted February 3, 2010 Author Posted February 3, 2010 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? Quote Windows 7 Ultimate x64bit / Intel Core 2 Quad Q8400 / 4GB DDR2 SDRAM / GeForce 8800 GTS Resource War Developer [ dev blog ]
Canardia Posted February 3, 2010 Posted February 3, 2010 No, it's because you use the quick hack (GetParent()), instead of the correct GetMeshModel() function from gamelib. 1 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 ■
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.