예제 #1
0
    // /////////////////////////////////////////////////////////////////
    //
    // /////////////////////////////////////////////////////////////////
    bool SetColorFromLua(const LuaPlus::LuaObject &colorData, Vector4 &color)
    {
        if(!colorData.IsTable()) {
            return (false);
        }

        LuaPlus::LuaObject rData = colorData["r"];
        LuaPlus::LuaObject gData = colorData["g"];
        LuaPlus::LuaObject bData = colorData["b"];
        LuaPlus::LuaObject aData = colorData["a"];

        if(!rData.IsNumber() || !gData.IsNumber() || !bData.IsNumber() || !aData.IsNumber()) {
            return (false);
        }

        F32 r = static_cast<F32>(rData.GetNumber());
        F32 g = static_cast<F32>(gData.GetNumber());
        F32 b = static_cast<F32>(bData.GetNumber());
        F32 a = static_cast<F32>(aData.GetNumber());
        Clamp<F32>(r, 0.0f, 1.0f);
        Clamp<F32>(g, 0.0f, 1.0f);
        Clamp<F32>(b, 0.0f, 1.0f);
        Clamp<F32>(a, 0.0f, 1.0f);
        color.Set(r, g, b, a);

        return (true);
    }
예제 #2
0
 // /////////////////////////////////////////////////////////////////
 //
 // /////////////////////////////////////////////////////////////////
 void SliderControl::SetLuaSliderPosition(const LuaPlus::LuaObject &table)
 {
     if(table.IsNumber()) {
         m_sliderPos = static_cast<F32>(table.GetNumber());
         Clamp(m_sliderPos, 0.0f, 1.0f);
     }
 }
예제 #3
0
    // /////////////////////////////////////////////////////////////////
    //
    // /////////////////////////////////////////////////////////////////
    bool SetFloatFromLua(const LuaPlus::LuaObject &numberData, F32 &number)
    {
        if(!numberData.IsNumber()) {
            return (false);
        }

        number = static_cast<F32>(numberData.GetNumber());
        return (true);
    }
예제 #4
0
    // /////////////////////////////////////////////////////////////////
    //
    // /////////////////////////////////////////////////////////////////
    bool SetVector3FromLua(const LuaPlus::LuaObject &dirData, Vector3 &direction)
    {
        if(!dirData.IsTable()) {
            return (false);
        }

        LuaPlus::LuaObject xData = dirData["x"];
        LuaPlus::LuaObject yData = dirData["y"];
        LuaPlus::LuaObject zData = dirData["z"];

        if(!xData.IsNumber() || !yData.IsNumber() || !zData.IsNumber()) {
            return (false);
        }

        F32 x = static_cast<F32>(xData.GetNumber());
        F32 y = static_cast<F32>(yData.GetNumber());
        F32 z = static_cast<F32>(zData.GetNumber());
        direction.Set(x, y, z);

        return (true);
    }
예제 #5
0
    // /////////////////////////////////////////////////////////////////
    //
    // /////////////////////////////////////////////////////////////////
    bool SetPoint3FromLua(const LuaPlus::LuaObject &posData, Point3 &position)
    {
        if(!posData.IsTable()) {
            return (false);
        }

        LuaPlus::LuaObject xData = posData["x"];
        LuaPlus::LuaObject yData = posData["y"];
        LuaPlus::LuaObject zData = posData["z"];

        if(!xData.IsNumber() || !yData.IsNumber() || !zData.IsNumber()) {
            return (false);
        }

        F32 x = static_cast<F32>(xData.GetNumber());
        F32 y = static_cast<F32>(yData.GetNumber());
        F32 z = static_cast<F32>(zData.GetNumber());
        position.Set(x, y, z);

        return (true);
    }
예제 #6
0
	// /////////////////////////////////////////////////////////////////
	// 
	// /////////////////////////////////////////////////////////////////
	bool BallActorParams::VInit(LuaPlus::LuaObject srcData, TErrorMessageList &errorMessages)
	{
		if (!Pool3dActorParams::VInit(srcData, errorMessages))
		{
			return (false);
		}

		VSetType(AT_Ball);

		LuaPlus::LuaObject rObj = srcData["Radius"];
		if(rObj.IsNumber())
		{
			m_radius = static_cast<F32>(rObj.GetNumber());
		}
		LuaPlus::LuaObject slObj = srcData["Slices"];
		if(slObj.IsInteger())
		{
			m_slices = slObj.GetInteger();
		}
		LuaPlus::LuaObject stObj = srcData["Stacks"];
		if(stObj.IsInteger())
		{
			m_stacks = stObj.GetInteger();
		}
		LuaPlus::LuaObject groupObj = srcData["Group"];
		if(groupObj.IsString())
		{
			const char *groupStr = groupObj.GetString();
			if(strcmp(groupStr, "cue") == 0)
			{
				m_group = eCue;
			}
			else if(strcmp(groupStr, "stripes") == 0)
			{
				m_group = eStripes;
			}
			else if(strcmp(groupStr, "plain") == 0)
			{
				m_group = ePlain;
			}
			else if(strcmp(groupStr, "black") == 0)
			{
				m_group = eBlack;
			}
			else
			{
				m_group = eCue;
			}
		}

		return (true);
	}