Пример #1
0
static void fontPrintTextImpl(FT_Bitmap* bitmap, int xofs, int yofs, u32 text_color, u32* framebuffer, int width, int height, int lineSize){
	int x, y;
	
	u8* line = bitmap->buffer;
	u32* fbLine = framebuffer + xofs + yofs * lineSize;
	for (y = 0; y < bitmap->rows; y++) {
		u8* column = line;
		u32* fbColumn = fbLine;
		for (x = 0; x < bitmap->width; x++) {
			if (x + xofs < width && x + xofs >= 0 && y + yofs < height && y + yofs >= 0) {
				u8 val = *column;
				u32 color = *fbColumn;

				float f_val = ((float)val) / 255.0;
				f_val *= Af(text_color);

				float r = min(1.0, Rf(text_color) * f_val + Rf(color) * (1.0 - f_val));
				float g = min(1.0, Gf(text_color) * f_val + Gf(color) * (1.0 - f_val));
				float b = min(1.0, Bf(text_color) * f_val + Bf(color) * (1.0 - f_val));
				float a = min(1.0, Af(color) + f_val);

				*fbColumn = RGBAf(r, g, b, a);
			}
			column++;
			fbColumn++;
		}
		line += bitmap->pitch;
		fbLine += lineSize;
	}

//	gePrintDebug(0x100, "fontPrintTextImpl(bitmap, %d, %d, 0x%8.8X, framebuffer, %d, %d, %d)\n", xofs, yofs, color, width, height, lineSize);
	/*
	u8* line = bitmap->buffer;
	u32* fbLine = framebuffer + xofs + yofs * lineSize;
	for (y = 0; y < bitmap->rows; y++) {
		u8* column = line;
		u32* fbColumn = fbLine;
		for (x = 0; x < bitmap->width; x++) {
			if (x + xofs < width && x + xofs >= 0 && y + yofs < height && y + yofs >= 0) {
				u8 val = *column;
				color = *fbColumn;
				u8 r = color & 0xff;
				u8 g = (color >> 8) & 0xff;
				u8 b = (color >> 16) & 0xff;
				u8 a = (color >> 24) & 0xff;
				r = rf * val / 255 + (255 - val) * r / 255;
				g = gf * val / 255 + (255 - val) * g / 255;
				b = bf * val / 255 + (255 - val) * b / 255;
				a = af * val / 255 + (255 - val) * a / 255;
				*fbColumn = RGBA(r, g, b, a);
			//	*fbColumn = RGBA(255, 255, 255, val);
			}
			column++;
			fbColumn++;
		}
		line += bitmap->pitch;
		fbLine += lineSize;
	}
	*/
}
Пример #2
0
/**
 * Get the diffuse color of this material.
 */
