MCPcopy Create free account
hub / github.com/OGRECave/ogre / createTextureAtlasObject

Method createTextureAtlasObject

Samples/ShaderSystem/src/ShaderSystem.cpp:1166–1271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1164}
1165
1166ManualObject* Sample_ShaderSystem::createTextureAtlasObject()
1167{
1168 TextureAtlasSamplerFactory * textureAtlasSamplerFactory =
1169 static_cast<TextureAtlasSamplerFactory *>(mShaderGenerator->getSubRenderStateFactory(TextureAtlasSampler::Type));
1170 TextureAtlasTablePtr textureAtlasTable(new TextureAtlasTable);
1171
1172 DataStreamPtr taiFile = Ogre::ResourceGroupManager::getSingleton().openResource("TextureAtlasSampleWrap.tai");
1173
1174 textureAtlasSamplerFactory->addTexutreAtlasDefinition(taiFile, textureAtlasTable);
1175
1176 //Generate the geometry that will seed the particle system
1177 ManualObject* textureAtlasObject = mSceneMgr->createManualObject("TextureAtlasObject");
1178
1179 int sliceSize = 30.0;
1180 int wrapSize = 5.0;
1181
1182 String curMatName;
1183
1184 // create original texture geometry
1185 for( size_t i = 0 ; i < textureAtlasTable->size() ; i++ )
1186 {
1187 bool changeMat = (curMatName != (*textureAtlasTable)[i].atlasTextureName);
1188
1189 if (changeMat)
1190 {
1191 if (curMatName.empty() == false) // we don't want to end before we begin
1192 {
1193 textureAtlasObject->end();
1194 }
1195
1196 curMatName = (*textureAtlasTable)[i].originalTextureName;
1197 createMaterialForTexture(curMatName, false);
1198 textureAtlasObject->begin(curMatName, RenderOperation::OT_TRIANGLE_LIST);
1199 }
1200
1201 // triangle 0
1202 textureAtlasObject->position(i * sliceSize, 0, 0); //Position
1203 textureAtlasObject->textureCoord(0,0); //UV
1204
1205 textureAtlasObject->position(i * sliceSize, 0, sliceSize); //Position
1206 textureAtlasObject->textureCoord(0,wrapSize); //UV
1207
1208 textureAtlasObject->position((i + 1) * sliceSize, 0 , sliceSize); //Position
1209 textureAtlasObject->textureCoord(wrapSize,wrapSize); //UV
1210
1211 // triangle 1
1212 textureAtlasObject->position(i * sliceSize, 0, 0); //Position
1213 textureAtlasObject->textureCoord(0,0); //UV
1214
1215 textureAtlasObject->position((i + 1) * sliceSize, 0, sliceSize); //Position
1216 textureAtlasObject->textureCoord(wrapSize,wrapSize); //UV
1217
1218 textureAtlasObject->position((i + 1) * sliceSize, 0, 0); //Position
1219 textureAtlasObject->textureCoord(wrapSize, 0); //UV
1220
1221 }
1222
1223 // create texture atlas geometry

Callers

nothing calls this directly

Calls 7

createManualObjectMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected