StageDataBase::StageDataBase(void) :
    Inherited(),
    _sfPartitionRangeBegin    (Int32(-1)),
    _sfPartitionRangeEnd      (Int32(-1)),
    _sfGroupMode              (Int32(0))
{
}
Example #2
0
Vec2f CSMNativeWindow::translateToScreenCoordinatesAbs(Real32 rX,
                                                       Real32 rY)
{
    Vec2f returnValue(0, 0);

    X11Window qChild = 0;

    Int32    qW     = 0;
    Int32    qH     = 0;

    XTranslateCoordinates( _pDisplay, 
                           _pXWindow->getWindow(), 
                           _pRootWindow, 
                          
                            Int32(rX), 
                            Int32(rY), 
                          
                          & qW, 
                          & qH, 
                          
                          & qChild);

    returnValue.setValues(qW, qH);

    return returnValue;
}
hsIntRect *hsRect::Truncate(hsIntRect* r) const
{
	r->fLeft		= Int32(fLeft);
	r->fTop		= Int32(fTop);
	r->fRight		= Int32(fRight);
	r->fBottom	= Int32(fBottom);
	return r;
}
Example #4
0
		void MinusLife::onApply(Player& player, World& world, Int32 duration) const
		{
			Int32 hit = (Int32(D6_MAX_LIFE) / 7) + rand() % (Int32(D6_MAX_LIFE) / 2);
			if (player.hit(Float32(hit)))
			{
				player.playSound(PlayerSounds::Type::WasKilled);
			}
			world.getMessageQueue().add(player, Format("Life -{0}") << hit);
		}
