aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra
diff options
context:
space:
mode:
authorJacek Antonelli2009-11-26 20:14:35 -0600
committerJacek Antonelli2009-11-26 20:15:14 -0600
commit090099a14ee243ec11e4d6a1804e2eaa936af2a0 (patch)
tree8926301607c23c1a6f058dd765f49d94b8f703a1 /linden/indra
parentUpdated Windows libpng url (diff)
downloadmeta-impy-090099a14ee243ec11e4d6a1804e2eaa936af2a0.zip
meta-impy-090099a14ee243ec11e4d6a1804e2eaa936af2a0.tar.gz
meta-impy-090099a14ee243ec11e4d6a1804e2eaa936af2a0.tar.bz2
meta-impy-090099a14ee243ec11e4d6a1804e2eaa936af2a0.tar.xz
Reverted "Updated primbackup from latest meerkat svn (r246)"
This reverts commit 8af226efd89b2f2190555ce578d4e7f1cde99f32.
Diffstat (limited to 'linden/indra')
-rw-r--r--linden/indra/newview/primbackup.cpp659
-rw-r--r--linden/indra/newview/primbackup.h9
2 files changed, 52 insertions, 616 deletions
diff --git a/linden/indra/newview/primbackup.cpp b/linden/indra/newview/primbackup.cpp
index 8af8cd3..8dbf1df 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
159class CacheReadResponder : public LLTextureCache::ReadResponder 159class CacheReadResponder : public LLTextureCache::ReadResponder
160 { 160 {
@@ -197,32 +197,7 @@ 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
226 if(!mFormattedImage->save(primbackup::getInstance()->getfolder()+"//"+name)) 201 if(!mFormattedImage->save(primbackup::getInstance()->getfolder()+"//"+name))
227 { 202 {
228 llinfos << "FAIL saving texture "<<mID<< llendl; 203 llinfos << "FAIL saving texture "<<mID<< llendl;
@@ -248,7 +223,6 @@ class CacheReadResponder : public LLTextureCache::ReadResponder
248 223
249 224
250 225
251*/
252primbackup::primbackup() 226primbackup::primbackup()
253: LLFloater( std::string("Prim Import Floater") ) 227: LLFloater( std::string("Prim Import Floater") )
254{ 228{
@@ -359,7 +333,6 @@ void primbackup::pre_export_object()
359{ 333{
360 textures.clear(); 334 textures.clear();
361 llsd.clear(); 335 llsd.clear();
362 xml = new LLXMLNode("group", FALSE);
363 this_group.clear(); 336 this_group.clear();
364 337
365 // Open the file save dialog 338 // Open the file save dialog
@@ -373,8 +346,8 @@ void primbackup::pre_export_object()
373 file_name = file_picker.getCurFile(); 346 file_name = file_picker.getCurFile();
374 folder = gDirUtilp->getDirName(file_name); 347 folder = gDirUtilp->getDirName(file_name);
375 348
376// export_state=EXPORT_INIT; 349 export_state=EXPORT_INIT;
377 //gIdleCallbacks.addFunction(exportworker, NULL); 350 gIdleCallbacks.addFunction(exportworker, NULL);
378} 351}
379 352
380 353
@@ -389,43 +362,40 @@ bool primbackup::check_perms( LLSelectNode* node )
389} 362}
390 363
391 364
392/*
393void primbackup::exportworker(void *userdata) 365void primbackup::exportworker(void *userdata)
394{ 366{
395 primbackup::getInstance()->updateexportnumbers(); 367 primbackup::getInstance()->updateexportnumbers();
396 368
397 switch(primbackup::getInstance()->export_state) 369 switch(primbackup::getInstance()->export_state)
398 { 370 {
399 case EXPORT_INIT: 371 case EXPORT_INIT: {
372 primbackup::getInstance()->show();
373 LLSelectMgr::getInstance()->getSelection()->ref();
374
375 struct ff : public LLSelectedNodeFunctor
400 { 376 {
401 primbackup::getInstance()->show(); 377 virtual bool apply(LLSelectNode* node)
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
415 { 378 {
416 llwarns<<"Incorrect permission to export"<<llendl; 379 return primbackup::check_perms( node );
417 primbackup::getInstance()->export_state=EXPORT_DONE;
418 primbackup::getInstance()->close();
419 gIdleCallbacks.deleteFunction(exportworker);
420 LLSelectMgr::getInstance()->getSelection()->unref();
421
422 } 380 }
423 break; 381 } func;
424 }
425 382
383 if(LLSelectMgr::getInstance()->getSelection()->applyToNodes(&func,false))
384 {
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 }
426 break; 395 break;
427 case EXPORT_STRUCTURE: 396 }
428 { 397
398 case EXPORT_STRUCTURE: {
429 struct ff : public LLSelectedObjectFunctor 399 struct ff : public LLSelectedObjectFunctor
430 { 400 {
431 virtual bool apply(LLViewerObject* object) 401 virtual bool apply(LLViewerObject* object)
@@ -433,46 +403,12 @@ void primbackup::exportworker(void *userdata)
433 object->boostTexturePriority(TRUE); 403 object->boostTexturePriority(TRUE);
434 LLViewerObject::child_list_t children = object->getChildren(); 404 LLViewerObject::child_list_t children = object->getChildren();
435 children.push_front(object); //push root onto list 405 children.push_front(object); //push root onto list
436#if 0 406 LLSD prim_llsd=primbackup::getInstance()->prims_to_llsd(children);
437 LLSD prim_llsd=primbackup::getInstance()->prims_to_llsd(children);
438 LLSD stuff; 407 LLSD stuff;
439 stuff["root_position"] = object->getPosition().getValue(); 408 stuff["root_position"] = object->getPosition().getValue();
440 stuff["root_rotation"] = ll_sd_from_quaternion(object->getRotation()); 409 stuff["root_rotation"] = ll_sd_from_quaternion(object->getRotation());
441 stuff["group_body"] = prim_llsd; 410 stuff["group_body"] = prim_llsd;
442 primbackup::getInstance()->llsd["data"].append(stuff); 411 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));
476 return true; 412 return true;
477 } 413 }
478 } func; 414 } func;
@@ -483,7 +419,8 @@ void primbackup::exportworker(void *userdata)
483 419
484 break; 420 break;
485 } 421 }
486 case EXPORT_TEXTURES: 422
423 case EXPORT_TEXTURES: {
487 if(primbackup::getInstance()->m_nexttextureready==false) 424 if(primbackup::getInstance()->m_nexttextureready==false)
488 return; 425 return;
489 426
@@ -497,524 +434,26 @@ void primbackup::exportworker(void *userdata)
497 } 434 }
498 435
499 primbackup::getInstance()->export_next_texture(); 436 primbackup::getInstance()->export_next_texture();
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;
517 }
518
519 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
520
521
522 LLXMLNode *temp_xml = new LLXMLNode("project", FALSE);
523
524 temp_xml->createChild("schema", FALSE)->setValue("1.0");
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 }
552 break;
553 case EXPORT_DONE:
554 llinfos<<"Backup complete"<<llendl
555 gIdleCallbacks.deleteFunction(exportworker);
556 primbackup::getInstance()->close();
557 break; 437 break;
558 }
559}
560
561LLXMLNode *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";
648 } 438 }
649 439
650 if (object->getParameterEntryInUse(LLNetworkData::PARAMS_SCULPT)) 440 case EXPORT_LLSD: {
651 { 441 // Create a file stream and write to it
652 selected_item = "sculpt"; 442 llofstream export_file(primbackup::getInstance()->file_name);
653 } 443 LLSDSerialize::toPrettyXML(primbackup::getInstance()->llsd, export_file);
654 444 export_file.close();
655 // Create an LLSD object that represents this prim. It will be injected in to the overall LLSD 445 primbackup::getInstance()->m_nexttextureready=true;
656 // tree structure 446 primbackup::getInstance()->export_state=EXPORT_TEXTURES;
657 LLXMLNode *prim_xml = new LLXMLNode(selected_item.c_str(), FALSE); 447 break;
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;
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 } 448 }
905 449
906 //<texture> 450 case EXPORT_DONE: {
907 LLXMLNodePtr texture_xml = prim_xml->createChild("texture", FALSE); 451 llinfos << "Backup complete" << llendl;
908 452 gIdleCallbacks.deleteFunction(exportworker);
909 // Textures 453 primbackup::getInstance()->close();
910 LLSD te_llsd; 454 break;
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 } 455 }
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
1013 } 456 }
1014
1015 updateexportnumbers();
1016
1017 return xml;
1018} 457}
1019 458
1020LLSD primbackup::prims_to_llsd(LLViewerObject::child_list_t child_list) 459LLSD primbackup::prims_to_llsd(LLViewerObject::child_list_t child_list)
@@ -1121,7 +560,7 @@ LLSD primbackup::prims_to_llsd(LLViewerObject::child_list_t child_list)
1121 return llsd; 560 return llsd;
1122} 561}
1123 562
1124/* 563
1125void primbackup::export_next_texture() 564void primbackup::export_next_texture()
1126{ 565{
1127 if(textures.empty()) 566 if(textures.empty())
@@ -1174,7 +613,7 @@ void primbackup::export_next_texture()
1174 LLAppViewer::getTextureCache()->readFromCache(id,LLWorkerThread::PRIORITY_HIGH,0,999999,responder); 613 LLAppViewer::getTextureCache()->readFromCache(id,LLWorkerThread::PRIORITY_HIGH,0,999999,responder);
1175} 614}
1176 615
1177*/ 616
1178 617
1179void primbackup::import_object(bool upload) 618void primbackup::import_object(bool upload)
1180{ 619{
@@ -1294,7 +733,7 @@ void primbackup::rez_agent_offset(LLVector3 offset)
1294 LLToolPlacer* mPlacer = new LLToolPlacer(); 733 LLToolPlacer* mPlacer = new LLToolPlacer();
1295 mPlacer->setObjectType(LL_PCODE_CUBE); 734 mPlacer->setObjectType(LL_PCODE_CUBE);
1296 //LLVector3 pos=offset_agent(offset); 735 //LLVector3 pos=offset_agent(offset);
1297 mPlacer->placeObject((S32)offset.mV[0], (S32)offset.mV[1],(S32)offset.mV[2]); 736 mPlacer->placeObject((S32)(offset.mV[0]), (S32)(offset.mV[1]), 0);
1298} 737}
1299 738
1300void primbackup::import_object1a() 739void primbackup::import_object1a()
@@ -1629,7 +1068,7 @@ void primbackup::upload_next_asset()
1629 // gen a new transaction ID for this asset 1068 // gen a new transaction ID for this asset
1630 tid.generate(); 1069 tid.generate();
1631 uuid = tid.makeAssetID(gAgent.getSecureSessionID()); 1070 uuid = tid.makeAssetID(gAgent.getSecureSessionID());
1632/* 1071
1633 S32 file_size; 1072 S32 file_size;
1634 apr_file_t* fp = ll_apr_file_open(filename, LL_APR_RB, &file_size); 1073 apr_file_t* fp = ll_apr_file_open(filename, LL_APR_RB, &file_size);
1635 if (fp) 1074 if (fp)
@@ -1650,7 +1089,7 @@ void primbackup::upload_next_asset()
1650 llwarns<<"Unable to access output file "<<filename<<llendl; 1089 llwarns<<"Unable to access output file "<<filename<<llendl;
1651 upload_next_asset(); 1090 upload_next_asset();
1652 return; 1091 return;
1653 }*/ 1092 }
1654 1093
1655 myupload_new_resource( 1094 myupload_new_resource(
1656 tid, LLAssetType::AT_TEXTURE, struid, 1095 tid, LLAssetType::AT_TEXTURE, struid,
@@ -1661,7 +1100,7 @@ void primbackup::upload_next_asset()
1661 "Uploaded texture", 1100 "Uploaded texture",
1662 NULL, 1101 NULL,
1663 NULL); 1102 NULL);
1664return; 1103
1665 1104
1666} 1105}
1667 1106
diff --git a/linden/indra/newview/primbackup.h b/linden/indra/newview/primbackup.h
index 7db26ec..cbd757a 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}; 6enum export_states {EXPORT_INIT,EXPORT_STRUCTURE,EXPORT_TEXTURES,EXPORT_LLSD,EXPORT_DONE};
7 7
8class primbackup : public LLFloater 8class 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,8 +79,6 @@ 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);
84 //Convert a selection list of objects to LLSD 82 //Convert a selection list of objects to LLSD
85 LLSD prims_to_llsd(LLViewerObject::child_list_t child_list); 83 LLSD prims_to_llsd(LLViewerObject::child_list_t child_list);
86 84
@@ -119,8 +117,6 @@ private:
119 LLSD this_group; 117 LLSD this_group;
120 LLUUID expecting_update; 118 LLUUID expecting_update;
121 119
122 LLXMLNodePtr xml;
123
124 //working llsd itterators for objects and linksets 120 //working llsd itterators for objects and linksets
125 LLSD::map_const_iterator prim_import_iter; 121 LLSD::map_const_iterator prim_import_iter;
126 LLSD::array_const_iterator group_prim_import_iter; 122 LLSD::array_const_iterator group_prim_import_iter;
@@ -135,3 +131,4 @@ private:
135 LLQuaternion agent_rot; 131 LLQuaternion agent_rot;
136 132
137}; 133};
134