Viola texture
This commit is contained in:
parent
f7c9c0c31f
commit
b092ceaf14
@ -225,6 +225,13 @@ namespace ZL
|
||||
vertices[i] = Vector3f{floatValues[0], floatValues[1], floatValues[2]};
|
||||
}
|
||||
|
||||
|
||||
//==== process uv and normals begin
|
||||
|
||||
std::cout << "Hello x1" << std::endl;
|
||||
|
||||
std::getline(f, tempLine); //===UV Coordinates:
|
||||
|
||||
std::getline(f, tempLine); //triangle count
|
||||
int numberTriangles;
|
||||
|
||||
@ -236,6 +243,97 @@ namespace ZL
|
||||
throw std::runtime_error("No number found in the input string.");
|
||||
}
|
||||
|
||||
|
||||
// Now process UVs
|
||||
std::vector<std::array<Vector2f, 3>> uvCoords;
|
||||
|
||||
uvCoords.resize(numberTriangles);
|
||||
|
||||
for (int i = 0; i < numberTriangles; i++)
|
||||
{
|
||||
std::getline(f, tempLine); //Face 0
|
||||
|
||||
int uvCount;
|
||||
std::getline(f, tempLine);
|
||||
if (std::regex_search(tempLine, match, pattern_count)) {
|
||||
std::string number_str = match.str();
|
||||
uvCount = std::stoi(number_str);
|
||||
}
|
||||
else {
|
||||
throw std::runtime_error("No number found in the input string.");
|
||||
}
|
||||
|
||||
if (uvCount != 3)
|
||||
{
|
||||
throw std::runtime_error("more than 3 uvs");
|
||||
}
|
||||
|
||||
std::vector<float> floatValues;
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
std::getline(f, tempLine); //UV <Vector (-0.3661, -1.1665)>
|
||||
|
||||
auto b = tempLine.cbegin();
|
||||
auto e = tempLine.cend();
|
||||
floatValues.clear();
|
||||
while (std::regex_search(b, e, match, pattern_float)) {
|
||||
floatValues.push_back(std::stof(match.str()));
|
||||
b = match.suffix().first;
|
||||
}
|
||||
|
||||
if (floatValues.size() != 2)
|
||||
{
|
||||
throw std::runtime_error("more than 2 uvs---");
|
||||
}
|
||||
|
||||
uvCoords[i][j] = Vector2f{ floatValues[0],floatValues[1] };
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
std::cout << "Hello eee" << std::endl;
|
||||
|
||||
std::getline(f, tempLine); //===Normals:
|
||||
|
||||
|
||||
std::vector<Vector3f> normals;
|
||||
|
||||
normals.resize(numberVertices);
|
||||
for (int i = 0; i < numberVertices; i++)
|
||||
{
|
||||
std::getline(f, tempLine);
|
||||
|
||||
std::vector<float> floatValues;
|
||||
|
||||
auto b = tempLine.cbegin();
|
||||
auto e = tempLine.cend();
|
||||
while (std::regex_search(b, e, match, pattern_float)) {
|
||||
floatValues.push_back(std::stof(match.str()));
|
||||
b = match.suffix().first;
|
||||
}
|
||||
|
||||
normals[i] = Vector3f{ floatValues[0], floatValues[1], floatValues[2] };
|
||||
}
|
||||
|
||||
//==== process uv and normals end
|
||||
|
||||
std::getline(f, tempLine); //triangle count.
|
||||
//numberTriangles; //Need to check if new value is the same as was read before
|
||||
|
||||
if (std::regex_search(tempLine, match, pattern_count)) {
|
||||
std::string number_str = match.str();
|
||||
numberTriangles = std::stoi(number_str);
|
||||
}
|
||||
else {
|
||||
throw std::runtime_error("No number found in the input string.");
|
||||
}
|
||||
|
||||
std::vector<std::array<int, 3>> triangles;
|
||||
|
||||
triangles.resize(numberTriangles);
|
||||
@ -447,6 +545,10 @@ namespace ZL
|
||||
verticesBoneWeight.push_back(localVerticesBoneWeight[triangles[i][0]]);
|
||||
verticesBoneWeight.push_back(localVerticesBoneWeight[triangles[i][1]]);
|
||||
verticesBoneWeight.push_back(localVerticesBoneWeight[triangles[i][2]]);
|
||||
|
||||
mesh.TexCoordData.push_back(uvCoords[i][0]);
|
||||
mesh.TexCoordData.push_back(uvCoords[i][1]);
|
||||
mesh.TexCoordData.push_back(uvCoords[i][2]);
|
||||
}
|
||||
|
||||
startMesh = mesh;
|
||||
|
||||
@ -70,10 +70,8 @@ void GameObjectManager::initialize() {
|
||||
|
||||
|
||||
|
||||
//violaIdleModel.LoadFromFile("./idleviola001.txt");
|
||||
violaIdleModel.LoadFromFile("./idleviola008.txt");
|
||||
|
||||
violaWalkModel.LoadFromFile("./walkviola008.txt");
|
||||
violaIdleModel.LoadFromFile("./idleviola_uv009.txt");
|
||||
violaWalkModel.LoadFromFile("./walkviola_uv009.txt");
|
||||
sideThreadLoadingCompleted = true;
|
||||
});
|
||||
|
||||
@ -235,6 +233,9 @@ void GameObjectManager::initialize() {
|
||||
monsterScreenMeshMutable.RefreshVBO();
|
||||
|
||||
|
||||
violaTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./viola.bmp"));
|
||||
|
||||
|
||||
//SDL_ShowCursor(SDL_DISABLE);
|
||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ public:
|
||||
|
||||
std::shared_ptr<ZL::Texture> testObjTexturePtr;
|
||||
//std::shared_ptr<ZL::Texture> roomTexturePtr;
|
||||
std::shared_ptr<ZL::Texture> coneTexturePtr;
|
||||
//std::shared_ptr<ZL::Texture> coneTexturePtr;
|
||||
|
||||
//ZL::VertexDataStruct colorCubeMesh;
|
||||
//ZL::VertexRenderStruct colorCubeMeshMutable;
|
||||
@ -43,10 +43,12 @@ public:
|
||||
|
||||
ZL::BoneSystem violaIdleModel;
|
||||
ZL::VertexRenderStruct violaIdleModelMutable;
|
||||
|
||||
|
||||
ZL::BoneSystem violaWalkModel;
|
||||
ZL::VertexRenderStruct violaWalkModelMutable;
|
||||
|
||||
std::shared_ptr<ZL::Texture> violaTexturePtr;
|
||||
|
||||
std::vector<ZL::VertexDataStruct> preloadedRoomMeshArr;
|
||||
|
||||
|
||||
|
||||
@ -49,9 +49,12 @@ void RenderSystem::drawViola(GameObjectManager& gameObjects)
|
||||
static const std::string vColorName = "vColor";
|
||||
static const std::string textureUniformName = "Texture";
|
||||
|
||||
renderer.shaderManager.PushShader(colorShaderName);
|
||||
|
||||
renderer.shaderManager.PushShader(defaultShaderName);
|
||||
renderer.RenderUniform1i(textureUniformName, 0);
|
||||
|
||||
renderer.EnableVertexAttribArray(vPositionName);
|
||||
renderer.EnableVertexAttribArray(vTexCoordName);
|
||||
|
||||
renderer.PushPerspectiveProjectionMatrix(1.0 / 1.5,
|
||||
static_cast<float>(Environment::width) / static_cast<float>(Environment::height),
|
||||
50, 10000);
|
||||
@ -78,12 +81,14 @@ void RenderSystem::drawViola(GameObjectManager& gameObjects)
|
||||
{
|
||||
gameObjects.violaIdleModelMutable.AssignFrom(gameObjects.violaIdleModel.mesh);
|
||||
gameObjects.violaIdleModelMutable.RefreshVBO();
|
||||
glBindTexture(GL_TEXTURE_2D, gameObjects.violaTexturePtr->getTexID());
|
||||
renderer.DrawVertexRenderStruct(gameObjects.violaIdleModelMutable);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObjects.violaWalkModelMutable.AssignFrom(gameObjects.violaWalkModel.mesh);
|
||||
gameObjects.violaWalkModelMutable.RefreshVBO();
|
||||
glBindTexture(GL_TEXTURE_2D, gameObjects.violaTexturePtr->getTexID());
|
||||
renderer.DrawVertexRenderStruct(gameObjects.violaWalkModelMutable);
|
||||
}
|
||||
|
||||
@ -91,6 +96,7 @@ void RenderSystem::drawViola(GameObjectManager& gameObjects)
|
||||
renderer.PopMatrix();
|
||||
renderer.PopProjectionMatrix();
|
||||
renderer.DisableVertexAttribArray(vPositionName);
|
||||
renderer.DisableVertexAttribArray(vTexCoordName);
|
||||
|
||||
renderer.shaderManager.PopShader();
|
||||
}
|
||||
|
||||
@ -81,6 +81,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>Viola</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
||||
42311
idleviola_uv009.txt
Normal file
42311
idleviola_uv009.txt
Normal file
File diff suppressed because it is too large
Load Diff
43494
walkviola_uv009.txt
Normal file
43494
walkviola_uv009.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user