Extending OctaneLight object with MaxScript (help needed)

3D Studio Max Plugin (Export Script Plugins developed by [gk] and KilaD; Integrated Plugin developed by Karba)
Forum rules
Please post only in English in this subforum. For alternate language discussion please go here http://render.otoy.com/forum/viewforum.php?f=18
Post Reply
User avatar
cmatias
Licensed Customer
Posts: 61
Joined: Fri Dec 28, 2012 8:52 am
Location: France
Contact:

Hi.
I'd like to extend the OctaneLight to make it an "OctaneLight video projector" (I'll call it OCProjector).
First of all, I'm a real beginner at Maxscript coding... but I am a quick learner ;)

So, here is what I want to achieve:
- Extend the OctaneLight class with a new class called OCProjector
- Add some parameters to this new class like the projector size (WxHxD), so I can draw a box behind the OctaneLight plane.
- Create & Assign a Distribution map (RGB image) to the OctaneLight
- Create & Assign an Octane “Perspective Map” to the Projection slot of the “RGB image” distribution map.
- Create & Assign à “3D transformation” to the “Plane Transformation” of the previous “Perspective map”.
- Add rollout controls to the OCProjector to control Rotation, Scale, and Translation of the previous “3d transform”, directly from the OCProjector rollouts.

I already found the way to achieve some of those functions, by defining a new class object plugin from Maxscript :

Code: Select all

plugin Light OCProjector
name:"OCProjector"
classID:#(0x47db14ff, 0x4e9b5f91)
category:"Octane"
extends:OctaneLight
replaceUI:false
Then, I can create visual controllers by declaring “parameters” and “rollout” interface:

Code: Select all

parameters pblock rollout:params
(
  projboxwidth type:#float animatable:false ui:projector_Width default:40.0
  projboxheight type:#float animatable:false ui:projector_Height default:20.0
  projboxdepth type:#float animatable:false ui:projector_Depth default:20.0
)
rollout params "Projector Parameters"
(
  Spinner projector_Width "Width :" range:[0, 1e9, 40]
  Spinner projector_Height "Height :" range:[0, 1e9, 20]
  Spinner projector_Depth "Depth :" range:[0, 1e9, 20]
)
To display the projector, I’ve defined a local variable “meshObject” to store the “box” representing the videoprojector, so I can display it within the “on getDisplayMesh do” method using the statement:

Code: Select all

on getDisplayMesh do
(
  if (meshObj == undefined) do
  (
     meshObj = createInstance box [...]
  )
  meshObj.mesh
)
As I can see on the Maxscript documentation about Scripted light plugins (https://help.autodesk.com/view/3DSMAX/2 ... 7C0D57_htm)

Current limitations prevent certain plug-ins from being extended, in particular those with custom creation managers. These include target light plug-ins. You can tell if a plug-in is not extendable if your new rollouts do not appear.

In my case, the rollouts appear ! (good news)

Image

By the way, on the same document, there’s a sentence about the Create tool :
“If a create tool is specified, it will override the delegate's create tool.”

Actually, if a set no “Tool Create” delegate’s function, my plugin simply crashes 3ds Max when I try to draw (create) the OCProjector light on the viewports.
I've also being trying to set a "Tool Create" delegate's function with the same crash issue...

So here I am stucked at this “tool create” point.
Does anyone of you have an idea?

Regards.
C MATIAS
HHbomb
Licensed Customer
Posts: 1378
Joined: Wed Jun 30, 2010 8:45 pm
Contact:

Hi,
do you see the scripted camera plugin ?
Perhaps some undefined locals ?
--------------------------------------------------------------------------------
plugin Camera CamTest_DisplayMesh
name:"CamTest"
classID:#(0x6ca13d13, 0x12afbfd4)
category:"Standard"
extends:FreeCamera
(
local lastR1, lastR2, meshObj
parameters pblock rollout:params
(
radius1 type:#float animatable:true ui:r1_amount default:40.0
radius2 type:#float animatable:true ui:r2_amount default:20.0
)
rollout params "CamTest Parameters"
(
Spinner r1_amount "Radius 1:" range:[0, 1e9, 40]
Spinner r2_amount "Radius 2:" range:[0, 1e9, 20]
)
on getDisplayMesh do
(
if (meshObj == undefined) do
(
meshObj = createInstance torus radius1:radius1 radius2:radius2 mapCoords:false
lastR1 = radius1; lastR2 = radius2
)
if radius1 != lastR1 do (meshObj.radius1 = radius1; lastR1 = radius1)
if radius2 != lastR2 do (meshObj.radius2 = radius2; lastR2 = radius2)
meshObj.mesh
)--end on getDisplayMesh
tool create
(
on mousePoint click do (nodeTM.translation = gridPoint;#stop )
)--end tool
)--end plugin
--------------------------------------------------------------------------------
YOKO Studio | win 10 64 | i7 5930K GTX 3090 | 3dsmax 2022.3 |
User avatar
cmatias
Licensed Customer
Posts: 61
Joined: Fri Dec 28, 2012 8:52 am
Location: France
Contact:

HHbomb wrote:Hi,
do you see the scripted camera plugin ?
Perhaps some undefined locals ?
My local variables aren't used yet before it crashes...
I'm actually only declaring the rollouts, but it crashes as soon as I click on the viewport to create the light :

Code: Select all

plugin Light OCProjector
name:"OCProjector"
classID:#(0x47db14ff, 0x4e9b5f91)
category:"Octane"
extends:OctaneLight
replaceUI:false
(
  local prw, prh, prd, meshObj
  parameters pblock rollout:params
  (
    projboxwidth type:#float animatable:false ui:projector_Width default:40.0
    projboxheight type:#float animatable:false ui:projector_Height default:20.0
	projboxdepth type:#float animatable:false ui:projector_Depth default:20.0
  )
  rollout params "Projector Parameters"
  (
    Spinner projector_Width "Width :" range:[0, 1e9, 40]
    Spinner projector_Height "Height :" range:[0, 1e9, 20]
	Spinner projector_Depth "Depth :" range:[0, 1e9, 20]
  )
)
Post Reply

Return to “Autodesk 3Ds Max”