void	set_bitmap(gameswf::bitmap_info* bi, const gameswf::matrix& m, bitmap_wrap_mode wm, const gameswf::cxform& color_transform)
		{
			m_mode = (wm == WRAP_REPEAT) ? BITMAP_WRAP : BITMAP_CLAMP;
			m_bitmap_info = bi;
			m_bitmap_matrix = m;
			m_bitmap_color_transform = color_transform;
			m_bitmap_color_transform.clamp();

			m_color = gameswf::rgba(
				Uint8(m_bitmap_color_transform.m_[0][0] * 255.0f), 
				Uint8(m_bitmap_color_transform.m_[1][0] * 255.0f), 
				Uint8(m_bitmap_color_transform.m_[2][0] * 255.0f), 
				Uint8(m_bitmap_color_transform.m_[3][0] * 255.0f));

			if (m_bitmap_color_transform.m_[0][1] > 1.0f
			    || m_bitmap_color_transform.m_[1][1] > 1.0f
			    || m_bitmap_color_transform.m_[2][1] > 1.0f
			    || m_bitmap_color_transform.m_[3][1] > 1.0f)
			{
				m_has_nonzero_bitmap_additive_color = true;
			}
			else
			{
				m_has_nonzero_bitmap_additive_color = false;
			}
		}
