Using axis tripad in own helper plugin


#1

Is there some way to have axis tripod in own helper plugin the same way it is used in point helper?


#2
static void DrawAnAxis(GraphicsWindow* gw, TCHAR* label, Point3& axis, bool z)
{
	Point3 v1(axis * 0.9f), v2((z ? Point3(axis.x,axis.z,-axis.y) : Point3(axis.y,-axis.x,axis.z)) * 0.1f), seg[2];

	gw->text(&axis, label);

	gw->startSegments();

	seg[0] = axis;
	seg[1] = origin;
	gw->segment(seg, TRUE);
	seg[1] = v1+v2;
	gw->segment(seg, TRUE);
	seg[1] = v1-v2;
	gw->segment(seg, TRUE);

	gw->endSegments();
}

#3

Looks like C++ for me, but defenetlly not maxscript. My fault, forgot to mention that I need to do it in maxscript. I tried to create a helper that extend point helper, but when I tried to enable axis tripod it didn´t worck.


#4

works for me ?

plugin Helper point_helper
	name:"point_helper"
	classID:#(0x55331391, 0x481550e6)
	category:"Standard"
	extends:point
	replaceUI:true;
(
	on create do 
	(
		delegate.axistripod = on;
		delegate.cross = off;
	)
)

#5

Strange, I used true instead of on, but is that really the reason it didn´t worck for me? OK I haven´t set:

delegate.cross = off

Is this posibly the reason it didn´t worck?


#6

i doubt it, this works fine too

plugin Helper point_helper
	name:"point_helper"
	classID:#(0x55331391, 0x481550e6)
	category:"Standard"
	extends:point
	replaceUI:true;
(
	on create do 
	(
		delegate.axistripod = true;
		delegate.cross = true;
	)
)

or removing the cross line altogether works fine as well


#7

OK thanks, will try it with:

delegate.cross = true;


#8

OK, your code worcks fine and I think to know why my haven´t worck. Seems like having axistripod and a mesh at the same time is not posible. Here is my code:

plugin Helper HelperTest_DisplayMesh
name:"HelperTest"
classID:#(0x47db14fe, 0x4e9b5f90)
category:"Standard"
extends:Point
replaceUI:true
(
local lastSize, meshObj
parameters pblock rollout:params
(
size type:#float animatable:true ui:amount default:40.0
)
rollout params "HelperTest Parameters"
(
Spinner amount "Size:" range:[0, 1e9, 40]
)
on create do 
    (
        delegate.axistripod = true;
        delegate.cross = true;
    )
on getDisplayMesh do
(
if (meshObj == undefined) do
(
meshObj = createInstance box length:size \
width:size height:size mapCoords:false
lastSize = size
)
if size != lastSize do
(
meshObj.length = meshObj.width = meshObj.height = size
lastSize = size
)
meshObj.mesh
)
tool create
(
on mousePoint click do
(
nodeTM.translation = gridPoint;#stop
)
)
)

#9

as i remember the helper ‘Mesh Display’ method overwrites gw drawing. so you can’t use both


#10
plugin Helper tripod_helper
	name:"tripod_helper"
	classID:#(0x597143dd, 0x51733211)
	category:"Standard"
	extends:dummy
	replaceUI:true;
(
	local lastsize, msh = trimesh(), initialized = false;
	
	parameters main rollout:params
	(
		size type:#worldunits ui:ui_size default:10.0;
	)
	
	rollout params "Params"
	(
		spinner ui_size "Size:" range:[0, 100000000.0, size] fieldwidth:64 type:#worldunits align:#right;
	)

	tool create
	(
 		on mousePoint click do case click of
 		(
 			1: 
 			(
 				nodeTM.translation = gridPoint;
 				size = 0.01;
 			)
 			2: #stop
 		)
 		on mouseMove click do case click of
 		(
 			2:  size = amax (abs gridDist.x) (abs gridDist.y);
 		)
	)
		
	fn setedgevisflags m face flags =
	(	
		setEdgeVis m face 1 flags[1];
		setEdgeVis m face 2 flags[2];
		setEdgeVis m face 3 flags[3];
	)

	fn BuildMesh =
	(
		if not initialized then
		(	
			setNumVerts msh 10;
			setNumFaces msh 12;
			setface msh 1 [4,3,1];
			setface msh 2 [1,2,4];
			setface msh 3 [4,5,6];
			setface msh 4 [6,7,4];
			setface msh 5 [4,8,9];
			setface msh 6 [9,10,4];
			setface msh 7 [5,4,6];
			setface msh 8 [7,6,4];
			setface msh 9 [3,4,1];
			setface msh 10 [2,1,4];
			setface msh 11 [8,4,9];
			setface msh 12 [10,9,4];
			setedgevisflags msh  1 #{2..3};
			setedgevisflags msh  2 #{1, 3};
			setedgevisflags msh  3 #{2..3};
			setedgevisflags msh  4 #{1, 3};
			setedgevisflags msh  5 #{2..3};
			setedgevisflags msh  6 #{1, 3};
			setedgevisflags msh  7 #{2..3};
			setedgevisflags msh  8 #{1..2};
			setedgevisflags msh  9 #{2..3};
			setedgevisflags msh  10 #{1..2};
			setedgevisflags msh  11 #{2..3};
			setedgevisflags msh  12 #{1..2};
			initialized = true;
		)
		
		setvert msh 1 ([1,0,0] * size);
		setvert msh 2 ([0.9,-0.1,0] * size);
		setvert msh 3 ([0.9,0.1,0] * size);
		setvert msh 4 ([0,0,0] * size);
		setvert msh 5 ([-0.1,0.9,0] * size);
		setvert msh 6 ([0,1,0] * size);
		setvert msh 7 ([0.1,0.9,0] * size);
		setvert msh 8 ([0,0.1,0.9] * size);
		setvert msh 9 ([0,0,1] * size);
		setvert msh 10 ([0,-0.1,0.9] * size);
				
		update msh;
	)
	
	on getDisplayMesh do 
	(
		if size != lastsize then
		(
			buildmesh();
			lastsize = size;
		)
		msh;
	)
)

#11

And is there any way around? Not really need the complete tripod, but at least 1 axis to show the normal of a 2D mesh and an other axis for direction.


#12

i said you above - use manipulator


#13

You mean in that other thread? I searched for that manipulator thing, but what I found was of no help for me with my very low maxscript knowledge.
I just need scripted 2D mesh helper plugin with a posibility to see where the front and the back side of the mesh is.
Posibly I could write a helper plugin containing 2 meshes: 2D mesh and the tripod mesh using the code by Klvnk?