Пример #1
0
void CClientMgr::UntagAllTextures() {
    LTLink *pListHead, *pCur;
    SharedTexture *pTexture;

    pListHead = &m_SharedTextures.m_Head;
    for (pCur=pListHead->m_pNext; pCur != pListHead; pCur=pCur->m_pNext)
    {
        pTexture = ((SharedTexture*)pCur->m_pData);
        pTexture->SetFlags(pTexture->GetFlags() & ~ST_TAGGED);
    }
}
Пример #2
0
void CClientMgr::FreeUnusedSharedTextures() {
    LTLink *pCur, *pNext, *pListHead;
    SharedTexture *pTexture;

    // Get rid of untagged ones.
    pListHead = &m_SharedTextures.m_Head;
    pCur = pListHead->m_pNext;
    while (pCur != pListHead)
    {
        pNext = pCur->m_pNext;

        pTexture = (SharedTexture*)pCur->m_pData;

        if (!(pTexture->GetFlags() & ST_TAGGED))
        {
            FreeSharedTexture(pTexture);
        }

        pCur = pNext;
    }
}
Пример #3
0
// Free the textures associated with a model if nobody else is using them
// Note : This assumes that the model textures aren't being used by
// anything other than models!
void CClientMgr::FreeUnusedModelTextures(LTObject *pObject) {
    ModelInstance *pInstance = pObject->ToModel();

    LTLink *pCur, *pListHead;
    SharedTexture *pTexture;
    uint32 nTextureLoop;

    // Handle the case where there are duplicate entries in the skins..
    for (nTextureLoop = 0; nTextureLoop < MAX_MODEL_TEXTURES; ++nTextureLoop)
    {
        for (uint32 nDupeLoop = nTextureLoop + 1; nDupeLoop < MAX_MODEL_TEXTURES; ++nDupeLoop)
        {
            if ((pInstance->m_pSkins[nTextureLoop] == pInstance->m_pSkins[nDupeLoop]) && (pInstance->m_pSkins[nTextureLoop]))
            {
                pInstance->m_pSkins[nDupeLoop] = LTNULL;
            }
        }
    }

    // Untag the textures used by this model
    for (nTextureLoop = 0; nTextureLoop < MAX_MODEL_TEXTURES; ++nTextureLoop)
    {
        pTexture = pInstance->m_pSkins[nTextureLoop];
        if (!pTexture)
            continue;
        // Make sure sprites don't get unloaded
        if (pInstance->m_pSprites[nTextureLoop])
            pTexture->SetFlags(pTexture->GetFlags() | ST_TAGGED);
        else
            pTexture->SetFlags(pTexture->GetFlags() & ~ST_TAGGED);
    }

    // Mark all client side model object textures as touched
    pListHead = &m_ObjectMgr.m_ObjectLists[OT_MODEL].m_Head;
    for (pCur=pListHead->m_pNext; pCur != pListHead; pCur=pCur->m_pNext)
    {
        ModelInstance *pFlagInstance = (ModelInstance*)pCur->m_pData;

        if (pFlagInstance == pInstance)
            continue;

        for (nTextureLoop = 0; nTextureLoop < MAX_MODEL_TEXTURES; ++nTextureLoop)
        {
            TagTexture(pFlagInstance->m_pSkins[nTextureLoop]);
        }
    }

    // Get rid of the model's textures if they haven't been tagged
    for (nTextureLoop = 0; nTextureLoop < MAX_MODEL_TEXTURES; ++nTextureLoop)
    {
        pTexture = pInstance->m_pSkins[nTextureLoop];
        if (!pTexture)
            continue;
        if ((pTexture->GetFlags() & ST_TAGGED) == 0)
        {
            FreeSharedTexture(pTexture);
            pInstance->m_pSkins[nTextureLoop] = LTNULL;
        }
    }
}
Пример #4
0
ImageView::ImageView(const char *name, float w, float h) : View() {
	figure = NULL;
	clickable = false;
	
	ApplicationController *ctl = ApplicationController::getInstance();
	TextureManager *texMgr = ctl->texMgr;
	Texture *tex = NULL;
	SharedTexture *stex = NULL;
	if ((stex = texMgr->findSharedTexture(name))) {
		if (w > 0 && h > 0) {
			this->setFigure(stex->makePlateWithSize(name, w, h));
		} else if (w > 0) {
			this->setFigure(stex->makeFixPlate(name, w));
		} else {
			this->setFigure(stex->makePlate(name));
		}
		this->setTexture(stex);
	} else if ((tex = texMgr->loadTexture(name))) {
		this->setFigure(tex->makePlate());
		this->setTexture(tex);
	}
}
Пример #5
0
void CClientMgr::TagUsedTextures() {
    LTLink *pCur, *pListHead;
    ModelInstance *pModelInst;
    LTParticleSystem *pSystem;
    uint32 i;
    SharedTexture *pTexture;

    uint32 nTagCount = 0;

    // Tag textures that the game code has references to.
    pListHead = &m_SharedTextures.m_Head;
    for (pCur=pListHead->m_pNext; pCur != pListHead; pCur=pCur->m_pNext)
    {
        pTexture = ((SharedTexture*)pCur->m_pData);
        if (pTexture->GetRefCount() > 0)
        {
            nTagCount += TagTexture(pTexture);
        }
    }

    // Tag all linked textures
    pListHead = &m_SharedTextures.m_Head;
    for (pCur=pListHead->m_pNext; pCur != pListHead; pCur=pCur->m_pNext)
    {
        pTexture = (SharedTexture*)pCur->m_pData;
        nTagCount += TagTexture(pTexture->GetLinkedTexture(eLinkedTex_Detail));
		nTagCount += TagTexture(pTexture->GetLinkedTexture(eLinkedTex_EnvMap));
		nTagCount += TagTexture(pTexture->GetLinkedTexture(eLinkedTex_BumpMap));
		nTagCount += TagTexture(pTexture->GetLinkedTexture(eLinkedTex_EffectTexture1));
		nTagCount += TagTexture(pTexture->GetLinkedTexture(eLinkedTex_EffectTexture2));
		nTagCount += TagTexture(pTexture->GetLinkedTexture(eLinkedTex_EffectTexture3));
		nTagCount += TagTexture(pTexture->GetLinkedTexture(eLinkedTex_EffectTexture4));
    }

    // Tag all textures we can't unload.
    if (m_pCurShell) {
        for (i=0; i < world_bsp_client->NumWorldModels(); i++)
        {
            const WorldData *pWorldData = world_bsp_client->GetWorldModel(i);

            nTagCount += _TagWorldBspTextures(pWorldData->OriginalBSP());
            if (pWorldData->m_pWorldBsp)
                nTagCount += _TagWorldBspTextures(pWorldData->m_pWorldBsp);
        }
    }

    // Go thru objects..
    pListHead = &m_ObjectMgr.m_ObjectLists[OT_MODEL].m_Head;
    for (pCur=pListHead->m_pNext; pCur != pListHead; pCur=pCur->m_pNext)
    {
        pModelInst = (ModelInstance*)pCur->m_pData;
        for (i=0; i < MAX_MODEL_TEXTURES; i++)
        {
            nTagCount += TagTexture(pModelInst->m_pSkins[i]);
        }
    }

    pListHead = &m_Sprites.m_Head;
    for (pCur=pListHead->m_pNext; pCur != pListHead; pCur=pCur->m_pNext)
    {
        nTagCount += _TagSpriteTextures((Sprite*)pCur->m_pData);
    }

    pListHead = &m_ObjectMgr.m_ObjectLists[OT_PARTICLESYSTEM].m_Head;
    for (pCur=pListHead->m_pNext; pCur != pListHead; pCur=pCur->m_pNext)
    {
        pSystem = (LTParticleSystem*)pCur->m_pData;
        nTagCount += TagTexture(pSystem->m_pCurTexture);
    }
}
Пример #6
0
/**
 * Initializes the data of the object.
 */
