diff options
author | McCabe Maxsted | 2009-11-09 17:36:58 -0700 |
---|---|---|
committer | McCabe Maxsted | 2009-11-09 17:36:58 -0700 |
commit | 8af226efd89b2f2190555ce578d4e7f1cde99f32 (patch) | |
tree | c4c75ffe4f8d76956f4b2d5f2a8469babf79b0b7 /linden/indra | |
parent | Attachment size limits need to use the max prim size set in llmanipscale (diff) | |
download | meta-impy-8af226efd89b2f2190555ce578d4e7f1cde99f32.zip meta-impy-8af226efd89b2f2190555ce578d4e7f1cde99f32.tar.gz meta-impy-8af226efd89b2f2190555ce578d4e7f1cde99f32.tar.bz2 meta-impy-8af226efd89b2f2190555ce578d4e7f1cde99f32.tar.xz |
Updated primbackup from latest meerkat svn (r246)
Diffstat (limited to 'linden/indra')
-rw-r--r-- | linden/indra/newview/primbackup.cpp | 659 | ||||
-rw-r--r-- | linden/indra/newview/primbackup.h | 9 |
2 files changed, 616 insertions, 52 deletions
diff --git a/linden/indra/newview/primbackup.cpp b/linden/indra/newview/primbackup.cpp index 8dbf1df..8af8cd3 100644 --- a/linden/indra/newview/primbackup.cpp +++ b/linden/indra/newview/primbackup.cpp | |||
@@ -154,7 +154,7 @@ class importResponder: public LLNewAgentInventoryResponder | |||
154 | 154 | ||
155 | }; | 155 | }; |
156 | 156 | ||
157 | 157 | /* | |
158 | 158 | ||
159 | class CacheReadResponder : public LLTextureCache::ReadResponder | 159 | class CacheReadResponder : public LLTextureCache::ReadResponder |
160 | { | 160 | { |
@@ -197,7 +197,32 @@ class CacheReadResponder : public LLTextureCache::ReadResponder | |||
197 | 197 | ||
198 | std::string name; | 198 | std::string name; |
199 | mID.toString(name); | 199 | mID.toString(name); |
200 | llinfos << "Saving to "<<(primbackup::getInstance()->getfolder()+"//"+name)<<llendl; | 200 | llinfos << "Saving to "<<(primbackup::getInstance()->getfolder()+"//"+name)<<llendl; |
201 | |||
202 | |||
203 | //////////////////////////////////// | ||
204 | // if (save targas) -Patrick Sapinski (Thursday, September 24, 2009) | ||
205 | LLPointer<LLImageTGA> image_tga = new LLImageTGA; | ||
206 | LLPointer<LLImageRaw> raw = new LLImageRaw; | ||
207 | |||
208 | mFormattedImage->decode(raw, 0); | ||
209 | |||
210 | if( !image_tga->encode( raw ) ) | ||
211 | { | ||
212 | LLStringUtil::format_map_t args; | ||
213 | args["[FILE]"] = name; | ||
214 | gViewerWindow->alertXml("CannotEncodeFile", args); | ||
215 | } | ||
216 | else if( !image_tga->save( primbackup::getInstance()->getfolder()+"//textures//"+name + ".tga" ) ) | ||
217 | { | ||
218 | LLStringUtil::format_map_t args; | ||
219 | args["[FILE]"] = name; | ||
220 | gViewerWindow->alertXml("CannotWriteFile", args); | ||
221 | } | ||
222 | |||
223 | //////////////////////////////////////// | ||
224 | |||
225 | |||
201 | if(!mFormattedImage->save(primbackup::getInstance()->getfolder()+"//"+name)) | 226 | if(!mFormattedImage->save(primbackup::getInstance()->getfolder()+"//"+name)) |
202 | { | 227 | { |
203 | llinfos << "FAIL saving texture "<<mID<< llendl; | 228 | llinfos << "FAIL saving texture "<<mID<< llendl; |
@@ -223,6 +248,7 @@ class CacheReadResponder : public LLTextureCache::ReadResponder | |||
223 | 248 | ||
224 | 249 | ||
225 | 250 | ||
251 | */ | ||
226 | primbackup::primbackup() | 252 | primbackup::primbackup() |
227 | : LLFloater( std::string("Prim Import Floater") ) | 253 | : LLFloater( std::string("Prim Import Floater") ) |
228 | { | 254 | { |
@@ -333,6 +359,7 @@ void primbackup::pre_export_object() | |||
333 | { | 359 | { |
334 | textures.clear(); | 360 | textures.clear(); |
335 | llsd.clear(); | 361 | llsd.clear(); |
362 | xml = new LLXMLNode("group", FALSE); | ||
336 | this_group.clear(); | 363 | this_group.clear(); |
337 | 364 | ||
338 | // Open the file save dialog | 365 | // Open the file save dialog |
@@ -346,8 +373,8 @@ void primbackup::pre_export_object() | |||
346 | file_name = file_picker.getCurFile(); | 373 | file_name = file_picker.getCurFile(); |
347 | folder = gDirUtilp->getDirName(file_name); | 374 | folder = gDirUtilp->getDirName(file_name); |
348 | 375 | ||
349 | export_state=EXPORT_INIT; | 376 | // export_state=EXPORT_INIT; |
350 | gIdleCallbacks.addFunction(exportworker, NULL); | 377 | //gIdleCallbacks.addFunction(exportworker, NULL); |
351 | } | 378 | } |
352 | 379 | ||
353 | 380 | ||
@@ -362,40 +389,43 @@ bool primbackup::check_perms( LLSelectNode* node ) | |||
362 | } | 389 | } |
363 | 390 | ||
364 | 391 | ||
392 | /* | ||
365 | void primbackup::exportworker(void *userdata) | 393 | void primbackup::exportworker(void *userdata) |
366 | { | 394 | { |
367 | primbackup::getInstance()->updateexportnumbers(); | 395 | primbackup::getInstance()->updateexportnumbers(); |
368 | 396 | ||
369 | switch(primbackup::getInstance()->export_state) | 397 | switch(primbackup::getInstance()->export_state) |
370 | { | 398 | { |
371 | case EXPORT_INIT: { | 399 | case EXPORT_INIT: |
372 | primbackup::getInstance()->show(); | ||
373 | LLSelectMgr::getInstance()->getSelection()->ref(); | ||
374 | |||
375 | struct ff : public LLSelectedNodeFunctor | ||
376 | { | 400 | { |
377 | virtual bool apply(LLSelectNode* node) | 401 | primbackup::getInstance()->show(); |
402 | LLSelectMgr::getInstance()->getSelection()->ref(); | ||
403 | |||
404 | struct ff : public LLSelectedNodeFunctor | ||
405 | { | ||
406 | virtual bool apply(LLSelectNode* node) | ||
407 | { | ||
408 | return primbackup::check_perms( node ); | ||
409 | } | ||
410 | } func; | ||
411 | |||
412 | if(LLSelectMgr::getInstance()->getSelection()->applyToNodes(&func,false)) | ||
413 | primbackup::getInstance()->export_state=EXPORT_STRUCTURE; | ||
414 | else | ||
378 | { | 415 | { |
379 | return primbackup::check_perms( node ); | 416 | llwarns<<"Incorrect permission to export"<<llendl; |
380 | } | 417 | primbackup::getInstance()->export_state=EXPORT_DONE; |
381 | } func; | 418 | primbackup::getInstance()->close(); |
419 | gIdleCallbacks.deleteFunction(exportworker); | ||
420 | LLSelectMgr::getInstance()->getSelection()->unref(); | ||
382 | 421 | ||
383 | if(LLSelectMgr::getInstance()->getSelection()->applyToNodes(&func,false)) | 422 | } |
384 | { | 423 | break; |
385 | primbackup::getInstance()->export_state=EXPORT_STRUCTURE; | ||
386 | } | ||
387 | else | ||
388 | { | ||
389 | llwarns << "Incorrect permission to export" << llendl; | ||
390 | primbackup::getInstance()->export_state=EXPORT_DONE; | ||
391 | primbackup::getInstance()->close(); | ||
392 | gIdleCallbacks.deleteFunction(exportworker); | ||
393 | LLSelectMgr::getInstance()->getSelection()->unref(); | ||
394 | } | 424 | } |
395 | break; | ||
396 | } | ||
397 | 425 | ||
398 | case EXPORT_STRUCTURE: { | 426 | break; |
427 | case EXPORT_STRUCTURE: | ||
428 | { | ||
399 | struct ff : public LLSelectedObjectFunctor | 429 | struct ff : public LLSelectedObjectFunctor |
400 | { | 430 | { |
401 | virtual bool apply(LLViewerObject* object) | 431 | virtual bool apply(LLViewerObject* object) |
@@ -403,12 +433,46 @@ void primbackup::exportworker(void *userdata) | |||
403 | object->boostTexturePriority(TRUE); | 433 | object->boostTexturePriority(TRUE); |
404 | LLViewerObject::child_list_t children = object->getChildren(); | 434 | LLViewerObject::child_list_t children = object->getChildren(); |
405 | children.push_front(object); //push root onto list | 435 | children.push_front(object); //push root onto list |
406 | LLSD prim_llsd=primbackup::getInstance()->prims_to_llsd(children); | 436 | #if 0 |
437 | LLSD prim_llsd=primbackup::getInstance()->prims_to_llsd(children); | ||
407 | LLSD stuff; | 438 | LLSD stuff; |
408 | stuff["root_position"] = object->getPosition().getValue(); | 439 | stuff["root_position"] = object->getPosition().getValue(); |
409 | stuff["root_rotation"] = ll_sd_from_quaternion(object->getRotation()); | 440 | stuff["root_rotation"] = ll_sd_from_quaternion(object->getRotation()); |
410 | stuff["group_body"] = prim_llsd; | 441 | stuff["group_body"] = prim_llsd; |
411 | primbackup::getInstance()->llsd["data"].append(stuff); | 442 | primbackup::getInstance()->llsd["data"].append(stuff); |
443 | #endif | ||
444 | |||
445 | |||
446 | //primbackup::getInstance()->xml->createChild("root_position", FALSE)->setValue(object->getPosition().getValue()); | ||
447 | //primbackup::getInstance()->xml->createChild("root_rotation", FALSE)->setValue(ll_sd_from_quaternion(object->getRotation())); | ||
448 | |||
449 | LLBBox bbox = LLSelectMgr::getInstance()->getBBoxOfSelection(); | ||
450 | |||
451 | LLXMLNodePtr max_xml = primbackup::getInstance()->xml->createChild("max", FALSE); | ||
452 | LLVector3 max = object->getPosition(); | ||
453 | max_xml->createChild("x", TRUE)->setValue(llformat("%.5f", max.mV[VX])); | ||
454 | max_xml->createChild("y", TRUE)->setValue(llformat("%.5f", max.mV[VY])); | ||
455 | max_xml->createChild("z", TRUE)->setValue(llformat("%.5f", max.mV[VZ])); | ||
456 | |||
457 | LLXMLNodePtr min_xml = primbackup::getInstance()->xml->createChild("min", FALSE); | ||
458 | LLVector3 min = object->getPosition(); | ||
459 | min_xml->createChild("x", TRUE)->setValue(llformat("%.5f", min.mV[VX])); | ||
460 | min_xml->createChild("y", TRUE)->setValue(llformat("%.5f", min.mV[VY])); | ||
461 | min_xml->createChild("z", TRUE)->setValue(llformat("%.5f", min.mV[VZ])); | ||
462 | |||
463 | LLXMLNodePtr center_xml = primbackup::getInstance()->xml->createChild("center", FALSE); | ||
464 | LLVector3 center = object->getPosition(); | ||
465 | center_xml->createChild("x", TRUE)->setValue(llformat("%.5f", center.mV[VX])); | ||
466 | center_xml->createChild("y", TRUE)->setValue(llformat("%.5f", center.mV[VY])); | ||
467 | center_xml->createChild("z", TRUE)->setValue(llformat("%.5f", center.mV[VZ])); | ||
468 | |||
469 | |||
470 | //primbackup::getInstance()->xml->createChild("max", FALSE)->setValue(object->getPosition().getValue()); | ||
471 | //primbackup::getInstance()->xml->createChild("min", FALSE)->setValue(object->getPosition().getValue()); | ||
472 | //primbackup::getInstance()->xml->createChild("center", FALSE)->setValue(object->getPosition().getValue()); | ||
473 | |||
474 | |||
475 | primbackup::getInstance()->xml->addChild(primbackup::getInstance()->prims_to_xml(children)); | ||
412 | return true; | 476 | return true; |
413 | } | 477 | } |
414 | } func; | 478 | } func; |
@@ -419,8 +483,7 @@ void primbackup::exportworker(void *userdata) | |||
419 | 483 | ||
420 | break; | 484 | break; |
421 | } | 485 | } |
422 | 486 | case EXPORT_TEXTURES: | |
423 | case EXPORT_TEXTURES: { | ||
424 | if(primbackup::getInstance()->m_nexttextureready==false) | 487 | if(primbackup::getInstance()->m_nexttextureready==false) |
425 | return; | 488 | return; |
426 | 489 | ||
@@ -434,26 +497,524 @@ void primbackup::exportworker(void *userdata) | |||
434 | } | 497 | } |
435 | 498 | ||
436 | primbackup::getInstance()->export_next_texture(); | 499 | primbackup::getInstance()->export_next_texture(); |
437 | break; | 500 | break; |
501 | |||
502 | case EXPORT_LLSD: | ||
503 | { | ||
504 | // Create a file stream and write to it | ||
505 | llofstream export_file(primbackup::getInstance()->file_name); | ||
506 | LLSDSerialize::toPrettyXML(primbackup::getInstance()->llsd, export_file); | ||
507 | export_file.close(); | ||
508 | |||
509 | #if 1 | ||
510 | //-Patrick Sapinski (Thursday, September 17, 2009) | ||
511 | |||
512 | llofstream out(primbackup::getInstance()->file_name); | ||
513 | |||
514 | if (!out.good()) | ||
515 | { | ||
516 | llwarns << "Unable to open for output." << llendl; | ||
438 | } | 517 | } |
439 | 518 | ||
440 | case EXPORT_LLSD: { | 519 | out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
441 | // Create a file stream and write to it | 520 | |
442 | llofstream export_file(primbackup::getInstance()->file_name); | 521 | |
443 | LLSDSerialize::toPrettyXML(primbackup::getInstance()->llsd, export_file); | 522 | LLXMLNode *temp_xml = new LLXMLNode("project", FALSE); |
444 | export_file.close(); | 523 | |
445 | primbackup::getInstance()->m_nexttextureready=true; | 524 | temp_xml->createChild("schema", FALSE)->setValue("1.0"); |
446 | primbackup::getInstance()->export_state=EXPORT_TEXTURES; | 525 | temp_xml->createChild("name", FALSE)->setValue(primbackup::getInstance()->file_name); |
526 | temp_xml->createChild("date", FALSE)->setValue("test"); | ||
527 | temp_xml->createChild("sotware", FALSE)->setValue("Meerkat 0.3.0"); | ||
528 | temp_xml->createChild("platform", FALSE)->setValue("Second Life"); | ||
529 | temp_xml->createChild("grid", FALSE)->setValue("test"); | ||
530 | |||
531 | temp_xml->addChild(primbackup::getInstance()->xml); | ||
532 | |||
533 | /* | ||
534 | <schema>1.0</schema> | ||
535 | <name>TextureTest</name> | ||
536 | <date>7/8/2009 12:46 AM</date> | ||
537 | <software>Maxproxy 1.3.2</software> | ||
538 | <creator>3b520582-1d15-41c6-8849-afdd1b2528bd</creator> | ||
539 | <platform>OpenSim</platform> | ||
540 | <grid>unknown</grid> | ||
541 | *//* | ||
542 | |||
543 | |||
544 | temp_xml->writeToOstream(out); | ||
545 | out.close(); | ||
546 | /////////////////////////////////////////////// | ||
547 | #endif | ||
548 | |||
549 | primbackup::getInstance()->m_nexttextureready=true; | ||
550 | primbackup::getInstance()->export_state=EXPORT_TEXTURES; | ||
551 | } | ||
447 | break; | 552 | break; |
553 | case EXPORT_DONE: | ||
554 | llinfos<<"Backup complete"<<llendl | ||
555 | gIdleCallbacks.deleteFunction(exportworker); | ||
556 | primbackup::getInstance()->close(); | ||
557 | break; | ||
558 | } | ||
559 | } | ||
560 | |||
561 | LLXMLNode *primbackup::prims_to_xml(LLViewerObject::child_list_t child_list) | ||
562 | { | ||
563 | |||
564 | LLViewerObject* object; | ||
565 | LLXMLNode *xml = new LLXMLNode("linkset", FALSE); | ||
566 | |||
567 | char localid[16]; | ||
568 | |||
569 | for (LLViewerObject::child_list_t::iterator i = child_list.begin(); i != child_list.end(); ++i) | ||
570 | { | ||
571 | object=(*i); | ||
572 | LLUUID id = object->getID(); | ||
573 | |||
574 | llinfos << "Exporting prim " << object->getID().asString() << llendl; | ||
575 | |||
576 | std::string selected_item = "box"; | ||
577 | F32 scale_x=1.f, scale_y=1.f; | ||
578 | |||
579 | const LLVolumeParams &volume_params = object->getVolume()->getParams(); | ||
580 | |||
581 | // Volume type | ||
582 | U8 path = volume_params.getPathParams().getCurveType(); | ||
583 | U8 profile_and_hole = volume_params.getProfileParams().getCurveType(); | ||
584 | U8 profile = profile_and_hole & LL_PCODE_PROFILE_MASK; | ||
585 | U8 hole = profile_and_hole & LL_PCODE_HOLE_MASK; | ||
586 | |||
587 | // Scale goes first so we can differentiate between a sphere and a torus, | ||
588 | // which have the same profile and path types. | ||
589 | |||
590 | // Scale | ||
591 | scale_x = volume_params.getRatioX(); | ||
592 | scale_y = volume_params.getRatioY(); | ||
593 | |||
594 | BOOL linear_path = (path == LL_PCODE_PATH_LINE) || (path == LL_PCODE_PATH_FLEXIBLE); | ||
595 | if ( linear_path && profile == LL_PCODE_PROFILE_CIRCLE ) | ||
596 | { | ||
597 | selected_item = "cylinder"; | ||
598 | } | ||
599 | else if ( linear_path && profile == LL_PCODE_PROFILE_SQUARE ) | ||
600 | { | ||
601 | selected_item = "box"; | ||
602 | } | ||
603 | else if ( linear_path && profile == LL_PCODE_PROFILE_ISOTRI ) | ||
604 | { | ||
605 | selected_item = "prism"; | ||
606 | } | ||
607 | else if ( linear_path && profile == LL_PCODE_PROFILE_EQUALTRI ) | ||
608 | { | ||
609 | selected_item = "prism"; | ||
610 | } | ||
611 | else if ( linear_path && profile == LL_PCODE_PROFILE_RIGHTTRI ) | ||
612 | { | ||
613 | selected_item = "prism"; | ||
614 | } | ||
615 | else if (path == LL_PCODE_PATH_FLEXIBLE) // shouldn't happen | ||
616 | { | ||
617 | selected_item = "cylinder"; // reasonable default | ||
618 | } | ||
619 | else if ( path == LL_PCODE_PATH_CIRCLE && profile == LL_PCODE_PROFILE_CIRCLE && scale_y > 0.75f) | ||
620 | { | ||
621 | selected_item = "sphere"; | ||
622 | } | ||
623 | else if ( path == LL_PCODE_PATH_CIRCLE && profile == LL_PCODE_PROFILE_CIRCLE && scale_y <= 0.75f) | ||
624 | { | ||
625 | selected_item = "torus"; | ||
626 | } | ||
627 | else if ( path == LL_PCODE_PATH_CIRCLE && profile == LL_PCODE_PROFILE_CIRCLE_HALF) | ||
628 | { | ||
629 | selected_item = "sphere"; | ||
630 | } | ||
631 | else if ( path == LL_PCODE_PATH_CIRCLE2 && profile == LL_PCODE_PROFILE_CIRCLE ) | ||
632 | { | ||
633 | // Spirals aren't supported. Make it into a sphere. JC | ||
634 | selected_item = "sphere"; | ||
635 | } | ||
636 | else if ( path == LL_PCODE_PATH_CIRCLE && profile == LL_PCODE_PROFILE_EQUALTRI ) | ||
637 | { | ||
638 | selected_item = "ring"; | ||
639 | } | ||
640 | else if ( path == LL_PCODE_PATH_CIRCLE && profile == LL_PCODE_PROFILE_SQUARE && scale_y <= 0.75f) | ||
641 | { | ||
642 | selected_item = "tube"; | ||
643 | } | ||
644 | else | ||
645 | { | ||
646 | llinfos << "Unknown path " << (S32) path << " profile " << (S32) profile << " in getState" << llendl; | ||
647 | selected_item = "box"; | ||
448 | } | 648 | } |
449 | 649 | ||
450 | case EXPORT_DONE: { | 650 | if (object->getParameterEntryInUse(LLNetworkData::PARAMS_SCULPT)) |
451 | llinfos << "Backup complete" << llendl; | 651 | { |
452 | gIdleCallbacks.deleteFunction(exportworker); | 652 | selected_item = "sculpt"; |
453 | primbackup::getInstance()->close(); | 653 | } |
454 | break; | 654 | |
655 | // Create an LLSD object that represents this prim. It will be injected in to the overall LLSD | ||
656 | // tree structure | ||
657 | LLXMLNode *prim_xml = new LLXMLNode(selected_item.c_str(), FALSE); | ||
658 | |||
659 | if (!object->isRoot()) | ||
660 | { | ||
661 | |||
662 | // Parent id | ||
663 | snprintf(localid, sizeof(localid), "%u", object->getSubParent()->getLocalID()); | ||
664 | prim_xml->createChild("uuid", FALSE)->setValue(localid); | ||
665 | } | ||
666 | |||
667 | |||
668 | LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->findNode(object); | ||
669 | if (node) | ||
670 | { | ||
671 | prim_xml->createChild("name", FALSE)->setValue("<![CDATA[" + node->mName + "]]>"); | ||
672 | prim_xml->createChild("description", FALSE)->setValue("<![CDATA[" + node->mDescription + "]]>"); | ||
673 | } | ||
674 | |||
675 | // Transforms | ||
676 | LLXMLNodePtr position_xml = prim_xml->createChild("position", FALSE); | ||
677 | LLVector3 position; | ||
678 | position.setVec(object->getPositionRegion()); | ||
679 | position_xml->createChild("x", TRUE)->setValue(llformat("%.5f", position.mV[VX])); | ||
680 | position_xml->createChild("y", TRUE)->setValue(llformat("%.5f", position.mV[VY])); | ||
681 | position_xml->createChild("z", TRUE)->setValue(llformat("%.5f", position.mV[VZ])); | ||
682 | |||
683 | LLXMLNodePtr scale_xml = prim_xml->createChild("size", FALSE); | ||
684 | LLVector3 scale = object->getScale(); | ||
685 | scale_xml->createChild("x", TRUE)->setValue(llformat("%.5f", scale.mV[VX])); | ||
686 | scale_xml->createChild("y", TRUE)->setValue(llformat("%.5f", scale.mV[VY])); | ||
687 | scale_xml->createChild("z", TRUE)->setValue(llformat("%.5f", scale.mV[VZ])); | ||
688 | |||
689 | LLXMLNodePtr rotation_xml = prim_xml->createChild("rotation", FALSE); | ||
690 | LLQuaternion rotation = object->getRotationEdit(); | ||
691 | rotation_xml->createChild("x", TRUE)->setValue(llformat("%.5f", rotation.mQ[VX])); | ||
692 | rotation_xml->createChild("y", TRUE)->setValue(llformat("%.5f", rotation.mQ[VY])); | ||
693 | rotation_xml->createChild("z", TRUE)->setValue(llformat("%.5f", rotation.mQ[VZ])); | ||
694 | rotation_xml->createChild("w", TRUE)->setValue(llformat("%.5f", rotation.mQ[VW])); | ||
695 | |||
696 | // Flags | ||
697 | if(object->flagPhantom()) | ||
698 | { | ||
699 | LLXMLNodePtr shadow_xml = prim_xml->createChild("phantom", FALSE); | ||
700 | shadow_xml->createChild("val", TRUE)->setValue("true"); | ||
701 | } | ||
702 | |||
703 | if(object->mFlags & FLAGS_USE_PHYSICS) | ||
704 | { | ||
705 | LLXMLNodePtr shadow_xml = prim_xml->createChild("physical", FALSE); | ||
706 | shadow_xml->createChild("val", TRUE)->setValue("true"); | ||
707 | } | ||
708 | |||
709 | // Grab S path | ||
710 | F32 begin_s = volume_params.getBeginS(); | ||
711 | F32 end_s = volume_params.getEndS(); | ||
712 | |||
713 | // Compute cut and advanced cut from S and T | ||
714 | F32 begin_t = volume_params.getBeginT(); | ||
715 | F32 end_t = volume_params.getEndT(); | ||
716 | |||
717 | // Hollowness | ||
718 | F32 hollow = volume_params.getHollow(); | ||
719 | |||
720 | // Twist | ||
721 | F32 twist = volume_params.getTwist() * 180.0; | ||
722 | F32 twist_begin = volume_params.getTwistBegin() * 180.0; | ||
723 | |||
724 | // Cut interpretation varies based on base object type | ||
725 | F32 cut_begin, cut_end, adv_cut_begin, adv_cut_end; | ||
726 | |||
727 | if ( selected_item == "sphere" || selected_item == "torus" || | ||
728 | selected_item == "tube" || selected_item == "ring" ) | ||
729 | { | ||
730 | cut_begin = begin_t; | ||
731 | cut_end = end_t; | ||
732 | adv_cut_begin = begin_s; | ||
733 | adv_cut_end = end_s; | ||
455 | } | 734 | } |
735 | else | ||
736 | { | ||
737 | cut_begin = begin_s; | ||
738 | cut_end = end_s; | ||
739 | adv_cut_begin = begin_t; | ||
740 | adv_cut_end = end_t; | ||
741 | } | ||
742 | |||
743 | if (selected_item != "sphere") | ||
744 | { | ||
745 | // Shear | ||
746 | //<top_shear x="0" y="0" /> | ||
747 | F32 shear_x = volume_params.getShearX(); | ||
748 | F32 shear_y = volume_params.getShearY(); | ||
749 | LLXMLNodePtr shear_xml = prim_xml->createChild("top_shear", FALSE); | ||
750 | shear_xml->createChild("x", TRUE)->setValue(llformat("%.5f", shear_x)); | ||
751 | shear_xml->createChild("y", TRUE)->setValue(llformat("%.5f", shear_y)); | ||
752 | |||
753 | |||
754 | } | ||
755 | |||
756 | if (selected_item == "box" || selected_item == "cylinder" || selected_item == "prism") | ||
757 | { | ||
758 | // Taper | ||
759 | //<taper x="0" y="0" /> | ||
760 | F32 taper_x = 1.f - volume_params.getRatioX(); | ||
761 | F32 taper_y = 1.f - volume_params.getRatioY(); | ||
762 | LLXMLNodePtr taper_xml = prim_xml->createChild("taper", FALSE); | ||
763 | taper_xml->createChild("x", TRUE)->setValue(llformat("%.5f", taper_x)); | ||
764 | taper_xml->createChild("y", TRUE)->setValue(llformat("%.5f", taper_y)); | ||
765 | } | ||
766 | else if (selected_item == "torus" || selected_item == "tube" || selected_item == "ring") | ||
767 | { | ||
768 | // Taper | ||
769 | //<taper x="0" y="0" /> | ||
770 | F32 taper_x = volume_params.getTaperX(); | ||
771 | F32 taper_y = volume_params.getTaperY(); | ||
772 | LLXMLNodePtr taper_xml = prim_xml->createChild("taper", FALSE); | ||
773 | taper_xml->createChild("x", TRUE)->setValue(llformat("%.5f", taper_x)); | ||
774 | taper_xml->createChild("y", TRUE)->setValue(llformat("%.5f", taper_y)); | ||
775 | |||
776 | |||
777 | //Hole Size | ||
778 | //<hole_size x="0.2" y="0.35" /> | ||
779 | F32 hole_size_x = volume_params.getRatioX(); | ||
780 | F32 hole_size_y = volume_params.getRatioY(); | ||
781 | LLXMLNodePtr hole_size_xml = prim_xml->createChild("hole_size", FALSE); | ||
782 | hole_size_xml->createChild("x", TRUE)->setValue(llformat("%.5f", hole_size_x)); | ||
783 | hole_size_xml->createChild("y", TRUE)->setValue(llformat("%.5f", hole_size_y)); | ||
784 | |||
785 | |||
786 | //Advanced cut | ||
787 | //<profile_cut begin="0" end="1" /> | ||
788 | LLXMLNodePtr profile_cut_xml = prim_xml->createChild("profile_cut", FALSE); | ||
789 | profile_cut_xml->createChild("begin", TRUE)->setValue(llformat("%.5f", adv_cut_begin)); | ||
790 | profile_cut_xml->createChild("end", TRUE)->setValue(llformat("%.5f", adv_cut_end)); | ||
791 | |||
792 | |||
793 | } | ||
794 | |||
795 | //<path_cut begin="0" end="1" /> | ||
796 | LLXMLNodePtr path_cut_xml = prim_xml->createChild("path_cut", FALSE); | ||
797 | path_cut_xml->createChild("begin", TRUE)->setValue(llformat("%.5f", cut_begin)); | ||
798 | path_cut_xml->createChild("end", TRUE)->setValue(llformat("%.5f", cut_end)); | ||
799 | |||
800 | //<twist begin="0" end="0" /> | ||
801 | LLXMLNodePtr twist_xml = prim_xml->createChild("twist", FALSE); | ||
802 | twist_xml->createChild("begin", TRUE)->setValue(llformat("%.5f", twist_begin)); | ||
803 | twist_xml->createChild("end", TRUE)->setValue(llformat("%.5f", twist)); | ||
804 | |||
805 | |||
806 | // All hollow objects allow a shape to be selected. | ||
807 | if (hollow > 0.f) | ||
808 | { | ||
809 | const char *selected_hole = "1"; | ||
810 | |||
811 | switch (hole) | ||
812 | { | ||
813 | case LL_PCODE_HOLE_CIRCLE: | ||
814 | selected_hole = "3"; | ||
815 | break; | ||
816 | case LL_PCODE_HOLE_SQUARE: | ||
817 | selected_hole = "2"; | ||
818 | break; | ||
819 | case LL_PCODE_HOLE_TRIANGLE: | ||
820 | selected_hole = "4"; | ||
821 | break; | ||
822 | case LL_PCODE_HOLE_SAME: | ||
823 | default: | ||
824 | selected_hole = "1"; | ||
825 | break; | ||
826 | } | ||
827 | |||
828 | //<hollow amount="0" shape="1" /> | ||
829 | LLXMLNodePtr hollow_xml = prim_xml->createChild("hollow", FALSE); | ||
830 | hollow_xml->createChild("amount", TRUE)->setValue(llformat("%.5f", hollow * 100.0)); | ||
831 | hollow_xml->createChild("shape", TRUE)->setValue(llformat("%s", selected_hole)); | ||
832 | } | ||
833 | |||
834 | // Extra params // b6fab961-af18-77f8-cf08-f021377a7244 | ||
835 | |||
836 | // Flexible | ||
837 | if (object->isFlexible()) | ||
838 | { //FIXME | ||
839 | LLFlexibleObjectData* flex = (LLFlexibleObjectData*)object->getParameterEntry(LLNetworkData::PARAMS_FLEXIBLE); | ||
840 | prim_xml->createChild("flexible", FALSE)->setValue(flex->asLLSD()); | ||
841 | } | ||
842 | |||
843 | // Light | ||
844 | if (object->getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT)) | ||
845 | { | ||
846 | LLLightParams* light = (LLLightParams*)object->getParameterEntry(LLNetworkData::PARAMS_LIGHT); | ||
847 | |||
848 | //<light> | ||
849 | LLXMLNodePtr light_xml = prim_xml->createChild("light", FALSE); | ||
850 | |||
851 | //<color r="255" g="255" b="255" /> | ||
852 | LLXMLNodePtr color_xml = light_xml->createChild("color", FALSE); | ||
853 | LLColor4 color = light->getColor(); | ||
854 | color_xml->createChild("r", TRUE)->setValue(llformat("%u", color.mV[VRED])); | ||
855 | color_xml->createChild("g", TRUE)->setValue(llformat("%u", color.mV[VGREEN])); | ||
856 | color_xml->createChild("b", TRUE)->setValue(llformat("%u", color.mV[VBLUE])); | ||
857 | |||
858 | //<intensity val="1.0" /> | ||
859 | LLXMLNodePtr intensity_xml = light_xml->createChild("intensity", FALSE); | ||
860 | intensity_xml->createChild("val", TRUE)->setValue(llformat("%.5f", color.mV[VALPHA])); | ||
861 | |||
862 | //<radius val="10.0" /> | ||
863 | LLXMLNodePtr radius_xml = light_xml->createChild("radius", FALSE); | ||
864 | radius_xml->createChild("val", TRUE)->setValue(llformat("%.5f", light->getRadius())); | ||
865 | |||
866 | //<falloff val="0.75" /> | ||
867 | LLXMLNodePtr falloff_xml = light_xml->createChild("falloff", FALSE); | ||
868 | falloff_xml->createChild("val", TRUE)->setValue(llformat("%.5f", light->getFalloff())); | ||
869 | |||
870 | //return light->getCutoff(); wtf is this? | ||
871 | } | ||
872 | |||
873 | // Sculpt | ||
874 | if (object->getParameterEntryInUse(LLNetworkData::PARAMS_SCULPT)) | ||
875 | { | ||
876 | LLSculptParams* sculpt = (LLSculptParams*)object->getParameterEntry(LLNetworkData::PARAMS_SCULPT); | ||
877 | |||
878 | //<topology val="4" /> | ||
879 | LLXMLNodePtr topology_xml = prim_xml->createChild("topology", FALSE); | ||
880 | topology_xml->createChild("val", TRUE)->setValue(llformat("%u", sculpt->getSculptType())); | ||
881 | |||
882 | //<sculptmap_uuid>1e366544-c287-4fff-ba3e-5fafdba10272</sculptmap_uuid> | ||
883 | //<sculptmap_file>apple_map.tga</sculptmap_file> | ||
884 | //FIXME png/tga/j2c selection itt. | ||
885 | prim_xml->createChild("sculptmap_file", FALSE)->setValue(llformat("%s", "testing")); | ||
886 | prim_xml->createChild("sculptmap_uuid", FALSE)->setValue(llformat("%s", "testing")); | ||
887 | |||
888 | //prim_xml->createChild("sculptmap_file", FALSE)->setValue(llformat("%s", sculpt->getSculptTexture())); | ||
889 | //prim_xml->createChild("sculptmap_uuid", FALSE)->setValue(llformat("%s", sculpt->getSculptTexture())); | ||
890 | |||
891 | LLUUID sculpt_texture=sculpt->getSculptTexture(); | ||
892 | bool alreadyseen=false; | ||
893 | std::list<LLUUID>::iterator iter; | ||
894 | for(iter = textures.begin(); iter != textures.end() ; iter++) | ||
895 | { | ||
896 | if( (*iter)==sculpt_texture) | ||
897 | alreadyseen=true; | ||
898 | } | ||
899 | if(alreadyseen==false) | ||
900 | { | ||
901 | llinfos << "Found a sculpt texture, adding to list "<<sculpt_texture<<llendl; | ||
902 | textures.push_back(sculpt_texture); | ||
903 | } | ||
904 | } | ||
905 | |||
906 | //<texture> | ||
907 | LLXMLNodePtr texture_xml = prim_xml->createChild("texture", FALSE); | ||
908 | |||
909 | // Textures | ||
910 | LLSD te_llsd; | ||
911 | U8 te_count = object->getNumTEs(); | ||
912 | for (U8 i = 0; i < te_count; i++) | ||
913 | { | ||
914 | bool alreadyseen=false; | ||
915 | te_llsd.append(object->getTE(i)->asLLSD()); | ||
916 | std::list<LLUUID>::iterator iter; | ||
917 | for(iter = textures.begin(); iter != textures.end() ; iter++) | ||
918 | { | ||
919 | if( (*iter)==object->getTE(i)->getID()) | ||
920 | alreadyseen=true; | ||
921 | } | ||
922 | |||
923 | //<face id=0> | ||
924 | LLXMLNodePtr face_xml = texture_xml->createChild("face", FALSE); | ||
925 | //This may be a hack, but it's ok since we're not using id in this code. We set id differently because for whatever reason | ||
926 | //llxmlnode filters a few parameters including ID. -Patrick Sapinski (Friday, September 25, 2009) | ||
927 | face_xml->mID = llformat("%d", i); | ||
928 | |||
929 | //<tile u="-1" v="1" /> | ||
930 | //object->getTE(face)->mScaleS | ||
931 | //object->getTE(face)->mScaleT | ||
932 | LLXMLNodePtr tile_xml = face_xml->createChild("tile", FALSE); | ||
933 | tile_xml->createChild("u", TRUE)->setValue(llformat("%.5f", object->getTE(i)->mScaleS)); | ||
934 | tile_xml->createChild("v", TRUE)->setValue(llformat("%.5f", object->getTE(i)->mScaleT)); | ||
935 | |||
936 | //<offset u="0" v="0" /> | ||
937 | //object->getTE(face)->mOffsetS | ||
938 | //object->getTE(face)->mOffsetT | ||
939 | LLXMLNodePtr offset_xml = face_xml->createChild("offset", FALSE); | ||
940 | offset_xml->createChild("u", TRUE)->setValue(llformat("%.5f", object->getTE(i)->mOffsetS)); | ||
941 | offset_xml->createChild("v", TRUE)->setValue(llformat("%.5f", object->getTE(i)->mOffsetT)); | ||
942 | |||
943 | |||
944 | //<rotation w="0" /> | ||
945 | //object->getTE(face)->mRotation | ||
946 | LLXMLNodePtr rotation_xml = face_xml->createChild("rotation", FALSE); | ||
947 | rotation_xml->createChild("w", TRUE)->setValue(llformat("%.5f", object->getTE(i)->mRotation)); | ||
948 | |||
949 | |||
950 | //<image_file><![CDATA[76a0319a-e963-44b0-9f25-127815226d71.tga]]></image_file> | ||
951 | //<image_uuid>76a0319a-e963-44b0-9f25-127815226d71</image_uuid> | ||
952 | LLUUID texture = object->getTE(i)->getID(); | ||
953 | std::string uuid_string; | ||
954 | object->getTE(i)->getID().toString(uuid_string); | ||
955 | |||
956 | face_xml->createChild("image_file", FALSE)->setValue("<![CDATA[" + uuid_string + ".tga]]>"); | ||
957 | face_xml->createChild("image_uuid", FALSE)->setValue(uuid_string); | ||
958 | |||
959 | |||
960 | //<color r="255" g="255" b="255" /> | ||
961 | LLXMLNodePtr color_xml = face_xml->createChild("color", FALSE); | ||
962 | LLColor4 color = object->getTE(i)->getColor(); | ||
963 | color_xml->createChild("r", TRUE)->setValue(llformat("%.5f", color.mV[VRED])); | ||
964 | color_xml->createChild("g", TRUE)->setValue(llformat("%.5f", color.mV[VGREEN])); | ||
965 | color_xml->createChild("b", TRUE)->setValue(llformat("%.5f", color.mV[VBLUE])); | ||
966 | |||
967 | //<transparency val="0" /> | ||
968 | LLXMLNodePtr transparency_xml = face_xml->createChild("transparency", FALSE); | ||
969 | transparency_xml->createChild("val", TRUE)->setValue(llformat("%.5f", color.mV[VALPHA])); | ||
970 | |||
971 | //<glow val="0" /> | ||
972 | //object->getTE(face)->getGlow() | ||
973 | LLXMLNodePtr glow_xml = face_xml->createChild("glow", FALSE); | ||
974 | glow_xml->createChild("val", TRUE)->setValue(llformat("%.5f", object->getTE(i)->getGlow())); | ||
975 | |||
976 | //<fullbright val="false" /> | ||
977 | //object->getTE(face)->getFullbright() | ||
978 | if(object->getTE(i)->getFullbright()) | ||
979 | { | ||
980 | LLXMLNodePtr fullbright_xml = face_xml->createChild("fullbright", FALSE); | ||
981 | fullbright_xml->createChild("val", TRUE)->setValue("true"); | ||
982 | } | ||
983 | |||
984 | //<shine val="0" /> | ||
985 | //object->getTE(face)->getShiny() | ||
986 | if (object->getTE(i)->getShiny()) | ||
987 | { | ||
988 | LLXMLNodePtr shine_xml = face_xml->createChild("shine", FALSE); | ||
989 | shine_xml->createChild("val", TRUE)->setValue("1"); | ||
990 | } | ||
991 | |||
992 | //<bump val="0" /> | ||
993 | //object->getTE(face)->getBumpmap() | ||
994 | if (object->getTE(i)->getBumpmap()) | ||
995 | { | ||
996 | LLXMLNodePtr bumpmap_xml = face_xml->createChild("bumpmap", FALSE); | ||
997 | bumpmap_xml->createChild("val", TRUE)->setValue("1"); | ||
998 | } | ||
999 | |||
1000 | //<mapping val="0" /> | ||
1001 | |||
1002 | if(alreadyseen==false) | ||
1003 | textures.push_back(object->getTE(i)->getID()); | ||
1004 | } | ||
1005 | |||
1006 | // The keys in the primitive maps do not have to be localids, they can be any | ||
1007 | // string. We simply use localids because they are a unique identifier | ||
1008 | snprintf(localid, sizeof(localid), "%u", object->getLocalID()); | ||
1009 | //put prim_xml inside of xml? -Patrick Sapinski (Thursday, September 17, 2009) | ||
1010 | //llsd[(const char*)localid] = prim_llsd; | ||
1011 | xml->addChild(prim_xml); | ||
1012 | |||
456 | } | 1013 | } |
1014 | |||
1015 | updateexportnumbers(); | ||
1016 | |||
1017 | return xml; | ||
457 | } | 1018 | } |
458 | 1019 | ||
459 | LLSD primbackup::prims_to_llsd(LLViewerObject::child_list_t child_list) | 1020 | LLSD primbackup::prims_to_llsd(LLViewerObject::child_list_t child_list) |
@@ -560,7 +1121,7 @@ LLSD primbackup::prims_to_llsd(LLViewerObject::child_list_t child_list) | |||
560 | return llsd; | 1121 | return llsd; |
561 | } | 1122 | } |
562 | 1123 | ||
563 | 1124 | /* | |
564 | void primbackup::export_next_texture() | 1125 | void primbackup::export_next_texture() |
565 | { | 1126 | { |
566 | if(textures.empty()) | 1127 | if(textures.empty()) |
@@ -613,7 +1174,7 @@ void primbackup::export_next_texture() | |||
613 | LLAppViewer::getTextureCache()->readFromCache(id,LLWorkerThread::PRIORITY_HIGH,0,999999,responder); | 1174 | LLAppViewer::getTextureCache()->readFromCache(id,LLWorkerThread::PRIORITY_HIGH,0,999999,responder); |
614 | } | 1175 | } |
615 | 1176 | ||
616 | 1177 | */ | |
617 | 1178 | ||
618 | void primbackup::import_object(bool upload) | 1179 | void primbackup::import_object(bool upload) |
619 | { | 1180 | { |
@@ -733,7 +1294,7 @@ void primbackup::rez_agent_offset(LLVector3 offset) | |||
733 | LLToolPlacer* mPlacer = new LLToolPlacer(); | 1294 | LLToolPlacer* mPlacer = new LLToolPlacer(); |
734 | mPlacer->setObjectType(LL_PCODE_CUBE); | 1295 | mPlacer->setObjectType(LL_PCODE_CUBE); |
735 | //LLVector3 pos=offset_agent(offset); | 1296 | //LLVector3 pos=offset_agent(offset); |
736 | mPlacer->placeObject((S32)(offset.mV[0]), (S32)(offset.mV[1]), 0); | 1297 | mPlacer->placeObject((S32)offset.mV[0], (S32)offset.mV[1],(S32)offset.mV[2]); |
737 | } | 1298 | } |
738 | 1299 | ||
739 | void primbackup::import_object1a() | 1300 | void primbackup::import_object1a() |
@@ -1068,7 +1629,7 @@ void primbackup::upload_next_asset() | |||
1068 | // gen a new transaction ID for this asset | 1629 | // gen a new transaction ID for this asset |
1069 | tid.generate(); | 1630 | tid.generate(); |
1070 | uuid = tid.makeAssetID(gAgent.getSecureSessionID()); | 1631 | uuid = tid.makeAssetID(gAgent.getSecureSessionID()); |
1071 | 1632 | /* | |
1072 | S32 file_size; | 1633 | S32 file_size; |
1073 | apr_file_t* fp = ll_apr_file_open(filename, LL_APR_RB, &file_size); | 1634 | apr_file_t* fp = ll_apr_file_open(filename, LL_APR_RB, &file_size); |
1074 | if (fp) | 1635 | if (fp) |
@@ -1089,7 +1650,7 @@ void primbackup::upload_next_asset() | |||
1089 | llwarns<<"Unable to access output file "<<filename<<llendl; | 1650 | llwarns<<"Unable to access output file "<<filename<<llendl; |
1090 | upload_next_asset(); | 1651 | upload_next_asset(); |
1091 | return; | 1652 | return; |
1092 | } | 1653 | }*/ |
1093 | 1654 | ||
1094 | myupload_new_resource( | 1655 | myupload_new_resource( |
1095 | tid, LLAssetType::AT_TEXTURE, struid, | 1656 | tid, LLAssetType::AT_TEXTURE, struid, |
@@ -1100,7 +1661,7 @@ void primbackup::upload_next_asset() | |||
1100 | "Uploaded texture", | 1661 | "Uploaded texture", |
1101 | NULL, | 1662 | NULL, |
1102 | NULL); | 1663 | NULL); |
1103 | 1664 | return; | |
1104 | 1665 | ||
1105 | } | 1666 | } |
1106 | 1667 | ||
diff --git a/linden/indra/newview/primbackup.h b/linden/indra/newview/primbackup.h index cbd757a..7db26ec 100644 --- a/linden/indra/newview/primbackup.h +++ b/linden/indra/newview/primbackup.h | |||
@@ -3,7 +3,7 @@ | |||
3 | 3 | ||
4 | #define LL_GRID_PERMISSIONS 1 | 4 | #define LL_GRID_PERMISSIONS 1 |
5 | 5 | ||
6 | enum export_states {EXPORT_INIT,EXPORT_STRUCTURE,EXPORT_TEXTURES,EXPORT_LLSD,EXPORT_DONE}; | 6 | //enum export_states {EXPORT_INIT,EXPORT_STRUCTURE,EXPORT_TEXTURES,EXPORT_LLSD,EXPORT_DONE}; |
7 | 7 | ||
8 | class primbackup : public LLFloater | 8 | class primbackup : public LLFloater |
9 | 9 | ||
@@ -13,7 +13,7 @@ class primbackup : public LLFloater | |||
13 | enum export_states export_state; | 13 | enum export_states export_state; |
14 | 14 | ||
15 | //Export idle callback | 15 | //Export idle callback |
16 | static void exportworker(void *userdata); | 16 | //static void exportworker(void *userdata); |
17 | 17 | ||
18 | //Static accessor | 18 | //Static accessor |
19 | static primbackup* getInstance(); | 19 | static primbackup* getInstance(); |
@@ -79,6 +79,8 @@ private: | |||
79 | void updateimportnumbers(); | 79 | void updateimportnumbers(); |
80 | void updateexportnumbers(); | 80 | void updateexportnumbers(); |
81 | 81 | ||
82 | //Convert a selection list of objects to HPA | ||
83 | LLXMLNode *prims_to_xml(LLViewerObject::child_list_t child_list); | ||
82 | //Convert a selection list of objects to LLSD | 84 | //Convert a selection list of objects to LLSD |
83 | LLSD prims_to_llsd(LLViewerObject::child_list_t child_list); | 85 | LLSD prims_to_llsd(LLViewerObject::child_list_t child_list); |
84 | 86 | ||
@@ -117,6 +119,8 @@ private: | |||
117 | LLSD this_group; | 119 | LLSD this_group; |
118 | LLUUID expecting_update; | 120 | LLUUID expecting_update; |
119 | 121 | ||
122 | LLXMLNodePtr xml; | ||
123 | |||
120 | //working llsd itterators for objects and linksets | 124 | //working llsd itterators for objects and linksets |
121 | LLSD::map_const_iterator prim_import_iter; | 125 | LLSD::map_const_iterator prim_import_iter; |
122 | LLSD::array_const_iterator group_prim_import_iter; | 126 | LLSD::array_const_iterator group_prim_import_iter; |
@@ -131,4 +135,3 @@ private: | |||
131 | LLQuaternion agent_rot; | 135 | LLQuaternion agent_rot; |
132 | 136 | ||
133 | }; | 137 | }; |
134 | |||