Ejemplo n.º 1
0
void Version::ToString(Ogre::String& text) const
{
    Ogre::StringUtil::StrStreamType versionText;

    //Find the last non-zero component
    int lastNonzeroComponent = -1;
    for (int index = MAX_COMPONENTS - 1; index >= 0; index--)
    {
        if (this->components[index] != 0)
        {
            lastNonzeroComponent = index;
            break;
        }
    }

    //Output everything up to the last non-zero component
    if (lastNonzeroComponent >= 0)
    {
        for (int index = 0; index <= lastNonzeroComponent; index++)
        {
            versionText << this->components[index];
            if (index < lastNonzeroComponent)
                versionText << ".";
        }
    }
    else
    {
        //All components are zero
        versionText << "0";
    }

    text = versionText.str();
}
static Ogre::ShadowTechnique ParseShadowTechnique(const gkString& technique)
{
	gkString techniqueLower = technique;
	Ogre::StringUtil::toLowerCase(techniqueLower);

	if (techniqueLower == "none")
		return Ogre::SHADOWTYPE_NONE;
	else if (techniqueLower == "stencilmodulative")
		return Ogre::SHADOWTYPE_STENCIL_MODULATIVE;
	else if (techniqueLower == "stenciladditive")
		return Ogre::SHADOWTYPE_STENCIL_ADDITIVE;
	else if (techniqueLower == "texturemodulative")
		return Ogre::SHADOWTYPE_TEXTURE_MODULATIVE;
	else if (techniqueLower == "textureadditive")
		return Ogre::SHADOWTYPE_TEXTURE_ADDITIVE;
	else if (techniqueLower == "texturemodulativeintegrated")
		return Ogre::SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED;
	else if (techniqueLower == "textureadditiveintegrated")
		return Ogre::SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED;

	Ogre::StringUtil::StrStreamType errorMessage;
	errorMessage << "Invalid shadow technique specified: " << technique;

	OGRE_EXCEPT
	(
	    Ogre::Exception::ERR_INVALIDPARAMS,
	    errorMessage.str(),
	    "ParseShadowTechnique"
	);
}
Ejemplo n.º 3
0
gkString getNativeWinHandleFromWxWin(wxWindow* win)
{
	gkString handle;
	if (!win) return handle;
#ifdef WIN32
	handle = Ogre::StringConverter::toString((size_t)((HWND)win->GetHandle()));
#elif defined(__WXGTK__)
	// copied from wxOgreMVC
	// handle format: display:screen:window of types ulong:uint:ulong
	GtkWidget* widget = win->GetHandle();
	gtk_widget_realize( widget );   // Mandatory. Otherwise, a segfault happens.
	Ogre::StringUtil::StrStreamType handleStream;
	Display* display = GDK_WINDOW_XDISPLAY( widget->window );
	Window wid = GDK_WINDOW_XWINDOW( widget->window );   // Window is a typedef for XID, which is a typedef for unsigned int
	// Get the right display (DisplayString() returns ":display.screen")
	gkString displayStr = DisplayString( display );
	displayStr = displayStr.substr( 1, ( displayStr.find( ".", 0 ) - 1 ) );
	// Put all together
	handleStream << displayStr << ':' << DefaultScreen( display ) << ':' << wid;
	handle = handleStream.str();
#else
#error Not supported yet!
#endif
	return handle;
}
Ejemplo n.º 4
0
Ogre::SceneNode *VLogicModel::_createLocatorSceneNode(const Ogre::Vector3 &pos, const Ogre::Quaternion &ori)
{
    static VUINT32 count = 0;
    Ogre::StringUtil::StrStreamType str;
    str<<"Locator_"<<std::setw(5)<<std::setfill('0')<<count++<<std::ends;
    Ogre::SceneNode *locatorNode = mModelMainNode->createChildSceneNode(str.str());
    locatorNode->translate(pos);
    locatorNode->setOrientation(ori);
    return locatorNode;
}
Ejemplo n.º 5
0
    //-----------------------------------------------------------------------
    //                       g e t U n i q u e N a m e
    //-----------------------------------------------------------------------
    Ogre::String TGTexture::getUniqueName(void)
    {
        Ogre::String str;

        Ogre::StringUtil::StrStreamType strstream;
        strstream << "_tgui_ogre_" << m_texturenumber;
        str = strstream.str();

        ++m_texturenumber;

        return str;
    }
Ejemplo n.º 6
0
/*************************************************************************
	return a Ogre::string that contains a unique name.	
*************************************************************************/
Ogre::String OgreCEGUITexture::getUniqueName(void)
{
	Ogre::String str;

#ifdef CEGUI_USEOLDOGRESTRING
	str << "_cegui_ogre_" << d_texturenumber;
#else
	Ogre::StringUtil::StrStreamType strstream;
	strstream << "_cegui_ogre_" << d_texturenumber;
	str = strstream.str();
#endif

	++d_texturenumber;

	return str;
}
Ejemplo n.º 7
0
    BoxCenterMovable::BoxCenterMovable()
    : mObjectCenterPointRect(NULL)
    , mObjectCenterPointOverlay(NULL)
    {
        // Disable cast shadows by default
        mCastShadows = false;

        m_pParentSceneManager = NULL;

        mParentNode = NULL;
        m_pCamera = NULL;

        // Generate name
		Ogre::StringUtil::StrStreamType str;
		str << "BoxCenterMovable" << ms_uGenNameCount++;
		mName = str.str();
    }
