Problem with CurveControl tool

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  07 July 2012
Problem with CurveControl tool

I'm using CurveControl in my script and I've encountered a problem:

rollout rlt_curveCtrl  "CurveControlTest" width:464 height:250
(
	CurveControl curveCtrl "Curve" numCurves:1
)
CreateDialog rlt_curveCtrl


I need to create an "empty curve" and then add points to it, but it seems that when you create a curve in the curve control it automatically adds two points at the limits of the range of values for the x-axis of the curve, with value 0 on the y-axis.
When I add for example two points, I want to consider only the range of values between them, but having these two limit points I'm forced to consider also the intervals from the left limit point to my first point, and from my last point to the right limit point. I've also tried to modify the CurveControl x_range property to consider only the x values between the two points x values, but the only effect is that the curve is resized and it still mantains all its points.

I would like to have a functioning similar to the Reaction Manager: when the reaction has no states, the reaction curve is empty. When you add a state for a reaction, a new point in the reaction curve is created, and you can also move the limit points, modifying the range of values
__________________
My Homepage
 
  07 July 2012
Create your own!


try(form.close())catch()
clearListener()


form=dotNetObject "MaxCustomControls.MaxForm"
	
graph=dotNetObject "label"
graph.backColor=(dotNetClass "system.drawing.color").fromArgb 100 100 100
graph.bounds=dotNetObject "system.drawing.rectangle" 10 10 300 300
	
lb1=dotNetObject "label"
lb1.size=dotNetObject "system.drawing.size" 11 11
lb1.backColor=(dotNetClass "system.drawing.color").green
lb1.location=dotNetObject "system.drawing.point" 20 280

lb1t=dotNetObject "label"
lb1t.size=dotNetObject "system.drawing.size" 5 5
lb1t.backColor=(dotNetClass "system.drawing.color").green
lb1t.location=dotNetObject "system.drawing.point" 100 280

lb2=dotNetObject "label"
lb2.size=dotNetObject "system.drawing.size" 11 11
lb2.backColor=(dotNetClass "system.drawing.color").red
lb2.location=dotNetObject "system.drawing.point" 280 20

lb2t=dotNetObject "label"
lb2t.size=dotNetObject "system.drawing.size" 5 5
lb2t.backColor=(dotNetClass "system.drawing.color").red
lb2t.location=dotNetObject "system.drawing.point" 200 20
	
fn bezier2D p1 p1t p2t p2 t=
(
	Q1 = (p1t - p1) * t + p1
	Q2 = (p2t - p1t) * t +p1t
	Q3 = (p2 - p2t) * t +p2t
	
	Q4 = (Q2 - Q1) * t + Q1
	Q5 = (Q3 - Q2) * t + Q2
	
	Q5 = (Q5 - Q4) * t + Q4
)
	
	
-- .DrawLine <System.Drawing.Pen>pen <System.Drawing.Point>pt1 <System.Drawing.Point>pt2
redCol=(dotNetClass "system.drawing.color").orange
blueCol=(dotNetClass "system.drawing.color").blue
col=(dotNetClass "system.drawing.color").blue
redPen=dotNetObject "system.drawing.pen" redCol 2
bluePen=dotNetObject "system.drawing.pen" blueCol 2
	
fn paintGraph sender arg =
(
	g=arg.graphics
-- 	showProperties g.SmoothingMode
	g.SmoothingMode=g.SmoothingMode.AntiAlias
	
	local p1=sender.controls.item[0].location
	local p1t=sender.controls.item[1].location
	local p2t=sender.controls.item[2].location
	local p2=sender.controls.item[3].location
	
 	g.drawLine redPen p1 p1t
 	g.drawLine redPen p1t p2t
 	g.drawLine redPen p2t p2
	
	for t = 0 to 1 by .05 do
	(
		dp=bezier2D [p1.x+5,p1.y+5] [p1t.x+2,p1t.y+2] [p2t.x+2,p2t.y+2] [p2.x+5,p2.y+5] t
		drawPoint=dotNetObject "system.drawing.point" dp.x dp.y
		
		if sender.tag!=undefined do
		(
			g.drawLine bluePen sender.tag drawPoint
		)
		sender.tag=drawPoint
	)
	sender.tag=undefined
)
	
fn mouseMove sender arg=
(
	if arg.button==arg.button.left do
	(
		sender.location=(sender.parent.PointToClient sender.MousePosition)
		graph.invalidate()
		graph.update()
	)
)


dotNet.addEventHandler graph "paint" paintGraph
dotNet.addEventHandler lb1 "mouseMove" mouseMove
dotNet.addEventHandler lb1t "mouseMove" mouseMove
dotNet.addEventHandler lb2 "mouseMove" mouseMove
dotNet.addEventHandler lb2t "mouseMove" mouseMove


--Note the order they are added. This is just so I know what order to calc them in. 
graph.controls.add lb1
graph.controls.add lb1t
	
graph.controls.add lb2t
graph.controls.add lb2


form.controls.add graph

form.show()
form.size=dotNetObject "system.drawing.size" 340 360
form.text="Bezier Control Test"

dotNet.setLifeTimeControl graph #dotNet
dotNet.setLifeTimeControl lb1 #dotNet
dotNet.setLifeTimeControl lb1t #dotNet
dotNet.setLifeTimeControl lb2 #dotNet
dotNet.setLifeTimeControl lb2t #dotNet


	

	
__________________
Paul Neale
http://paulneale.com
 
  07 July 2012
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:44 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.