コード例 #1
0
void CameraAdapter::loadResource()
{
	mShader = gl::GlslProg( loadAsset( "shaders/passThru_vert.glsl"),  loadAsset( "shaders/shriner.frag") );		
	mShaderColor = gl::GlslProg( loadAsset( "shaders/passThru_vert_color.glsl"),  loadAsset( "shaders/shriner_color.frag") );	

	mPhotoDownloadFolder = Params::getPhotosStorageDirectory();
    if (!fs::exists(mPhotoDownloadFolder)) fs::create_directories(mPhotoDownloadFolder); 
}
コード例 #2
0
	BlackHole::BlackHole()
	{
		mMesh = gl::VboMesh::create(ObjLoader(loadAsset("meshes/MSH_CS.obj")));
		mTexMain = gl::Texture2d::create(loadImage(loadAsset("textures/TX_BlackHole.tif")));
		mTexMain->setWrap(GL_REPEAT, GL_REPEAT);

		mShader = gl::GlslProg::create(loadAsset("shaders/black_hole.vert"), loadAsset("shaders/black_hole.frag"));
		mShader->uniform("u_samplerRGBA", 0);

	}
コード例 #3
0
void HodginDidItApp::setupGraphics()
{
	mDepthBuffer = new uint16_t[mDepthW*mDepthH];
	mSurfDepth = Surface8u(mDepthW, mDepthH, true, SurfaceChannelOrder::RGBA);
	mBlendAmt = S_BLEND_MAX;

	mFont = gl::TextureFont::create(Font(loadAsset("IntelClear_RG.ttf"), 48));
	mHello = "Hello.";
	mQuestion = "Are You There?";
	mCursor = '_';
	mScreenText.clear();

	mTexBg = gl::Texture(loadImage(loadAsset("bg_test.png")));
	mPixelSize = Vec2f::one()/Vec2f(160,120);
}
コード例 #4
0
ファイル: llpreview.cpp プロジェクト: Katharine/kittyviewer
void LLPreview::onOpen(const LLSD& key)
{
	if (!getFloaterHost() && !getHost() && getAssetStatus() == PREVIEW_ASSET_UNLOADED)
	{
		loadAsset();
	}
}
コード例 #5
0
void fsExperiments::setup()
{
	gl::disableVerticalSync();

	GlobalData::get().mFaceShift.import( "export" );

	mEyeDistance = -300;

	mEffects.push_back( fsExpRef( new Android() ) );
	mEffects.push_back( fsExpRef( new Devil() ) );
	mEffects.push_back( fsExpRef( new Twister() ) );

	setupParams();
	setupVbo();
	setupEyes();
	setupEffects();

	Surface headImg = loadImage( loadAsset( "loki2.png" ) );
	ip::flipVertical( &headImg );
	GlobalData::get().mHeadTexture = gl::Texture( headImg );

	//GlobalData::get().mFaceShift.connect();

	gl::enable( GL_CULL_FACE );
}
コード例 #6
0
ファイル: llpreview.cpp プロジェクト: Katharine/kittyviewer
void LLPreview::setObjectID(const LLUUID& object_id)
{
	mObjectUUID = object_id;
	if (getAssetStatus() == PREVIEW_ASSET_UNLOADED)
	{
		loadAsset();
	}
}
コード例 #7
0
ファイル: llpreview.cpp プロジェクト: Boy/rainbow
void LLPreview::open()	/*Flawfinder: ignore*/
{
	if (!getFloaterHost() && !getHost() && getAssetStatus() == PREVIEW_ASSET_UNLOADED)
	{
		loadAsset();
	}
	LLFloater::open();		/*Flawfinder: ignore*/
}
コード例 #8
0
ファイル: llpreview.cpp プロジェクト: Katharine/kittyviewer
void LLPreview::setItem( LLInventoryItem* item )
{
	mItem = item;
	if (mItem && getAssetStatus() == PREVIEW_ASSET_UNLOADED)
	{
		loadAsset();
	}
}
コード例 #9
0
ファイル: Manager.hpp プロジェクト: Mezozoysky/tktk
 SharedAssetTypeT load( const std::string& name, bool reload = false ) noexcept
 {
     std::size_t index{ add( name ) };
     if ( mSharedAssets[ index ] == nullptr || reload )
     {
         mSharedAssets[ index ] = loadAsset( name );
     }
     return ( mSharedAssets[ index ] );
 }
