示例#1
0
void DeferredLight::SetAttenuation(float c, float b, float a)
{
    float outerRadius = mParentLight->getAttenuationRange();

    // There is attenuation? Set material accordingly
    if (c != 1.0f || b != 0.0f || a != 0.0f)
    {
        ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_ATTENUATED);

        if (mParentLight->getType() == Ogre::Light::LT_POINT)
        {
            // Calculate radius from attenuation
            int thresholdLevel = 10;    // difference of 10-15 levels deemed unnoticeable
            float threshold = 1.0f / ((float)thresholdLevel / 256.0f);

            // Use quadratic formula to Determine outer radius
            c = c - threshold;
            float d = sqrt(b * b - 4.0f * a * c);
            outerRadius = (-2.0f * c) / (b + d);
            outerRadius *= 1.2f;
        }
    }
    else
    {
        DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_ATTENUATED);
    }

    SetupGeometry(outerRadius);
}
void DeferredLight::setSpecularColour(const Ogre::ColourValue& colour) {
    if (colour.r != 0.0 || colour.g != 0.0 || colour.b != 0.0) {
        ENABLE_BIT(permutation,LightMaterialGenerator::MI_SPECULAR);
    } else {
        DISABLE_BIT(permutation,LightMaterialGenerator::MI_SPECULAR);
    }
}
void DeferredLight::updateFromParent() {
    setAttenuation(parentLight->getAttenuationConstant(), parentLight->getAttenuationLinear(), parentLight->getAttenuationQuadric());
    setSpecularColour(parentLight->getSpecularColour());

    if (getCastChadows()) {
        ENABLE_BIT(permutation,LightMaterialGenerator::MI_SHADOW_CASTER);
    } else {
        DISABLE_BIT(permutation, LightMaterialGenerator::MI_SHADOW_CASTER);
    }
}
示例#4
0
void DeferredLight::SetupGeometry(float radius)
{
    // Disable all 3 bits
    DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_POINT);
    DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_SPOTLIGHT);
    DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_DIRECTIONAL);

    mIgnoreWorldTrans = mParentLight->getType() == Ogre::Light::LT_DIRECTIONAL;

    switch (mParentLight->getType())
    {
    case Ogre::Light::LT_DIRECTIONAL:
        // TODO: Effectively infinite bounds
        mRenderOp = mLightRenderOp->mDirectionalLightOp;
        setBoundingBox(Ogre::AxisAlignedBox(-10000, -10000, -10000, 10000, 10000, 10000));
        mRadius = 15000.0f;
        ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_DIRECTIONAL);
        break;

    case Ogre::Light::LT_POINT:
        mRenderOp = mLightRenderOp->mPointLightOp;
        setBoundingBox(Ogre::AxisAlignedBox(
                    Ogre::Vector3(-radius, -radius, -radius),
                    Ogre::Vector3(radius, radius, radius)));
        mRadius = radius;
        ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_POINT);
        break;

    case Ogre::Light::LT_SPOTLIGHT:
        mHeight = mParentLight->getAttenuationRange();
        mRadius = math::Tan(mParentLight->getSpotlightOuterAngle().valueRadians() * 0.5f) * mHeight;
        mRenderOp = mLightRenderOp->mSpotlightOp;
        setBoundingBox(Ogre::AxisAlignedBox(
                    Ogre::Vector3(-mRadius, 0, -mRadius),
                    Ogre::Vector3(mRadius, mHeight, mRadius)));
        ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_SPOTLIGHT);
        break;

    default:
        break;
    }
}
void DeferredLight::rebuildGeometry(Ogre::Real radius) {
    DISABLE_BIT(permutation, LightMaterialGenerator::MI_POINT);
    DISABLE_BIT(permutation, LightMaterialGenerator::MI_SPOTLIGHT);
    DISABLE_BIT(permutation, LightMaterialGenerator::MI_DIRECTIONAL);

    switch (parentLight->getType()) {
        case Ogre::Light::LT_DIRECTIONAL:
            createRectangle2D();
            ENABLE_BIT(permutation,LightMaterialGenerator::MI_DIRECTIONAL);
            break;
        case Ogre::Light::LT_POINT:
            createSphere(radius, 10, 10);
            ENABLE_BIT(permutation,LightMaterialGenerator::MI_POINT);
            break;
        case Ogre::Light::LT_SPOTLIGHT:
            Ogre::Real height = parentLight->getAttenuationRange();
            Ogre::Radian coneRadiusAngle = parentLight->getSpotlightOuterAngle() / 2;
            Ogre::Real rad = Ogre::Math::Tan(coneRadiusAngle) * height;
            createCone(rad, height, 20);
            ENABLE_BIT(permutation,LightMaterialGenerator::MI_SPOTLIGHT);
            break;
    }
}
示例#6
0
void DeferredLight::SetSpecularColour(const Ogre::ColourValue& col)
{
    // setCustomParameter(2, Vector4(col.r, col.g, col.b, col.a));

    // There is a specular component? Set material accordingly
    if (col.r != 0.0f || col.g != 0.0f || col.b != 0.0f)
    {
        ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_SPECULAR);
    }
    else
    {
        DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_SPECULAR);
    }
}
示例#7
0
void DeferredLight::UpdateFromParent()
{
    // TODO : Don't do this unless something changed
    SetAttenuation(mParentLight->getAttenuationConstant(), mParentLight->getAttenuationLinear(),
                    mParentLight->getAttenuationQuadric());
    SetSpecularColour(mParentLight->getSpecularColour());

    if (getCastChadows())
    {
        ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_SHADOW_CASTER);
    }
    else
    {
        DISABLE_BIT(mPermutation, LightMaterialGenerator::MI_SHADOW_CASTER);
    }
}
void DeferredLight::setAttenuation(Ogre::Real c, Ogre::Real b, Ogre::Real a) {
    Ogre::Real outerRadius = parentLight->getAttenuationRange();

    if (c != 1.0 || b != 0.0 || a != 0.0) {
        ENABLE_BIT(permutation, LightMaterialGenerator::MI_ATTENUATED);
        if (parentLight->getType() == Ogre::Light::LT_POINT) {
            int thresholdLevel = 10;
            Ogre::Real threshold = 1.0 / ((Ogre::Real)thresholdLevel / 256.0);

            c -= threshold;
            Ogre::Real d = Ogre::Math::Sqrt(b * b - 4 * a * c);
            outerRadius = (-2 * c) / (b + d);
            outerRadius *= 1.2;
        }
    } else {
        DISABLE_BIT(permutation, LightMaterialGenerator::MI_ATTENUATED);
    }

    rebuildGeometry(outerRadius);
}
示例#9
0
void DeferredLight::setAttenuation(float c, float b, float a)
{
	float outerRadius = mParentLight->getAttenuationRange();
	if (c != 1.0f || b != 0.0f || a != 0.0f)
	{
		ENABLE_BIT(mPermutation, LightMaterialGenerator::MI_ATTENUATED);
		if (mParentLight->getType() == Ogre::Light::LT_POINT)
		{
			float minAttenuation = 1.0f / (MINIMUM_ATTENUATION / 256.0f);
			c -= minAttenuation;
			outerRadius = (-2 * c) / (b + sqrt(b * b - 4 * a * c));
		}
	}
	else
	{
		DISABLE_BIT(mPermutation,LightMaterialGenerator::MI_ATTENUATED);
	}
    
	rebuildGeometry(outerRadius);
}
示例#10
0
文件: wmx.c 项目: Romppanen/gammu
void DCT3SetDebug(int argc, char *argv[])
{
	int		x,count;
	unsigned int y;
	unsigned char 	reqDisable[] = {0x01, 0x01, 0x71};
	GSM_Error error;
//	unsigned char 	reqTest[] = {0x01, 0x01, 0x96, 0xFF, 0xFF};

	/* RPC testing packets: */

	/* RPC: Get version */
	//unsigned char 	reqTest2[] = {0x01, 0x01, 0x00, 0x03, 0x00};
	/* RPC: read I/O 0x6D mask 0xFF */
	//unsigned char 	reqTest2[] = {0x01, 0x01, 0x02, 0x01, 0x02, 0x6D, 0xFF}; /*  */
	/* RPC: write I/O 0x03 mask 0xFF value 0x31 */
	//unsigned char 	reqTest2[] = {0x01, 0x01, 0x01, 0x01, 0x07, 0x03, 0xFF, 0x31}; /* write I/O */

	/* RPC: write forged FBUS packet to MDISND */
//	unsigned char 	reqTest2[] = {0x01, 0x01, 0x16, 0x01, 0x06,
//	0x14, // R0 -- length
//	0x05, // R1 -- MDI type identifier 0x05(FBUS)
//	0x1e, 0x0c, 0x00, 0x66,
//	0x00, 0x0e, 0x01, 0x01,
//	0x66, 0x55, 0x44, 0x33,
//	0x0d, 0x01, 0x01, 0x01,
//	0x1b, 0x58, 0x01, 0x44};
//	1805 t=cb37 nr=e2 :D 05:

	/* debug enable packet */
	unsigned char reqEnable[] = {
		0x00, 0x01, 0x70,
		/* Debug bits
		   byte[bit>>3]&(1<<(7-(bit&7)))
		*/
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00 */
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40 */
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80 */
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */
		/* Debug verbose bits
		   byte[bit>>3]&(1<<(7-(bit&7)))
		*/
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		};
	FILE *xout;

	#define ENABLE_BIT(bit,verbose) reqEnable[3 + (bit>>3)] |= 1<<(7-(bit&7)); if(verbose){reqEnable[3 + 32 + (bit>>3)] |= 1<<(7-(bit&7));}

	/* Enable some bit
	   TODO command line or GUI interface
	*/
	//ENABLE_BIT(0x18, 1);	/* Enable MDISND debugging */
	//ENABLE_BIT(0x19, 1);	/* Enable MDIRCV debugging */
	//ENABLE_BIT(0x31, 1);

	gsmdec = GSMDecoder_new();
	/* Open XML file .. needs to be argument */
	xout = fopen("out.xml", "w");
	if (xout == NULL) {
		return;
	}
	GSMDecoder_xmlout(gsmdec, xout);

	printf("Debug Trace Mode -- wumpus 2003\n");
	traces = wmx_tracestruct_load(argv[2]);
	if(traces == NULL)
		printf("Warning: could not load trace description file %s\n", argv[2]);
	printf("Activating ranges:\n");
	count = 0;
	for(x=3; x<argc; x++) {
		char 		*ptr = argv[x];
		unsigned 	from,to,verbose;

		while(*ptr) {
		 	verbose = 0;
			if(*ptr == 'v') {
				verbose = 1;
				ptr++;
			}
			to = from = strtol(ptr, &ptr, 16);
			if(*ptr == '-') {
				ptr ++;
				to = strtol(ptr, &ptr, 16);
			}
			if(*ptr != ',' && *ptr != 0) {
				printf("Invalid parameter '%s'\n", argv[x]);
				return;
			}
			if(*ptr == ',')
				ptr++;
			if(from > 0xFF) from=0xFF;
			if(to > 0xFF) to=0xFF;
			printf("  %02x-%02x verbose=%i\n",from,to,verbose);
			for(y=from; y<=to; y++) {
				ENABLE_BIT(y, verbose);
				count++;
			}
		}
	}
	if(count == 0) {
		printf("Nothing activated -- bailing out\n");
		return;
	}
	//ENABLE_BIT(0x20, 1);  /* SIM commands (literal) */
	//ENABLE_BIT(0x21, 1);  /* SIML2 commands (literal) */
	//ENABLE_BIT(0x22, 1);  /* SIM commands (literal) */
	//ENABLE_BIT(0x3B, 1);	/* PHCTRL state */

	GSM_Init(TRUE);

	/* We Need DCT3 */
	CheckDCT3();

	error=DCT3_EnableSecurity (gsm, 0x01);
	Print_Error(error);

	gsm->User.UserReplyFunctions=UserReplyFunctionsX;

	//error=GSM_WaitFor (gsm, reqTest, sizeof(reqTest), 0x40, 1, ID_DebugSwitch);

	//error=GSM_WaitFor (gsm, reqTest2, sizeof(reqTest2), 0xD1, 4, ID_RPC);

	/* Enable Debug Mode */
	error=GSM_WaitFor (gsm, reqEnable, sizeof(reqEnable), 0x40, 4, ID_DebugSwitch);

	Print_Error(error);
	signal(SIGINT, interrupt);
	printf("Press Ctrl+C to interrupt...\n");
	x=0;

	/*
	while(x<100) {
		//printf(": %02x\n",x);
		gsm->Phone.Data.RequestID	= ID_DebugTrace;
		res = gsm->Device.Functions->ReadDevice(gsm, buff, 255);
		if(res) {
			printf("%02x\n",x);
			for(y=0;y<res;y++) {
				//printf("%02x\n",x,buff[y]&0xFF);
				gsm->Protocol.Functions->StateMachine(gsm,buff[y]);
				x++;
			}
		}
	}
	*/
	;

	/* todo: wait and dump for some time */
	while (!gshutdown) {
		GSM_ReadDevice(gsm,TRUE);
		usleep(10000);
	}
	signal(SIGINT, SIG_DFL);
	printf("Disabling\n");
	error=GSM_WaitFor (gsm, reqDisable, sizeof(reqDisable), 0x40, 10, ID_DebugSwitch);
	Print_Error(error);

	GSMDecoder_free(gsmdec);
}