コード例 #1
0
SceneA::SceneA()
{
	SetWireframe(true);
	SetLight(false);
	SetTexture(false);
	s = MakeObject(SPHERE);
}
コード例 #2
0
void
SubsetAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("SubsetAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("colorType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetColorType(ColoringMethod(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            ColoringMethod value;
            if(ColoringMethod_FromString(node->AsString(), value))
                SetColorType(value);
        }
    }
    if((node = searchNode->GetNode("colorTableName")) != 0)
        SetColorTableName(node->AsString());
    if((node = searchNode->GetNode("invertColorTable")) != 0)
        SetInvertColorTable(node->AsBool());
    if((node = searchNode->GetNode("filledFlag")) != 0)
        SetFilledFlag(node->AsBool());
    if((node = searchNode->GetNode("legendFlag")) != 0)
        SetLegendFlag(node->AsBool());
    if((node = searchNode->GetNode("lineStyle")) != 0)
        SetLineStyle(node->AsInt());
    if((node = searchNode->GetNode("lineWidth")) != 0)
        SetLineWidth(node->AsInt());
    if((node = searchNode->GetNode("singleColor")) != 0)
        singleColor.SetFromNode(node);
    if((node = searchNode->GetNode("multiColor")) != 0)
        multiColor.SetFromNode(node);
    if((node = searchNode->GetNode("subsetNames")) != 0)
        SetSubsetNames(node->AsStringVector());
    if((node = searchNode->GetNode("subsetType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 6)
                SetSubsetType(Subset_Type(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Subset_Type value;
            if(Subset_Type_FromString(node->AsString(), value))
                SetSubsetType(value);
        }
    }
    if((node = searchNode->GetNode("opacity")) != 0)
        SetOpacity(node->AsDouble());
    if((node = searchNode->GetNode("wireframe")) != 0)
        SetWireframe(node->AsBool());
    if((node = searchNode->GetNode("drawInternal")) != 0)
        SetDrawInternal(node->AsBool());
    if((node = searchNode->GetNode("smoothingLevel")) != 0)
        SetSmoothingLevel(node->AsInt());
    if((node = searchNode->GetNode("pointSize")) != 0)
        SetPointSize(node->AsDouble());
    if((node = searchNode->GetNode("pointType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 8)
                SetPointType(PointType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            PointType value;
            if(PointType_FromString(node->AsString(), value))
                SetPointType(value);
        }
    }
    if((node = searchNode->GetNode("pointSizeVarEnabled")) != 0)
        SetPointSizeVarEnabled(node->AsBool());
    if((node = searchNode->GetNode("pointSizeVar")) != 0)
        SetPointSizeVar(node->AsString());
    if((node = searchNode->GetNode("pointSizePixels")) != 0)
        SetPointSizePixels(node->AsInt());
}
コード例 #3
0
void VDebugOptions::OnHandleCallback(IVisCallbackDataObject_cl* pData)
{
  if (pData->m_pSender == &Vision::Callbacks.OnUpdateSceneBegin)
  {
#if defined(WIN32)
    if (GetParent()->GetInputMap()->GetTrigger(TOGGLE_FPS))
    {
      SetFrameRateVisible(!IsFrameRateVisible());
    }
    else if (GetParent()->GetInputMap()->GetTrigger(TOGGLE_WIREFRAME))
    {
      SetWireframe(!IsWireframe());
    }
#endif

    // FPS accumulation
    {
      m_iFrameCounter++;
      m_fTimeAccumulator += Vision::GetUITimer()->GetTimeDifference();

      if (m_fTimeAccumulator >= 1.0f)
      {
        m_fCurrentFrameTime = m_fTimeAccumulator / m_iFrameCounter;
        m_fCurrentFps = m_iFrameCounter / m_fTimeAccumulator;

        m_fTimeAccumulator = 0.0f;
        m_iFrameCounter = 0;
      }
    }

    if (m_bFpsVisible)
      Vision::Message.Print(1, 10, Vision::Video.GetYRes() - 35, "FPS : %.1f\nFrame Time : %.2f", m_fCurrentFps, m_fCurrentFrameTime * 1000.0f);
  }
  else if (pData->m_pSender == &Vision::Callbacks.OnBeforeSwapBuffers)
  {
    if (m_bSaveScreenshot)
    {
      VScreenShotHelper helper;
      helper.Capture();
      if (helper.PendingDataInBuffer())
      {
        if (helper.SaveBufferToFile("", NULL, 1.0f, 1.0f))
          Vision::Message.Add(0, "Screenshot saved to \"%s\".\n", helper.GetScreenShotPath());
        else
          Vision::Message.Add(0, "Screenshot could not be saved.\n");
      }

      // Re-enable the VAppMenu again
      VAppMenu* pMainMenu = GetParent()->GetAppModule<VAppMenu>();
      if (pMainMenu)
        pMainMenu->SetVisible(true);

      m_bSaveScreenshot = false;
    }
  }
  else if (pData->m_pSender == &Vision::Callbacks.OnRenderHook)
  {
    VisRenderHookDataObject_cl *pRenderHookData = (VisRenderHookDataObject_cl *)pData;
    if (pRenderHookData->m_iEntryConst == VRH_PRE_SCREENMASKS)
    {
      // Debug drawing of all visible touch areas.
#if defined(SUPPORTS_MULTITOUCH)
      if (m_bTouchAreaDebug)
      {
        IVMultiTouchInput* pMultiTouchInput = NULL;
        pMultiTouchInput = static_cast<IVMultiTouchInput*>(&VInputManager::GetInputDevice(INPUT_DEVICE_TOUCHSCREEN));
        VPListT<VTouchArea> touchAreas = pMultiTouchInput->GetTouchAreas();

        const float fBorderWidth = 3.0f;
        VSimpleRenderState_t alphaState(VIS_TRANSP_ALPHA, RENDERSTATEFLAG_FRONTFACE|RENDERSTATEFLAG_NOWIREFRAME|RENDERSTATEFLAG_ALWAYSVISIBLE);

        IVRender2DInterface *pRI = Vision::RenderLoopHelper.BeginOverlayRendering();
        {
          for (int i=0; i<touchAreas.GetLength(); ++i)
          {
            const VRectanglef& rect = touchAreas.Get(i)->GetArea();
            const VColorRef color = touchAreas.Get(i)->GetTouchPointIndex() < 0 ? VColorRef(0, 255, 0, 64) : VColorRef(0, 255, 0, 96);
            pRI->DrawSolidQuad(rect.m_vMin, rect.m_vMax, color, alphaState);

            pRI->DrawSolidQuad(rect.m_vMin, hkvVec2(rect.m_vMax.x, rect.m_vMin.y + fBorderWidth), VColorRef(0, 255, 0, 255), alphaState);
            pRI->DrawSolidQuad(hkvVec2(rect.m_vMin.x, rect.m_vMax.y - fBorderWidth), rect.m_vMax, VColorRef(0, 255, 0, 255), alphaState);
            pRI->DrawSolidQuad(hkvVec2(rect.m_vMin.x, rect.m_vMin.y + fBorderWidth), hkvVec2(rect.m_vMin.x + fBorderWidth, rect.m_vMax.y - fBorderWidth), VColorRef(0, 255, 0, 255), alphaState);
            pRI->DrawSolidQuad(hkvVec2(rect.m_vMax.x - fBorderWidth, rect.m_vMin.y + fBorderWidth), hkvVec2(rect.m_vMax.x, rect.m_vMax.y - fBorderWidth), VColorRef(0, 255, 0, 255), alphaState);
          }
        }
        Vision::RenderLoopHelper.EndOverlayRendering();
      }
#endif
    }
  }

  int iIndex = GetCallbackIndex(pData);
  if (iIndex >= 0)
  {
    if (iIndex == OPTION_FPS)
    {
      m_bFpsVisible = !m_bFpsVisible;
    }
    else if (iIndex == OPTION_WIREFRAME)
    {
      if (Vision::Renderer.GetWireframeMode())
        Vision::Renderer.SetWireframeMode(false);
      else
        Vision::Renderer.SetWireframeMode(true);
    }
    else if (iIndex == OPTION_RELOAD_RESOURCES)
    {
      int iCount = Vision::ResourceSystem.ReloadModifiedResourceFiles(NULL, VURO_HOT_RELOAD);       

      // Clear effect caches so that material shaders will be re-created (not re-used).
      Vision::Shaders.GetShaderFXLibManager().ResetCompiledEffectCaches();

      // Reassign all material shaders.
      Vision::Shaders.ReloadAllShaderAssignmentFiles();

      Vision::Message.Add(1, "%i resources were outdated and have been reloaded.", iCount);
    }
    else if (iIndex == OPTION_TIME_STEP_GRAPH)
    {
      m_pTimeStepGraph->SetVisible(!m_pTimeStepGraph->IsVisible());
    }
#if defined(SUPPORTS_MULTITOUCH)
    else if (iIndex == OPTION_MULTITOUCH)
    {
      m_bTouchAreaDebug = !m_bTouchAreaDebug;
    }
#endif
    else if (iIndex == OPTION_SAVE_SCREENSHOT)
    {
      m_bSaveScreenshot = true;

      // We don't want the menu to be visible in the screenshot
      VAppMenu* pMainMenu = GetParent()->GetAppModule<VAppMenu>();
      if (pMainMenu != NULL)
        pMainMenu->SetVisible(false);
    }
  }

  iIndex = GetCallbackIndex(m_debugInfos, pData);
  if (iIndex >= 0)
    Vision::Profiling.ToggleDebugRenderFlags((unsigned int)iIndex);
}
コード例 #4
0
void
FilledBoundaryAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("FilledBoundaryAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("colorType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetColorType(ColoringMethod(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            ColoringMethod value;
            if(ColoringMethod_FromString(node->AsString(), value))
                SetColorType(value);
        }
    }
    if((node = searchNode->GetNode("colorTableName")) != 0)
        SetColorTableName(node->AsString());
    if((node = searchNode->GetNode("invertColorTable")) != 0)
        SetInvertColorTable(node->AsBool());
    if((node = searchNode->GetNode("filledFlag")) != 0)
        SetFilledFlag(node->AsBool());
    if((node = searchNode->GetNode("legendFlag")) != 0)
        SetLegendFlag(node->AsBool());
    if((node = searchNode->GetNode("lineStyle")) != 0)
        SetLineStyle(node->AsInt());
    if((node = searchNode->GetNode("lineWidth")) != 0)
        SetLineWidth(node->AsInt());
    if((node = searchNode->GetNode("singleColor")) != 0)
        singleColor.SetFromNode(node);
    if((node = searchNode->GetNode("multiColor")) != 0)
        multiColor.SetFromNode(node);
    if((node = searchNode->GetNode("boundaryNames")) != 0)
        SetBoundaryNames(node->AsStringVector());
    if((node = searchNode->GetNode("boundaryType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 4)
                SetBoundaryType(Boundary_Type(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Boundary_Type value;
            if(Boundary_Type_FromString(node->AsString(), value))
                SetBoundaryType(value);
        }
    }
    if((node = searchNode->GetNode("opacity")) != 0)
        SetOpacity(node->AsDouble());
    if((node = searchNode->GetNode("wireframe")) != 0)
        SetWireframe(node->AsBool());
    if((node = searchNode->GetNode("drawInternal")) != 0)
        SetDrawInternal(node->AsBool());
    if((node = searchNode->GetNode("smoothingLevel")) != 0)
        SetSmoothingLevel(node->AsInt());
    if((node = searchNode->GetNode("cleanZonesOnly")) != 0)
        SetCleanZonesOnly(node->AsBool());
    if((node = searchNode->GetNode("mixedColor")) != 0)
        mixedColor.SetFromNode(node);
    if((node = searchNode->GetNode("pointSize")) != 0)
        SetPointSize(node->AsDouble());
    if((node = searchNode->GetNode("pointType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 8)
                SetPointType(PointType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            PointType value;
            if(PointType_FromString(node->AsString(), value))
                SetPointType(value);
        }
    }
    if((node = searchNode->GetNode("pointSizeVarEnabled")) != 0)
        SetPointSizeVarEnabled(node->AsBool());
    if((node = searchNode->GetNode("pointSizeVar")) != 0)
        SetPointSizeVar(node->AsString());
    if((node = searchNode->GetNode("pointSizePixels")) != 0)
        SetPointSizePixels(node->AsInt());
    // We are no longer using MultiColor as the source for the "mixed"
    // color (in clean zones only), but someone may have saved their
    // settings with the "mixed" color in the list.  Remove it if it's
    // in there.
    //
    // NOTE: This code can be removed in a few months, as soon as
    // 1.3 is at least a few versions old, since it represents a little
    // bit of a hack.
    bool done = false;
    while (!done)
    {
        done = true;
        size_t index;
        for (index=0; index<boundaryNames.size(); index++)
        {
            if (boundaryNames[index] == "mixed")
            {
                done = false;
                break;
            }
        }
        if (!done)
        {
            multiColor.RemoveColors((int)index);
            for (size_t i=index+1; i<boundaryNames.size(); i++)
                boundaryNames[i-1] = boundaryNames[i];
            boundaryNames.resize(boundaryNames.size() - 1);
        }
    }

}
コード例 #5
0
void
ContourAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("ContourAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;

    // Set the default palette from the values in the DataNode.
    if((node = searchNode->GetNode("defaultPalette")) != 0)
        defaultPalette.SetFromNode(node);

    if((node = searchNode->GetNode("colorType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetColorType(ColoringMethod(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            ColoringMethod value;
            if(ColoringMethod_FromString(node->AsString(), value))
                SetColorType(value);
        }
    }
    if((node = searchNode->GetNode("colorTableName")) != 0)
        SetColorTableName(node->AsString());
    if((node = searchNode->GetNode("legendFlag")) != 0)
        SetLegendFlag(node->AsBool());
    if((node = searchNode->GetNode("invertColorTable")) != 0)
        SetInvertColorTable(node->AsBool());
    if((node = searchNode->GetNode("lineStyle")) != 0)
        SetLineStyle(node->AsInt());
    if((node = searchNode->GetNode("lineWidth")) != 0)
        SetLineWidth(node->AsInt());
    if((node = searchNode->GetNode("singleColor")) != 0)
        singleColor.SetFromNode(node);
    if((node = searchNode->GetNode("contourNLevels")) != 0)
        SetContourNLevels(node->AsInt());
    if((node = searchNode->GetNode("contourValue")) != 0)
        SetContourValue(node->AsDoubleVector());
    if((node = searchNode->GetNode("contourPercent")) != 0)
        SetContourPercent(node->AsDoubleVector());
    if((node = searchNode->GetNode("contourMethod")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetContourMethod(Select_by(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Select_by value;
            if(Select_by_FromString(node->AsString(), value))
                SetContourMethod(value);
        }
    }
    if((node = searchNode->GetNode("minFlag")) != 0)
        SetMinFlag(node->AsBool());
    if((node = searchNode->GetNode("maxFlag")) != 0)
        SetMaxFlag(node->AsBool());
    if((node = searchNode->GetNode("min")) != 0)
        SetMin(node->AsDouble());
    if((node = searchNode->GetNode("max")) != 0)
        SetMax(node->AsDouble());
    if((node = searchNode->GetNode("scaling")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetScaling(Scaling(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Scaling value;
            if(Scaling_FromString(node->AsString(), value))
                SetScaling(value);
        }
    }
    if((node = searchNode->GetNode("wireframe")) != 0)
        SetWireframe(node->AsBool());
}