void PuzzleManager::Initialize() {
    if (!initialized_) {
        auto * core = CoreManager::Instance();

        // Get memory for the internal data.
        data_.reset(new InnerData());

        // Load the textures of the game.
        data_->tileset = core->LoadTexture("Content/Textures/Puzzle01.png");
        data_->puzzleSurface = core->LoadTexture("Content/Textures/Puzzle02.png");
        data_->puzzleTexture.Load(data_->puzzleSurface);

        // Set some initial data.
        int w = data_->puzzleTexture.Width(), h = data_->puzzleTexture.Height();
        data_->pieceSizes = sf::Vector2i(w / SIDE_LENGTH, h / SIDE_LENGTH);

        data_->puzzleArea = sf::IntRect(
            (CoreManager::LOW_WIDTH - w) / 2,
            ((CoreManager::LOW_HEIGHT - 24 - h) / 2) + 24,
            data_->puzzleTexture.Width(),
            data_->puzzleTexture.Height()
        );

        data_->gameState = INITIAL_STATE;
        data_->board = NPuzzle::Puzzle();

        // Setting the blank piece texture.
        const auto BORDER_COLOR = AtariPalette::Hue00Lum00;
        w = data_->pieceSizes.x, h = data_->pieceSizes.y;

        sf::Image blankImage;
        blankImage.create(w, h, AtariPalette::Hue00Lum14);

        for (int i = 0; i < w; ++i) {
            blankImage.setPixel(i, 0, BORDER_COLOR);
            blankImage.setPixel(i, h - 1, BORDER_COLOR);
        }
        for (int i = 0; i < h; ++i) {
            blankImage.setPixel(0, i, BORDER_COLOR);
            blankImage.setPixel(w - 1, i, BORDER_COLOR);
        }

        SharedTexture blankSurface = std::make_shared<sf::Texture>();
        blankSurface->loadFromImage(blankImage);
        data_->puzzleTextures[0].Load(blankSurface);

        // Setting the pieces textures.
        int x = w, y = 0;
        for (int i = 1; i < MAX_PIECES; ++i) {
            auto area = sf::IntRect(x, y, w, h);
            data_->puzzleTextures[i].Load(data_->puzzleSurface, area);
            x += w;
            if (x >= data_->puzzleArea.width) {
                x = 0; y += h;
            }
        }

        // Load the sounds of the game.
        data_->keyboardSound.Load("Content/Sounds/SharedKey.wav");
        data_->clickSound.Load("Content/Sounds/SharedClick.wav");
        data_->winSound.Load("Content/Sounds/PuzzleWin.wav");

        // Set the initialized flag.
        initialized_ = true;
    }
}
Пример #7
0
SceneTitle::SceneTitle(ApplicationController *controller) : Scene(controller) {
	LOGD("****SceneTitle");
	index = 0;
	
	//	HttpClient client;
	//	PngData png;
	//	Scene sn(controller);
	//
	//	class ps : public XMLParser {
	//		virtual void startElement(const XML_Char *name, const XML_Char *atts[]) {};
	//		virtual void endElement(const XML_Char *name) {};
	//		virtual void bodyElement(const XML_Char *s, int len) {};
	//	};
	//
	//	ps a;
	
	
	
	TextureManager *mgr = controller->texMgr;
	
	SharedTexture *tex = mgr->getSharedTexture(
											   "texture/chara_texture.png",
											   "texture/chara_texture.txt");
	
	ViewGroup *root = new ViewGroup(controller);
	
	//TextTexture使用サンプル
	//結構メモリを使用するので動的に生成するのはおすすめしない
    GCDrawText("Test", 60, 1.0, 1.0, 1.0);
    GCDrawText("Red", 60, 1.0, 0.0, 0.0);
    GCDrawText("日本語", 40, 1.0, 0.0, 1.0);
	
    //GCGetTextTextureでテクスチャを取得
    PackerTexture *strTexture = GCGetTextTexture();
	
    //TextureManagerにテクスチャを登録する。
    //登録しておかないと復帰時の再ロードが行われない。
    //任意の名前で登録する "TextTexture"
    //登録後は mgr->getSharedTexture("TextTexture",NULL); で取得できる
    mgr->addExtraTexture("TextTexture", strTexture);
	
    ImageView *textLabel = new ImageView(controller);
    textLabel->setFigure(strTexture->makePlate(0, 0));//登録順のインデックスもしくは、 strTexture->makePlate("Test") GCDrawText時の文字列を指定する
    textLabel->setTexture(&strTexture->getTexture());
    textLabel->setPosition(0, 1.0/controller->getAspect()-textLabel->size.y);
    root->addView(textLabel);
    textLabel->release();
	
    ImageView *textLabel2 = new ImageView(controller);
    textLabel2->setFigure(strTexture->makePlate(1, 0));
    textLabel2->setTexture(&strTexture->getTexture());
    textLabel2->setPosition(1.0 - textLabel2->size.x, 1.0/controller->getAspect()-textLabel2->size.y);
    root->addView(textLabel2);
    textLabel2->release();
	
    ImageView *textLabel3 = new ImageView(controller);
    textLabel3->setFigure(strTexture->makePlate(2, 0));
    textLabel3->setTexture(&strTexture->getTexture());
    textLabel3->setPosition(-1.0 + textLabel3->size.x, -1.0/controller->getAspect()+textLabel3->size.y);
    root->addView(textLabel3);
    textLabel3->release();
	
	static const char *filename[] = {
		"chara00.png",
		"chara01.png",
		"chara02.png",
		"chara03.png",
		"chara04.png",
		"chara05.png",
		"chara06.png",
		"chara07.png",
		"chara08.png",
		"chara09.png",
		"chara10.png",
		"chara11.png",
	};
	
	ImageAnimationView *animView = new ImageAnimationView(controller);
	for (int i = 0; i < 12; i++) {
		ImageView *image = new ImageView(controller);
		image->setFigure(tex->makePlate(filename[i]));
		image->setTexture(&tex->getTexture());
		animView->addView(image);
	}
	
	// 下
	animView->addAnimationFrame(1, 0, 0.12);
	animView->addAnimationFrame(1, 2, 0.12);
	// 上
	animView->addAnimationFrame(2, 9, 0.12);
	animView->addAnimationFrame(2, 11, 0.12);
	// 右
	animView->addAnimationFrame(3, 6, 0.12);
	animView->addAnimationFrame(3, 8, 0.12);
	// 左
	animView->addAnimationFrame(4, 3, 0.12);
	animView->addAnimationFrame(4, 5, 0.12);
	
	animView->setAnimationFrameIndex(1);
	animView->setUserID(10);
	
	//	animView->setRotate(30);
	animView->setScale(2.0, 2.0);
	
	root->addView(animView);
	
	
	
	
	Layer2D *layer = new Layer2D(controller);
	layer->setContentView(root);
	
	
	
	PhysicsLayer2D *pLayer = new PhysicsLayer2D(controller);
	ImageView *pv = new ImageView(controller);
	pv->setFigure(tex->makePlate(filename[0]));
	pv->setTexture(&tex->getTexture());
	pv->setPosition(0, 1);
	pv->setScale(2, 2);
	
	
	ImageView *wall = new ImageView(controller);
	//	wall->setFigure(tex->makePlate(filename[0]));
	wall->setPosition(0, -1/controller->getAspect());
	wall->setSize(1, 0.05);
	//	wall->setTexture(&tex->getTexture());
	
	
	
	PhysicsParams param;
	param.type = b2_dynamicBody;
	PhysicsParams param2;
	param2.type = b2_staticBody;
	
	pLayer->addBody(pv, param);
	pLayer->addBody(wall, param2);
	pv->release();
	wall->release();
	
	addLayer(1, layer);
	addLayer(2, pLayer);
	
	/*
	 Matrix3D *mtx1 = new Matrix3D();
	 mtx1->translate(1.5, 1, -1);
	 
	 // キューブ
	 Figure *fig = createBox(0.5, 0.5, 0.5);
	 fig->build();
	 Matrix3D *mtx2 = new Matrix3D();
	 mtx2->rotate(30, RotateDirX);
	 mtx2->translate(2, 3, 0);
	 RigidBodyOption opt;
	 opt.sizeX = 0.5;
	 opt.sizeY = 0.5;
	 opt.sizeZ = 0.5;
	 opt.mass = 3.0;
	 opt.restitution = 0.3;
	 opt.friction = 1.0;
	 
	 // 床
	 Figure *fig2 = createPlate(3, 3);
	 fig2->build();
	 fig2->transForm->rotate(90, RotateDirX);
	 RigidBodyOption opt2;
	 opt.restitution = 0.3;
	 opt.friction = 1.0;
	 
	 // 
	 WFObjLoader loader;
	 Figure *fig3 = loader.loadFile("model/kotoji.model");
	 fig3->build();
	 fig3->transForm->translate(-1.5, 5, 0);
	 
	 Light *light = new Light();
	 light->position.x = 0;
	 light->position.y = 4;
	 light->position.z = 5;
	 
	 Texture *tex2 = new Texture("texture/gclue_logo.png");
	 //
	 Layer3D *l3 = new Layer3D(controller);
	 l3->addLight(1, light);
	 
	 FigureInfo info = {NULL};
	 info.fig = fig;
	 info.mtx = mtx1;
	 l3->addFigure(info);
	 
	 info.tex = tex2;
	 info.mtx = mtx2;
	 opt.type = RigidBodyType_Box;
	 l3->addFigure(info, opt);
	 
	 info.fig = fig2;
	 info.mtx = NULL;
	 info.tex = NULL;
	 opt.type = RigidBodyType_Ground;
	 l3->addFigure(info, opt);
	 
	 info.fig = fig3;
	 info.mtx = NULL;
	 info.tex = NULL;
	 opt.type = RigidBodyType_Mesh;
	 l3->addFigure(info, opt);
	 
	 fig->release();
	 fig2->release();
	 fig3->release();
	 mtx1->release();
	 mtx2->release();
	 tex2->release();
	 
	 addLayer(0, l3);
	 */
}