MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / fromString

Method fromString

Engine/modules/Verve/VPath/VPathNode.cpp:257–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257bool VPathNode::fromString( const String &pString )
258{
259 // Split Data.
260 // {Position} {Rotation} {Weight}
261 const char *baseData = StringUnit::getUnit( pString.c_str(), 0, "\t" );
262
263 Point3F pos;
264 AngAxisF aa;
265 F32 weight;
266
267 // Scan Base.
268 dSscanf( baseData, "%g %g %g %g %g %g %g %g", &pos.x, &pos.y, &pos.z,
269 &aa.axis.x, &aa.axis.y, &aa.axis.z, &aa.angle,
270 &weight );
271
272 // Apply Changes.
273 setLocalPosition( pos );
274 setLocalRotation( QuatF( aa ) );
275 setWeight( weight );
276
277 // Fetch Orientation Data.
278 String orientationData = StringUnit::getUnit( pString.c_str(), 1, "\t" );
279
280 // Fetch Orientation Type.
281 String orientationTypeString = orientationData;
282 if ( orientationData.find( " " ) )
283 {
284 // Use First Word.
285 orientationTypeString = orientationData.substr( 0, orientationData.find( " " ) );
286 }
287
288 // Set Orientation Type.
289 const eOrientationType &orientationType = getOrientationTypeEnum( orientationTypeString.c_str() );
290 switch( orientationType )
291 {
292 case k_OrientationFree :
293 {
294 // Apply Mode.
295 setOrientationMode( orientationType );
296
297 } break;
298
299 case k_OrientationToPoint:
300 {
301 // Fetch Point.
302 Point3F lookAtPoint;
303 // Buffer String.
304 dSscanf( orientationData.c_str(), "%*s %f %f %f", &lookAtPoint.x, &lookAtPoint.y, &lookAtPoint.z );
305
306 // Apply Mode.
307 setOrientationMode( orientationType, lookAtPoint );
308
309 } break;
310 }
311
312 return true;
313}
314

Callers 1

readFieldsMethod · 0.45

Calls 6

getUnitFunction · 0.85
dSscanfFunction · 0.85
substrMethod · 0.80
QuatFClass · 0.50
c_strMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected