Notifications
Clear all

[Closed] Custom editable_mesh plugin

I would like to have a custom mesh plugin, with all editable_mesh posibilities but also some additional custom properties. I tried to reach this aim by extending editable_mesh, the results can be seen in this thread. So wondering if there is some other way to reach this aim?

9 Replies

A parametric object with all the options of an Editable Mesh doesn’t sound right.

Instead, if you would like to create a “fixed” static object with all the options of an Editable Mesh, you would just be creating an Editable Mesh.

As @denisT pointed out in the other thread, it can’t be done in MXS, so what you may want to create is a custom tool. But in the end you’ll be just creating an Editable Mesh, so I don’t see the point of re-building the whole Editable Mesh UI.

If you could explain exactly what you want to do, perhaps someone may be able to point you in the right direction.

Perhaps you could use Custom Attributes for extending it. Who knows?

Like I said would like to have custom parameters, which are not relevant for geometry, but for how the mesh handled ingame. So for example a proberty of type bool canBeDestroied, which defines if the mesh can be destroied ingame, or a property of type float renderingDistance, which defines a distance to the mesh ingame when it should be rendered. I know a solution can be using userProps, what I have to do at the moment, but in my opinion it´s an ugly solution as editing the properties is not so easy.

Using “User Properties” is one way of doing it. The other way (most commonly used) is by adding Custom Attributes to your object.

For example, the following code will create a sphere and then assign some Custom Attributes.

(
	delete objects
	gc()
	
	-- Create a test object
	obj = converttomesh (sphere isselected:on)
	max modify mode
	
	-- Define the Custom Attributes
	MyGameAttributes = attributes GameAttributes
	(
		parameters main rollout:params
		(
			canBeDestroyed type:#boolean ui:chk_destroy    default:false
			renderDistance type:#float   ui:spn_renderDist default:100.0
		)
		
		rollout params "Game Attributes"
		(
			checkbox chk_destroy    "Can be Destroyed" align:#left type:#boolean
			spinner  spn_renderDist "Render Distance"  align:#left type:#float fieldwidth:64 range:[0,10000.0,0]
		)
	)
	
	-- Asign the Custom Attributes to the object
	custattributes.add obj MyGameAttributes #unique
	
)

Then you can access these attributes just as any other object property, i.e.
$.canBeDestroyed
$.renderDistance

There will also be a Sub-Rollout in the object showing these Attributes.

OK, thanks I try this.

OK, worcks fine. Is it also posible to initialize for example the renderDistance value, while adding the attribute?

1 Reply
(@polytools3d)
Joined: 1 year ago

Posts: 0

renderDistance type:#float ui:spn_renderDist default:100.0

Sorry, my bad english again, I mean initialize it similar like plugin. So for example I would like to add the attribute with renderDistance value of 50 to mesh1 an renderDistance value of 200 to mesh2. At the moment the code have to look like this:

custattributes.add mesh1 MyGameAttributes #unique
mesh1.renderDistance=50
custattributes.add mesh2 MyGameAttributes #unique
mesh2.renderDistance=200

4 lines are necesary. I would like to do it this way:

custattributes.add mesh1 (MyGameAttributes  renderDistance:50) #unique
custattributes.add mesh2 (MyGameAttributes renderDistance:200) #unique

unfortunatelly it´s not worcking.

OK, got an other problem:

custattributes.add $ MyGameAttributes #unique

this worcks fine and the attribute is added so its rolout can be seen, but when I do this:

custAttributes.get $ MyGameAttributes

it returns undefined.

OK, the problem was because of that #unique if I just do:

custattributes.add $ MyGameAttributes

and after that

custAttributes.get $ MyGameAttributes

everithing worcks fine. Not understanding what that #unique should be good for.