PostShaderStageDataBase::PostShaderStageDataBase(void) :
    Inherited(),
    _mfShaderMaterials        (),
    _sfWidth                  (Int32(0)),
    _sfHeight                 (Int32(0)),
    _mfRenderTargets          (),
    _sfCamera                 (NULL)
{
}
TextureImageChunkBase::TextureImageChunkBase(void) :
    Inherited(),
    _sfTexture                (NULL),
    _sfLevel                  (Int32(0)),
    _sfLayer                  (Int32(-1)),
    _sfAccess                 (GLenum(GL_READ_ONLY)),
    _sfFormat                 (GLenum(GL_NONE))
{
}
FogStageDataBase::FogStageDataBase(void) :
    Inherited(),
    _sfFogMaterial            (NULL),
    _sfWidth                  (Int32(0)),
    _sfHeight                 (Int32(0)),
    _sfRenderTarget           (NULL),
    _sfCamera                 (NULL)
{
}
Example #8
0
*/	REBINT PD_String(REBPVS *pvs)
/*
***********************************************************************/
{
	REBVAL *data = pvs->value;
	REBVAL *val = pvs->setval;
	REBINT n = 0;
	REBCNT i;
	REBINT c;
	REBSER *ser = VAL_SERIES(data);

	if (IS_INTEGER(pvs->select)) {
		n = Int32(pvs->select) + VAL_INDEX(data) - 1;
	}
	else return PE_BAD_SELECT;

	if (val == 0) {
		if (n < 0 || (REBCNT)n >= SERIES_TAIL(ser)) return PE_NONE;
		if (IS_BINARY(data)) {
			SET_INTEGER(pvs->store, *BIN_SKIP(ser, n));
		} else {
			SET_CHAR(pvs->store, GET_ANY_CHAR(ser, n));
		}
		return PE_USE;
	}

	if (n < 0 || (REBCNT)n >= SERIES_TAIL(ser)) return PE_BAD_RANGE;

	if (IS_CHAR(val)) {
		c = VAL_CHAR(val);
		if (c > MAX_CHAR) return PE_BAD_SET;
	}
	else if (IS_INTEGER(val)) {
		c = Int32(val);
		if (c > MAX_CHAR || c < 0) return PE_BAD_SET;
		if (IS_BINARY(data)) { // special case for binary
			if (c > 0xff) Trap_Range(val);
			BIN_HEAD(ser)[n] = (REBYTE)c;
			return PE_OK;
		}
	}
	else if (ANY_BINSTR(val)) {
		i = VAL_INDEX(val);
		if (i >= VAL_TAIL(val)) return PE_BAD_SET;
		c = GET_ANY_CHAR(VAL_SERIES(val), i);
	}
	else
		return PE_BAD_SELECT;

	TRAP_PROTECT(ser);

	if (BYTE_SIZE(ser) && c > 0xff) Widen_String(ser);
	SET_ANY_CHAR(ser, n, c);

	return PE_OK;
}
ShadowMapEngineBase::ShadowMapEngineBase(void) :
    Inherited(),
    _sfShadowTexChunk         (NULL),
    _sfWidth                  (Int32(512)),
    _sfHeight                 (Int32(512)),
    _sfOffsetBias             (Real32(4.f)),
    _sfOffsetFactor           (Real32(10.f)),
    _sfShadowTravMask         (UInt32(TypeTraits<UInt32>::BitsSet))
{
}
DisplayFilterGroupBase::DisplayFilterGroupBase(void) :
    Inherited(),
    _sfCalibrationPatternFilter(NULL),
    _sfResolutionFilter       (NULL),
    _sfColorFilter            (NULL),
    _sfDistortionFilter       (NULL),
    _sfDrawerId               (Int32(-1)),
    _sfDrawableId             (Int32(-1))
{
}
MultiDisplayWindowBase::MultiDisplayWindowBase(void) :
    Inherited(),
    _sfHServers               (),
    _sfVServers               (),
    _sfManageClientViewports  (bool(true)),
    _sfXOverlap               (Int32(0)),
    _sfYOverlap               (Int32(0)),
    _sfMaxDepth               (Int32(999))
{
}
Int32 FBOViewport::getPixelBottom(void) const
{
    if(getBottom() > 1)
        return Int32(getBottom());
    
    if(getFrameBufferObject() == NULL)
        return Int32(getBottom());

    return Int32(getFrameBufferObject()->getHeight() * getBottom());
}
//////////////////////////////////////////////////////////////////////////////
// STATIC
void
verifySignature(std::streambuf & istrm, UInt8 validSig)
{
	UInt8 val;
	read(istrm, val);
	if (val != validSig)
	{
		BLOCXX_THROW(BadSignatureException,
			Format("Received invalid signature. Got: %1 Expected: %2", Int32(val),
				Int32(validSig)).c_str());
	}
}
Int32 FBOViewport::getPixelTop(void) const
{
    // >1: pixel
    if(getTop() > 1)
        return Int32(getTop());
 
    if(getFrameBufferObject() == NULL)
        return Int32(getTop());
   
    // <=1: partial screen, use 1 less to not overlap other windows
    return Int32(getFrameBufferObject()->getHeight() * getTop() - 1);
}
StencilChunkBase::StencilChunkBase(void) :
    Inherited(),
    _sfStencilFunc            (GLenum(GL_NONE)),
    _sfStencilValue           (Int32(0)),
    _sfStencilMask            (UInt32(0x1)),
    _sfStencilOpFail          (GLenum(GL_KEEP)),
    _sfStencilOpZFail         (GLenum(GL_KEEP)),
    _sfStencilOpZPass         (GLenum(GL_KEEP)),
    _sfClearBuffer            (Int32(0)),
    _sfBitMask                (UInt32(0xFFFFFFFF))
{
}
Example #16
0
Int32 getQuadtreeDepth(Int32 iSamplesX, Int32 iSamplesY, Int32 iTileSize)
{
#ifdef WIN32
    return Int32(log(Real32(getQuadtreeLeafNodeCount(iSamplesX, 
                                                     iSamplesY, 
                                                     iTileSize)))/log(2.f) +
                 1.f);
#else
    return Int32(log2(Real32(getQuadtreeLeafNodeCount(iSamplesX, 
                                                      iSamplesY, 
                                                      iTileSize))) + 1.f);
#endif
}
void DrawEnv::calcViewportDimension(Real32 rLeft,
                                    Real32 rBottom,
                                    Real32 rRight,
                                    Real32 rTop,
                                    
                                    UInt16 iTargetWidth,
                                    UInt16 iTargetHeight)
{
    if(rLeft > 1.f)
        _iPixelLeft = Int32(rLeft);
    else
        _iPixelLeft = Int32(iTargetWidth * rLeft);

    if(rRight > 1.f)
        _iPixelRight = Int32(rRight);
    else
        _iPixelRight = Int32(iTargetWidth * rRight) - 1;


    if(rBottom > 1.f)
        _iPixelBottom = Int32(rBottom);
    else
        _iPixelBottom = Int32(iTargetHeight * rBottom);

    if(rTop > 1.f)
        _iPixelTop = Int32(rTop);
    else
        _iPixelTop = Int32(iTargetHeight * rTop) - 1;


    _bFull = ( (_iPixelLeft   == 0                ) &&
               (_iPixelRight  == iTargetWidth  - 1) &&
               (_iPixelBottom == 0                ) &&
               (_iPixelTop    == iTargetHeight - 1)  );
}
Example #18
0
Int32 StagedViewport::getPixelBottom(void) const
{
    if(!getFrameBufferObject())
    {   // => behave like normal viewport
        return Viewport::calcPixelBottom();
    }
    else
    {   // => behave like FBOViewport
        if(getBottom() > 1)
            return Int32(getBottom());

        return Int32(getFrameBufferObject()->getHeight() * getBottom());
    }
}
void GrabForeground::draw(DrawEnv *, Viewport *port)
{
    if(getActive() == false)
        return;
    
    Image *i = getImage();
    
    if(i == NULL)       // No image, no grab.
        return;

    Int32 w = osgMax(2, port->getPixelWidth ());
    Int32 h = osgMax(2, port->getPixelHeight());

    // If image is smaller than 2x2, resize it to vp size
    // the 2x2 is because you can't create 0x0 images
    // If autoResize then update img size if vp changed

    if( (i->getWidth() <= 1 || i->getHeight() <= 1) ||
         (getAutoResize() && (w != i->getWidth() || h != i->getHeight())) )
    {
        i->set(i->getPixelFormat(),
               w, 
               h);
    }
    
    bool storeChanged = false;    

    if ( !getAutoResize() )
    {
        w = osgMin(Int32(i->getWidth ()), port->getPixelWidth());
        h = osgMin(Int32(i->getHeight()), port->getPixelHeight());
        
        if(Int32(i->getWidth()) != port->getPixelWidth())
        {
            glPixelStorei(GL_PACK_ROW_LENGTH, i->getWidth());
            storeChanged = true;
        }
    }
    
    glReadPixels(port->getPixelLeft(), 
                 port->getPixelBottom(), 
                 w, 
                 h, 
                 i->getPixelFormat(),
                 i->getDataType(), 
                 i->editData());

    if(storeChanged)
        glPixelStorei(GL_PACK_ROW_LENGTH, 0);
}
Example #20
0
Vec2i CSMNativeWindow::translateGlobalCoordinatesRel(Real32 rX,
                                                     Real32 rY)
{
    Vec2i returnValue(0, 0);

    X11Window qRoot   = 0;

    Int32     qX      = 0;
    Int32     qY      = 0;

    UInt32    qW      = 0;
    UInt32    qH      = 0;

    UInt32    qBorder = 0;
    UInt32    qDepth  = 0;

    XGetGeometry( _pDisplay, 
                  _pRootWindow, 
                 
                 & qRoot,
                 
                 & qX,
                 & qY,
                 
                 & qW,
                 & qH, 
                      
                 & qBorder, 
                 & qDepth );

    qX = Int32(floor(rX * qW + 0.5f));
    qY = Int32(floor(rY * qH + 0.5f));

    X11Window qChild = 0;

    XTranslateCoordinates( _pDisplay, 
                           _pRootWindow, 
                           _pXWindow->getWindow(), 
                          
                            qX, 
                            qY, 
                          
                          & (returnValue[0]), 
                          & (returnValue[1]), 
                          
                          & qChild);

    return returnValue;
}
Example #21
0
	static Hit WPN_ShotWallCollision(Shot& shot, const Level& level)
	{
		const Rectangle box = shot.getCollisionRect();
		Int32 up = Int32(box.right.y);
		Int32 down = Int32(box.left.y);
		Int32 left = Int32(box.left.x);
		Int32 right = Int32(box.right.x);

		bool hitsWall = level.isWall(left, up, true) ||
			level.isWall(left, down, true) ||
			level.isWall(right, up, true) ||
			level.isWall(right, down, true);

		return { hitsWall, nullptr };
	}
