コード例 #1
0
ファイル: THMesh.cpp プロジェクト: SZSilence06/THXYY
	bool Mesh::AssimpLoader::LoadAssimpMesh(Ptr<Mesh> mesh, const aiMesh* aimesh, const aiScene* scene)
	{
		auto assetManager = AssetManager::GetInstance();

		for (size_t i = 0; i < aimesh->mNumVertices; i++)
		{
			mesh->vertices.push_back(Vector3f(aimesh->mVertices[i].x, aimesh->mVertices[i].y, aimesh->mVertices[i].z));
			mesh->normals.push_back(Vector3f(aimesh->mNormals[i].x, aimesh->mNormals[i].y, aimesh->mNormals[i].z));
			mesh->tangents.push_back(Vector3f(aimesh->mTangents[i].x, aimesh->mTangents[i].y, aimesh->mTangents[i].z));

			for (size_t j = 0; j < aimesh->GetNumUVChannels() && j < 4; j++)
			{
				mesh->uv[j].push_back(Vector2f(aimesh->mTextureCoords[j][i].x, aimesh->mTextureCoords[j][i].y));
			}
		}

		for (size_t i = 0; i < aimesh->mNumFaces; i++)
		{
			for (size_t j = 0; j < aimesh->mFaces[i].mNumIndices; j++)
				mesh->triangles.push_back(aimesh->mFaces[i].mIndices[j]);
		}

		// TODO : 支持更多材质样式
		if (aimesh->mMaterialIndex >= 0)
		{
			aiMaterial* material = scene->mMaterials[aimesh->mMaterialIndex];

			aiColor4D diffuse, specular, ambient, emissive;
			ai_real shininess;
			unsigned int max = 1;
			if (AI_SUCCESS == aiGetMaterialColor(material, AI_MATKEY_COLOR_DIFFUSE, &diffuse))
				mesh->material.diffuse = Vector4f(diffuse.r, diffuse.g, diffuse.b, diffuse.a);
			if (AI_SUCCESS == aiGetMaterialColor(material, AI_MATKEY_COLOR_SPECULAR, &specular))
				mesh->material.specular = Vector4f(specular.r, specular.g, specular.b, specular.a);
			if (AI_SUCCESS == aiGetMaterialColor(material, AI_MATKEY_COLOR_AMBIENT, &ambient))
				mesh->material.ambient = Vector4f(ambient.r, ambient.g, ambient.b, ambient.a);
			if (AI_SUCCESS == aiGetMaterialColor(material, AI_MATKEY_COLOR_EMISSIVE, &emissive))
				mesh->material.emissive = Vector4f(emissive.r, emissive.g, emissive.b, emissive.a);
			if (AI_SUCCESS == aiGetMaterialFloatArray(material, AI_MATKEY_SHININESS, &shininess, &max))
				mesh->material.shininess = shininess;

			for (size_t i = 0; i < material->GetTextureCount(aiTextureType_DIFFUSE); i++)
			{
				aiString path;
				material->GetTexture(aiTextureType_DIFFUSE, i, &path);
				String fullPath = this->dir + "/" + path.data;
				Ptr<Texture> tex = assetManager->CreateTextureFromFile(fullPath);
				if (tex == nullptr)
					return false;

				mesh->material.texture = tex;

				break;  // 目前只支持一张diffuse texture
			}
		}

		return true;
	}
