Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to draw cones dynamically by TE

Shulou Source: shulou.com Published: 2022-06-01 03:38:03 09月11日 Update

This article mainly introduces how TE dynamically plots cones, which is very detailed and has a certain reference value. Friends who are interested must read it!

In the secondary development of TE, the three-dimensional cone can be plotted, and the conical drawing can be carried out in accordance with the way operated in TE.

The implementation of the javascript code in BS is as follows:

Events to add actions:

/ / left button, right button, real-time refresh

Sgworld.AttachEvent ("OnLButtonDown", OnLButtonDown)

Sgworld.AttachEvent ("OnRButtonDown", OnRButtonDown)

Sgworld.AttachEvent ("OnFrame", OnFrame)

/ / left button event

Function OnLButtonDown (Flags,X,Y)

{

/ / the sign of whether to start plotting

If (cflag)

{

Var Iwordpoint= sgworld.Window.PixelToWorld (Xmeny Yphai0)

If (Cone==null)

{

Var nLineColor = 0xFF0000FF

/ / create a conical object

Cone=sgworld.Creator.CreateCone (Iwordpoint.Position,1,0,nLineColor,nLineColor,12,0, "circle")

}

Else

{

Var dis = sgworld.CoordServices.GetDistance (Cone.Position.X, Cone.Position.Y, Iwordpoint.Position.X, Iwordpoint.Position.Y)

/ / judge the circle at the bottom first

If (hflag)

{

Var dis1 = sgworld.CoordServices.GetDistance (0, Cone.Position.Y, 0, Iwordpoint.Position.Y)

Cone.Height=dis

Cflag = false

}

/ / set the radius and height of the cone

If (Cone.Height = = 0 percent percent flag) {

Cone.Radius = dis

Cone.Height=dis

Hflag=true

}

}

}

}

/ / right-click event to end the cone drawing

Function OnRButtonUpp (Flags,X,Y)

{

Cflag = false

Cone=null

Hflag=false

}

/ / Real-time refresh event

Function Onframe ()

{

If (cflag)

{

/ / Radius transformation of the bottom circle

If (contains contains null)

{

Var Imousinfo = sgworld.Window.GetMouseInfo ()

Var Iwordpoint = sgworld.Window.PixelToWorld (Imousinfo.X, Imousinfo.Y, 0)

/ / change the radius according to the distance

Var dis = sgworld.CoordServices.GetDistance (Cone.Position.X, Cone.Position.Y, Iwordpoint.Position.X, Iwordpoint.Position.Y)

If (Cone.Height = = 0 percent percent flag) {

Cone.Radius = dis

}

If (hflag)

{

/ / height change

Var dis1 = Imethod.getdistance (0, Cone.Position.Y, 0, Iwordpoint.Position.Y)

Cone.Height=dis1

}

}

}

}

The above is all the content of the article "how to dynamically draw cones in TE". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Cone event radius dynamic content real-time bottom article height transformation code value interest cone object boy buddy way more logo Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Huawei MariaDB Xiaomi Linux