Example #22
0
Int32 StagedViewport::getPixelTop(void) const
{
    if(!getFrameBufferObject())
    {   // => behave like normal viewport
        return Viewport::calcPixelTop();
    }
    else
    {   // => behave like FBOViewport
        if(getTop() > 1)
            return Int32(getTop());

        // <=1: partial screen, use 1 less to not overlap other windows
        return Int32(getFrameBufferObject()->getHeight() * getTop() - 1);
    }
}
Example #23
0
PhysicsWorldBase::PhysicsWorldBase(void) :
    _sfErp                    (Real32(0.2)), 
    _sfGravity                (), 
    _sfCfm                    (), 
    _sfAutoDisableFlag        (), 
    _sfAutoDisableLinearThreshold(Real32(0.01)), 
    _sfAutoDisableAngularThreshold(Real32(0.01)), 
    _sfAutoDisableSteps       (Int32(10)), 
    _sfAutoDisableTime        (Real32(0)), 
    _sfWorldQuickStepNumIterations(Int32(20)), 
    _sfWorldContactMaxCorrectingVel(), 
    _sfWorldContactSurfaceLayer(Real32(0)), 
    Inherited() 
{
}
ParticlesBase::ParticlesBase(void) :
    Inherited(),
    _sfMode                   (UInt32(2)),
    _sfPositions              (this,
                          PositionsFieldId,
                          GeoVectorProperty::ParentsFieldId),
    _mfSizes                  (),
    _sfSecPositions           (this,
                          SecPositionsFieldId,
                          GeoVectorProperty::ParentsFieldId),
    _sfColors                 (this,
                          ColorsFieldId,
                          GeoVectorProperty::ParentsFieldId),
    _sfNormals                (this,
                          NormalsFieldId,
                          GeoVectorProperty::ParentsFieldId),
    _mfIndices                (),
    _mfTextureZs              (),
    _sfDrawOrder              (UInt32(0)),
    _sfDynamic                (bool(true)),
    _sfPump                   (),
    _sfBsp                    (),
    _sfNumParticles           (Int32(-1))
{
}
Example #25
0
*/	REBINT PD_Block(REBPVS *pvs)
/*
***********************************************************************/
{
	REBINT n = 0;

	/* Issues!!!
		a/1.3
		a/not-found: 10 error or append?
		a/not-followed: 10 error or append?
	*/

	if (IS_INTEGER(pvs->select)) {
		n = Int32(pvs->select) + VAL_INDEX(pvs->value) - 1;
	}
	else if (IS_WORD(pvs->select)) {
		n = Find_Word(VAL_SERIES(pvs->value), VAL_INDEX(pvs->value), VAL_WORD_CANON(pvs->select));
		if (n != NOT_FOUND) n++;
	}
	else {
		// other values:
		n = Find_Block_Simple(VAL_SERIES(pvs->value), VAL_INDEX(pvs->value), pvs->select) + 1;
	}

	if (n < 0 || (REBCNT)n >= VAL_TAIL(pvs->value)) {
		if (pvs->setval) return PE_BAD_SELECT;
		return PE_NONE;
	}

	if (pvs->setval) TRAP_PROTECT(VAL_SERIES(pvs->value));
	pvs->value = VAL_BLK_SKIP(pvs->value, n);
	// if valset - check PROTECT on block
	//if (NOT_END(pvs->path+1)) Next_Path(pvs); return PE_OK;
	return PE_SET;
}
Example #26
0
File: t-pair.c Project: Oldes/r3
*/	REBINT PD_Pair(REBPVS *pvs)
/*
***********************************************************************/
{
	REBVAL *sel;
	REBVAL *val;
	REBINT n = 0;
	REBD32 dec;

	if (IS_WORD(sel = pvs->select)) {
		if (VAL_WORD_CANON(sel) == SYM_X) n = 1;
		else if (VAL_WORD_CANON(sel) == SYM_Y) n = 2;
		else return PE_BAD_SELECT;
	}
	else if (IS_INTEGER(sel)) {
		n = Int32(sel);
		if (n != 1 && n !=2) return PE_BAD_SELECT;
	}
	else
		return PE_BAD_SELECT;

	if (NZ(val = pvs->setval)) {
		if (IS_INTEGER(val)) dec = (REBD32)VAL_INT64(val);
		else if (IS_DECIMAL(val)) dec = (REBD32)VAL_DECIMAL(val);
		else return PE_BAD_SET;
		if (n == 1) VAL_PAIR_X(pvs->value) = dec;
		else VAL_PAIR_Y(pvs->value) = dec;
	} else {
		dec = (n == 1 ? VAL_PAIR_X(pvs->value) : VAL_PAIR_Y(pvs->value));
		SET_DECIMAL(pvs->store, dec);
		return PE_USE;
	}

	return PE_OK;
}
Example #27
0
void runTests(bool write,BinaryDataHandler &pMem)
{
    runTest  (write,pMem, std::string("Hallo") );
    runTest1 (write,pMem, Time(222.22) );
    runTest  (write,pMem, Color3f(1.1,2.2,3.3) );
    runTest  (write,pMem, Color4f(1.1,2.2,3.3,4.4) );
    runTest  (write,pMem, Color3ub(1,2,3) );
    runTest  (write,pMem, Color4ub(1,2,3,4) );
    runTest  (write,pMem, DynamicVolume(DynamicVolume::BOX_VOLUME) );
    runTest  (write,pMem, DynamicVolume(DynamicVolume::SPHERE_VOLUME) );
    runTest1 (write,pMem, BitVector(0xabcd) );
    runTest  (write,pMem, Plane(Vec3f(1.0,0),0.222) );
    runTest  (write,pMem, Matrix(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) );
    runTest  (write,pMem, Quaternion(Vec3f(1,2,3),22) );
    runTest2<bool>(write,pMem, true );
    runTest  (write,pMem, Int8(-22) );
    runTest  (write,pMem, UInt8(11) );
    runTest  (write,pMem, Int16(-10233) );
    runTest  (write,pMem, UInt16(20233) );
    runTest  (write,pMem, Int32(-222320233) );
    runTest  (write,pMem, UInt32(522320233) );
    runTest<Int64>  (write,pMem, Int64(-522323334) );
    runTest  (write,pMem, UInt64(44523423) );
    runTest  (write,pMem, Real32(22.333224) );
    runTest  (write,pMem, Real64(52.334534533224) );
    runTest  (write,pMem, Vec2f(1.1,2.2) );
    runTest  (write,pMem, Vec3f(1.1,2.2,3.3) );
    runTest  (write,pMem, Vec4f(1.1,2.2,3.3,4.4) );
    runTest  (write,pMem, Pnt2f(1.1,2.2) );
    runTest  (write,pMem, Pnt2d(1.1,2.2) );
    runTest  (write,pMem, Pnt3f(1.1,2.2,3.3) );
    runTest  (write,pMem, Pnt3d(1.1,2.2,3.3) );
    runTest  (write,pMem, Pnt4f(1.1,2.2,3.3,4.4) );
    runTest  (write,pMem, Pnt4d(1.1,2.2,3.3,4.4) );
}
//---------------------------------------------------------------------------
void __fastcall TFrDeviceExplorer::btnWriteClick(TObject *Sender)
{
	TBluetoothLEDevice * ADevice = NULL;
	ADevice = GetCurrentDevice();
	if(ADevice != NULL) {
		TBluetoothGattService * AService = ADevice->Services->Items[CurrentService];
		TBluetoothGattCharacteristic * AChar = AService->Characteristics->Items[CurrentCharacteristic];
		if((AChar->Properties.Contains(TBluetoothProperty::Write)) || (AChar->Properties.Contains(TBluetoothProperty::WriteNoResponse))
			|| (AChar->Properties.Contains(TBluetoothProperty::SignedWrite)))
		{
			if(CbWriteTypes->ItemIndex ==  0) AChar->SetValueAsString(EdCharacWrite->Text);
			if(CbWriteTypes->ItemIndex ==  1) AChar->SetValueAsString(EdCharacWrite->Text, false);
			if(CbWriteTypes->ItemIndex ==  2) AChar->SetValueAsUInt8(UInt8(StrToInt(EdCharacWrite->Text)));
			if(CbWriteTypes->ItemIndex ==  3) AChar->SetValueAsUInt16(UInt16(StrToInt(EdCharacWrite->Text)));
			if(CbWriteTypes->ItemIndex ==  4) AChar->SetValueAsUInt32(UInt32(StrToInt(EdCharacWrite->Text)));
			if(CbWriteTypes->ItemIndex ==  5) AChar->SetValueAsUInt64(StrToInt(EdCharacWrite->Text));
			if(CbWriteTypes->ItemIndex ==  6) AChar->SetValueAsInt8(Int8(StrToInt(EdCharacWrite->Text)));
			if(CbWriteTypes->ItemIndex ==  7) AChar->SetValueAsInt16(Int16(StrToInt(EdCharacWrite->Text)));
			if(CbWriteTypes->ItemIndex ==  8) AChar->SetValueAsInt32(Int32(StrToInt(EdCharacWrite->Text)));
			if(CbWriteTypes->ItemIndex ==  9) AChar->SetValueAsInt64(StrToInt(EdCharacWrite->Text));
			if(CbWriteTypes->ItemIndex == 10) AChar->SetValueAsDouble(StrToFloat(EdCharacWrite->Text));
			if(CbWriteTypes->ItemIndex == 11) AChar->SetValueAsSingle(StrToFloat(EdCharacWrite->Text));
			ADevice->WriteCharacteristic(AChar);
		}
		else {
			ShowMessage("This characteristic doesn''t allow Write");
        }
	}
	else {
		ShowMessage(EdCurrentDevice->Text + " is not available");
	}
}
Example #29
0
*/	REBFLG MT_Tuple(REBVAL *out, REBVAL *data, REBCNT type)
/*
***********************************************************************/
{
	REBYTE	*vp;
	REBINT len = 0;
	REBINT n;

	vp = VAL_TUPLE(out);
	for (; NOT_END(data); data++, vp++, len++) {
		if (len >= 10) return FALSE;
		if (IS_INTEGER(data)) {
			n = Int32(data);
		}
		else if (IS_CHAR(data)) {
			n = VAL_CHAR(data);
		}
		else return FALSE;
		if (n > 255 || n < 0) return FALSE;
		*vp = n;
	}

	VAL_TUPLE_LEN(out) = len;

	for (; len < 10; len++) *vp++ = 0;

	VAL_SET(out, type);
	return TRUE;
}
Example #30
0
//
//  Partial1: C
// 
// Process the /part (or /skip) and other length modifying
// arguments.
//
REBINT Partial1(REBVAL *sval, REBVAL *lval)
{
    REBI64 len;
    REBINT maxlen;
    REBINT is_ser = ANY_SERIES(sval);

    // If lval is not set or is BAR!, use the current len of the target value:
    if (IS_UNSET(lval) || IS_BAR(lval)) {
        if (!is_ser) return 1;
        if (VAL_INDEX(sval) >= VAL_LEN_HEAD(sval)) return 0;
        return (VAL_LEN_HEAD(sval) - VAL_INDEX(sval));
    }
    if (IS_INTEGER(lval) || IS_DECIMAL(lval)) len = Int32(lval);
    else {
        if (is_ser && VAL_TYPE(sval) == VAL_TYPE(lval) && VAL_SERIES(sval) == VAL_SERIES(lval))
            len = (REBINT)VAL_INDEX(lval) - (REBINT)VAL_INDEX(sval);
        else
            fail (Error(RE_INVALID_PART, lval));
    }

    if (is_ser) {
        // Restrict length to the size available:
        if (len >= 0) {
            maxlen = (REBINT)VAL_LEN_AT(sval);
            if (len > maxlen) len = maxlen;
        } else {
            len = -len;
            if (len > (REBINT)VAL_INDEX(sval)) len = (REBINT)VAL_INDEX(sval);
            VAL_INDEX(sval) -= (REBCNT)len;
        }
    }

    return (REBINT)len;
}