apply a state for every camera in the scene!

I have a house in 3d and a background in it! I want to create scene states for every camera, so when I switch to any of them, I would see automatically the changes according to it's state! Any ideas?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

You can't acess local

You can't acess local variable d. You need to put local d outside event ei. function. Or even better why not add all inside "on btn2" event

on btn2 pressed do 
(
	objTMData = attributes objData
    (
		local objTMS = for o in objects collect DataPair o o.transform 
		fn setObjTM arr = 
		(
			for i in 1 to arr.count where isValidNode arr[i].v1 do arr[i].v1.transform = arr[i].v2
		)
    )
    local d = FreeCamera()
	custAttributes.add d objTMData
 
)
on btn2 rightclick do
(
    ca = custAttributes.get d objTMData
    ca.setObjTM ca.objTMS
)

bga

artrender.info's picture

thx

I wonder, are you just one person - barigazy, or a big team of experts! You answer 24h/24h to our question! Do you sleep, do you eat? Or you have made a script for all this things that take too much time! Share with me if you have such scripts? A script - not to go to the shop, not to cook and so on!

barigazy's picture

:)

Yup. I'm human :) No team just me.

bga

artrender.info's picture

Barigazy, tell me please

How to check if an object is parent?

barigazy's picture

...

Check

$.children.count
--if more the zero then this is the parent

bga

barigazy's picture

some useful fn's

fn getGrandParentName obj =
(
	local pn = obj.name
	-- repeat while there are more parents
	while obj.parent != undefined do
	(
		-- follow link out to next parent & pretend its name
		obj = obj.parent ; pn = obj.name
	) ; pn
)
grandParentname = getGrandParentName $
--------------------------------------------
--to check if obj transform is animated
$[3].isAnimated
--------------------------------------------
fn getAllChildren obj =
(
	local o = obj,childArr = #()
	while o.children[1] != undefined do
	(
		append childArr o.children[1]
		o = childArr[childArr.count]
	)
	childArr
)

bga

artrender.info's picture

thx

I think, I will have for every camera from the listbox, rightclick/ in a popup window- button pick object you want to transform => pick the object => check if it is animated and then if it is parent-=>if not allow user to move/scale/rotate that object! a button-save transform, dropdown lsit with objects that are linked to that camera and with the option to remove any of objects from the list! This way, the script will do it's job!

I need of course much more time to do that, but I will try to make it later! I appreciate very much your time, Barigazy!!!!!!!!!!!

artrender.info's picture

great

but may be we have to give possibility to select from non animated objects and nonparent only, because we change coordinates of them for given cameras!

Thank you Barigazy! It's a blessing to have you here! You help us a lot! May be, that's why 3d max does not contain scene states for object transforms - because of animation of the object!

barigazy's picture

...

this is the recursive code from mxs help

animated_props = #()
fn getAnimatedProps theObject =
(
	if try(theObject.isAnimated)catch(false) do append animated_props theObject
	for i = 1 to theObject.numSubs do getAnimatedProps theObject[i]
)
getAnimatedProps $
if animated_props.count == 0 then "non animated object" else "animated object"

bga

barigazy's picture

...

-- test with this:
-- create first some random objects in the scenes
 
-- define custAttributes  and assigne to some object in this case free camera
objTMData = attributes objData
(
	local objTMS = for o in objects collect DataPair o o.transform 
	fn setObjTM arr = for i in 1 to arr.count where isValidNode arr[i].v1 do arr[i].v1.transform = arr[i].v2
)
d = FreeCamera()
--assigne to camera
custAttributes.add d objTMData
-- now you can test by changing position and rotation of scene objects
-- and finaly run next two lines
ca = custAttributes.get d objTMData
ca.setObjTM ca.objTMS
 
-- this is not good way if some objects are parented or animated

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.