Problem with material - Sketchup to Ogre

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Problem with material - Sketchup to Ogre

Post 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.
zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Re: Problem with material - Sketchup to Ogre

Post by zakato »

up
bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia
x 201

Re: Problem with material - Sketchup to Ogre

Post 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.
zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Re: Problem with material - Sketchup to Ogre

Post by zakato »

i tried also this:

Code: Select all

  Entity->setMaterialName("vico");
but it does'nt work either.
zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Re: Problem with material - Sketchup to Ogre

Post 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...
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: Problem with material - Sketchup to Ogre

Post 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.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Re: Problem with material - Sketchup to Ogre

Post 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.
User avatar
saejox
Goblin
Posts: 260
Joined: Tue Oct 25, 2011 1:07 am
x 36

Re: Problem with material - Sketchup to Ogre

Post by saejox »

i don't see a material named "vico" in your .material file.
Nimet - Advanced Ogre3D Mesh/dotScene Viewer
asPEEK - Remote Angelscript debugger with html interface
ogreHTML - HTML5 user interfaces in Ogre
zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Re: Problem with material - Sketchup to Ogre

Post 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.
User avatar
saejox
Goblin
Posts: 260
Joined: Tue Oct 25, 2011 1:07 am
x 36

Re: Problem with material - Sketchup to Ogre

Post by saejox »

materials dont have automatic inheritance like that.

you should iterate over your sub-meshes then assign each sub-mesh the correct material.
Nimet - Advanced Ogre3D Mesh/dotScene Viewer
asPEEK - Remote Angelscript debugger with html interface
ogreHTML - HTML5 user interfaces in Ogre
zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Re: Problem with material - Sketchup to Ogre

Post 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?
User avatar
saejox
Goblin
Posts: 260
Joined: Tue Oct 25, 2011 1:07 am
x 36

Re: Problem with material - Sketchup to Ogre

Post 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.
Nimet - Advanced Ogre3D Mesh/dotScene Viewer
asPEEK - Remote Angelscript debugger with html interface
ogreHTML - HTML5 user interfaces in Ogre
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Problem with material - Sketchup to Ogre

Post 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.
Post Reply