RGBAf vtMaterial::GetDiffuse() const
{
	osg::Vec4 col = m_pMaterial->getDiffuse(FAB);
	return RGBAf(col[0], col[1], col[2], col[3]);
}
Пример #3
0
void LoadProbes(bool isRerun) {
    #define mod(a,b) a = fmod(fmod(a,b)+b,b)
    mod(gPosition.x,GLH_SIZEX);
    mod(gPosition.y,GLH_SIZEY);
    mod(gPosition.z,GLH_SIZEZ);
    
    if (!gGodMode) {
        gh.MapOffset = gPosition;
    }
    
    Vec3f gv; //Goal direction.
    Vec3f d = {0, 0, 0};

    if (!isRerun) {
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::T)) {
            //reset full map.
            gh.TMap->DefaultIt();
            gh.TMap->RecalculateAccelerationStructure(0, 0, 0, GLH_SIZEX, GLH_SIZEY, GLH_SIZEZ);
            gh.TMap->m_bReloadFullTexture = true;

        }
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) d.x -= 1.;
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)) d.x += 1.;
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::S)) d.y += 1.;
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)) d.y -= 1.;
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::RBracket)) d.z += 1.;
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::LBracket)) d.z -= 1.;
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && gTimeSinceOnGround < 0.1) gh.v.z = 10; // && gh.gTimeSinceOnGround < 0.1
        gTimeSinceOnGround += worldDeltaTime;

        /*
                float ny = dx * sin( -Yaw/180.*3.14159 ) + dy * cos( -Yaw/180.*3.14159 );
                float nx = dx * cos( -Yaw/180.*3.14159 ) - dy * sin( -Yaw/180.*3.14159 );
                Roll = Roll * .95; //auto-righting.
         */
    }

    Vec3f ForwardVec = LookQuaternion * Vec3f{0, 0, -1};
    ForwardVec.z = -ForwardVec.z; //??? WHY? WHY WHY??? Is LookQuaternion busted???
    Vec3f MoveVec = LookQuaternion * Vec3f{d.x, 0, d.y};
    float nx = MoveVec.x;
    float ny = MoveVec.y;

    //	printf( "%f %f %f\n", fwdx, fwdy, fwdz );

    if (gGodMode) {
        gh.v = {nx * 4.f, ny * 4.f, d.z * 4.f};
        gh.MapOffset += gh.v*worldDeltaTime;
    } else {
        if (!isRerun) {
            float xymag = sqrt(nx * nx + ny * ny);
            if (xymag > .001) {
                nx /= xymag;
                ny /= xymag;
            }

            gh.v.x = nx * 4.;
            gh.v.y = ny * 4.;
            gh.v.z -= worldDeltaTime * 16.; //gravity
            gh.v.z *= .995; //terminal velocity
        }
    }


    if (!isRerun) {
        if(worldDeltaTime != 0) gv = gh.v*worldDeltaTime;
        else gv = {1e-10,1e-10,1e-10}; //TODO fix crash when gv == 0,0,0
    } else {
        printf("GVRerun\n");
    }
    //Spew out a boatload of rays, trying to intersect things.

    int i, j;
    const int stacks = 6;
    for (i = 0; i < stacks * 2; i++) {
        //Stack goes: 1 2 3 4 5 4 3 2 1, i goes 012345678
        int stack = i;
        if (i >= stacks) stack = stacks * 2 - stack - 1;

        //Stack is the number of radial rays.
        float sigma = (i / ((float) stacks * 2 - 1)* 3.14159);
        d.z = cos(sigma);
        float mz = sin(sigma);
        stack++;
        for (j = 0; j < stack; j++) {
            float theta = (j / (float) stack) * 3.14159 * 2.0;
            d.x = mz * cos(theta);
            d.y = mz * sin(theta);
            CollisionProbe * p;
            probes.push_back(p = gh.AddProbe());
            p->Position = gh.MapOffset;
            p->Direction = RGBAf(d + gv, 10000);
        }
    }


    {
        gpTest = gh.AddProbe();
        gpTest->Position = gh.MapOffset;
        gpTest->Direction = RGBAf(gv, gv.len());

        gpTestVelocity = gh.AddProbe();
        gpTestVelocity->Position = gh.MapOffset;
        gpTestVelocity->Direction = RGBAf(gv, gv.len());
        gpTestVelocity->AuxRotation = gh.v;

    }


    gpForward = gh.AddProbe();
    gpForward->Position = gh.MapOffset;
    gpForward->Direction = RGBAf(ForwardVec, 10000);


    //	Yaw
    //	Pitch
    //	Roll
    //???


    Vec3f FrontRot = LookQuaternion * Vec3f{1, 0, 0};
    Vec3f UpRot = LookQuaternion * Vec3f{0, 1, 0};

    //	FrontRot[1] *= -1;
    //	FrontRot[0] *= -1;
    //	FrontRot[2] *= -1;
    //	UpRot[2] *= -1;

    gpRotFwd = gh.AddProbe();
    gpRotFwd->Position = gh.MapOffset;
    gpRotFwd->Direction = RGBAf(gv, gv.len());
    gpRotFwd->AuxRotation = FrontRot;

    gpRotUp = gh.AddProbe();
    gpRotUp->Position = gh.MapOffset;
    gpRotUp->Direction = RGBAf(gv, gv.len());
    gpRotUp->AuxRotation = UpRot;


}