Jump to content

Enumerating Materials in C++


photo

Recommended Posts

Hi,

I am using following code to extract the materials.

World* world = World::get();
Vector<NodePtr> vecNodes;
		
if( world->isLoaded())
{
      world->getNodes(vecNodes);
      for( int iNodeCount = 0; iNodeCount < vecNodes.size(); iNodeCount++)
      {
           if( vecNodes[iNodeCount]->isObject() )
	   {
                //Is this correct? How to get the ObjectPtr instance from NodePtr?
		ObjectPtr object = Object::create(vecNodes[iNodeCount]);										
		if( object.get() )
		{
	             for( int iSurfaceCount = 0; iSurfaceCount < object->getNumSurfaces(); iSurfaceCount++ )
		     {
			MaterialPtr materialPtr = object->getMaterial(iSurfaceCount);
			const char* str = materialPtr->getImageTextureName(0);
			TexturePtr texturePtr = materialPtr->getImageTexture(0);
	             }
		}
	   }
      }
}

The D3D11Textures I am aquiring and changing the texture in it. But there are no changes visible. Probably the Object::create(vecNodes[iNodeCount]); creates new object. 

 

Please help how to do it?

 

Rohit

Link to comment

Hi Rohit,

As long as I can see there is nothing wrong with your code.
"Object::create" method performs the cast and while you get yet another Ptr<> in the stack, the new engine object is not created.
Actually, in latest versions of the Unigine, all such methods were renamed to "cast".

Perhaps there is something with the way you modify the texture.
Could you please provide a small test scene to reproduce the problem and specify your SDK version as well?

Thanks!

Link to comment

Hi Ded,

Thanks for your help. I am using the old Unigine Version 07-07-2014.

My management wants me to integrate the old unigine first in our engine before we proceed with Unigine 2 license.

I have taken the output texture of rendering using TextureRenderer and it is merged with our engine.

The code above is giving proper data now. But

 

Now with above approach I want to capture specific textures from Unigine nodes that I want to map with textures  coming from our engine.

cpD3DDevCont->CopyResource((ID3D11Texture2D*) texturePtr->getD3D11Texture(), ourTexture); 

After this I call Update, Render and Swap. Nothing happens to that grabbed texture. It shows the old texture only.

 

What should I do?

Link to comment
m_context.cpD3DDevCont->ResolveSubresource(m_cpSubResolvedTexture,0,ourtexture,0,DXGI_FORMAT_R8G8B8A8_UNORM);
m_context.cpD3DDevCont->CopyResource((ID3D11Texture2D*) texturePtr->getD3D11Texture(),m_cpSubResolvedTexture);

I forgot to sub resolve the multi sampled texture.  It works.

Check attached image 03.

 

_03.bmp

 

the frames coming from our engine are mapped onto Unigine Textures where required. These frames are directly coming from camera.

 

_04.bmp

 

But in another image if the media file loaded in our engine with different dimensions than the sub resolved then the result is like this.

 

So I will take another approach in our engine.

I will Render the quad onto m_cpSubResolvedTexture with incoming shader resource views and then copy resource to the texture acquired from Unigine.

Hope it will resolve the problem and all size incoming textures will be fit to scale....

 

Rohit.

 

 

 

Link to comment

 

So I will take another approach in our engine.

I will Render the quad onto m_cpSubResolvedTexture with incoming shader resource views and then copy resource to the texture acquired from Unigine.

Hope it will resolve the problem and all size incoming textures will be fit to scale....

 

Rohit.

 

 

It worked. Finally the whole of Unigine is integrated with our engine. Now few bugs and configuration will make it perfect. Bingo!!.

Link to comment
×
×
  • Create New...