Esempio n. 2
0
void InstanceProvider::initialize(CIMOMHandle & cimom)
{
	// create default instances
	CIMInstance instance1("Sample_InstanceProviderClass");
        instance1.setPath(CIMObjectPath("Sample_InstanceProviderClass.Identifier=1"));

	instance1.addProperty(CIMProperty("Identifier", Uint8(1)));   // key
	instance1.addProperty(CIMProperty("Message", String("Hello World")));

	_instances.append(instance1);

	CIMInstance instance2("Sample_InstanceProviderClass");
        instance2.setPath(CIMObjectPath("Sample_InstanceProviderClass.Identifier=2"));

	instance2.addProperty(CIMProperty("Identifier", Uint8(2)));   // key
	instance2.addProperty(CIMProperty("Message", String("Yo Planet")));

	_instances.append(instance2);

	CIMInstance instance3("Sample_InstanceProviderClass");
        instance3.setPath(CIMObjectPath("Sample_InstanceProviderClass.Identifier=3"));

	instance3.addProperty(CIMProperty("Identifier", Uint8(3)));   // key
	instance3.addProperty(CIMProperty("Message", String("Hey Earth")));

	_instances.append(instance3);
}
Esempio n. 3
0
void colorf::store_rgba(Uint8* ptr) const
{
    ptr[0] = Uint8(r * 255);
    ptr[1] = Uint8(g * 255);
    ptr[2] = Uint8(b * 255);
    ptr[3] = Uint8(a * 255);
}
Esempio n. 4
0
inline Boolean _getQName(char*& p, const char*& localName)
{
    localName = p;

    if (!CharSet::isAlNumUnder(Uint8(*p)))
        return false;

    p++;

    // No explicit test for NULL termination is needed.
    // On position 0 of the array false is returned.
    while (_isInnerElementChar[Uint8(*p)])
        p++;

    // We've validated the prefix, now validate the local name
    if (*p == ':')
    {
        localName = ++p;

        if (!CharSet::isAlNumUnder(Uint8(*p)))
            return false;

        p++;
        // No explicit test for NULL termination is needed.
        // On position 0 of the array false is returned.
        while (_isInnerElementChar[Uint8(*p)])
            p++;
    }

    return true;
}
Esempio n. 5
0
PerlinApp::PerlinApp():m_png("perlin.png"),m_perlin(256,5,0.7f) {
	float tmp=0.0f;
	Uint8 expand=0;
	Uint16 i,j;
	for (i=0;i<5;i++)
		tmp+=pow(0.7f,i);
	expand=Uint8(255/tmp);
	Uint16 hmin=255,hmax=0,height;
	m_t = new Uint8[PICTURE_SIZE*PICTURE_SIZE];
	for (i=0;i<PICTURE_SIZE;i++)
		for (j=0;j<PICTURE_SIZE;j++) {
			height=expand*m_perlin.Noise(i,j);
			if (height<hmin)
				hmin=height;
			else if (height>hmax)
				hmax=height;
			m_t[PICTURE_SIZE*i+j]=height;
		}
	printf("%d - %d\n",hmin,hmax);
	// Rescale to 0-255
	tmp=(255/float(hmax-hmin));
	for (i=0;i<PICTURE_SIZE;i++)
		for (j=0;j<PICTURE_SIZE;j++)
			m_t[PICTURE_SIZE*i+j]=Uint8((m_t[PICTURE_SIZE*i+j]-hmin)*tmp);
}
Esempio n. 6
0
void ExceptionsTest::initialize(CIMOMHandle & cimom)
{

    cout <<" ExceptionsTest::initialize" << endl;

    CheckExceptionType(EXCEPTION_TYPE);

    // create default instances for FirstClass
    CIMInstance instance1("FirstClass");
    CIMObjectPath reference1("FirstClass.Id=1");

    instance1.addProperty(CIMProperty("Id", Uint8(1)));   // key
    instance1.addProperty(CIMProperty("Message", String("Subodh.....")));

    _instances.append(instance1);
    _instanceNames.append(reference1);

    CheckExceptionType(EXCEPTION_TYPE);

    CIMInstance instance2("FirstClass");
    CIMObjectPath reference2("FirstClass.Id=2");

    instance2.addProperty(CIMProperty("Id", Uint8(2)));   // key
    instance2.addProperty(CIMProperty("Message", String("Soni....")));

    _instances.append(instance2);
    _instanceNames.append(reference2);

    CheckExceptionType(EXCEPTION_TYPE);

    // create default instances for SecondClass
    CIMInstance instance_1("SecondClass");
    CIMObjectPath reference_1("SecondClass.Srno=11");

    instance_1.addProperty(CIMProperty("Srno", Uint8(1)));   // key
    instance_1.addProperty(
        CIMProperty("Name", String("Class Two Instance 1.....")));

    _instances_second.append(instance_1);
    _instanceNames_second.append(reference_1);

    CheckExceptionType(EXCEPTION_TYPE);

    CIMInstance instance_2("SecondClass");
    CIMObjectPath reference_2("SecondClass.Srno=2");

    instance_2.addProperty(CIMProperty("Srno", Uint8(2)));   // key
    instance_2.addProperty(
        CIMProperty("Name", String("Class Two Instance 2....")));

    _instances_second.append(instance_2);
    _instanceNames_second.append(reference_2);

    CheckExceptionType(EXCEPTION_TYPE);
}
Esempio n. 7
0
void active_change_state(SdlActivationType type, Uint8 changed_app_state)
{
	Uint8 old_app_state = app_state;

	if(type == GAIN)
		app_state = Uint8(app_state | changed_app_state);
	else
		app_state = Uint8(app_state & ~changed_app_state);

	// generate an event - but only if the given state flags actually changed.
	if((old_app_state & changed_app_state) != (app_state & changed_app_state))
		queue_active_event(type, changed_app_state);
}
Esempio n. 8
0
void Client::package_clear()
{
	if (package)
		delete package;
	package = new Packet();
	*package << Uint8(NET_INDEX::FRAME);
}
Esempio n. 9
0
COligoFarApp::COligoFarApp( int argc, char ** argv ) :
    CApp( argc, argv ),
    m_hashPass( 0 ),
    m_strands( 0x03 ),
    m_readsPerRun( 250000 ),
    m_minRun(0),
    m_maxRun( numeric_limits<int>::max() ),
    m_topCnt( 10 ),
    m_topPct( 99 ),
    m_minPctid( 60 ),
    m_identityScore(  1.0 ),
    m_mismatchScore( -1.0 ),
    m_gapOpeningScore( -3.0 ),
    m_gapExtentionScore( -1.5 ),
    m_extentionPenaltyDropoff( -100 ),
    m_qualityChannels( 0 ),
    m_qualityBase( 33 ),
    m_minBlockLength( 1000 ),