コード例 #10
0
ファイル: sprite.cpp プロジェクト: frameland/Aiqo-Game-Source
Sprite::Sprite(Vec2f atPosition, const string& path)
{
    position = atPosition;
    image = loadImage(loadAsset(path));
    alpha = 1.0;
    color.set(1.0, 1.0, 1.0);
    scale.set(1.0, 1.0);
    rotation = 0;
}
コード例 #11
0
void HodginDidItApp::setupShaders()
{
	try
	{
		mShaderDisplace = gl::GlslProg(loadAsset("shaders/vert_passthru.glsl"), loadAsset("shaders/frag_displace.glsl"));
	}
	catch(gl::GlslProgCompileExc e)
	{
		console() << e.what() << endl;
	}
	try
	{
		mShaderRipple = gl::GlslProg(loadAsset("shaders/vert_passthru.glsl"), loadAsset("shaders/frag_ripple.glsl"));
	}
	catch(gl::GlslProgCompileExc e)
	{
		console() << e.what() << endl;
	}
}
コード例 #12
0
void LLPreviewNotecard::refreshFromInventory(const LLUUID& new_item_id)
{
	if (new_item_id.notNull())
	{
		mItemUUID = new_item_id;
		setKey(LLSD(new_item_id));
	}
	lldebugs << "LLPreviewNotecard::refreshFromInventory()" << llendl;
	loadAsset();
}
コード例 #13
0
void Wormhole3ContinuousOutputs::setup()
{
	setupParams();

	mReceived = vec3(1);
	mCamera.setPerspective(60.0f, getWindowAspectRatio(), 0.1f, 10.f);
	mCamera.lookAt(vec3(0, kEyeDepth, 0), vec3(), vec3(0, 1, 0));

	mShader = gl::GlslProg::create(loadAsset("shaders/wormhole.vert"), loadAsset("shaders/wormhole.frag"));

	auto mesh = gl::VboMesh::create(geom::Torus().center(vec3()).radius(0.5f, 0.49f).subdivisionsAxis(64).subdivisionsHeight(4));
	geom::BufferLayout attribs;
	attribs.append(geom::CUSTOM_0, 4, sizeof(Ring), offsetof(Ring, Tint), 1);
	attribs.append(geom::CUSTOM_1, 3, sizeof(Ring), offsetof(Ring, Position), 1);
	attribs.append(geom::CUSTOM_2, 2, sizeof(Ring), offsetof(Ring, Size), 1);

	mRings.push_back(Ring(Color(1, 0, 0), vec2(mReceived.x, mReceived.y)));
	mData = gl::Vbo::create(GL_ARRAY_BUFFER, mRings, GL_DYNAMIC_DRAW);
	mesh->appendVbo(attribs, mData);

	mDraw = gl::Batch::create(mesh, mShader, { {geom::CUSTOM_0, "i_Tint"},{ geom::CUSTOM_1, "i_Position" },{ geom::CUSTOM_2, "i_Size" } });

	setupListener();
}
コード例 #14
0
DOFFilter::DOFFilter() {
#ifdef ADVANCED_SHADER
  mGlslProg = gl::GlslProg::create(loadAsset("shaders/dofPass.vs"), loadAsset("shaders/dofPass.fs"));
#else
  mGlslProg = gl::GlslProg::create(loadAsset("shaders/basicBokeh.vs"), loadAsset("shaders/basicBokeh.fs"));
#endif
  mUseAutofocus = true;
  mManualFocalDepth = 0.95;
  mAutofocusCenter = vec2(0.5, 0.5);
  mAperture = 4.0;
  mMaxBlur = 1.5;
  mNumRings = 5;
  mNumSamples = 4;
  mHighlightThreshold = 0.5;
  mHighlightGain = 20.0;
  mBokehEdgeBias = 0.4;
  mBokehFringe = 0.5;
  mIsRetina = false;
  mFBOSamples = 1;

  createBuffers(mFBOSamples);
  
  mQuadBatch = gl::Batch::create(geom::Rect(), mGlslProg);
}
コード例 #15
0
    void PretzelColorPicker::setup(){
        
        bDragging = false;
        
        // load images
        mArrowTex = mGlobal->getTextureFromSkin( Rectf(28, 0, 42, 12) );
        mCrosshairTex = mGlobal->getTextureFromSkin( Rectf(44, 0, 52, 8) );
        
        mHueSurf = ci::Surface( loadImage( loadResource(PRETZEL_HSL_BAR) ) );
        mHueStrip = gl::Texture::create( mHueSurf );
        
        mBoxFbo = gl::Fbo::create(256, 256);
        mBoxShader = gl::GlslProg::create( loadAsset("shaders/colorpicker/colorpicker.vert"), loadAsset("shaders/colorpicker/colorpicker.frag") );
        redrawBox();
        
        // set rects
        mCollapsedRect.set(0, 0, mBounds.getWidth(), 23);
        mExpandedRect.set( 0, 0, mBounds.getWidth(), 23+150);
        
        int boxW = 36, boxH = 19;
        mColorPickRect = Rectf( mBounds.x2 - boxW, 0, mBounds.x2, boxH );
        mColorPickRect.offset( vec2(-10, -1) );
        
        int swatchSize = 150;
        mColorSwatchRect = Rectf(mColorPickRect.x2 - swatchSize, mColorPickRect.y2, mColorPickRect.x2, mColorPickRect.y2 + swatchSize);
        mColorSwatchRect.offset( vec2(-1,1) );
        
        Surface checkerSurf( mColorPickRect.getWidth(), mColorPickRect.getHeight(), false);
        ip::fill(&checkerSurf, Color(1,1,1) );
        
        // draw the checkboard pattern
        gl::color(Color::white());
        gl::drawSolidRect(mColorPickRect);
        for( int k=0; k<mColorPickRect.getHeight(); k+=4){
            int i = ((k/4)%2) * 4;
            for( ; i<mColorPickRect.getWidth(); i+=8){
                Rectf tmp(0,0,4,4);
                tmp.offset( vec2(i, k) );
                ip::fill(&checkerSurf, Color::gray(198.0/255.0), Area(tmp));
            }
        }

        mCheckerPat = gl::Texture::create(checkerSurf);
        
        mCrosshairPos = vec2(1,0);
    }