Ejemplo n.º 8
0
EditorFrameHandler::EditorFrameHandler(const char *scene_config_path) : 
ScriptFrameHandler(),
ExitRequested(false),
SceneRootElement(NULL),
CollisionModels(1000),
EditorCamera(NULL),
CameraMoveDirection(Ogre::Vector3::ZERO),
CameraVelocity(30),
SelectedObject(NULL),
ObjectDescription(NULL)
{
	ConfigPath = AAUtilities::StringCopy(scene_config_path);

	TiXmlDocument *xml = new TiXmlDocument(ConfigPath);	
	    
	bool loadOkay = xml->LoadFile();
	assert(loadOkay);
    
	if (!loadOkay)
	{
		Ogre::StringUtil::StrStreamType errorMessage;
		errorMessage << "There was an error with the xml file: " << scene_config_path;

		OGRE_EXCEPT
			(
			Ogre::Exception::ERR_INVALID_STATE,
			errorMessage.str(), 
			"XMLConfigurable::Parse"
			);
		return;
	}

	SceneRootElement = xml->FirstChildElement()->Clone()->ToElement();
	delete xml;
	assert( SceneRootElement );
}
Ejemplo n.º 9
0
	BillboardSetElement::BillboardSetElement(const String &type, System *system) :
	EffectElement(type, system),
	mBillboardSet(NULL),
    mBillboardColour(Ogre::ColourValue::White),
    mScaleIntervalTime(0.1f),
    mSizeChanged(false),
	mBillboardCount(5),
	mBillboardMaterial("BaseWhiteNoLighting"),
	mBillboardInterval(10.0f),
	mBillboardWidth(100.0f),
	mBillboardHeight(100.0f),
    mAlphaValue(1.0f),
    mColourChanged(false),
    mStacks(1),
    mSlices(1),
    mTexIntervalTime(0.1f),
    mCurrentTexIntervalTime(0.0f)
	{
        for (int i=0; i<MAX_STAGES; ++i)
        {
            mBillboardScale[i] = Ogre::Vector3(1.0f, 1.0f, 1.0f);
        }

		if ( initDefaults(mElementType) )
		{
			Ogre::ParamDictionary* dict = getParamDictionary();

			// Custom params      

            dict->addParameter(Ogre::ParameterDef("BillboardColour", 
                "BillboardColour",
                Ogre::PT_COLOURVALUE), &msBillboardColourCmd);

            dict->addParameter(Ogre::ParameterDef("BillboardAlpha", 
                "Billboard Alpha Value of first point and second point.",
                Ogre::PT_REAL),&msBillboardAlphaCmd);

			dict->addParameter(Ogre::ParameterDef("BillboardCount", 
				"the life time of the vertex.",
				Ogre::PT_INT),&msBillboardCountCmd);

			dict->addParameter(Ogre::ParameterDef("Material", 
				"alpha factor of head point.",
				Ogre::PT_STRING),&msBillboardMaterialCmd);

			dict->addParameter(Ogre::ParameterDef("BillboardInterval", 
				"alpha factor of tail point.",
				Ogre::PT_REAL),&msBillboardIntervalCmd);

			dict->addParameter(Ogre::ParameterDef("BillboardHeight", 
				"alpha factor of tail point.",
				Ogre::PT_REAL),&msBillboardHeightCmd);

			dict->addParameter(Ogre::ParameterDef("BillboardWidth", 
				"alpha factor of tail point.",
				Ogre::PT_REAL),&msBillboardWidthCmd); 

            for (int i=0;i<MAX_STAGES;i++)
            {
                msBillboardScaleCmd[i].mIndex	= i;

                Ogre::StringUtil::StrStreamType stage;
                stage << i;
                String	colour_title	= String("BillboardScale") + stage.str();
                String	colour_descr	= String("Stage ") + stage.str() +
                    String(" BillboardScale of first point and second point.");

                dict->addParameter(Ogre::ParameterDef(colour_title, colour_descr,
                    Ogre::PT_VECTOR3), &msBillboardScaleCmd[i]);
            }

            dict->addParameter(Ogre::ParameterDef("ScaleIntervalTime", 
                "the interval time of changing scale.",
                Ogre::PT_REAL),&msScaleIntervalTimeCmd);   

            dict->addParameter(Ogre::ParameterDef("stacks", 
                "the stacks of texture coordinates.",
                Ogre::PT_UNSIGNED_LONG),
                &msStacksCmd);

            dict->addParameter(Ogre::ParameterDef("slices",
                "the slices of texture coordinates.",
                Ogre::PT_UNSIGNED_LONG),
                &msSlicesCmd);

            dict->addParameter(Ogre::ParameterDef("TexIntervalTime", 
                "the interval time of changing texture index.",
                Ogre::PT_REAL),&msTexIntervalTimeCmd);   

		}    
	}
Ejemplo n.º 10
0
 String ColourRGB2String(const Ogre::ColourValue& val)
 {
     Ogre::StringUtil::StrStreamType stream;
     stream << val.r << " " << val.g << " " << val.b;
     return stream.str();
 }