//    m_guideFilemaxMismatch( 0 ),
    m_memoryLimit( Uint8( sizeof(void*) == 4 ? 3 : 8 ) * int(kGigaByte) ),
    m_performTests( false ),
    m_colorSpace( false ),
    m_sodiumBisulfiteCuration( false ),
    m_outputSam( true ),
    m_printStatistics( false ),
    m_fastaParseIDs( false ),
#ifdef _WIN32
    //m_guideFile( "nul:" ),
    m_outputFile( "con:" ),
#else
    m_guideFile( "/dev/null" ),
    m_outputFile( "/dev/stdout" ),
#endif
    m_outputFlags( "z" ),
    m_geometry( "p" )
{
    m_passParam.push_back( CPassParam() );
#ifndef _WIN32
    ifstream meminfo( "/proc/meminfo" );
    string buff;
    if( !meminfo.fail() ) {
        m_memoryLimit = 0;

        while( getline( meminfo, buff ) ) {
            istringstream line(buff);
            string name, units;
            Uint8 value;
            line >> name >> value >> units;
            if( units.length() ) {
                switch( tolower( units[0] ) ) {
                case 'g': value *= kKiloByte;
                case 'm': value *= kKiloByte;
                case 'k': value *= kKiloByte;
                }
            }
            if( name == "MemFree:" || name == "Buffers:" || name == "Cached:" || name == "SwapCached:" ) {
                m_memoryLimit += value;
            }
        }
    }
Esempio n. 10
0
    void Sprite::render(Renderer &renderer) const {
        if (!visible) {
            return;
        }

        if (isNoDepth()) {
            renderer.enableDepthTest(false);
        }
        if (isTransparent()) {
            renderer.setBlendFunc(blendFunc);
        }

        Int32 textureIndex = animation[frame];
        Material material(texture, Color(255, 255, 255, Uint8(255 * alpha)), !isTransparent());

        bool rotated = zRotation != 0.0;
        if (rotated) {
            Matrix rotate = Matrix::rotateAroundPoint(zRotation, Vector::UNIT_Z, position + rotationCentre);
            renderer.setModelMatrix(rotate);
        }

        bool reversed = (orientation == Orientation::Right);
        Vector texturePos = Vector(reversed ? 1.0f : 0.0f, 1.0f, Float32(textureIndex));
        Vector textureSize = Vector(reversed ? -1.0f : 1.0f, -1.0f);

        renderer.quadXY(Vector(position.x, position.y, z), size, texturePos, textureSize, material);

        if (rotated) {
            renderer.setModelMatrix(Matrix::IDENTITY);
        }

        if (isNoDepth()) {
            renderer.enableDepthTest(true);
        }
    }
Esempio n. 11
0
void HudTrail::Render(Graphics::Renderer *r)
{
	PROFILE_SCOPED();
	//render trail
	if (m_trailPoints.size() > 1) {
		const vector3d vpos = m_transform * m_body->GetInterpPosition();
		m_transform[12] = vpos.x;
		m_transform[13] = vpos.y;
		m_transform[14] = vpos.z;
		m_transform[15] = 1.0;

		static std::vector<vector3f> tvts;
		static std::vector<Color> colors;
		tvts.clear();
		colors.clear();
		const vector3d curpos = m_body->GetInterpPosition();
		tvts.reserve(MAX_POINTS);
		colors.reserve(MAX_POINTS);
		tvts.push_back(vector3f(0.f));
		colors.push_back(Color::BLANK);
		float alpha = 1.f;
		const float decrement = 1.f / m_trailPoints.size();
		const Color tcolor = m_color;
		for (size_t i = m_trailPoints.size()-1; i > 0; i--) {
			tvts.push_back(-vector3f(curpos - m_trailPoints[i]));
			alpha -= decrement;
			colors.push_back(tcolor);
			colors.back().a = Uint8(alpha * 255);
		}

		r->SetTransform(m_transform);
		m_lines.SetData(tvts.size(), &tvts[0], &colors[0]);
		m_lines.Draw(r, m_renderState, Graphics::LINE_STRIP);
	}
}
void CSDLVideo::setLightIntensity(const float intensity)
{
    Uint8 intense = Uint8(intensity*255.0f);

    mOverlaySurface.setAlpha(255-intense);
    mOverlaySurface.fillRGB(0, 0, 0);
}
Esempio n. 13
0
void draw_solid_tinted_rectangle(int x, int y, int w, int h,
								 int r, int g, int b,
								 double alpha, surface target)
{

	SDL_Rect rect = create_rect(x, y, w, h);
	fill_rect_alpha(rect,SDL_MapRGB(target->format,r,g,b),Uint8(alpha*255),target);
}
Esempio n. 14
0
void Client::new_connection_packet(string _name)
{
	Packet* out;
	out = new Packet();
	*out << Uint8(NET_INDEX::NEW_CONNECTION);
	*out << _name;
	con->send(out);
	delete out;
}
Esempio n. 15
0
moon::moon()
{
	map_diffuse = texture::ptr(new texture(get_texture_dir()+"moon_d.png", texture::LINEAR));
	// compute moon normal map
	const unsigned mns = 256; // moon normal map size
	std::vector<Uint8> mnp(3*mns*mns);
	const double mid = (mns-1) * 0.5;
	unsigned mnpc = 0;
	for (unsigned k = 0; k < mns; ++k) {
		double y = -(k - mid)/mid;
		for (unsigned j = 0; j < mns; ++j) {
			double x = (j - mid)/mid;
			double l = x*x + y*y;
			double y2 = y;
			if (l > 0.999) {
				l = 1.0/sqrt(l);
				y2 = y*l;
				x = x*l;
			}
			double cosbetha2 = std::max(1.0 - y2*y2, 0.0);
			double sinalpha2 = std::max(1.0 - x*x / cosbetha2, 0.0);
			double z = sqrt(sinalpha2 * cosbetha2);
			mnp[mnpc+0] = Uint8(x * 127 + 127.5);
			mnp[mnpc+1] = Uint8(y2 * 127 + 127.5);
			mnp[mnpc+2] = Uint8(z * 127 + 127.5);
			mnpc += 3;
		}
	}
	map_normal = texture::ptr(new texture(mnp, mns, mns, GL_RGB, texture::LINEAR, texture::CLAMP));
	glsl_moon.reset(new glsl_shader_setup(get_shader_dir() + "moon.vshader",
					      get_shader_dir() + "moon.fshader"));
	glsl_moon->use();
	loc_diffcol = glsl_moon->get_uniform_location("tex_diff");
	loc_nrml = glsl_moon->get_uniform_location("tex_nrml");
	loc_lightdir = glsl_moon->get_uniform_location("light_dir");

#if 0
	// Test code:
 	ofstream oss("moon.ppm");
 	oss << "P6\n" << mns << " " << mns << "\n255\n";
 	oss.write((const char*)(&mnp[0]), mns*mns*3);
#endif
}
Esempio n. 16
0
void queue_button_event(int button, int state, int x, int y)
{
	SDL_Event ev;
	ev.type = Uint8((state == SDL_PRESSED)? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP);
	ev.button.button = (uint8_t)button;
	ev.button.state  = (uint8_t)state;
	ev.button.x = (Uint16)x;
	ev.button.y = (Uint16)y;
	queue_event(ev);
}
void SDLSoundManager::play(SoundManager::SoundID sid, std::string channel, FPoint pos, bool loop) {

	SoundMapIterator it;
	VirtualChannelMapIterator vcit = channels.end();

	if (!sid || !AUDIO || !SOUND_VOLUME)
		return;

	it = sounds.find(sid);
	if (it == sounds.end())
		return;

	/* create playback object and start playback of sound chunk */
	Playback p;
	p.sid = sid;
	p.location = pos;
	p.virtual_channel = channel;
	p.loop = loop;
	p.finished = false;

	if (p.virtual_channel != GLOBAL_VIRTUAL_CHANNEL) {

		/* if playback exists, stop it befor playin next sound */
		vcit = channels.find(p.virtual_channel);
		if (vcit != channels.end())
			Mix_HaltChannel(vcit->second);

		vcit = channels.insert(std::pair<std::string, int>(p.virtual_channel, -1)).first;
	}

	// Let playback own a reference to prevent unloading playbacked sound.
	if (!loop)
		it->second->refCnt++;

	Mix_ChannelFinished(&channel_finished);
	int c = Mix_PlayChannel(-1, it->second->chunk, (loop ? -1 : 0));

	if (c == -1)
		logError("SoundManager: Failed to play sound, no more channels available.");

	// precalculate mixing volume if sound has a location
	Uint8 d = 0;
	if (p.location.x != 0 || p.location.y != 0) {
		float v = 255.0f * (calcDist(lastPos, p.location) / (SOUND_FALLOFF));
		clamp(v, 0.f, 255.f);
		d = Uint8(v);
	}

	Mix_SetPosition(c, 0, d);

	if (vcit != channels.end())
		vcit->second = c;

	playback.insert(std::pair<int, Playback>(c, p));
}
Esempio n. 18
0
void TimingProvider::initialize(CIMOMHandle & cimom)
{
    cout <<" TimingProvider::initialize" << endl;

    // Create Instances for TimeOne Class
    CIMInstance instance1("TimeOne");
    CIMObjectPath reference1("TimeOne.Id=1");

    instance1.addProperty(CIMProperty("Id", Uint8(1)));   // key
    instance1.addProperty(CIMProperty("Message", String("Class One I1")));

    _instances.append(instance1);
    _instanceNames.append(reference1);


    CIMInstance instance2("TimeOne");
    CIMObjectPath reference2("TimeOne.Id=2");

    instance2.addProperty(CIMProperty("Id", Uint8(2)));   // key
    instance2.addProperty(CIMProperty("Message", String("Class One I2")));

    _instances.append(instance2);
    _instanceNames.append(reference2);

    // Create Instances for TimeTwo Class
     CIMInstance instance_1("TimeTwo");
     CIMObjectPath reference_1("TimeTwo.Srno=22");

    instance_1.addProperty(CIMProperty("Srno", Uint8(1)));   // key
    instance_1.addProperty(CIMProperty("TimeVar", Uint16(1111)));
    _instances_2.append(instance_1);
    _instanceNames_2.append(reference_1);

    CIMInstance instance_2("TimeTwo");
    CIMObjectPath reference_2("TimeTwo.Srno=2");

    instance_2.addProperty(CIMProperty("Srno", Uint8(2)));   // key
    instance_2.addProperty(CIMProperty("TimeVar", Uint16(2222)));

    _instances_2.append(instance_2);
    _instanceNames_2.append(reference_2);
}
Esempio n. 19
0
void CSeqDBAtlas::x_GarbageCollect(Uint8 reduce_to)
{
    Verify(true);
    if (Uint8(m_CurAlloc) <= reduce_to) {
        return;
    }

    x_FlushAll();
        
    Verify(true);
}
Esempio n. 20
0
bool cInput::GetActionKeyState(EGameAction::TYPE action) const
{
    sActionKey key = GetKeyForAction(action);

    if(key.m_Key == SDLK_UNKNOWN && key.m_KeyboardInput)
        return false;

    if(key.m_Button == Uint8(-1) && !key.m_KeyboardInput)
        return false;

    return key.m_KeyboardInput ? SDL_GetKeyState(NULL)[key.m_Key] != 0 : (SDL_GetMouseState(NULL, NULL) & key.m_Button) != 0;
}
Esempio n. 21
0
void test02()
{
    const CIMNamespaceName NAMESPACE = CIMNamespaceName("/zzz");

    CIMClass cimClass(CIMName("MyClass"));

    cimClass
        .addProperty(CIMProperty(CIMName("Last"), String())
            .addQualifier(CIMQualifier(CIMName("key"), true)))
        .addProperty(CIMProperty(CIMName("First"), String())
            .addQualifier(CIMQualifier(CIMName("key"), true)))
        .addProperty(CIMProperty(CIMName("Age"), String())
            .addQualifier(CIMQualifier(CIMName("key"), true)));

    CIMInstance cimInstance(CIMName("MyClass"));
    cimInstance.addProperty(CIMProperty(CIMName("first"), String("John")));
    cimInstance.addProperty(CIMProperty(CIMName("last"), String("Smith")));
    cimInstance.addProperty(CIMProperty(CIMName("age"), Uint8(101)));

    assert(cimInstance.findProperty(CIMName("first")) != PEG_NOT_FOUND);
    assert(cimInstance.findProperty(CIMName("last")) != PEG_NOT_FOUND);
    assert(cimInstance.findProperty(CIMName("age")) != PEG_NOT_FOUND);

    assert(cimInstance.getPropertyCount() == 3);


    CIMObjectPath instanceName =
        cimInstance.buildPath(CIMConstClass(cimClass));

    CIMObjectPath tmp("myclass.age=101,first=\"John\",last=\"Smith\"");

    assert(tmp.makeHashCode() == instanceName.makeHashCode());

    // Test CIMInstance::buildPath with incomplete keys in the instance

    Boolean caughtNoSuchPropertyException = false;

    try
    {
        CIMInstance badInstance(CIMName("MyClass"));
        badInstance.addProperty(CIMProperty(CIMName("first"), String("John")));
        badInstance.addProperty(CIMProperty(CIMName("last"), String("Smith")));
        CIMObjectPath instanceName =
            badInstance.buildPath(CIMConstClass(cimClass));
    }
    catch (const NoSuchProperty&)
    {
        caughtNoSuchPropertyException = true;
    }

    assert(caughtNoSuchPropertyException);
}
Esempio n. 22
0
eeColorA cLight::ProcessVertex( const eeFloat& PointX, const eeFloat& PointY, const eeColorA& VertexColor, const eeColorA& BaseColor ) {
	eeFloat VertexDist;

	if ( mActive ) {
		if ( mType == LIGHT_NORMAL )
			VertexDist = eeabs( mPos.Distance( eeVector2f( PointX, PointY ) ) );
		else {
			eeFloat XDist = eeabs(mPos.x - PointX) * 0.5f;
			eeFloat YDist = eeabs(mPos.y - PointY);
			VertexDist = eesqrt( XDist * XDist + YDist * YDist ) * 2.0f;
		}

		if ( VertexDist <= mRadius ) {
			eeColorA	TmpRGB;
			Uint8		TmpColor;
			eeFloat		LightC;

			LightC			= eeabs( static_cast<eeFloat> ( mColor.R() - BaseColor.R() ) ) / mRadius;
			TmpColor		= Uint8( (eeFloat)mColor.R() - (VertexDist * LightC) );
			TmpRGB.Red		= VertexColor.R() + ( TmpColor - VertexColor.R() );

			LightC			= eeabs( static_cast<eeFloat> ( mColor.G() - BaseColor.G() ) ) / mRadius;
			TmpColor		= Uint8( (eeFloat)mColor.G() - (VertexDist * LightC) );
			TmpRGB.Green	= VertexColor.G() + ( TmpColor - VertexColor.G() );

			LightC			= eeabs( static_cast<eeFloat> ( mColor.B() - BaseColor.B() ) ) / mRadius;
			TmpColor		= Uint8( (eeFloat)mColor.B() - (VertexDist * LightC) );
			TmpRGB.Blue		= VertexColor.B() + ( TmpColor - VertexColor.B() );

			if ( TmpRGB.R() < VertexColor.R() ) TmpRGB.Red		= VertexColor.R();
			if ( TmpRGB.G() < VertexColor.G() ) TmpRGB.Green	= VertexColor.G();
			if ( TmpRGB.B() < VertexColor.B() ) TmpRGB.Blue		= VertexColor.B();

			return TmpRGB;
		}
	}

	return BaseColor;
}
Esempio n. 23
0
void CSDLVideo::setLightIntensity(const float intensity)
{
    Uint8 intense = Uint8(intensity*255.0f);

    auto *sfc = mpOverlaySurface.get();
    Uint32 color = SDL_MapRGB(sfc->format, 0, 0, 0);

#if SDL_VERSION_ATLEAST(2, 0, 0)
    SDL_SetSurfaceAlphaMod( sfc, 255-intense);
#else
    SDL_SetAlpha( sfc, SDL_SRCALPHA, 255-intense);
#endif

    SDL_FillRect( sfc, nullptr, color);
}
Esempio n. 24
0
primitives primitives::cylinder_z(double radius_bottom, double radius_top,
				  double z_bottom, double z_top,
				  double alpha, const texture& tex,
				  double u_scal, unsigned nr_segs, bool inside)
{
	primitives cyl(GL_QUAD_STRIP, (nr_segs+1)*2, tex);
	color col(255, 255, 255, 255);
	double us = u_scal / nr_segs;
	for (unsigned i = 0; i <= nr_segs; ++i) {
		double a = -2*M_PI*i/nr_segs;
		double sa = sin(a);
		double ca = cos(a);
		if (inside) ca = -ca;
		col.a = Uint8(128 + 127*alpha);
		cyl.colors[2*i] = col;
		col.a = Uint8(255*alpha);
		cyl.colors[2*i+1] = col;
		cyl.texcoords[2*i] = vector2f(i * us, 1);
		cyl.texcoords[2*i+1] = vector2f(i * us, 0);
		cyl.vertices[2*i] = vector3f(radius_bottom * ca, radius_bottom * sa, z_bottom);
		cyl.vertices[2*i+1] = vector3f(radius_top * ca, radius_top * sa, z_top);
	}
	return cyl;
}
Esempio n. 25
0
void Client::network_OUT(float dt)
{
	if (msg_out != "")
	{
		Packet* out;
		out = new Packet();
		*out << Uint8(NET_INDEX::MESSAGE) << conID << scope_out << msg_out;
			con->send(out);
		delete out;

		msg_out = "";
	}

	if(package->getDataSize() > 1) //only send if contains data
		con->send(package);
	package_clear();
}
Esempio n. 26
0
bool AxisBinding::FromString(const char *str, AxisBinding &ab) {
	if (strcmp(str, "disabled") == 0) {
		ab.Clear();
		return true;
	}

	const char *p = str;

	if (p[0] == '-') {
		ab.direction = NEGATIVE;
		p++;
	}
	else
		ab.direction = POSITIVE;

	if (strncmp(p, "Joy", 3) != 0)
		return false;
	p += 3;

	const int JoyUUIDLength = 33;
	char joyUUIDBuf[JoyUUIDLength];

	// read the UUID
	if (!ReadToTok('/', &p, joyUUIDBuf, JoyUUIDLength)) {
		return false;
	}
	// force terminate
	joyUUIDBuf[JoyUUIDLength-1] = '\0';
	// now, map the GUID to a joystick number
	const int joystick = Pi::JoystickFromGUIDString(joyUUIDBuf);
	if (joystick == -1) {
		return false;
	}
	// found a joystick
	assert(joystick < 256);
	ab.joystick = Uint8(joystick);

	if (strncmp(p, "Axis", 4) != 0)
		return false;

	p += 4;
	ab.axis = atoi(p);

	return true;
}
Esempio n. 27
0
void CBitmaskBuilder::SequenceBuffer( CSeqBuffer * ncbi8na )
{
    CProgressIndicator progress( "Listing "+NStr::IntToString( m_wSize )+"-mers of length "+NStr::IntToString( m_wLength )+" for "+m_seqId );
    fourplanes::CHashGenerator hgen( m_wLength );
    for( const char * seq = ncbi8na->GetBeginPtr(); seq < ncbi8na->GetEndPtr(); ++seq ) {
        hgen.AddBaseMask( CNcbi8naBase( seq ) );
        // cerr << CIupacnaBase( CNcbi8naBase( seq ) ) << "\t";
        if( hgen.GetAmbiguityCount() <= (int)m_maxAmb ) {
            for( fourplanes::CHashIterator h( hgen ); h; ++h ) {
                Uint8 packed = CBitHacks::PackWord( Uint8(*h), m_pattern2na );
                // cerr << hex << DISPLAY( Uint8(*h) ) << DISPLAY( m_pattern2na ) << DISPLAY( packed ) << dec << "\n";
                SetBit( packed );                
            }
        } //else cerr << "-\n";
        progress.Increment();
    }
    progress.Summary();
}
Esempio n. 28
0
  inline
  uint64_t Decoder<Endian>::Varint64Rtmfp() {
    uint64_t value = 0;
    const int maxBytes = 9;
    for (int i = 0; i < maxBytes && !Error(); ++i) {
      uint8_t bit7 = Uint8();
      value = (value << 7) | (bit7 & 0x7F);

      if ((bit7 & 0x80) == 0) {
        return value;
      }
    }

    if (!Error()) {
      setError(E_BAD_VARINT);
    }

    return 0;
  }
Esempio n. 29
0
Uint8 Galaxy::GetSectorDensity(int sx, int sy, int sz)
{
    // -1.0 to 1.0
    float offset_x = (sx*Sector::SIZE + SOL_OFFSET_X)/GALAXY_RADIUS;
    float offset_y = (-sy*Sector::SIZE + SOL_OFFSET_Y)/GALAXY_RADIUS;
    // 0.0 to 1.0
    offset_x = Clamp((offset_x + 1.0)*0.5, 0.0, 1.0);
    offset_y = Clamp((offset_y + 1.0)*0.5, 0.0, 1.0);

    int x = int(floor(offset_x * (m_galaxybmp->w - 1)));
    int y = int(floor(offset_y * (m_galaxybmp->h - 1)));

    SDL_LockSurface(m_galaxybmp);
    int val = static_cast<unsigned char*>(m_galaxybmp->pixels)[x + y*m_galaxybmp->pitch];
    SDL_UnlockSurface(m_galaxybmp);
    // crappy unrealistic but currently adequate density dropoff with sector z
    val = val * (256 - std::min(abs(sz),256)) / 256;
    // reduce density somewhat to match real (gliese) density
    val /= 2;
    return Uint8(val);
}
	// public lineStyle(thickness:Number, rgb:Number, alpha:Number, pixelHinting:Boolean,
	// noScale:String, capsStyle:String, jointStyle:String, miterLimit:Number) : Void
	void sprite_line_style(const fn_call& fn)
	{
		sprite_instance* sprite = sprite_getptr(fn);
		canvas* canva = sprite->get_canvas();
		assert(canva);

		// If a thickness is not specified, or if the parameter is undefined, a line is not drawn
		if (fn.nargs == 0)
		{
			canva->m_current_line = 0;
			canva->add_path(false);
			return;
		}

		Uint16 width = (Uint16) PIXELS_TO_TWIPS(fclamp(fn.arg(0).to_float(), 0, 255));
		rgba color(0, 0, 0, 255);

		if (fn.nargs >= 2)
		{
			color.set(fn.arg(1).to_float());
			if (fn.nargs >= 3)
			{
				float alpha = fclamp(fn.arg(2).to_float(), 0, 100);
				color.m_a = Uint8(255 * (alpha/100));

				// capsStyle:String - Added in Flash Player 8. 
				// A string that specifies the type of caps at the end of lines.
				// Valid values are: "round", "square", and "none". 
				// If a value is not indicated, Flash uses round caps. 
				if (fn.nargs >= 6)
				{
					//TODO
				}
			}
		}

		canva->set_line_style(width, color);
	}