コード例 #2
0
ファイル: Player.cpp プロジェクト: Angeldude/essentialmath
//-------------------------------------------------------------------------------
// @ Player::Player()
//-------------------------------------------------------------------------------
// Constructor
//-------------------------------------------------------------------------------
Player::Player()
{
    mRotate.Identity();
    mScale = 1.0f;
    mTranslate.Zero();

    mRadius = 3.0f;

    mCylinderVerts = 0;
    mCylinderIndices = 0;

    mBlendMode = kOpacityBlendMode;

    unsigned int i;

    mBaseTexture = nullptr;

    for (i = 0; i < NUM_BLEND_TEX; i++)
        mBlendTextures[i] = nullptr;

    mCurrentBlendTexIndex = 0;

    mBaseTexture = CreateTextureFromFile("image.tga");
    mBlendTextures[0] = CreateTextureFromFile("fence.tga");
    mBlendTextures[1] = CreateTextureFromFile("darkdots.tga");
    mBlendTextures[2] = CreateTextureFromFile("glowdots.tga");

    mShader = IvRenderer::mRenderer->GetResourceManager()->CreateShaderProgram(
        IvRenderer::mRenderer->GetResourceManager()->CreateVertexShaderFromFile(
        "textureShader"),
        IvRenderer::mRenderer->GetResourceManager()->CreateFragmentShaderFromFile(
        "textureShader"));

    mTextureUniform = mShader->GetUniform("Texture");

    mTextureUniform->SetValue(mBaseTexture);

    IvRenderer::mRenderer->SetShaderProgram(mShader);

    CreateCylinder();
}   // End of Player::Player()
コード例 #3
0
ファイル: Stage01.cpp プロジェクト: SZSilence06/THXYY
void Stage01::OnLoad()
{
	auto assetManager = AssetManager::GetInstance();
	auto engine = STGEngine::GetInstance();

	texRoad = assetManager->CreateTextureFromFile("res/background/stage01/road.jpg");
	if (texRoad == nullptr)
	{
		THMessageBox(ExceptionManager::GetInstance()->GetException()->GetInfo());
	}

	texLogo = assetManager->CreateTextureFromFile("res/front/logo/stage01_logo.png");
	if (texLogo == nullptr)
	{
		THMessageBox(ExceptionManager::GetInstance()->GetException()->GetInfo());
	}

	sky = assetManager->CreateCubeMapFromFile("res/background/stage01/skybox/BluePinkNebular_front.jpg",
		"res/background/stage01/skybox/BluePinkNebular_back.jpg",
		"res/background/stage01/skybox/BluePinkNebular_left.jpg",
		"res/background/stage01/skybox/BluePinkNebular_right.jpg",
		"res/background/stage01/skybox/BluePinkNebular_top.jpg",
		"res/background/stage01/skybox/BluePinkNebular_bottom.jpg");
	if (sky == nullptr)
	{
		THMessageBox(ExceptionManager::GetInstance()->GetException()->GetInfo());
	}

	house = Mesh::CreateMeshFromFile("res/model/house/house.x");
	if (house == nullptr)
	{
		THMessageBox(ExceptionManager::GetInstance()->GetException()->GetInfo());
	}

	this->SetBGM(Audio::GetInstance()->CreateMusic("bgm/stage01.wav"));
}
コード例 #4
0
ファイル: graphics.cpp プロジェクト: nakunaku794/lobster
    STARTDECL(gl_loadtexture) (Value &name)
    {
        TestGL();

        ValueRef nameref(name);
        auto it = texturecache.find(name.sval->str());
        if (it != texturecache.end())
        {
            return Value((int)it->second);
        }

        uint id = CreateTextureFromFile(name.sval->str());

        if (id) texturecache[name.sval->str()] = id;

        return Value((int)id);
    }
