mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-06-11 14:22:58 -06:00
SurfaceCtrl: working demo
git-svn-id: svn://ultimatepp.org/upp/trunk@14881 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
82982103c4
commit
a0cee6d856
4 changed files with 36 additions and 4 deletions
|
|
@ -13,7 +13,7 @@ namespace Upp{
|
|||
glm::vec3 UnProject2(float winX, float winY,float winZ)const noexcept;
|
||||
public:
|
||||
MagicCamera(){}
|
||||
MagicCamera& Init(){transform.SetPosition(0, 10, 20); focus = glm::vec3(0.0f,0.0f,0.0f); return *this;}
|
||||
MagicCamera& Init(){transform.SetPosition(0, 0, 20); focus = glm::vec3(0.0f,0.0f,0.0f); return *this;}
|
||||
|
||||
glm::mat4 GetProjectionMatrix()const noexcept;
|
||||
glm::mat4 GetViewMatrix()const noexcept;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ class Mesh : public Moveable<Mesh>{
|
|||
|
||||
Material material; //The material object is a representation of material property of the object (it change how light affect it)
|
||||
|
||||
unsigned int textureIndice = 0;
|
||||
|
||||
/**
|
||||
All stuff about texture
|
||||
|
|
@ -102,6 +103,9 @@ class Mesh : public Moveable<Mesh>{
|
|||
}
|
||||
}
|
||||
|
||||
Mesh& SetTextureIndice(unsigned int indice){textureIndice = indice; return *this;}
|
||||
unsigned int GetTextureIndice(){return textureIndice;}
|
||||
|
||||
Material& GetMaterial(){return material;}
|
||||
|
||||
void SetName(const Upp::String& n){name = n;}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ bool Object3D::LoadModel(const String& Filename, Color color, unsigned int pFlag
|
|||
*/
|
||||
bool Object3D::InitFromScene(const aiScene* pScene, const String& Filename){
|
||||
meshes.AddN(pScene->mNumMeshes);
|
||||
textures.AddN(pScene->mNumMaterials);
|
||||
//Add Texture vector init here
|
||||
|
||||
// Initialise les maillages de la scène, un par un
|
||||
|
|
@ -146,7 +147,7 @@ bool Object3D::InitFromScene(const aiScene* pScene, const String& Filename){
|
|||
}
|
||||
void Object3D::InitMesh(unsigned int Index, const aiMesh* paiMesh){
|
||||
//For texture / material data
|
||||
//meshes[Index].MaterialIndex = paiMesh->mMaterialIndex;
|
||||
meshes[Index].SetTextureIndice(paiMesh->mMaterialIndex);
|
||||
|
||||
Vector<float>& vertices = meshes[Index].GetVertices();
|
||||
Vector<float>& normals = meshes[Index].GetNormals();
|
||||
|
|
@ -195,8 +196,34 @@ void Object3D::InitMesh(unsigned int Index, const aiMesh* paiMesh){
|
|||
}
|
||||
}
|
||||
bool Object3D::InitMaterials(const aiScene* pScene, const String& Filename){
|
||||
//TODO
|
||||
return true;
|
||||
bool Ret = false;
|
||||
for (unsigned int i = 0 ; i < pScene->mNumMaterials ; i++) {
|
||||
const aiMaterial* pMaterial = pScene->mMaterials[i];
|
||||
textures[i] = NULL;
|
||||
if (pMaterial->GetTextureCount(aiTextureType_DIFFUSE) > 0) {
|
||||
aiString Path;
|
||||
|
||||
if (pMaterial->GetTexture(aiTextureType_DIFFUSE, 0, &Path, NULL, NULL, NULL, NULL, NULL) == AI_SUCCESS) {
|
||||
//std::string FullPath = Dir + "/" + Path.data;
|
||||
|
||||
//LOAD texture here:
|
||||
//m_Textures[i] = new Texture(GL_TEXTURE_2D, FullPath.c_str());
|
||||
|
||||
/*if (!textures[i]->Load()) {
|
||||
printf("Error loading texture '%s'\n", FullPath.c_str());
|
||||
delete m_Textures[i];
|
||||
m_Textures[i] = NULL;
|
||||
Ret = false;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
if (!textures[i]) {
|
||||
//textures[i] = new Texture(GL_TEXTURE_2D, "../Content/white.png");
|
||||
//Ret = textures[i]->Load();
|
||||
}
|
||||
}
|
||||
// return Ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ class Object3D : public Upp::Moveable<Object3D>{
|
|||
int ID;
|
||||
|
||||
Vector<Mesh> meshes;
|
||||
Vector<unsigned int> textures; //Vector carrying all texture of the object, every meshes refer to it via one iterator
|
||||
|
||||
bool loaded = false;
|
||||
bool moved = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue