| 2391 | if (head) |
| 2392 | { |
| 2393 | obj->SetTransform(Matrix4(MRotationY, head * (H_PI / 180))); |
| 2394 | } |
| 2395 | Point3 nPos = pos + obj->DirectionModelToWorld(shape->BoundingCenter()); |
| 2396 | obj->SetPosition(nPos); |
| 2397 | AddObject(obj); |
| 2398 | return obj; |
| 2399 | } |
| 2400 | |
| 2401 | Object* Landscape::ObjectCreate(int id, const char* name, const Matrix4& transform, int* x, int* z, |
| 2402 | bool avoidRecalculation) |
| 2403 | { |
| 2404 | // create object based on Class hint in LOD 0 |
| 2405 | Ref<LODShapeWithShadow> shape = Shapes.New(name, false, true); |
| 2406 | Object* obj = NewObject(shape, id); |
| 2407 | |
| 2408 | if (obj->GetType() != Primary && obj->GetType() != Network) |
| 2409 | { |
| 2410 | obj->SetType(Primary); |
| 2411 | } |
| 2412 | |
| 2413 | // object id list cleared after load is finished |
| 2414 | _objectIds.Access(id); |
| 2415 | _objectIds[id] = obj; |
| 2416 | PoseidonAssert(obj->ID() == id); |
| 2417 | // check matrix type |
| 2418 | |
| 2419 | Matrix4 nTransform = transform; |
| 2420 | |
| 2421 | #if 1 |
| 2422 | // "repair" matrix |
| 2423 | // matrix should be scaled rotation |
| 2424 | // (S*R, where S is scale matrix and R is rotation) |
| 2425 | // some matrices must not be repaired |
| 2426 | // this holds especially for forests |
| 2427 | static RStringB forestString("forest"); |
| 2428 | if (shape->GetPropertyClass() != forestString) |
| 2429 | { |
| 2430 | float scale = obj->GetType() == Network ? 1.0f : nTransform.Scale(); |
| 2431 | // if object is slope following, up should be VUp |
| 2432 | // if (shape->GetAndHints()&ClipLandKeep) |
| 2433 | if (shape->GetOrHints() & ClipLandKeep) |
| 2434 | { |
| 2435 | nTransform.SetUpAndAside(VUp, nTransform.DirectionAside()); |
| 2436 | } |
| 2437 | else |
| 2438 | { |
| 2439 | nTransform.SetUpAndAside(nTransform.DirectionUp(), nTransform.DirectionAside()); |
| 2440 | } |
| 2441 | nTransform.SetScale(scale); |
| 2442 | } |
| 2443 | #endif |
| 2444 | |
| 2445 | obj->SetTransform(nTransform); |
| 2446 | |
| 2447 | #if 1 |
| 2448 | |
| 2449 | if (!ENGINE_CONFIG.landEditor) |
| 2450 | { |
no test coverage detected