Dynamically change flags in 3ds Max with Maxscript - flags

My main problem is that I don't know how to dynamically create a flag variable in 3ds Max with maxscript. I would have hoped you could have just put a pound sign in front of a concatenated sting but that didn't work.
I'm writing a script that will dynamically create a flag for the material. This works to change a materials' animation texture start time:
meditMaterials[21][#Maps][#Diffuse_Color__Bitmaptexture__011_0060_ifl].starttime = 101f
I want the material flag (#Diffuse_Color__Bitmaptexture__011_0060_ifl) to be dynamically created, based off user input to get input like:
#Diffuse_Color__Bitmaptexture__020_0040_ifl
#Diffuse_Color__Bitmaptexture__046_0010_ifl
#Diffuse_Color__Bitmaptexture__300_0020_ifl

You can create / get / set global variables using the globalVars structure:
http://help.autodesk.com/view/3DSMAX/2015/ENU/?guid=__files_GUID_E7584E94_8696_421E_920C_2A83FCD9ABBF_htm
Does that point you in the right direction?

Related

User input on subsequent images to store coordinates

function main()
clear all;clc;
path='.\image_files\'; %___________image files path
path_posmap='.\pos_maps\';%_________stores positions of agents
NumOfImages = length(dir(path)) - 2;
w = dir(path);
img_names={}; %________stores names of all images
for i=3:NumOfImages+2,
img_names{i-2} = w(i).name;
end
for i=1:numel(img_names),
imname = [ path img_names{i}];
im0 = imread(imname);
imageHandle =imshow(im0);%_____________displays the image
xlabel(num2str(i));
set(imageHandle,'ButtonDownFcn',#ImageClickCallback);
end
end
function coordinates=ImageClickCallback ( objectHandle , eventData )
axesHandle = get(objectHandle,'Parent');
coordinates = get(axesHandle,'CurrentPoint');
coordinates = coordinates(1,1:2);
message = sprintf('x: %.1f , y: %.1f',coordinates (1) ,coordinates (2));
disp(coordinates); %___ add these coordinates for each image
close(gcf);
end
I want to display a series of images to a user. For each image request input from the user in the form of a mouse click on the image. Store the coordinates of each click in a matrix. Thus, in end having a matrix of dimension num_images x 2.
But in the above
a. I can't get the coordinates returned from the function ImageClickCallback
b. I am unable to close the image and display a new one whenever the user clicks.
I have no MATLAB here right now, so there are a couple guesses in my answer. Here we go:
Closing Figures
You don't close the image, so it won't close. Just add close gcf; at the end of your callback.
Passing Data
Now to get the coordinates I'd suggest using the base workspace instead of a global variable, or pass an argument to your callback.
Means I'd use assignin('base','newcords',coordinates); at the end of your callback.
Use evalin to get your coordinates back from the base workspace. You can try to access newcords without evalin, however I am pretty sure it isn't going to work.
newcords=evalin('base','newcords');
Now you create a new Variable (initialize it outside the for-loop), which holds all coordinates, assuming 2D-coordinates: allcords=zeros(2,numel(img_name));
Write the coordinates from the callback into your new-allcords-variable.
allcords(1,i)=newcords(1);
allcords(2,i)=newcords(2);
On Second thought you don't need to pass the coordinates back from the callback, go with:
Initialize allcords outside your loop:
allcords=zeros(2,1);
In your callback:
allcords=evalin('base',allcords);
allcordssize=size(allcords):
if min(allcordssize)=1
allcords(1,end)=coordinates(1);
allcords(2,end)=coordinates(2);
assignin('base','allcords',allcords);
else
allcords(1,end+1)=coordinates(1);
allcords(2,end+1)=coordinates(2);
assignin('base','allcords',allcords);
end
close gcf %close picture
With that you have all your coordinates from your callback. Another way you could use is, as I mentioned above, passing a variable to your callback.
Make sure data is matched with correct figure
The second problem is, your for loop does open all pictures at once I guess? (I Have no MATLAB available). So how about using uiwait(gcf); in your for loop? (After your set). This way you know which coordinates are assigned to which figure (also if all pictures are opened your coordinates are reverse to the img-list-indexes).
P.S.: I'm not sure if uiwait works in this case, what would work for sure is if you create a single GUI with just 1 handle (for your image), and instead of closing your figure just redraw your image each time your coordinates are chosen. Or load your GUI each loop-iteration, and pass the image name to the GUI.

Replacing part of geometry in three.js

Hello I have a OBJ file exported from 3d max. In the file I assigned parts of the model to groups. I can open my file in text editor I can see vertices and faces assigned to 20 groups.
However when I export to js (to rendered on a webpage using 3js) and look at my file I don't see my groups. Can I retain groups when I convert the file to js or does the json format doesn't support groups?
The overall aim is to be be able to replace parts of the geometry with a click or button. My plan was to write a script to replace groups on runtime but since I am not able to retain group names when exported to .js I am wondering if it's possible to do with 3js?

Matlab: How to clear the previous output image

I define values for the variables and call the function, it returns the output image in the figure. But when i want to test another set of data, the output image will come out, it's together with the previous output image. How can i solve it, do i need to add what code at the end of the function file?
Either close all before your generate the new figure if you're not interested in the old output figure, or make a figure call before creating the new image to ensure it pops up in a new figure window. Or, you can overwrite the current open figure by setting hold off first, although that's specifically for graphs.

How to pass a color value from one to another page in windowsphone 7?

I have a color palette in one XAML page. I want to pass the selected colour to another xaml page? As it is a color, string value is giving error, string cannot be converted to System.windows.media Can anyone help me in this. Thanks.
You'd pass it the same way you'd pass any non-string value.
There are 2 options:
Store it in an object with a global scope, so both pages/VMs can access the property.
Serialize the object and pass the serialized version. Because a Color does not support serialization directly you'll have to do this yourself. I'd do it by getting the A, R, G & B values of the color and writing them to a (probably delimited) string. Then constructing a new Color instance from the values, on the other page, using FromArgb().
You could also temporarily store it in the State cache.
Have a look at PhoneApplicationService.State
This is accessible from all your pages.

Automatic selection of control points in Matlab

Is there a way to select the control points automatically in Matlab instead of manually selecting them by cpselect? Thank you very much.
I just recently worked on a project where I had to do the same thing -- eventually I found that you can select control points automatically, but only if you use automatic selection to find the control points for both the unregistered and the orthophoto. (The control points used to define image transforms are stored in matrices, so if you can get your automated system to output a set of point coordinates in matrix form you can pass them to straight to cp2tform and bypass cpselect entirely.) On the other hand, cpselect stores corresponding pairs of image points using some kind of special data structure, so that I was never able to just pass it a set of control points for one image while leaving the other image blank.
I don't have the Matlab Image Processing Toolbox, but I see from the documentation that cpeselect can be called with an argument specifying the initial set of control points. Can you reduce your task to automating the creation of that initial set?

Resources