: Extracting vertex data of a 3D Model using 3D Modelling software I know the title might sound a bit confusing but there is method in my madness. Firstly, the type of data i'm trying to extract
I know the title might sound a bit confusing but there is method in my madness. Firstly, the type of data i'm trying to extract is every position and angle of every vertex used to form the 3D Model that you see inside the software (in a sense). Blender is a good example of being able to picture this as it has the wireframe render, whereby you can create a 3D wireframe, around the entire model. What i'd therefore be looking to do is get the position and angles of every wire in the wireframe, as blender must have a way of mapping the wireframe, based on vertices of the 3D model?
It may sound like a long-winded and confusing question, but I'm not sure how to put it into simpler terms, and seems like something that nobody has talked about or tried to find before?
Here's an example to help you understand what i'm trying to find:
This is a 3D Wireframe, made based on a 3D Model, in blender. Somehow, the software must know or calculate all the vertices it uses to make this wireframe. I imagine the data for each vertex is held in terms of xyz position vector local to the models origin, alongside an angle local to the models origin, otherwise how can the software form this wireframe? P.s. If I could extract the data on the position of the edges in the wireframe post rendering that could be even more helpful.
So after laying all the foundations, my end question to you is: Is there any way of extracting the data I've talked about from a piece of 3D Modelling software?
The reason behind my question: I'm trying to extract this data on the vertices so I can create some code that will use this data to recreate the model in a sandbox game such as garry's mod, with every square you see in the wireframe being an entity. This would be an amazing experiment and I can't wait to see if and how it's possible!
More posts by @Jessie844
2 Comments
Sorted by latest first Latest Oldest Best
If you want to do some processing with the mesh data or format it to your taste, you can access it directly in blender through the python API, either using the CLI to run a python script in the background, like blender -b myfile.blend -P myscript.py or running the script from blender's text editor, there is also a python console where you can access the data.
The mesh data that you want can be found in the mesh objects data property.
import bpy
obj_data = bpy.data.objects['Cube'].data
for v in obj_data.vertices:
print('Vertex',v.index,'is at', v.co)
for e in obj_data.edges:
print('Edge',e.index,'connects vertices',e.vertices[0],'and',e.vertices[1])
for f in obj_data.polygons:
print('Face',f.index,'uses vertices', end=' ')
for fv in f.vertices:
print(fv, end=', ')
print()
Yes its possible. That is after all what save does, writes down the positions of each vertex, normal information and connectivuty information to disk. So if we simplify the problem a bit and take a look at a box:
Then save it as *.obj and then open the thing in a text editor then you would see:
# This file uses centimeters as units for non-parametric coordinates.
mtllib test.mtl
g default
v -0.500000 -0.500000 0.500000
v 1.620616 -0.500000 0.500000
v -0.500000 0.500000 0.500000
v 1.620616 0.500000 0.500000
v -0.500000 0.500000 -0.500000
v 1.620616 0.500000 -0.500000
v -0.500000 -0.500000 -0.500000
v 1.620616 -0.500000 -0.500000
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.625000 0.250000
vt 0.375000 0.500000
vt 0.625000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 1.000000
vt 0.625000 1.000000
vt 0.875000 0.000000
vt 0.875000 0.250000
vt 0.125000 0.000000
vt 0.125000 0.250000
vn -0.000000 0.000000 1.000000
vn -0.000000 0.000000 1.000000
vn -0.000000 0.000000 1.000000
vn -0.000000 0.000000 1.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
s off
g pCube1
usemtl initialShadingGroup
f 1/1/1 2/2/2 4/4/3 3/3/4
f 3/3/5 4/4/6 6/6/7 5/5/8
f 5/5/9 6/6/10 8/8/11 7/7/12
f 7/7/13 8/8/14 2/10/15 1/9/16
f 2/2/17 8/11/18 6/12/19 4/4/20
f 7/13/21 1/1/22 3/3/23 5/14/24
Well simply the lines beginning with:
v are vertex positions, first one has index 1
vt are the texture coordinates, first one has index 1
vn are normals (or the angles pointing at), first one has index 1
.... Some extra stuff
f connevtivity info what triange/quad go with what postion, texture and normal index.
But to be honest you wont be doing this with the car model you have since it has hundreds of thousands of points.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.