Page 1 of 1

Problem with material - Sketchup to Ogre

Posted: Wed Nov 21, 2012 9:06 pm
by zakato
Hi everyone, I have a little problem with import of material from Sketchup to Ogre.
The problem is that, once i created my 3d scene with Sketchup and exported it using the plugin, created the file
.mesh, .materials and .jpeg, and copied the file ( .mesh in media/models, .materials in media/materials/scripts and .jpeg in media/materials/bitmap and copied this file also in the resource files of my project),
i compile the program with this code:

Code: Select all

#include "Ogre\ExampleApplication.h"




class Example1 : public ExampleApplication
{
public:

   void createScene()
   {



Ogre::SceneNode* Node = mSceneMgr->getRootSceneNode()->createChildSceneNode( "CubeNode" );
      Ogre::Entity* Entity = mSceneMgr->createEntity( "Cube", "vico.mesh" );
      Node->attachObject( Entity );
	  Entity->setMaterialName("vico.material");


	  Ogre::SceneNode* node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "Sesso");
	  Ogre::Entity* Sinbad = mSceneMgr->createEntity("Sinbad","Sinbad.mesh");
	  node2->attachObject(Sinbad);




	 Ogre::Light* light = mSceneMgr->createLight("Light1");
		light->setType(Ogre::Light::LT_SPOTLIGHT);
		
   }
};

int main (void)
{
   Example1 app;
   app.go();
   return 0;
}




The mesh is on the screen, but without material, it is all white.

Can you help me to figure out what is the problem.

Re: Problem with material - Sketchup to Ogre

Posted: Sun Nov 25, 2012 12:52 pm
by zakato
up

Re: Problem with material - Sketchup to Ogre

Posted: Sun Nov 25, 2012 2:03 pm
by bstone
zakato wrote:Entity->setMaterialName("vico.material");
Doesn't look like the correct material name to me. The material name is whatever you have after the "material" keyword in vico.material.

Re: Problem with material - Sketchup to Ogre

Posted: Sun Nov 25, 2012 3:53 pm
by zakato
i tried also this:

Code: Select all

  Entity->setMaterialName("vico");
but it does'nt work either.

Re: Problem with material - Sketchup to Ogre

Posted: Sun Nov 25, 2012 3:56 pm
by zakato
the vico.material, that i copied in the media/material/scripts folder is like this

Code: Select all

material Asfalto_Nuovo
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Asphalt_New.jpg
         }
      }
   }
}

material 0132_GrigioChiaro
{
   technique
   {
      pass
      {
         diffuse 0.662745098039216 0.662745098039216 0.662745098039216 1.0
         ambient 0.662745098039216 0.662745098039216 0.662745098039216 1.0
      }
   }
}

material Acqua_Frizzante
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Water_Sparkling.jpg
         }
      }
   }
}

material Blocco_di_Cemento_Effetto_Pietre_Grigie
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Concrete_Block_Retaining_Gray.jpg
         }
      }
   }
}

material Granito_Blu_Notte
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Stone_Granite_Midnite.jpg
         }
      }
   }
}

material SketchupDefault
{
   technique
   {
      pass
      {
         diffuse 0.890196078431373 0.882352941176471 0.870588235294118
         ambient 0.890196078431373 0.882352941176471 0.870588235294118
      }
   }
}

material SketchupDefault_Back
{
   technique
   {
      pass
      {
         diffuse 0.545098039215686 0.533333333333333 0.603921568627451
         ambient 0.545098039215686 0.533333333333333 0.603921568627451
      }
   }
}

all the .jpeg files that are present in the code of vico.material i copied in the media/material/textures.

I don't understand why it does'nt work...

Re: Problem with material - Sketchup to Ogre

Posted: Mon Nov 26, 2012 5:52 am
by syedhs
You keep mentioning jpeg but in your material, the file is jpg (not jpeg). Probably that is the source of error?
If renaming the file doesn't solve it, paste the Ogre.log here.

