Beispiel #1
0
void ReleaseObject( RwObject *obj )
{
    EngineInterface *engineInterface = (EngineInterface*)obj->engineInterface;

    // Increase the reference count.
    if ( refCountManager *refMan = refCountRegister.GetPluginStruct( (EngineInterface*)engineInterface ) )
    {
        if ( refCountPlugin *refCount = refMan->GetPluginStruct( engineInterface, obj ) )
        {
            // We just delete the object.
            engineInterface->DeleteRwObject( obj );
        }
    }
}
Beispiel #2
0
        void free(NodeId node)
        {
            beginMessage();

            oscPacket()
                .openMessage("/node/free", 1)
                .int32(node.id())
                .closeMessage();
            m_engine->nodeIdAllocator().free(node.id());
        }
Beispiel #3
0
    EngineInterface* EngineManager::createEngine(EngineDescription& d)
    {
        EngineInterface* current = NULL;

        if(d.type == "phyengine")
        {
            current = new PhyEngine(d.name, reps_.phyRepository);
        }
        else if(d.type == "stackengine")
        {
            current = new StackEngine(d.name, reps_.stackRepository); 
        }
        else
        {
            throw ResourceNotFoundException("Engine type \"" + d.type + "\" does not exist.");
        }

        // Give the engine an interface to this EngineManager
        current->setEngineManager(this);
        return current;
    }
Beispiel #4
0
        GroupId group(GroupId parent)
        {
            beginMessage();

            const int32_t nodeId = m_engine->nodeIdAllocator().alloc();

            oscPacket()
                .openMessage("/group/new", 3)
                    .int32(nodeId)
                    .int32(parent.id())
                    .int32(0) // add action
                .closeMessage();

            return GroupId(nodeId);
        }
Beispiel #5
0
        SynthId synth(const char* synthDef, GroupId parent, const std::vector<float>& controls, const std::list<Value>& options=std::list<Value>())
        {
            beginMessage();

            const int32_t nodeId = m_engine->nodeIdAllocator().alloc();

            oscPacket()
                .openMessage("/synth/new", 4 + OSCPP::Tags::array(controls.size()) + OSCPP::Tags::array(options.size()))
                    .string(synthDef)
                    .int32(nodeId)
                    .int32(parent.id())
                    .int32(0)
                    .putArray(controls.begin(), controls.end());

                    oscPacket().openArray();
                        for (const auto& x : options) {
                            x.put(oscPacket());
                        }
                    oscPacket().closeArray();

                oscPacket().closeMessage();

            return SynthId(nodeId);
        }
Beispiel #6
0
void texDictionaryStreamPlugin::Deserialize( Interface *intf, BlockProvider& inputProvider, RwObject *objectToDeserialize ) const
{
    EngineInterface *engineInterface = (EngineInterface*)intf;

    // Cast our object.
    TexDictionary *txdObj = (TexDictionary*)objectToDeserialize;

    // Read the textures.
    {
        BlockProvider texDictMetaStructBlock( &inputProvider );

        uint32 textureBlockCount = 0;
        bool requiresRecommendedPlatform = true;
        uint16 recDevicePlatID = 0;

        texDictMetaStructBlock.EnterContext();

        try
        {
            if ( texDictMetaStructBlock.getBlockID() == CHUNK_STRUCT )
            {
                // Read the header block depending on version.
                LibraryVersion libVer = texDictMetaStructBlock.getBlockVersion();

                if (libVer.rwLibMajor <= 2 || libVer.rwLibMajor == 3 && libVer.rwLibMinor <= 5)
                {
                    textureBlockCount = texDictMetaStructBlock.readUInt32();
                }
                else
                {
                    textureBlockCount = texDictMetaStructBlock.readUInt16();
                    uint16 recommendedPlatform = texDictMetaStructBlock.readUInt16();

                    // So if there is a recommended platform set, we will also give it one if we will write it.
                    requiresRecommendedPlatform = ( recommendedPlatform != 0 );
                    recDevicePlatID = recommendedPlatform;  // we want to store it aswell.
                }
            }
            else
            {
                engineInterface->PushWarning( "could not find texture dictionary meta information" );
            }
        }
        catch( ... )
        {
            texDictMetaStructBlock.LeaveContext();
            
            throw;
        }

        // We finished reading meta data.
        texDictMetaStructBlock.LeaveContext();

        txdObj->hasRecommendedPlatform = requiresRecommendedPlatform;
        txdObj->recDevicePlatID = recDevicePlatID;

        // Now follow multiple TEXTURENATIVE blocks.
        // Deserialize all of them.

        for ( uint32 n = 0; n < textureBlockCount; n++ )
        {
            BlockProvider textureNativeBlock( &inputProvider );

            // Deserialize this block.
            RwObject *rwObj = NULL;

            std::string errDebugMsg;

            try
            {
                rwObj = engineInterface->DeserializeBlock( textureNativeBlock );
            }
            catch( RwException& except )
            {
                // Catch the exception and try to continue.
                rwObj = NULL;

                if ( textureNativeBlock.doesIgnoreBlockRegions() )
                {
                    // If we failed any texture parsing in the "ignoreBlockRegions" parse mode,
                    // there is no point in continuing, since the environment does not recover.
                    throw;
                }

                errDebugMsg = except.message;
            }

            if ( rwObj )
            {
                // If it is a texture, add it to our TXD.
                bool hasBeenAddedToTXD = false;

                GenericRTTI *rttiObj = RwTypeSystem::GetTypeStructFromObject( rwObj );

                RwTypeSystem::typeInfoBase *typeInfo = RwTypeSystem::GetTypeInfoFromTypeStruct( rttiObj );

                if ( engineInterface->typeSystem.IsTypeInheritingFrom( engineInterface->textureTypeInfo, typeInfo ) )
                {
                    TextureBase *texture = (TextureBase*)rwObj;

                    texture->AddToDictionary( txdObj );

                    hasBeenAddedToTXD = true;
                }

                // If it has not been added, delete it.
                if ( hasBeenAddedToTXD == false )
                {
                    engineInterface->DeleteRwObject( rwObj );
                }
            }
            else
            {
                std::string pushWarning;

                if ( errDebugMsg.empty() == false )
                {
                    pushWarning = "texture native reading failure: ";
                    pushWarning += errDebugMsg;
                }
                else
                {
                    pushWarning = "failed to deserialize texture native block in texture dictionary";
                }

                engineInterface->PushWarning( pushWarning.c_str() );
            }
        }
    }

    // Read extensions.
    engineInterface->DeserializeExtensions( txdObj, inputProvider );
}
Beispiel #7
0
void Bitmap::scale(
    Interface *intf,
    uint32 width, uint32 height,
    const char *downsamplingMode, const char *upscaleMode
)
{
    EngineInterface *engineInterface = (EngineInterface*)intf;

    // This is actually scaling the bitmap, not changing the draw plane size.
    uint32 layerWidth = this->width;
    uint32 layerHeight = this->height;
    uint32 depth = this->depth;
    uint32 rowAlignment = this->rowAlignment;
    eRasterFormat rasterFormat = this->rasterFormat;
    eColorOrdering colorOrder = this->colorOrder;
    
    // Anything to do at all?
    if ( layerWidth == width && layerHeight == height )
        return;

    void *srcTexels = this->texels;

    // We want to perform default filtering, most of the time.
    rasterResizeFilterInterface *downsamplingFilter, *upscaleFilter;
    resizeFilteringCaps downsamplingCaps, upscaleCaps;

    FetchResizeFilteringFilters(
        engineInterface,
        downsamplingMode, upscaleMode,
        downsamplingFilter, upscaleFilter,
        downsamplingCaps, upscaleCaps
    );

    // The resize filtering expects a cached destination pipe.
    mipmapLayerResizeColorPipeline dstColorPipe(
        rasterFormat, depth, rowAlignment, colorOrder,
        PALETTE_NONE, NULL, 0
    );

    // We also have to determine the sampling types that should be used beforehand.
    eSamplingType horiSampling = determineSamplingType( layerWidth, width );
    eSamplingType vertSampling = determineSamplingType( layerHeight, height );

    // Since we always are a raw raster, we can easily perform the filtering.
    // We do not have to perform _any_ source and destionation transformations, unlike for rasters.
    // We also are not bound to raster size rules that prevent certain size targets.
    void *transMipData = NULL;
    uint32 transMipSize = 0;

    PerformRawBitmapResizeFiltering(
        engineInterface, layerWidth, layerHeight, srcTexels,
        width, height,
        rasterFormat, depth, rowAlignment, colorOrder, PALETTE_NONE, NULL, 0,
        depth,
        dstColorPipe,
        horiSampling, vertSampling,
        upscaleFilter, downsamplingFilter,
        upscaleCaps, downsamplingCaps,
        transMipData, transMipSize
    );

    // Replace the pixels.
    if ( srcTexels )
    {
        engineInterface->PixelFree( srcTexels );
    }

    this->width = width;
    this->height = height;
    this->texels = transMipData;
    this->dataSize = transMipSize;

    // Update the row size.
    this->rowSize = getRasterDataRowSize( width, depth, rowAlignment );
}
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	EngineDebugOutput("GUI client starts", CORE, 0);

	///////////////////////////////////////////////////////////////////////////
	// Initialise variables

	// Result to return
	bool bResult = false;
	
	// Name of the engine host
	string strHostName;
	
	// Port number for the GUI protocol
	unsigned short nPortNumber = 0;
	
	// Client, Interface and handler
	TcpIpConnection* pClient = 0;
	EngineInterface* pEngine = 0;
	EngineCallBackHandler* pHandler = 0;

	///////////////////////////////////////////////////////////////////////////
	// Parse the command line

	CommandLine cmd(lpCmdLine);
	if (!cmd.GetString("-h", strHostName) || !cmd.GetInteger("-p", nPortNumber))
	{
		// One of them was not defined, use defaults instead
		EngineDebugOutput("GUI client: Using default command line parameters", CORE, 0);

		strHostName = "localhost";
		nPortNumber = 4000;
	}

	///////////////////////////////////////////////////////////////////////////
	// Create user interface and tcpip client

	pClient = new TcpIpConnection();
	if (pClient != 0)
	{ pEngine = new EngineInterface(pClient); }
	if (pEngine != 0)
	{ pHandler = new EngineCallBackHandler(pEngine); }


	// Set host, port and handler
	if ((pClient != 0) && (pHandler != 0))
	{
		pClient->SetHost(strHostName);
		pClient->SetPortNumber(nPortNumber);
		pClient->SetCallbackHandler(pHandler);

		// Open the connection
		pClient->Open();

		// Start listening to tcp/ip port
		bResult = pClient->Start();

		// Register GUI at the engine
		pEngine->Register();
	}	
	
	///////////////////////////////////////////////////////////////////////////
	// Wait while the GUI is working
	
	if (bResult)
	{
		while (pHandler->Active())
		{ 
			Sleep(1000); 
		}

		// Stop listening
		pClient->Stop();
	}

	///////////////////////////////////////////////////////////////////////////
	// Free allocated memory

	delete pEngine;
	delete pClient;
	delete pHandler;

	pEngine=0;
	pClient=0;
	pHandler=0;

	EngineDebugOutput("GUI client exits", CORE, 0);

	// Return result
	return static_cast<int>(bResult);
}
Beispiel #9
0
 //* Finalize request and send to the engine.
 void send()
 {
     if (m_flags.isBundle && m_bundleCount > 0)
         throw std::runtime_error("openBundle without matching closeBundle");
     m_engine->sendPacket(m_packet);
 }