Jump to content

[Solved] Converting from std::string to str


Shard
 Share

Recommended Posts

Hey guys.

 

I'm coding a specific version of our game for a cinematic. Basically, Porsche will create animations in 3DS and then we will place it in the code.

Then the code will read it in and create mesh objects for them. Finally, he can hit "play" and all the animations would run from start to finish. Then we will Fraps it.

 

The problem that I'm having is doing this:

 


//Initialization
string objectName;


	// For aStar stuff
	if(className == "animation")
	{
		TMesh mesh;

		className = "\"abstract:" + className;
		className = className + ".gmf\"";

		mesh = LoadMesh(className);  //<------ error C2664: 'LoadMesh' : cannot convert parameter 1 from 'std::string' to 'str'
              }

 

 

The object name is defined in the Editor and is the same as the gmf file.

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Link to comment
Share on other sites

sdt::String has c_str() method use it. It should work.

 

 

Thanks. I did this and I got a new error

error C2664: 'LoadMesh' : cannot convert parameter 1 from 'const char *' to 'str'

 

 

I did a Google search on the error but I couldn't find a solution.

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Link to comment
Share on other sites

Try this:

string myString;

......

LoadMesh(str(myString.c_str()));

 

Thank You, worked perfectly.

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

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