コード例 #16
0
void LLPreview::onOpen(const LLSD& key)
{
	if (!getFloaterHost() && !getHost() && getAssetStatus() == PREVIEW_ASSET_UNLOADED)
	{
		loadAsset();
	}

	// <FS:Ansariel> Multi preview layout fix; Anim, gesture and sound previews can't be resized
	if (getHost() &&
		(dynamic_cast<LLPreviewAnim*>(this) ||
		dynamic_cast<LLPreviewGesture*>(this) ||
		dynamic_cast<LLPreviewSound*>(this)))
	{
		getHost()->setCanResize(FALSE);
	}
	// </FS:Ansariel>
}
コード例 #17
0
void ResourceManager::initResources()
{
//    mFont = Font(loadAsset("Blender-BOOK.ttf"), 14);
//    mFont = Font(loadAsset("Blender-BOLD.ttf"), 14);
    mFont = Font(loadAsset("Overlock-Bold.ttf"), 12);
    gl::TextureFont::Format format;
//    format.premultiply();
    mTextureFont = gl::TextureFont::create(mFont, format);
    
    mPlusTexture = loadImage(getAssetPath("plus.png"));
    
    colors.push_back(Color::hex(0xdc534e));
    colors.push_back(Color::hex(0x5f78b4));
    colors.push_back(Color::hex(0x5b3a6f));
    colors.push_back(Color::hex(0xbaa326));
    colors.push_back(Color::hex(0xF26835));
    
    ResourceManager::mainIsolate = v8::Isolate::New();
    ResourceManager::mainIsolate->Enter();
}
コード例 #18
0
void ReymentaServerApp::loadShader(const fs::path &fragment_path)
{
	try
	{	// load and compile our shader
		mProg = gl::GlslProg::create(gl::GlslProg::Format().vertex(loadAsset("default.vs"))
			.fragment(loadFile(fragment_path)));
		// no exceptions occurred, so store the shader's path for reloading on keypress
		//mCurrentShaderPath = fragment_path;
		mProg->uniform("iResolution", vec3(getWindowWidth(), getWindowHeight(), 0.0f));
		//const vector<Uniform> & unicorns = mProg->getActiveUniforms();
	}
	catch (ci::gl::GlslProgCompileExc &exc)
	{
		console() << "Error compiling shader: " << exc.what() << endl;
	}
	catch (ci::Exception &exc)
	{
		console() << "Error loading shader: " << exc.what() << endl;
	}
}
コード例 #19
0
/* setupScene() impelmented by user as if it where a normal application*/
void SystemCinderApp::setupScene()
{
	/* Following scene was created from Cinder's sample application CubeMappingApp */
	mCamFbo.setFov(45.0f);
	mCamFbo.setAspectRatio(getWindowAspectRatio());

	mCamFboUi = CameraUi(&mCamFbo, getWindow());
	mCubeMap = gl::TextureCubeMap::create(loadImage(loadAsset("env_map.jpg")), gl::TextureCubeMap::Format().mipmap());
#if defined (CINDER_GL_ES)
	auto envMapGlsl = gl::GlslProg::create(loadAsset("env_map_es2.vert"), loadAsset("env_map_es2.frag"));
	auto skyBoxGlsl = gl::GlslProg::create(loadAsset("sky_box_es2.vert"), load Asset("sky_box_es2.frag"));
#else
	auto envMapGlsl = gl::GlslProg::create(loadAsset("env_map.vert"), loadAsset("env_map.frag"));
	auto skyBoxGlsl = gl::GlslProg::create(loadAsset("sky_box.vert"), loadAsset("sky_box.frag"));
#endif

	mTeapotBatch = gl::Batch::create(geom::Teapot().subdivisions(7), envMapGlsl);
	//send uniform to a shader
	mTeapotBatch->getGlslProg()->uniform("uCubeMapTex", 0);

	mSkyBoxBatch = gl::Batch::create(geom::Cube(), skyBoxGlsl);
	mSkyBoxBatch->getGlslProg()->uniform("uCubeMapTex", 0);

}
コード例 #20
0
ファイル: tracking.cpp プロジェクト: FlowBo/CSM_OP_
void tracking::setup(){
    
    mWindow = getWindow();
    mCbMouseDown = mWindow->getSignalMouseDown().connect( std::bind( &tracking::mouseDown, this, std::placeholders::_1 ) );
    mCbMouseDrag = mWindow->getSignalMouseDrag().connect( std::bind( &tracking::mouseDrag, this, std::placeholders::_1 ) );
    mCbMouseMove = mWindow->getSignalMouseMove().connect( std::bind( &tracking::mouseMove, this, std::placeholders::_1 ) );
    mCbMouseUp = mWindow->getSignalMouseUp().connect( std::bind( &tracking::mouseUp, this, std::placeholders::_1 ) );
    
    mCbKeyDown = mWindow->getSignalKeyDown().connect( std::bind( &tracking::keyDown, this, std::placeholders::_1 ) );
    mCbKeyUp = mWindow->getSignalKeyUp().connect( std::bind( &tracking::keyUp, this, std::placeholders::_1 ) );
    mCbResize = mWindow->getSignalResize().connect(std::bind(&tracking::resize,this));
    
    mUseBeginEnd = false;
    // initialize warps
    mSettings = getAssetPath( "" ) / "warps.xml";
    if( fs::exists( mSettings ) ) {
        mWarps = Warp::readSettings( loadFile( mSettings ) );
    }
    else {
        mWarps.push_back( WarpPerspective::create() );
    }
    
    mTexturePlaceholder = gl::Texture::create(500,500);

    // load test image
    try {
        mImage = gl::Texture::create( loadImage( loadAsset( "help.png" ) ),
                                     gl::Texture2d::Format().loadTopDown().mipmap( true ).minFilter( GL_LINEAR_MIPMAP_LINEAR ) );
        
        mSrcArea = mImage->getBounds();
        
        // adjust the content size of the warps
        Warp::setSize( mWarps, mImage->getSize() );
    }
    catch( const std::exception &e ) {
        console() << e.what() << std::endl;
    }
}
コード例 #21
0
ファイル: title.cpp プロジェクト: Lacty/Connection
Title::Title(AppNative* app) :
SceneBase(app, Fade(Fade::Type::In)),
font_(loadAsset("rounded-l-mplus-1c-regular.ttf")),
pos_(0, 0),
net_("127.0.0.1", 12345) {
  font_.setSize(50);

  recv_.init(54321);

  enable_ = true;
  send_th_ = std::thread([&] {
    while (true) {
      picojson::object obj;
      obj.emplace(std::make_pair("posx", pos_.x));
      obj.emplace(std::make_pair("posy", pos_.y));

      picojson::value val(obj);

      net_.send(val.serialize());
      if (!enable_) break;
    }
  });

  recv_th_ = std::thread([&] {
    while (true) {
      std::string data;
      recv_ >> data;
      if (data.size() < 8) continue;
      picojson::value val;
      picojson::parse(val, data);
      picojson::object obj(val.get<picojson::object>());

      e_pos_.x = obj["posx"].get<double>();
      e_pos_.y = obj["posy"].get<double>();

      if (!enable_) break;
    }
  });
コード例 #22
0
void DataManager::loadDataFile( string path ){
    XmlTree doc( loadFile( getAssetPath(path) ) );
    DataSourceRef pathRef = loadAsset(path);
    XmlTree data( pathRef );
    parseData(data);
}
コード例 #23
0
void LLPreviewNotecard::refreshFromInventory()
{
	lldebugs << "LLPreviewNotecard::refreshFromInventory()" << llendl;
	loadAsset();
}
コード例 #24
0
void ReymentaServerApp::setup()
{
	// parameters
	mParameterBag = ParameterBag::create();
	mParameterBag->mLiveCode = true;
	mParameterBag->mRenderThumbs = false;
	loadShader(getAssetPath("default.fs"));
	// utils
	mBatchass = Batchass::create(mParameterBag);
	CI_LOG_V("reymenta setup");
	mFirstLaunch = true;

	setWindowSize(mParameterBag->mMainWindowWidth, mParameterBag->mMainWindowHeight);
	// 12 fps is enough for a router
	setFrameRate(120.0f);
	setWindowPos(ivec2(0, 40));

	// setup shaders and textures
	mBatchass->setup();

	mParameterBag->mMode = MODE_WARP;
	mParameterBag->iResolution.x = mParameterBag->mRenderWidth;
	mParameterBag->iResolution.y = mParameterBag->mRenderHeight;
	mParameterBag->mRenderResolution = ivec2(mParameterBag->mRenderWidth, mParameterBag->mRenderHeight);

	CI_LOG_V("createRenderWindow, resolution:" + toString(mParameterBag->iResolution.x) + "x" + toString(mParameterBag->iResolution.y));
	mParameterBag->mRenderResoXY = vec2(mParameterBag->mRenderWidth, mParameterBag->mRenderHeight);
	mParameterBag->mRenderPosXY = ivec2(mParameterBag->mRenderX, mParameterBag->mRenderY);

	// instanciate the console class
	mConsole = AppConsole::create(mParameterBag, mBatchass);

	// imgui
	margin = 3;
	inBetween = 3;
	// mPreviewFboWidth 80 mPreviewFboHeight 60 margin 10 inBetween 15 mPreviewWidth = 160;mPreviewHeight = 120;
	w = mParameterBag->mPreviewFboWidth + margin;
	h = mParameterBag->mPreviewFboHeight * 2.3;
	largeW = (mParameterBag->mPreviewFboWidth + margin) * 4;
	largeH = (mParameterBag->mPreviewFboHeight + margin) * 5;
	largePreviewW = mParameterBag->mPreviewWidth + margin;
	largePreviewH = (mParameterBag->mPreviewHeight + margin) * 2.4;
	displayHeight = mParameterBag->mMainDisplayHeight - 50;
	mouseGlobal = false;
	showConsole = showGlobal = showTextures = showAudio = showMidi = showChannels = showShaders = true;
	showTest = showTheme = showOSC = showFbos = false;
	/* set ui window and io events callbacks
	   with autorender == false, we have to use NewFrame and Render
	   but we have access to DrawData to send to remoteImGui
	   void Renderer::initFontTexture()
	   {
	   unsigned char* pixels;
	   int width, height;
	   ImGui::GetIO().Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
	   mFontTexture = gl::Texture::create( pixels, GL_RGBA, width, height, gl::Texture::Format().magFilter(GL_LINEAR).minFilter(GL_LINEAR) );
	   ImGui::GetIO().Fonts->ClearTexData();
	   ImGui::GetIO().Fonts->TexID = (void *)(intptr_t) mFontTexture->getId();
	   }
	  
	ui::initialize(ui::Options().autoRender(false).fonts({
		{ getAssetPath("KontrapunktBob-Light.ttf"), 12 },
		{ getAssetPath("KontrapunktBob-Bold.ttf"), 20 },
		{ getAssetPath("DroidSans.ttf"), 12 }
	})
	.fontGlyphRanges("DroidSans", { 0xf000, 0xf06e, 0 })); */
	ui::initialize(ui::Options().autoRender(false));

	// warping
	mUseBeginEnd = false;
	updateWindowTitle();
	disableFrameRate();

	// initialize warps
	mSettings = getAssetPath("") / "warps.xml";
	if (fs::exists(mSettings)) {
		// load warp settings from file if one exists
		mWarps = Warp::readSettings(loadFile(mSettings));
	}
	else {
		// otherwise create a warp from scratch
		mWarps.push_back(WarpBilinear::create());
		mWarps.push_back(WarpPerspective::create());
		mWarps.push_back(WarpPerspectiveBilinear::create());
	}

	// load test image
	try {
		mImage = gl::Texture::create(loadImage(loadAsset("help.jpg")),
			gl::Texture2d::Format().loadTopDown().mipmap(true).minFilter(GL_LINEAR_MIPMAP_LINEAR));

		//mSrcArea = mImage->getBounds();

		// adjust the content size of the warps
		Warp::setSize(mWarps, mImage->getSize());
	}
	catch (const std::exception &e) {
		console() << e.what() << std::endl;
	}
	mSrcArea = Area(0, 0, mParameterBag->mFboWidth*4, mParameterBag->mFboHeight*4);
	mMesh = gl::VboMesh::create(geom::Rect());
}
コード例 #25
0
void addMaterial(zoneInfo_t* info, const char* name, char* data, size_t dataLen)
{
	if(parseMatFile(data, dataLen) < 0) return;

	// load up the techset
	char techsetfname [128];
	_snprintf(techsetfname, 128, "techsets/%s.techset", techsetName);
	loadAsset(info, ASSET_TYPE_TECHSET, techsetfname, techsetName);

	int asset = addAsset(info, ASSET_TYPE_MATERIAL, name, NULL, 0);

	BUFFER* buf = new BUFFER(4096);

	Material* mat = new Material;
	memset(mat, 0, sizeof(Material));
	mat->name = (char*)0xFFFFFFFF;
	if(materialUsage == MATERIAL_USAGE_UI)
	{
		mat->flags = 0x2F;
		mat->animationX = 1;
		mat->animationY = 1;
		mat->unknown2 = 0xFFFFFFFF;
		mat->unknown3 = 0xFFFFFF00;
		memset(mat->unknown4, 0xFF, sizeof(mat->unknown4));
		mat->numMaps = materialMapCount;
		mat->stateMapCount = 1;
		mat->unknown6 = 3;
		mat->unknown7 = 4;
	}

	// null dem pointers!
	mat->techniqueSet = (MaterialTechniqueSet*)0x0;//0xFFFFFFFF;
	mat->maps = (MaterialTextureDef*)0xFFFFFFFF;
	mat->stateMap = (void*)0xFFFFFFFF;

	buf->write(mat, sizeof(Material), 1);
	buf->write((void*)name, strlen(name) + 1, 1);

	// techset
	int assetPatchTo = containsAsset(info, ASSET_TYPE_TECHSET, techsetName);
	addFixup(info, asset, 80, assetPatchTo);

	// maps
	for(int i=0; i<materialMapCount; i++)
	{
		MaterialTextureDef* tex = new MaterialTextureDef;
		memset(tex, 0, sizeof(MaterialTextureDef));
		tex->firstCharacter = materialMaps[i][0];
		tex->secondLastCharacter = materialMaps[i][strlen(materialMaps[i])];
		tex->typeHash = R_HashString(materialMaps[i]);
		tex->image = (GfxImage*)0xFFFFFFFF;
		tex->textureType = 0xE2;

		buf->write(tex, sizeof(MaterialTextureDef), 1);

		GfxImage* img = new GfxImage;
		memset(img, 0, sizeof(GfxImage));
		img->depth = 1;
		img->textureType = 3; // 2d texture
		img->textureType2 = 3;
		img->texture = (GfxImageLoadDef*)0xFFFFFFFF;
		img->name = (char*)0xFFFFFFFF;
		img->width = iwiHeaders[i].xsize;
		img->height = iwiHeaders[i].ysize;

		buf->write(img, sizeof(GfxImage), 1);
		buf->write((void*)materialTextureNames[i], strlen(materialTextureNames[i]) + 1, 1);

		GfxImageLoadDef * def = new GfxImageLoadDef;
		memset(def, 0, sizeof(GfxImageLoadDef));
		int format = 0;
		switch(iwiHeaders[i].format)
		{
		case IWI_ARGB:
			format = 21;
			break;
		case IWI_RGB8:
			format = 20;
			break;
		case IWI_DXT1:
			format = 0x31545844;
			break;
		case IWI_DXT3:
			format = 0x33545844;
			break;
		case IWI_DXT5:
			format = 0x35545844;
			break;
		}
		def->format = format;
		def->mipLevels = 1;

		buf->write(def, sizeof(GfxImageLoadDef), 1);
	}

	// unknown 8 goes here whenever we use it

	// statemap
	if(materialUsage == MATERIAL_USAGE_UI)
	{
		char statemap[] = {0x65, 0x51, 0x12, 0x18, 0x02, 0x00, 0x0E, 0xE0 };
		buf->write(statemap, 8, 1);
	}

	buf->resize(-1);

	// fix the data
	setAssetData(info, asset, buf->data(), buf->getsize());
}
コード例 #26
0
ファイル: model.cpp プロジェクト: Lacty/GetSpeed
Model::Model(const std::string& path) {
  std::ostringstream json_path;
  json_path << "Model/" << path << ".json";

  // Jsonからデータ取得
  JsonTree data(loadAsset(json_path.str()));


  //-------------------------------------------------------
  // ワイヤーフレームの情報

  // 頂点データの数を取得
  int Vertex_Num = data["vertex_num"].getValue<int>();

  // 頂点データの取得
  std::vector<Vec3f> v;
  for (int i = 0; i < Vertex_Num; ++i) {
    std::ostringstream path;
    path << "v" << i;
    v.push_back({ Vec3f(data[path.str()]["x"].getValue<float>(),
                        data[path.str()]["y"].getValue<float>(),
                        data[path.str()]["z"].getValue<float>()) });
  }

  // ワイヤーの色を取得
  ColorA wire_color(data["wire_color"]["r"].getValue<float>(),
                    data["wire_color"]["g"].getValue<float>(),
                    data["wire_color"]["b"].getValue<float>(),
                    data["wire_color"]["a"].getValue<float>());


  // Face(ポリゴン)の数を取得
  int Face_Num = data["face_num"].getValue<int>();

  // Face(ポリゴン)の頂点座標を取得
  for (int i = 0; i < Face_Num; ++i) {
    std::ostringstream path;
    path << "f" << i;
    faces.push_back({ { Vec3f(v[data[path.str()]["v1"].getValue<int>()]) },
                      { Vec3f(v[data[path.str()]["v2"].getValue<int>()]) },
                      { Vec3f(v[data[path.str()]["v3"].getValue<int>()]) },
                      { wire_color } });
  }


  //-------------------------------------------------------
  // Meshの情報

  // ポリゴンの頂点座標を取得
  std::vector<Vec3f> vertices;
  for (int i = 0; i < Face_Num; ++i) {
    vertices.push_back({ Vec3f(faces[i].v1) });
    vertices.push_back({ Vec3f(faces[i].v2) });
    vertices.push_back({ Vec3f(faces[i].v3) });
  }
  
  // 頂点座標の登録
  m_mesh.appendVertices(&vertices[0], vertices.size());


  // 頂点色を取得
  std::vector<ColorA> color;
  for (int i = 0; i < Vertex_Num; ++i) {
    std::ostringstream path;
    path << "c" << i;
    color.push_back({ ColorA(data[path.str()]["r"].getValue<float>(),
                             data[path.str()]["g"].getValue<float>(),
                             data[path.str()]["b"].getValue<float>(),
                             data[path.str()]["a"].getValue<float>()) });
  }

  // ポリゴンの頂点色情報を取得
  std::vector<ColorA> colors;
  for (int i = 0; i < Face_Num; ++i) {
    std::ostringstream path;
    path << "vc" << i;
    colors.push_back({ color[data[path.str()]["c1"].getValue<int>()] });
    colors.push_back({ color[data[path.str()]["c2"].getValue<int>()] });
    colors.push_back({ color[data[path.str()]["c3"].getValue<int>()] });
  }

  // 頂点色を登録
  m_mesh.appendColorsRgba(&colors[0], colors.size());


  // ポリゴン結合番号情報
  std::vector<uint32_t> indices;

  // Face_Num(ポリゴンの数) * 3 => ポリゴンそれぞれの頂点数を足したもの
  for (int i = 0; i < (Face_Num * 3); ++i) {
    indices.push_back(i);
  }

  // 結合番号を登録
  m_mesh.appendIndices(&indices[0], indices.size());
}