View Full Version : How to crete a box along an edge ?
Zbuffer 11-21-2005, 03:20 PM Hi,
Basically, I would like to place a box along one edge of a mesh.
I have tried different ways with no luck
i can get the position, by using the vertices,
but can't align the rotation ..
Could anyone help me out ?
thanks in advance.
|
|
Hi,
Basically, I would like to place a box along one edge of a mesh.
I have tried different ways with no luck
i can get the position, by using the vertices,
but can't align the rotation ..
Could anyone help me out ?
thanks in advance.
Every node has a .DIR property which is coincident with its positive Z axis.
So you can place the box at the first vertex and set the .DIR property to the vector defined by the second vertex minus the first vertex. Voila!
Every node has a .DIR property which is coincident with its positive Z axis.
So you can place the box at the first vertex and set the .DIR property to the vector defined by the second vertex minus the first vertex. Voila!
(
fn createBox v1 v2 theName =
(
b = box width:1 length:1 height:(distance v1 v2) name:("Edge_"+theName)
b.dir = v2 - v1
b.pos = v1
b
)
fn createEdgeBoxes theObj =
(
theMesh = snapshotasmesh theObj
edgesDone = #()
for f = 1 to theMesh.numfaces do
(
theFace = getFace theMesh f
theVert1 = getVert theMesh theFace.x
theVert2 = getVert theMesh theFace.y
theVert3 = getVert theMesh theFace.z
if (getEdgeVis theMesh f 1) AND findItem edgesDone (theFace.x as string + "_" + theFace.y as string) == 0 do
(
createBox theVert1 theVert2 (theFace.x as string + "_" + theFace.y as string)
append edgesDone (theFace.x as string + "_" + theFace.y as string)
append edgesDone (theFace.y as string + "_" + theFace.x as string)
)
if (getEdgeVis theMesh f 2) AND findItem edgesDone (theFace.y as string + "_" + theFace.z as string) == 0 do
(
createBox theVert2 theVert3 (theFace.y as string + "_" + theFace.z as string)
append edgesDone (theFace.y as string + "_" + theFace.z as string)
append edgesDone (theFace.z as string + "_" + theFace.y as string)
)
if (getEdgeVis theMesh f 3) AND findItem edgesDone (theFace.x as string + "_" + theFace.z as string)== 0 do
(
createBox theVert1 theVert3 (theFace.x as string + "_" + theFace.z as string)
append edgesDone (theFace.x as string + "_" + theFace.z as string)
append edgesDone (theFace.z as string + "_" + theFace.x as string)
)
)--end f loop
)--end script
for o in selection where superclassof o == GeometryClass and classof o != TargetObject do createEdgeBoxes o
)--end script
Zbuffer
11-22-2005, 01:42 AM
That's bobo ! you made my day,
This .DIR properties, i didn't know of !
That will be really usefull !
Thanks a million time :) :) :)
CGTalk Moderation
11-22-2005, 01:43 AM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.