Re: Problem with material - Sketchup to Ogre

Posted: Mon Nov 26, 2012 12:19 pm
by zakato
I change in the material script the extension of the files( jpg -> jpeg) but still does'nt work.
In the log of Ogre, it says that it find now the texture .jpeg but the program can't find the material script. But i have the material script file in media/materials/scripts.
I can't understand what is the problem.

Re: Problem with material - Sketchup to Ogre

Posted: Mon Nov 26, 2012 5:06 pm
by saejox
i don't see a material named "vico" in your .material file.

Re: Problem with material - Sketchup to Ogre

Posted: Mon Nov 26, 2012 7:17 pm
by zakato
The file .material was created using the plug-in for Sketchup to ogre. Now the file .material has the information about the
texture of the submesh of the mesh that i created with Sketchup. There are different texture for different sub mesh.
As you say, there is not a vico material in my file .material, and i think this is the problem. Because, when i try and write in the code

Code: Select all

Entity->setMaterialName("Asfalto_Nuovo");
, the entire mesh presented with this material.
Now how can manage it and make it so that the correct textures are loaded on the correct sub mesh?

I tried

Code: Select all

material vico{


material Asfalto_Nuovo
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Asphalt_New.jpeg
         }
      }
   }
}

material 0132_GrigioChiaro
{
   technique
   {
      pass
      {
         diffuse 0.662745098039216 0.662745098039216 0.662745098039216 1.0
         ambient 0.662745098039216 0.662745098039216 0.662745098039216 1.0
      }
   }
}

material Acqua_Frizzante
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Water_Sparkling.jpeg
         }
      }
   }
}

material Blocco_di_Cemento_Effetto_Pietre_Grigie
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Concrete_Block_Retaining_Gray.jpeg
         }
      }
   }
}

material Granito_Blu_Notte
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Stone_Granite_Midnite.jpeg
         }
      }
   }
}

material SketchupDefault
{
   technique
   {
      pass
      {
         diffuse 0.890196078431373 0.882352941176471 0.870588235294118
         ambient 0.890196078431373 0.882352941176471 0.870588235294118
      }
   }
}

material SketchupDefault_Back
{
   technique
   {
      pass
      {
         diffuse 0.545098039215686 0.533333333333333 0.603921568627451
         ambient 0.545098039215686 0.533333333333333 0.603921568627451
      }
   }
}

}
and replace again "vico" in the previous code, but it does'nt work either.

Re: Problem with material - Sketchup to Ogre

Posted: Mon Nov 26, 2012 10:41 pm
by saejox
materials dont have automatic inheritance like that.

you should iterate over your sub-meshes then assign each sub-mesh the correct material.

Re: Problem with material - Sketchup to Ogre

Posted: Tue Nov 27, 2012 12:11 am
by zakato
saejox wrote:materials dont have automatic inheritance like that.

you should iterate over your sub-meshes then assign each sub-mesh the correct material.

sorry, can you explain tis better, maybe can you help me with the code?

Re: Problem with material - Sketchup to Ogre

Posted: Tue Nov 27, 2012 12:18 am
by saejox
just a small documentation search yielded this.

Code: Select all

SubEntity * 	getSubEntity (unsigned int index) const
 	Gets a pointer to a SubEntity, ie a part of an Entity.
SubEntity * 	getSubEntity (const String &name) const
 	Gets a pointer to a SubEntity by name.
unsigned int 	getNumSubEntities (void) const
 	Retrieves the number of SubEntity objects making up this entity. 
also there are many subEntity material assignment questions on the forum.

Re: Problem with material - Sketchup to Ogre

Posted: Wed Nov 28, 2012 12:57 am
by Kojack
If the original vico.material file was generated by the exporter, then you don't need to set materials manually. Each submesh contains the name of the required material and will load it automatically.
So setMaterialName is only needed if you want to change the materials.