Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r680 - branches/itanium2/Model/Groups


Chronological Thread 
  • From: hansong@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r680 - branches/itanium2/Model/Groups
  • Date: Fri, 28 Oct 2005 17:38:32 -0600 (MDT)

Author: hansong
Date: Fri Oct 28 17:38:25 2005
New Revision: 680

Modified:
   branches/itanium2/Model/Groups/KDTree.cc
   branches/itanium2/Model/Groups/KDTree.h
   branches/itanium2/Model/Groups/TransparentKDTree.cc
   branches/itanium2/Model/Groups/TransparentKDTree.h
Log:
Improves picking: add ability to (1) have multiple objects picked at the same 
time and (2) have different actions on picked objects; currently the two 
actions are: highlight or remove. The limitatio for now is that remove works 
only in transparency mode. Picking mode selection has to be added to the gui.

Modified: branches/itanium2/Model/Groups/KDTree.cc
==============================================================================
--- branches/itanium2/Model/Groups/KDTree.cc    (original)
+++ branches/itanium2/Model/Groups/KDTree.cc    Fri Oct 28 17:38:25 2005
@@ -337,6 +337,10 @@
                                                                == 
triToGroupMap->get(pickedEndIndex))
                                                        pickedEndIndex ++;
                                                cerr << "picked begin " << 
pickedBeginIndex << " end " << pickedEndIndex << "\n";
+
+                                               cerr << "picked flag: " << 
(int)pickedFlag << std::endl;
+                                               for (int i=pickedBeginIndex; 
i<=pickedEndIndex; i++)
+                                                       triFlags->set(i, 
pickedFlag);
                                        }
                                
                                
@@ -373,11 +377,21 @@
           else
             e.hitInfo.scratchpad<ScratchPadInfo>().payload = 
Color(RGB(0.0,0.0,1.0));
 #else          
-                       if (pickedTri > 0 &&
-                                pickedBeginIndex <= isectData.rayHitTriIndex 
&&
-                                isectData.rayHitTriIndex <= pickedEndIndex) {
-                               Color &c = 
tris->get(isectData.rayHitTriIndex).payload;
-                       e.hitInfo.scratchpad<ScratchPadInfo>().payload = 
Color(RGB(1,1,1))-c;
+                       unsigned char flag;
+                       if ( pickedTri > 0 &&
+                                /*pickedBeginIndex <= 
isectData.rayHitTriIndex &&
+                                isectData.rayHitTriIndex <= pickedEndIndex*/
+                               
(flag=triFlags->get(isectData.rayHitTriIndex))!=0) 
+                       {
+                               switch(flag) {
+                                       case PICK_HIGHLIGHT:
+                               
e.hitInfo.scratchpad<ScratchPadInfo>().payload = Color(RGB(1,1,1))-
+                                               
tris->get(isectData.rayHitTriIndex).payload;
+                                       break;
+                                       case PICK_REMOVE:
+                               
e.hitInfo.scratchpad<ScratchPadInfo>().payload = Color(RGB(0,0,0));
+                                       break;
+                               }
                        } else
                        e.hitInfo.scratchpad<ScratchPadInfo>().payload = 
tris->get(isectData.rayHitTriIndex).payload;
 #endif

Modified: branches/itanium2/Model/Groups/KDTree.h
==============================================================================
--- branches/itanium2/Model/Groups/KDTree.h     (original)
+++ branches/itanium2/Model/Groups/KDTree.h     Fri Oct 28 17:38:25 2005
@@ -308,16 +308,29 @@
                        mutable long long pickedTri;
                        mutable int pickedBeginIndex, pickedEndIndex;
                        VArray<Color> pickedSavedColors;
+                       VArray<unsigned char> *triFlags;
+                       unsigned char pickedFlag;
                public:
+                       enum {
+                               PICK_HIGHLIGHT = 1,
+                               PICK_REMOVE = 2,
+                       };
+
                        void enablePicking() {
                                if (__pickingEnabled)
                                        pickingEnabled = true;
                        }
                        void disablePicking() { pickingEnabled = false; }
                        bool isPickingEnabled() const { return 
pickingEnabled&&__pickingEnabled; }
-                       void resetPicking() { pickedTri = -1; }
+                       void resetPicking() { 
+                               pickedTri = -1; 
+                               triFlags->clear();
+                       }
                        void __setPicking(bool flag) { __pickingEnabled = 
flag; }
 
+                       void setPickedFlag(unsigned char flag) { pickedFlag = 
flag; }
+                       unsigned char getPickedFlag() { return pickedFlag; }
+
     protected:
       // Copy data pointers from another kdtree. (Used by derived classes.)
       KDTree( KDTree *kdtree_, Material *material_ ) :
@@ -326,6 +339,7 @@
         tris( kdtree_->tris ), normals( kdtree_->normals )
       {
         bbox.extendByBox( bbox );
+               pickedFlag = PICK_HIGHLIGHT;
       }
 
       // This method intersects a list of triangles with the ray.
@@ -353,6 +367,7 @@
                  __pickingEnabled = true;
                  pickingEnabled = false;
                  pickedTri = -1;
+                 pickedFlag = PICK_HIGHLIGHT;
          };
 
       // This structure is used to record info about the hit.

Modified: branches/itanium2/Model/Groups/TransparentKDTree.cc
==============================================================================
--- branches/itanium2/Model/Groups/TransparentKDTree.cc (original)
+++ branches/itanium2/Model/Groups/TransparentKDTree.cc Fri Oct 28 17:38:25 
2005
@@ -91,7 +91,9 @@
                        pickingEnabled(kdtree_->pickingEnabled),
                        pickedTri(kdtree_->pickedTri),
                        pickedBeginIndex(kdtree_->pickedBeginIndex), 
-                       pickedEndIndex(kdtree_->pickedEndIndex)
+                       pickedEndIndex(kdtree_->pickedEndIndex),
+                       triFlags(kdtree_->triFlags),
+                       pickedFlag(kdtree_->pickedFlag)
 {
        
        bbox.extendByBox( kdtree_->bbox );
@@ -183,11 +185,23 @@
                for (int i=0; (i<isectbuf->getLen()) && (ray_alpha < 
(Real)0.95); i++) {
                        
                        Color *triangle_color = &tris->get( array[i].triIdx 
).payload;
+                       unsigned char flag;
                        if (pickedTri > 0 &&
-                                pickedBeginIndex <= array[i].triIdx &&
-                                               array[i].triIdx <= 
pickedEndIndex) {
+                                /*pickedBeginIndex <= array[i].triIdx &&
+                                               array[i].triIdx <= 
pickedEndIndex*/
+                               (flag = triFlags->get(array[i].triIdx)) != 0 
+                       ) {
+                               switch(flag) {
+                               case KDTree::PICK_HIGHLIGHT:
                                c = Color(RGB(1,1,1)) - *triangle_color;
                                triangle_color = &c;
+                               break;
+                               case KDTree::PICK_REMOVE:
+                               c = Color(RGB(0,0,0));
+                               triangle_color = &c;
+                               sample_alpha__ = 0;
+                               break;
+                               }
                        }
 
       // Interpolate the normal.
@@ -400,6 +414,9 @@
                                                                == 
triToGroupMap->get(pickedEndIndex))
                                                        pickedEndIndex ++;
                                                cerr << "picked begin " << 
pickedBeginIndex << "end " << pickedEndIndex << "\n";
+                                               cerr << "picked flag: " << 
(int)pickedFlag << std::endl;
+                                               for (int i=pickedBeginIndex; 
i<=pickedEndIndex; i++)
+                                                       triFlags->set(i, 
pickedFlag);
                                        }
 
                                        // Process the hit.

Modified: branches/itanium2/Model/Groups/TransparentKDTree.h
==============================================================================
--- branches/itanium2/Model/Groups/TransparentKDTree.h  (original)
+++ branches/itanium2/Model/Groups/TransparentKDTree.h  Fri Oct 28 17:38:25 
2005
@@ -76,6 +76,9 @@
                        mutable long long pickedTri;
                        mutable int pickedBeginIndex, pickedEndIndex;
                        VArray<Color> pickedSavedColors;
+                       VArray<unsigned char> *triFlags;
+                       unsigned char pickedFlag;
+
                public:
                        void enablePicking() {
                                if (__pickingEnabled)
@@ -83,8 +86,14 @@
                        }
                        void disablePicking() { pickingEnabled = false; }
                        bool isPickingEnabled() const { return 
pickingEnabled&&__pickingEnabled; }
-                       void resetPicking() { pickedTri = -1; }
+                       void resetPicking() { 
+                               pickedTri = -1; 
+                               triFlags->clear();
+                       }
                        void __setPicking(bool flag) { __pickingEnabled = 
flag; }
+
+                       void setPickedFlag(unsigned char flag) { pickedFlag = 
flag; }
+                       unsigned char getPickedFlag() { return pickedFlag; }
 
                private:                
                        Real sample_alpha;




  • [MANTA] r680 - branches/itanium2/Model/Groups, hansong, 10/28/2005

Archive powered by MHonArc 2.6.16.

Top of page