Get information from a mesh node?

Forums: Get information from a mesh node?
Forum for OctaneRender Lua scripting examples, discussion and support.

Re: Get information from a mesh node?

Postby stratified » Tue Jan 21, 2014 8:28 pm

stratified Tue Jan 21, 2014 8:28 pm
If you go via the vertices, it gives you the same dimensions as the original OBJ file... So if you scale it, you have to recalculate the scaling yourself.
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Get information from a mesh node?

Postby bepeg4d » Tue Jan 21, 2014 11:49 pm

bepeg4d Tue Jan 21, 2014 11:49 pm
ok thomas, thanks for the clarification ;)
ciao beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 9940
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Get information from a mesh node?

Postby AndreasBergmann » Mon Oct 08, 2018 8:12 am

AndreasBergmann Mon Oct 08, 2018 8:12 am
Hi,
I like this script, thanks!
Do you think it is posssible to get not only position but also rotation of a plane?

Best,
Andreas
AndreasBergmann
Licensed Customer
Licensed Customer
 
Posts: 15
Joined: Fri May 20, 2016 7:49 am

Re: Get information from a mesh node?

Postby jitendra » Thu Dec 08, 2022 3:56 am

jitendra Thu Dec 08, 2022 3:56 am
Hey Jason,
This script is still working well.
But can you help with converting this to a Scripted Nodegraph?
I want to use the output bounding box values in dynamically positioning other object (e.g. ground floor).
Happy to pay for the task as well.
Thanks.

grimm wrote:Thanks Thomas, that's good to know. Here is my function if anyone is interested, any ideas to make it better will be greatly appreciated.

Code: Select all
-- calculate the statistics of a mesh and return a table of those values
function getMeshStats(verts)
  local meshStats = {}
  local minX = 0
  local maxX = 0
  local minY = 0
  local maxY = 0
  local minZ = 0
  local maxZ = 0
  local lengthX = 0
  local lengthY = 0
  local lengthZ = 0
  local x, y, z

  -- find the bounding box
  for k,v in pairs(verts) do
    x = v[1]
    if x > maxX then maxX = x end
    if x < minX then minX = x end
    y = v[2]
    if y > maxY then maxY = y end
    if y < minY then minY = y end
    z = v[3]
    if z > maxZ then maxZ = z end
    if z < minZ then minZ = z end
  end

  meshStats["min_x"] = minX
  meshStats["max_x"] = maxX
  meshStats["min_y"] = minY
  meshStats["max_y"] = maxY
  meshStats["min_z"] = minZ
  meshStats["max_z"] = maxZ

  -- find the mesh's length for each axis
  lengthX = maxX - minX
  lengthY = maxY - minY
  lengthZ = maxZ - minZ

  meshStats["x_len"] = lengthX
  meshStats["y_len"] = lengthY
  meshStats["z_len"] = lengthZ

  -- find the mesh's position
  local posX = lengthX/2.0 + minX
  local posY = lengthY/2.0 + minY
  local posZ = lengthZ/2.0 + minZ

  meshStats["pos_x"] = posX
  meshStats["pos_y"] = posY
  meshStats["pos_z"] = posZ

  return meshStats
end

selectedMesh = octane.project.getSelection()[1]
verts = selectedMesh:getAttribute(octane.A_VERTICES)
meshStats = getMeshStats(verts)

print "X info"
print(meshStats["pos_x"])
print(meshStats["min_x"])
print(meshStats["max_x"])
print "Y info"
print(meshStats["pos_y"])
print(meshStats["min_y"])
print(meshStats["max_y"])
print "Z info"
print(meshStats["pos_z"])
print(meshStats["min_z"])
print(meshStats["max_z"])


If you do run the script, just make sure to select a mesh node first. Otherwise it will not work. :)

Jason
Best Regards, Jitendra
jitendra
Licensed Customer
Licensed Customer
 
Posts: 140
Joined: Sat Oct 16, 2010 6:09 am

Re: Get information from a mesh node?

Postby grimm » Fri May 05, 2023 4:26 pm

grimm Fri May 05, 2023 4:26 pm
jitendra wrote:Hey Jason,
This script is still working well.
But can you help with converting this to a Scripted Nodegraph?
I want to use the output bounding box values in dynamically positioning other object (e.g. ground floor).
Happy to pay for the task as well.
Thanks.


Hi jitendra,

Sorry for not getting back to you sooner, I didn't see your message until today. If you still need my help with converting the function over that is no problem.

Jason
Linux Mint 20 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 460.56
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1321
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA
Previous

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 7 guests

Thu Mar 28, 2024 2:35 pm [ UTC ]