コード例 #5
0
ファイル: Actor.cpp プロジェクト: csy200926/MyEngine
Actor::Actor(const char * textureName,const float width,const float height, bool i_is3DObj): IIsA("Actor")
{

    is3DObj = i_is3DObj;
    init();

    isTriggerBox = false;

    boundingBox.center.x = 0.0f;
    boundingBox.center.y = 0.0f;
    boundingBox.center.z = 0.0f;

    boundingBox.HalfX = width * 0.5f;
    boundingBox.HalfY = height * 0.5f;
    boundingBox.HalfZ = 25.0f;

    if (!is3DObj)
    {

        struct Cheesy::Point2D		center( 0.0f, 0.0f );
        struct Cheesy::Point2D		size( width, height );
        struct Cheesy::ColorRGBA	white( 255, 255, 255, 255 );
        Cheesy::UVSet UVs = { Cheesy::UV( 0.0f, 0.0f ), Cheesy::UV( 1.0f, 0.0f ), Cheesy::UV( 0.0f, 1.0f ), Cheesy::UV( 1.0f, 1.0f ) };


        //*******For Test Only***********

        Cheesy::Texture * pSampleTexture = CreateTextureFromFile(textureName);
        m_pSprite = Cheesy::Sprite::Create( center, 0.1f, size, white, *pSampleTexture, UVs );
        pSampleTexture->Release();

        //********************************
    } else
    {
        meshName = "MeshCube";
        materialName = textureName;

    }



}
コード例 #6
0
void BitmapImage::Init(void)
{
	bIsAnimatedGif = false;

    if(lpGifData)
    {
        Free(lpGifData);
        lpGifData = NULL;
    }

    animationTimes.Clear();

    delete texture;
    texture = NULL;

    CTSTR lpBitmap = filePath;
    if(!lpBitmap || !*lpBitmap)
    {
		Log::writeError(LOG_RTSPSERV, 1, "BitmapImage::Init: Empty path");
        CreateErrorTexture();
        return;
    }

    if(!bIsAnimatedGif)
    {
		UINT Width, Height;
		texture = CreateTextureFromFile(lpBitmap, TRUE, Width, Height);
        if(!texture)
        {
            Log::writeError(LOG_RTSPSERV,1,"BitmapImage::Init: could not create texture '%s'", WcharToAnsi(lpBitmap).c_str());
            CreateErrorTexture();
            return;
        }

		fullSize.x = Width;
		fullSize.y = Height;
    }
	
}
コード例 #7
0
void CSLiveManager::BulidD3D()
{
	Log::writeMessage(LOG_RTSPSERV, 1, "LiveSDK_Log:%s Invoke begin!", __FUNCTION__);
	bUseBack = BSParam.LiveSetting.bUseLiveSec;
	if (bUseBack)
	{
		if (BSParam.LiveSetting.Width < BSParam.LiveSetting.WidthSec || BSParam.LiveSetting.Height < BSParam.LiveSetting.HeightSec)
		{
			baseCX = BSParam.LiveSetting.WidthSec;
			baseCY = BSParam.LiveSetting.HeightSec;

			baseCX_back = BSParam.LiveSetting.Width;
			baseCY_back = BSParam.LiveSetting.Height;
		}
		else
		{
			baseCX = BSParam.LiveSetting.Width;
			baseCY = BSParam.LiveSetting.Height;

			baseCX_back = BSParam.LiveSetting.WidthSec;
			baseCY_back = BSParam.LiveSetting.HeightSec;
		}

// 		baseCX_back = BSParam.LiveSetting.WidthSec;
// 		baseCY_back = BSParam.LiveSetting.HeightSec;
// 		baseCX = BSParam.LiveSetting.Width;
// 		baseCY = BSParam.LiveSetting.Height;
	}
	else
	{

		if (baseCX == BSParam.LiveSetting.Width && baseCY == BSParam.LiveSetting.Height)
			return;

		baseCX = BSParam.LiveSetting.Width;
		baseCY = BSParam.LiveSetting.Height;
	}

	baseCX = MIN(MAX(baseCX, 128), 4096);
	baseCY = MIN(MAX(baseCY, 128), 4096);

	baseCX_back = MIN(MAX(baseCX_back, 128), 4096);
	baseCY_back = MIN(MAX(baseCY_back, 128), 4096);

	scaleCX = double(baseCX);
	scaleCY = double(baseCY);

	//align width to 128bit for fast SSE YUV4:2:0 conversion
	outputCX = scaleCX & 0xFFFFFFFC;
	outputCY = scaleCY & 0xFFFFFFFE;

	outputCX_back = baseCX_back & 0xFFFFFFFC;
	outputCY_back = baseCY_back & 0xFFFFFFFE;

	for (int i = 0; i < 2; ++i)
	{
		if (mainRenderTextures[i])
		{
			delete mainRenderTextures[i];
			mainRenderTextures[i] = NULL;
		}
		mainRenderTextures[i] = CreateRenderTarget(baseCX, baseCY, GS_BGRA, FALSE);
	}


	if (transitionTexture)
	{
		delete transitionTexture;
		transitionTexture = NULL;
	}

	transitionTexture = CreateRenderTarget(baseCX, baseCY, GS_BGRA, FALSE);

	if (transNewTexture)
	{
		delete transNewTexture;
		transNewTexture = NULL;
	}

	transNewTexture = CreateRenderTarget(baseCX, baseCY, GS_BGRA, FALSE);

	if (PreRenderTexture)
	{
		delete PreRenderTexture;
		PreRenderTexture = NULL;
	}

	PreRenderTexture = CreateRenderTarget(baseCX, baseCY, GS_BGRA, FALSE);

	if (yuvRenderTextures)
	{
		delete yuvRenderTextures;
		yuvRenderTextures = NULL;
	}
	yuvRenderTextures = CreateRenderTarget(outputCX, outputCY, GS_BGRA, FALSE);

	if (copyTextures)
	{
		delete copyTextures;
		copyTextures = NULL;
	}

	copyTextures = CreateTextureRead(outputCX, outputCY);


	if (copyRGBTexture)
	{
		delete copyRGBTexture;
		copyRGBTexture = NULL;
	}

	copyRGBTexture = CreateTextureRead(outputCX, outputCY);

	if (bUseBack)
	{
		if (yuvRenderTextures_back)
		{
			delete yuvRenderTextures_back;
			yuvRenderTextures_back = NULL;
		}
		yuvRenderTextures_back = CreateRenderTarget(outputCX_back, outputCY_back, GS_BGRA, FALSE);

		if (copyTextures_back)
		{
			delete copyTextures_back;
			copyTextures_back = NULL;
		}

		copyTextures_back = CreateTextureRead(outputCX_back, outputCY_back);

	}

	if (SDITexture)
	{
		delete SDITexture;
		SDITexture = NULL;
	}

	UINT Width, Heigth;

	SDITexture = CreateTextureFromFile(L"./img/SDIOUT.png",FALSE,Width,Heigth);

	if (ss)
	{
		delete ss;
		ss = NULL;
	}

	SamplerInfo si;
	zero(&si, sizeof(si));
	si.filter = GS_FILTER_LINEAR;

	si.addressU = GS_ADDRESS_BORDER;
	si.addressV = GS_ADDRESS_BORDER;
	ss = CreateSamplerState(si);

	colorDesc.fullRange = false;
	colorDesc.primaries = ColorPrimaries_BT709;
	colorDesc.transfer = ColorTransfer_IEC6196621;
	colorDesc.matrix = outputCX >= 1280 || outputCY > 576 ? ColorMatrix_BT709 : ColorMatrix_SMPTE170M;

	Log::writeMessage(LOG_RTSPSERV, 1, "LiveSDK_Log:%s Invoke end!", __FUNCTION__);
}