painting a Texture layer



  • On 05/12/2013 at 08:13, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R15 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    I'm trying to paint on a texture layer (Set pixels).
    So I go from Paintexture to Paintlayer to PaintlayerBmp and then use SetPixelCnt to set pixels in the layer (paint on it).

    However, from Paintlayer to Paintlayerbmp gives an error "cannot be used to initialize Paintlayerbmp".

    What to do?

    	// Get selected texture - layer
    	PaintTexture *pTex;
    	pTex = PaintTexture::GetSelectedTexture();
      
    	PaintLayer *pLayer = pTex->GetFirstLayer();
      
    	PaintLayerBmp*	cLayer = pLayer->GetLayerDownFirst();	//Here it goes wrong
    	
      
    	String name;
    	Int32 bh, bw;
    	
    	// getting the info of the painttexture and paintlayer is ok
    	name = pTex->GetPaintTexture()->GetName();	// texture name: myimage.jpg
    	bh = pTex->GetFirstLayer()->GetBh();
    	bw = pTex->GetFirstLayer()->GetBw();
    	GePrint ("bw -bh: " + String::IntToString(bw) + " - " + String::IntToString(bh));
      
    	Int32 y; UChar buf[] = { 128 };
    	for (y=0;y<100;y++)
       		cLayer->SetPixelCnt(0,y,100,buf,0,COLORMODE_GRAY, PIXELCNT_0);
    


  • On 06/12/2013 at 04:42, xxxxxxxx wrote:

    This seems to get the PaintLayerBump: pLayerBmp = (PaintLayerBmp* )pTex->GetLayerDownFirst();
    So I can use SetPixelCnt so write onto the layerbmp.

    However, the layer does not seem to change. Nothing happens.
    Do I have to write back or do some update?
    EventAdd() did not help.

    	PaintTexture *pTex;
    	PaintLayerBmp *pLayerBmp;
      
    	pTex = PaintTexture::GetSelectedTexture();
    	pLayerBmp = (PaintLayerBmp* )pTex->GetLayerDownFirst();
      
    	
    	Int32 y; UChar buf[] = { 128 }; 
    	for (y=0;y<200;y++)
    		pLayerBmp->SetPixelCnt(0,y,200,buf,0,COLORMODE_RGB, PIXELCNT_0);
    


  • On 07/12/2013 at 07:29, xxxxxxxx wrote:

    I can now read and write to the texture layer using pLayerBmp->SetPixelCnt();
    However how can I update the texture view.

    I used functions below, but it only updates when the cursor re-enters the texture layer view?

    	//pLayerBmp->UpdateRefresh(0,0, bw,bh, UPDATE_STD);
    	pLayerBmp->UpdateRefreshAll(UPDATE_STD, TRUE);
      
    	//onoff to update layer
    	//pLayer->SetShowBit(FALSE, 0);
    	//pLayer->SetShowBit(TRUE, 0);
      
    	//EventAdd(EVENT_FORCEREDRAW);
    


  • On 07/12/2013 at 08:54, xxxxxxxx wrote:

    I'm not sure I understand what it is you're trying to do.
    But if you're just trying to create a new BP texture then I think you need to use SetSelected_Texture() to update it after you've changed it.

    This how I create a new BP texture:

    //Creates a new paint texure in bodypaint  
      
      BaseContainer bc;  
      bc.SetLong(TEXTURE_FILEFORMAT,FILTER_JPG);  
      bc.SetLong(TEXTURE_WIDTH, 1024);  
      bc.SetLong(TEXTURE_HEIGHT, 1024);  
      bc.SetLong(TEXTURE_MODE, COLORMODE_RGB);  
      PaintTexture *pTex = PaintTexture::CreateNewTexture("C:\\Users\\user\\Desktop\\mytex", bc);  
      if(pTex)  
      {  
          PaintLayer *pLayer = pTex->GetFirstLayer();  
          if(pLayer && pLayer->IsInstanceOf(OBJECT_PAINTLAYERBMP))  
          {  
              Bool ret = PaintTexture::SetSelected_Texture((PaintLayerBmp* )pLayer,NULL);  
          }  
      }
    

    -ScottA



  • On 08/12/2013 at 09:41, xxxxxxxx wrote:

    Thanks for the information.
    Really helpful.


Log in to reply