Page 1 of 2

Question Regarding Octane's Map types

Posted: Sun Feb 08, 2015 12:11 am
by colinsenner
Hello Octane,
I'm working on integrating Octane support for Relink Bitmaps and have come across a strange problem. This is regarding the integration of octane maps in the 3dsmax 2014 plugin - octane demo. Take a look.


Regarding problem 1: Octane attempts to load the bitmap when accessing the .filename property on all Octane specific maps Image_Texture/Alpha_Image_Texture, etc. Relink Bitmaps has to access the filename property to check if it exists (doesFileExist theMap.filename). No other map types/objects work like I'm seeing from Octane. Can anyone shed some light on this?

Problem 2: isProperty (octanemap) #filename - reports false...That's strange when "show Image_Texture" reports (correctly) that there is a filename property.

Check the below code which shows off both problems.

Code: Select all

(
	clearListener()
	
	-- This code works fine and has no problem getting the property #filename in a BitmapTexture (not the bitmap is not attempted to be opened)	
	local bmaps = GetClassInstances BitmapTexture

	if (bmaps.count > 0) then (
		for m in bmaps do (
			format "% filename: \"%\"\n" m.name m.filename
		)	
	) else
		format "No BitmapTexture in the scene\n"
	
	/**************** PROBLEM #1 ****************/
	-- Octane Problem with textures
	-- This errors with a runtime error:  -- Runtime error: Error opening bitmap: C:\Users\###\textures\04_FUNGUS.jpg
	-- It shouldn't be attempting to open the bitmap when just accessing the #filename property
	for m in (getClassInstances Alpha_Image_Texture) do (
		print m.filename
	)
	
	-- Same thing for Image_Texture class
	for m in (getClassInstances Image_Texture) do (
		print m.filename
	)
	
	/**************** PROBLEM #2 ***************/
	-- Amazingly this doesn't work even though there is a #filename property on Image_Texture class
	local imgTexture = GetClassInstances Image_Texture		-- Get the first Image_Texture in the scene 
	local bitTexture = GetClassInstances BitmapTexture		-- Get the first BitmapTexture in the scene 
	
	if (bitTexture.count > 0) then
		format "isProperty bitTexture[1] #filename = %\n" ((isProperty bitTexture[1] #filename) as string)
	else 
		format "No BitmapTexture in the scene\n"
		
	if (imgTexture.count > 0) then
		format "isProperty imgTexture #filename = %\n" ((isProperty imgTexture #filename) as string)
	else
		format "No Image_Texture in the scene\n"
	
	
)

Re: Question Regarding Octane's Map types

Posted: Mon Feb 09, 2015 5:23 pm
by colinsenner
Devs? Any ideas? My only idea for a work around would be to throw the whole damn thing in a try/catch and detect for that error. This isn't good coding practice, but it might be all I can do for my users, and even it isn't great, because I can't assign the map a new filename without accessing the .filename prop anyway.

Re: Question Regarding Octane's Map types

Posted: Mon Feb 09, 2015 10:20 pm
by colinsenner
colinsenner wrote:Devs? Any ideas? My only idea for a work around would be to throw the whole damn thing in a try/catch and detect for that error. This isn't good coding practice, but it might be all I can do for my users, and even it isn't great, because I can't assign the map a new filename without accessing the .filename prop anyway.
Ok, I attempted the try/catch solution and can successfully get instances of the maps where bitmaps are missing in the catch(), however to assign them a new .filename (bitmap type)

I would have to do

(Image_Texture).filename = OpenBitmap filename:"C:\\test.jpg"

The problem with this is it will mess up any environment mapping, offsets, blur values, and the like if I don't save these prior. Are there any solutions that might work?

The problem doesn't only affect me and my script, This is why the Asset Tracker can't even pickup missing octane maps/filenames, as well as anyone's (Like Martin Breidt's excellent MB_ResourceCollect, among many others of collector/relinker scripts.

Re: Question Regarding Octane's Map types

Posted: Thu Feb 12, 2015 3:21 pm
by lunarstudio
Hey Colin. I messaged two admins/moderators and haven't heard back.
I don't know if they realize how useful your scripts are to the Max community but anyone that uses the scripts knows.

Perhaps they're just really busy. :cry:

Re: Question Regarding Octane's Map types

Posted: Thu Feb 12, 2015 7:35 pm
by colinsenner
Thanks lunarstudio, I'm hoping they are able to reply at some point soon as I was hoping to have RB support for octane by last weekend in. I added corona support but the octane stuff might have to be put on hold til they communicate that it is working as intended or they will do something about it. My trial runs out soon.

Re: Question Regarding Octane's Map types

Posted: Thu Feb 12, 2015 10:40 pm
by abstrax
We really don't know what the problem is and Andrey, the developer of the 3ds max plugin, doesn't know much about Max Script, so is not sure what the reason for those issues is.

Re: Question Regarding Octane's Map types

Posted: Fri Feb 13, 2015 12:19 am
by colinsenner
Ok, have Andrey take a look and run the example code I provided in a scene that has a bitmap texture (standard max map) applied to a material and assigned to an object, and do the same with an octane material. Run the code and you'll see the problem.

The implementation for the .filename property in Octane is inconsistent with all other filename properties in all other renderers and not like max's native way of treating these.

Andrey shouldn't have any problems decoding maxscript because they're (mostly) the same name API calls for the SDK as well.


In max you can create a standard map type - BitmapTexture that has a .filename property
In VRay you could create a VRayProxy object that has a .filename property
In Corona you could create a CoronaLight which has a .iesFile property
etc. the list goes on

All of these are treated the same way, just as a string property. This would allow you to access the .filename/.iesFile/etc property as a string

bitmapTexture.filename (returns a string pointing to the filename of the texture)
VRayProxy.filename (returns a string pointing to the filename of the texture)
CoronaLight.iesFile (returns a string pointing to the filename of the texture)

If you attempt this behavior in Octane, it will actually return a Bitmap() object

Image_Texture.filename

This is problematic because in the preceeding examples you could do things to the files at that location (move/copy functionality for "Resource collecting" scripts for example)

In Octane accessing a filename property on a map that doesn't exist will throw an error instead of just returning a string to the file path of the texture, like the other examples and how max natively handles this behavior.

I'm just trying to find a workaround the error for accessing a .filename property on any Octane map type for a missing texture.

Re: Question Regarding Octane's Map types

Posted: Fri Feb 13, 2015 1:31 am
by Karba
Hi

As Marcus said I don't have max script experience
This is how I access file name string in C++

Code: Select all

PBBitmap *bmp = pblock->GetBitmap(mMaxParamId, t);
MaxSDK::Util::Path filePath = bmp->bi.GetAsset().GetFullFilePath(filePath)
MCHAR *fileName = filePath.GetString();
I hope it helps

Re: Question Regarding Octane's Map types

Posted: Fri Feb 13, 2015 6:41 pm
by colinsenner
Thanks for replying. I'll see if I can code a workaround for the time being. You can consider this closed for now. Cheers.

Re: Question Regarding Octane's Map types

Posted: Fri Feb 13, 2015 7:55 pm
by lunarstudio
Thanks guys for trying to assist and sorry Colin - wasn't expecting this to be so much trouble when I asked for some help. It is however much appreciated.

I really hope it gets sorted as this script is a huge timesaver and offers up more functionality than anything else. ADesk should really consider just making it standard with their Max releases.