void
ContourOpAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

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

    DataNode *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(ContourMethod(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            ContourMethod value;
            if(ContourMethod_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(ContourScaling(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            ContourScaling value;
            if(ContourScaling_FromString(node->AsString(), value))
                SetScaling(value);
        }
    }
    if((node = searchNode->GetNode("variable")) != 0)
        SetVariable(node->AsString());
}
void transform(int i, float rot_offset, float rot_speed, float size,
    float height, float radius, int wobble) {
    float angle = (glutGet(GLUT_ELAPSED_TIME) / 1000.0) * (180/M_PI);
    float RotationMatrixAnim[16];
    float ScaleMatrix[16];
    float InitialTransform[16];
    float scale = 0.001;
    float maxHeight = height + 0.5;
    float minHeight = height - 0.5;
    static int up[OBJECTS];
    static int time[OBJECTS];

    if(wobble == 1) {
        if(up[i] == 0)  height = maxHeight - (time[i]++) * scale;
        else            height = minHeight + (time[i]++) * scale;
        if(time[i] >= 1000) {
            up[i] = (up[i] == 0) ? 1 : 0;
            time[i] = 0;
        }
    }

    SetScaling(size, size, size, ScaleMatrix);

    SetRotationY(rot_speed*angle + rot_offset, RotationMatrixAnim);
    SetTranslation(radius, height, 0, InitialTransform);
    
    MultiplyMatrix(InitialTransform, ScaleMatrix, ModelMatrix[i]);
    MultiplyMatrix(RotationMatrixAnim, ModelMatrix[i], ModelMatrix[i]);
}
Example #3
0
// Cut a single draw set
int LicutSVG::CutDrawSet( LicutIO& lio, int set, int x, int y, int width, int height )
{
	if (set < 0 || set >= m_drawSetCount) return -1;
	SetScaling( x, y, width, height );
	int oldVerbose = lio.GetVerbose();
	lio.SetVerbose( m_verbose );
	int n;
	int send_res, reply_res;
	unsigned int lastX, lastY, curX, curY, ctl1X, ctl1Y, ctl2X, ctl2Y;
	lastX = x;
	lastY = y;
	lio.Drain( m_intercommand * 6, m_verbose );
	for (n = 0; m_drawSets[set][n].type != 0; n++)
	{
		switch (m_drawSets[set][n].type)
		{
			case 'M':	// Move
				ScalePoint( m_drawSets[set][n].pt[0], lastX, lastY );
				send_res = lio.SendCmd_MoveCut( 2, lastX, lastY );
				reply_res = lio.ReadCmdReply( m_verbose );
				lio.Drain( m_verbose, m_intercommand );
				break;
			case 'L':	// Straight line from previous point
				ScalePoint( m_drawSets[set][n].pt[0], lastX, lastY );
				send_res = lio.SendCmd_MoveCut( 0, lastX, lastY );
				reply_res = lio.ReadCmdReply( m_verbose );
				lio.Drain( m_verbose, m_intercommand );
				break;
			case 'C':	// Bezier curve from previous point
				ScalePoint( m_drawSets[set][n].pt[0], ctl1X, ctl1Y );
				ScalePoint( m_drawSets[set][n].pt[1], ctl2X, ctl2Y );
				ScalePoint( m_drawSets[set][n].pt[2], curX, curY );
				// Bezier curve data are sent in sets of 4
				send_res = lio.SendCmd_MoveCut( 1, lastX, lastY );
				reply_res = lio.ReadCmdReply( m_verbose );
				lio.Drain( m_verbose, m_intercurve ); // Very short wait to drain since no physical movement required
				send_res = lio.SendCmd_MoveCut( 1, ctl1X, ctl1Y );
				reply_res = lio.ReadCmdReply( m_verbose );
				lio.Drain( m_verbose, m_intercurve ); // Very short wait to drain since no physical movement required
				send_res = lio.SendCmd_MoveCut( 1, ctl2X, ctl2Y );
				reply_res = lio.ReadCmdReply( m_verbose );
				lio.Drain( m_verbose, m_intercurve ); // Very short wait to drain since no physical movement required
				send_res = lio.SendCmd_MoveCut( 1, curX, curY );
				reply_res = lio.ReadCmdReply( m_verbose );
				lio.Drain( m_verbose, m_intercommand );
				lastX = curX;
				lastY = curY;
				break;
			default:
				printf( "%s(..., %d...) warning: unhandled cut type %c at index %d\n",
					__FUNCTION__, set, m_drawSets[set][n].type, n );
				break;
		}
	}
	lio.SetVerbose( oldVerbose );
	// Return number of sets executed
	return n;
}
Example #4
0
static void	OnCommand(HWND	hWnd,WPARAM wParam,LPARAM lParam)
{
	switch(wParam & 0xFFFF)
	{
	case IDM_AUTOSTRECH:
		SendMessage(hWnd,WM_SETFLAG,0,GetWindowLong(hWnd,0) ^ SHP_ZOOMAUTOSTRECH);
		break;
	case IDM_ZOOM_B:
		SetScaling(hWnd,GetScaling(hWnd)*2);
		if(GetScaling(hWnd)>20)
			SetScaling(hWnd,20);
		break;
	case IDM_ZOOM_S:
		SetScaling(hWnd,GetScaling(hWnd)/2);
		if(GetScaling(hWnd)< 0.1f)
			SetScaling(hWnd,0.1f);
		break;
	case IDM_ZOOM_ORIG:
		SetScaling(hWnd,1);
		break;
	}
	InvalidateRect(hWnd,0,0);
}
Example #5
0
  GXBOOL ScalingAxis::Update( const GVSCENEUPDATE& sContext )
  {
    if( ! IsVisible() || m_bTracking) {
      return TRUE;
    }

    float3 vLen = sContext.pCamera->GetPos() - GetPosition();
    const float3& vScaling = GetTransform().scaling;
    float fLength = vLen.length() * 0.15f;
    if(vScaling.x != fLength || vScaling.y != fLength || vScaling.z != fLength)
    {
      SetScaling(fLength);
    }
    return TRUE;
  }
Example #6
0
void
AxisLabels::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

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

    DataNode *node;
    if((node = searchNode->GetNode("visible")) != 0)
        SetVisible(node->AsBool());
    if((node = searchNode->GetNode("font")) != 0)
        font.SetFromNode(node);
    if((node = searchNode->GetNode("scaling")) != 0)
        SetScaling(node->AsInt());
}
Example #7
0
void GSRendererHW::VSync(int field)
{
	//Check if the frame buffer width or display width has changed
	SetScaling();

	if(m_reset)
	{
		m_tc->RemoveAll();

		m_reset = false;
	}

	GSRenderer::VSync(field);

	m_tc->IncAge();

	m_tc->PrintMemoryUsage();
	m_dev->PrintMemoryUsage();

	m_skip = 0;
}
bool
avtPseudocolorPlot::SetColorTable(const char *ctName)
{
    bool oldColorTableIsFullyOpaque = colorTableIsFullyOpaque;

    colorTableIsFullyOpaque =
        avtColorTables::Instance()->ColorTableIsFullyOpaque(ctName);
    
    bool namesMatch = (atts.GetColorTableName() == std::string(ctName));
    bool useOpacities = SetOpacityFromAtts();

    double rampOpacity;

    if( atts.GetOpacityType() == PseudocolorAttributes::Ramp )
    {
      useOpacities = false;
      rampOpacity = atts.GetOpacity();
    }
    else
      rampOpacity = -1;

    bool retval = (namesMatch &&
                   (oldColorTableIsFullyOpaque != colorTableIsFullyOpaque));

    if (atts.GetColorTableName() == "Default")
        retval |= avtLUT->SetColorTable(NULL, namesMatch,
                                        useOpacities, 
                                        atts.GetInvertColorTable(),
                                        rampOpacity );
    else
        retval |= avtLUT->SetColorTable(ctName, namesMatch,
                                        useOpacities, 
                                        atts.GetInvertColorTable(),
                                        rampOpacity ); 

    SetScaling(atts.GetScaling(), atts.GetSkewFactor());

    return retval;
}
BulletModel::BulletModel(glm::vec3 dir) : Lib3dsModel(), mAge(0)
{
	SetPhysicsType(Model::Dynamic);
	SetScaling(glm::vec3(0.5, 0.5, 0.5));

	mDirection = glm::normalize(dir);

	float verticalAngle = -glm::asin(mDirection.y); // approximately good
	float horizontalAngle = -((-3.14159 / 2.0) + glm::atan(mDirection.z / mDirection.x));

	// ATAN2
	if (mDirection.x < 0){
		if (mDirection.z >= 0){
			horizontalAngle -= 3.14159;
		}
		else{
			horizontalAngle += 3.14159;
		}
	}

	//std::cout << "Bullet model vAngle: " << verticalAngle << " hAngle " << horizontalAngle  << " x:  " << direction.x << " z: " << direction.z << std::endl;

	q3Quaternion rot_vert( q3Vec3(1,0,0), verticalAngle);
	q3Quaternion rot_horiz(q3Vec3(0,1,0), horizontalAngle);

	mRotation = rot_horiz * rot_vert;

	mScaling = glm::vec3(0.01, 0.01, 0.01);
	mMeshes.insert(13);
	mFileName = "../Assets/Objects/bombs.3ds";

	LoadModel();



	//mMaxAge = 90; // 90 second exipr date

}
Example #10
0
static DWORD	WINAPI	CreateViewPicWnd(void*bmp)
{
	SetThreadLocale(locale_ID);
	HWND	pic;
	MSG		msg;
	pic=CreateWindowEx(0,_T("ShowPicClass"),_T("截图查看(双击保存)"),
		WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,
		CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
		0,0,hInst,0);
	SendMessage(pic,STM_SETIMAGE,0,(LPARAM)bmp);
	SetWindowLong(pic,0,GetWindowLong(pic,0)|SHP_DELBMPONCLOSE);
	SendMessage(pic,WM_SETFLAG,0,0);
	SetScaling(pic,5.0);

	AnimateWindow(pic,500,AW_ACTIVATE|AW_VER_NEGATIVE|AW_SLIDE);
	
	while (GetMessage(&msg, NULL, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return msg.wParam;
}
void
avtPseudocolorPlot::SetAtts(const AttributeGroup *a)
{
    const PseudocolorAttributes *newAtts = (const PseudocolorAttributes *)a;

    // See if the colors will need to be updated.
    bool updateColors = (!colorsInitialized) ||
      (atts.GetColorTableName() != newAtts->GetColorTableName()) ||
      (atts.GetInvertColorTable() != newAtts->GetInvertColorTable()) ||
      (atts.GetOpacityType() != newAtts->GetOpacityType()) ||
      (atts.GetOpacityType() == PseudocolorAttributes::Ramp &&
       atts.GetOpacity() != newAtts->GetOpacity());

    // See if any attributes that require the plot to be regenerated were
    // changed and copy the state object.
    needsRecalculation = atts.ChangesRequireRecalculation(*newAtts);
    atts = *newAtts;

    // Update the plot's colors if needed.
    if(updateColors || atts.GetColorTableName() == "Default")
    {
        colorsInitialized = true;
        SetColorTable(atts.GetColorTableName().c_str());
    }
    else
      SetOpacityFromAtts();

    SetLighting(atts.GetLightingFlag());
    SetLegend(atts.GetLegendFlag());

    SetScaling(atts.GetScaling(), atts.GetSkewFactor());
    SetLimitsMode(atts.GetLimitsMode());

    glyphMapper->SetLineWidth(Int2LineWidth(atts.GetLineWidth()));
    glyphMapper->SetLineStyle(Int2LineStyle(atts.GetLineStyle()));
    glyphMapper->SetScale(atts.GetPointSize());

    // ARS - FIX ME  - FIX ME  - FIX ME  - FIX ME  - FIX ME 
    if( atts.GetOpacityType() == PseudocolorAttributes::VariableRange &&
        atts.GetOpacityVariable() != "" &&
        atts.GetOpacityVariable() != "\0")
    {   
      // glyphMapper->SetVariableOpacity(atts.GetOpacity());
      // if( atts.GetOpacityVarMinFlag() )
      //     glyphMapper->SetVariableMinOpacity(atts.GetOpacityVarMin());
      // if( atts.GetOpacityVarMaxFlag() )
      //     glyphMapper->SetVariableMaxOpacity(atts.GetOpacityVarMax());
        if (atts.GetOpacityVariable() == "default")
        { 
//            if (varname != NULL)
//                glyphMapper->ScaleOpacityByVar(varname);
        } 
        else
        { 
//            glyphMapper->ScaleOpacityByVar(atts.GetOpacityVariable());
        } 
    }
    else 
    {
//        glyphMapper->OpacityScalingOff();
    }

    // ARS - FIX ME  - FIX ME  - FIX ME  - FIX ME  - FIX ME 
    if( //(topoDim == 1 || (topoDim > 1 && atts.GetRenderWireframe())) &&
        atts.GetLineType() == PseudocolorAttributes::Tube && 
        atts.GetTubeRadiusVarEnabled() == true  &&
        atts.GetTubeRadiusVar() != "" &&
        atts.GetTubeRadiusVar() != "\0" )
    {
        if (atts.GetTubeRadiusVar() == "default")
        { 
//            if (varname != NULL)
//                glyphMapper->ScaleTubesByVar(varname);
        } 
        else
        { 
//            glyphMapper->ScaleTubesByVar(atts.GetTubeRadiusVar());
        } 
    }
    else 
    {
//        glyphMapper->TubeScalingOff();
    }

    if( //(topoDim == 0 || (topoDim > 0 && atts.GetRenderPoints())) &&
        atts.GetPointType() != PseudocolorAttributes::Point &&
        atts.GetPointType() != PseudocolorAttributes::Sphere &&
        atts.GetPointSizeVarEnabled() &&
        atts.GetPointSizeVar() != "" &&
        atts.GetPointSizeVar() != "\0" )
    {
        if (atts.GetPointSizeVar() == "default")
        { 
            if (varname != NULL)
                glyphMapper->ScaleByVar(varname);
        }
        else
        { 
            glyphMapper->ScaleByVar(atts.GetPointSizeVar());
        } 
    }
    else 
    {
        glyphMapper->DataScalingOff();
    }

    if (atts.GetPointType() == PseudocolorAttributes::Box)
        glyphMapper->SetGlyphType(avtPointGlypher::Box);
    else if (atts.GetPointType() == PseudocolorAttributes::Axis)
        glyphMapper->SetGlyphType(avtPointGlypher::Axis);
    else if (atts.GetPointType() == PseudocolorAttributes::Icosahedron)
        glyphMapper->SetGlyphType(avtPointGlypher::Icosahedron);
    else if (atts.GetPointType() == PseudocolorAttributes::Octahedron)
        glyphMapper->SetGlyphType(avtPointGlypher::Octahedron);
    else if (atts.GetPointType() == PseudocolorAttributes::Tetrahedron)
        glyphMapper->SetGlyphType(avtPointGlypher::Tetrahedron);
    else if (atts.GetPointType() == PseudocolorAttributes::SphereGeometry)
        glyphMapper->SetGlyphType(avtPointGlypher::SphereGeometry);
    else if (atts.GetPointType() == PseudocolorAttributes::Point)
        glyphMapper->SetGlyphType(avtPointGlypher::Point);
    else if (atts.GetPointType() == PseudocolorAttributes::Sphere)
        glyphMapper->SetGlyphType(avtPointGlypher::Sphere);

    SetPointGlyphSize();

    if (varname != NULL)
    {
        glyphMapper->ColorByScalarOn(std::string(varname));
    }
}
void
SurfaceFilterAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

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

    DataNode *node;
    if((node = searchNode->GetNode("limitsMode")) != 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)
                SetLimitsMode(LimitsMode(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            LimitsMode value;
            if(LimitsMode_FromString(node->AsString(), value))
                SetLimitsMode(value);
        }
    }
    if((node = searchNode->GetNode("minFlag")) != 0)
        SetMinFlag(node->AsBool());
    if((node = searchNode->GetNode("maxFlag")) != 0)
        SetMaxFlag(node->AsBool());
    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 < 3)
                SetScaling(Scaling(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Scaling value;
            if(Scaling_FromString(node->AsString(), value))
                SetScaling(value);
        }
    }
    if((node = searchNode->GetNode("skewFactor")) != 0)
        SetSkewFactor(node->AsDouble());
    if((node = searchNode->GetNode("min")) != 0)
        SetMin(node->AsDouble());
    if((node = searchNode->GetNode("max")) != 0)
        SetMax(node->AsDouble());
    if((node = searchNode->GetNode("zeroFlag")) != 0)
        SetZeroFlag(node->AsBool());
    if((node = searchNode->GetNode("variable")) != 0)
        SetVariable(node->AsString());
    if((node = searchNode->GetNode("useXYLimits")) != 0)
        SetUseXYLimits(node->AsBool());
    if((node = searchNode->GetNode("generateNodalOutput")) != 0)
        SetGenerateNodalOutput(node->AsBool());
}
Example #13
0
void
SurfaceAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

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

    DataNode *node;
    if((node = searchNode->GetNode("legendFlag")) != 0)
        SetLegendFlag(node->AsBool());
    if((node = searchNode->GetNode("lightingFlag")) != 0)
        SetLightingFlag(node->AsBool());
    if((node = searchNode->GetNode("surfaceFlag")) != 0)
        SetSurfaceFlag(node->AsBool());
    if((node = searchNode->GetNode("wireframeFlag")) != 0)
        SetWireframeFlag(node->AsBool());
    if((node = searchNode->GetNode("limitsMode")) != 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)
                SetLimitsMode(LimitsMode(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            LimitsMode value;
            if(LimitsMode_FromString(node->AsString(), value))
                SetLimitsMode(value);
        }
    }
    if((node = searchNode->GetNode("minFlag")) != 0)
        SetMinFlag(node->AsBool());
    if((node = searchNode->GetNode("maxFlag")) != 0)
        SetMaxFlag(node->AsBool());
    if((node = searchNode->GetNode("colorByZFlag")) != 0)
        SetColorByZFlag(node->AsBool());
    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 < 3)
                SetScaling(Scaling(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Scaling value;
            if(Scaling_FromString(node->AsString(), value))
                SetScaling(value);
        }
    }
    if((node = searchNode->GetNode("lineStyle")) != 0)
        SetLineStyle(node->AsInt());
    if((node = searchNode->GetNode("lineWidth")) != 0)
        SetLineWidth(node->AsInt());
    if((node = searchNode->GetNode("surfaceColor")) != 0)
        surfaceColor.SetFromNode(node);
    if((node = searchNode->GetNode("wireframeColor")) != 0)
        wireframeColor.SetFromNode(node);
    if((node = searchNode->GetNode("skewFactor")) != 0)
        SetSkewFactor(node->AsDouble());
    if((node = searchNode->GetNode("min")) != 0)
        SetMin(node->AsDouble());
    if((node = searchNode->GetNode("max")) != 0)
        SetMax(node->AsDouble());
    if((node = searchNode->GetNode("colorTableName")) != 0)
        SetColorTableName(node->AsString());
    if((node = searchNode->GetNode("invertColorTable")) != 0)
        SetInvertColorTable(node->AsBool());
}
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());
}
Example #15
0
void D3D::Render()
{
    HRESULT hr=m_pd3dDevice->TestCooperativeLevel();
    switch(hr)
    {
        case D3DERR_DEVICELOST:
            IsLost=true;
            Sleep(1);
            break;

        case D3DERR_DEVICENOTRESET:
            Reset();
            break;

        case S_OK:
            break;

        default:
            assert(false);
    }

    if(IsLost){
        return;
    }

    if(SUCCEEDED(m_pd3dDevice->BeginScene())){
        m_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,128), 1.0f, 0);

        // capture
        if(SUCCEEDED(m_movie->Update())){
            m_texture->Assign(static_cast<BYTE*>(m_movie->GetSample()),
                    m_movie->GetWidth(), m_movie->GetHeight());
            m_texture->Draw(m_pd3dDevice);

            // process OpenCV
            m_opencvImage->Assign(static_cast<BYTE*>(m_movie->GetSample()),
                    m_movie->GetWidth(), m_movie->GetHeight());
            m_opencv->Process(m_opencvImage->GetSample(),
                    m_opencvImage->GetWidth(), m_opencvImage->GetHeight());
            m_opencvTexture->Assign(m_opencvImage->GetSample(),
                    m_opencvImage->GetWidth(), m_opencvImage->GetHeight());
            m_opencvTexture->Draw(m_pd3dDevice);
        }

        if(!m_capturedTextures.empty()){
            auto texture=m_capturedTextures.back();
            texture->SetPosition(
                    static_cast<float>(m_movie->GetWidth()*2), 0);
            texture->SetScaling(1.0f);
            texture->Draw(m_pd3dDevice);
        }

        // thumbnail
        float THUMNAIL_W=150;
        float x=0;
        float y=m_d3dpp.BackBufferHeight-THUMNAIL_W;
        for(size_t i=0; i<m_capturedTextures.size(); ++i){
            if(x+THUMNAIL_W>m_d3dpp.BackBufferWidth){
                x=0;
                y-=THUMNAIL_W;
            }
            auto image=m_capturedImages[i];
            auto texture=m_capturedTextures[i];
            int w=texture->GetWidth();
            int h=texture->GetHeight();
            texture->SetPosition(x, y);
            texture->SetScaling(THUMNAIL_W/w);
            if(!texture->IsAssigend()){
                texture->Assign(image->GetSample(),
                        image->GetWidth(), image->GetHeight());
            }
            texture->Draw(m_pd3dDevice);

            x+=THUMNAIL_W+10;
        }

        // hud
        HUD::Update();
        m_hud->Assign(HUD::GetSample(),
                HUD::GetWidth(), HUD::GetHeight());
        m_hud->Draw(m_pd3dDevice);

        m_pd3dDevice->EndScene();
        m_pd3dDevice->Present(NULL, NULL, NULL, NULL);
    }
}
Example #16
0
void SceneObject::SetScaling(float scale)
{
	SetScaling(scale, scale, scale);
}