- December 17, 2009 at 2:17 am #30011
I am trying to export a spline from 3DS max 8 to be used as a path.
So apparently the powerVRpod exporter does not export splines, right? Or am I doing something wrong?
Does anyone have an easy and quick alternative or a solution to this issue? Maybe another exporter that I can use to export from max 8, that won’t be difficult?January 7, 2010 at 12:28 pm #33613
ScottModeratorHi,carnifex wrote:I am trying to export a spline from 3DS max 8 to be used as a path.
So apparently the powerVRpod exporter does not export splines, right? Or am I doing something wrong?You’re correct PVRGeoPOD does not export splines. The 3DS Max version of the exporter has been incorrectly including an ‘export splines’ option for a while and this has been removed for our next SDK release.carnifex wrote:Does anyone have an easy and quick alternative or a solution to this issue? Maybe another exporter that I can use to export from max 8, that won’t be difficult?Nothing quick and easy comes to mind. How do you plan to use the spline in your application?Thanks,ScottAugust 17, 2010 at 3:45 am #33614
Although I realize based on the above answer the option to export spline has been removed (and wasn’t really there either) I have a situation where it would be convenient to export a spline.
In particular, I have a spline in 3d studio max, which I (3d studio max) sorta lofts into a pipe. I edit the tunnel, flip the normals, slap some textures on the inside et voila, a tunnel is born.
Next I have a camera, which I place in the tunnel. I would like this camera to follow the spline/path on which the tunnel is based (the central path).
So ideally I would export the path + tunnel + camera in the same pod file, then move and rotate the camera along the vertexes of the path. However, as noted already, the export spline option does not exist. Bummer.
But now that I explained how I would want to use the spline as a path, can you suggest another method?
I’ve considered the following options:
– Export to OBJ and then use a perl script to get the unique vertexes. Even though it creates triangles when exporting, by getting the unique vertexes only I end up with vertex array that makes up the path. The problem with this approach is that I have no idea how to align the path vertexes with the tunnel mesh from the pod file. For example the camera position read from the POD file doesn’t match the position of the camera in 3d studio max.
– Store an addition camera for each node/vertex of the path/spline. That would mean abusing the camera nodes simply for to store locations. Even though it might actually work, it sounds like a bad idea, I would end up with 100 ghost cameras.
Any better suggestions? (I’m using the IntroducingPOD sample as a basis sort of).August 17, 2010 at 4:28 am #33615
I faced a similar problem when exporting from Lightwave .. in the end I ended up writing a simple Lightwave based script to export to an ascii file.
If you want to stay with PODs .. I could think of two ways …
1. Create a node based animation with each control point (spline) ending up as a keyframe ( I am not sure how to do it with MAX 8 but I know PODs do support these types of animations)
2. Create a chain of triangles with each triangle starting at a control point and terminating on another – if you encode your starting vertex with an unique color you could then
quickly scan the mesh and collect all relevant points.
In the end all you need is a collection of Vector3s – to get a decent camera animation you will need to treat them as a spline of sorts and parameterize on some t value.August 17, 2010 at 5:51 pm #33616
Thanks for the reply. I actually ended up using this SDK and the POD format based on one of your posts (at that blog about exporting to .h header format of that Apple sample code) and have read quit a few of your helpful answers in the Apple dev forums as well. So thanks for that too 🙂
I think option 1 will be similar to my option 2, with the difference being how the camera positions are stored. Doable but far from convenient (also because of 3dsm).
Option 2 sounds interesting, after all I’d only have to scan and collect once (basically at the start of a level, the tunnel being a ‘map’ or ‘track’) and the path’s scale would math the tunnel perfectly.
I would prefer to use my own scripts as well. I’m able to export the path to an array of Vec3, and use line loop to actually draw it, all works fine. However, the scaling is all off. I guess I could scale and rotate the path with a bunch of math to make it fit in the tunnel but that seems so wrong (calculating the word game logic space to match the POD scene rather than vice versa).
Perhaps I should rephrase my question:
Let’s say I have a POD scene with objects (the tunnel)+camera+light and I also have another 3d object (path) that is not in POD, how would I go about lining them up in terms of scale, position and rotation?
I’m going to try your option 2 unless anyone can suggest a more obvious/convenient option. (if it wasn’t obvious yet, I don’t merely want the camera to follow a path at a fixed speed, the path acts as a constraint while the playerobject+camera moves through the tunnel).
“In the end all you need is a collection of Vector3s – to get a
decent camera animation you will need to treat them as a spline of sorts
and parameterize on some t value.
” Exactly. I plan to read the vec3 array into a more extended array containing additional info per node, like the normal and maybe segment lengths and distance on path.August 17, 2010 at 9:47 pm #33617
I actually thought you wanted to build your geometry on the fly around your spline control points â€¦
If you do have a POD model for the tunnel then you could again create a separate color channel for your vertices ( which would not be used during rendering)
and encode each â€œringâ€ of vertices where your tunnel geometry changes direction with some sort of encoding scheme ( say rgb contains a sequential number so the first ring of your tunnel would be marked as 1 , the second as 10 or whatever and mark every other vertex which is not part of the â€œringâ€ with a designated color â€“( 0) )
When loading your POD file you could simply do something like this:
Std::map<int, std::vector<Vector3> > map;
You would scan all your vertices and for each vertex which is not designated as rgb 0 , you would add it to the corresponding entry in the map ( where the int key would map into your rgb value)
Then you would walk the map( which would already be sorted in the correct order given its keys) and calculate a mean average of all points within the vector , which should given you a pretty much perfect center point for each tunnel â€œringâ€ ( and thatâ€™s your spline control point)
It is kind of hackish ( I just came up with it ) but it should work â€¦ you would have to make sure that your tunnel â€œsegmentsâ€ are spaced at even intervals otherwise your will have problems â€œtravelingâ€ at a constant speed.August 18, 2010 at 12:30 am #33618
No, like I mentioned in my first post I would like to export the path+tunnel in to the same pod file but I actually did extensively consider a procedural tunnel but considering the performance of using POD and the ability to cut the tunnel model in separate meshes (and draw only those the player actually sees) and the flexibility in regards to shape and size variations I’m going for lofting the tunnel in 3dsm instead of opengl.
So basically, I have a spline in 3ds max, of which I create a copy, that copy gets lofted into a pipe/tunnel with the original spline as the central path. I texture the tunnel in 3dsmax as well. I have to change the central path from a spline into a mesh object before exporting.
If I’m reading your second reply correctly you are suggesting to procedurally create the central path based on the tunnel. An interesting suggestion be it that’s it’s the opposite of how I started, creating a procedural tunnel based on the path.
I don’t think that’s needed because I have both the tunnel ‘and’ the path now in the pod file based on your suggestion earlier. I now have a uhm… triangulated strip of square polygons as the central path (based on a copy of the tunnel with a tiny diameter of which I took 1 ‘side’). I set the color for the vertexes that matter, and I can abuse the R value to set the order and where the start of the tunnel is (regardless of the how it’s created/exported).
You reduced my question to: how to read xyz and R values of a given mesh in a POD file (once before any rendering, the path mesh itself is never rendered). Something I can hopefully find myself… looking, [edit: ah it’s actually inside the demo I’m using…]. Thanks again for the help.
JMan 2010-08-18 01:38:53August 18, 2010 at 10:57 am #33619
It seems the basic desire here is to get a camera to move along a spline. Why not just do this in 3dsmax (I’ve done it myself in the past but can’t remember how off the top of my head!) and export the POD file with animation? You still won’t have the actual spline in the POD file, but the camera’s animation will take it along that path.
Aaron 2010-08-18 10:58:11August 18, 2010 at 4:52 pm #33620Aaron wrote:It seems the basic desire here is to get a camera to move along a spline. Why not just do this in 3dsmax (I’ve done it myself in the past but can’t remember how off the top of my head!) and export the POD file with animation?
Well, because I’m creating an interactive game and not merely an animation
So there’s a lot more to it than merely moving a camera along a path. Player object and other game objects are also placed and rotated along the path (with offsets). The path will act as a constraint to keep stuff in the tunnel, camera and objects. Speed is variable and so is the rotation of the camera.
Having the spline available as a simple array of vec3, on the same scale as the tunnel, is the basic desire.
After going through the SDK tools yesterday I ran into the ReadVertex function and some podmodel functions that use it which I should be able to turn into function that reads only the positions of vertexes of which R (from ARGB) is > 0.
That all said, do you have any plans of adding the Export to Spline option (back) to the Max (and other) exporters? Besides being able to export ‘paths’ it could be used to draw lines/lineloops.
Thanks for the reply.August 19, 2010 at 1:14 am #33621
Turns out to be quite a bit more complicated than I hoped for. My Mesh.sVtxColours.eType = EPODDataARGB, which is not a ‘case’ in the ReadVertex function. I guess I could used the code for EPODDataRGBA and convert myself but is there a particular reason for the case EPODDataARGB in the ReadVertex function to be empty? (in PVRTVertex.cpp)
Here’s what I planned:
Create a function PVRTModelPodReadPath that takes SPODMesh &mesh as input and spits out vector3 array ‘path’ that contains only the vertex positions of the vertexes that have an R (from ARGB) value higher than 0.
Should I use ReadVertex for each vertex in sFaces.pData and get the same vertex from sVtxColours.pData to check if it’s R value > 0?
For some reason Mesh.sVertex.pData is always nil when debugging… even though the models are drawn fineAugust 19, 2010 at 2:58 am #33622
That’s probably because you exported your mesh with interleaved vertex data and everything is located at SPODMesh->pInterleaved.
When the mesh is interleaved CPODData.pData refers to an offset from SPODMesh->pInterleaved.
In case of sVertex, the offset it most likely 0 because Position is the first entry in iSPODMesh->pInterleaved.
In other words if you have a mesh which contains …say Position, Normal, Color and it is interleaved you will end up with something like this:
SPODMesh->pInterleaved = Position1,Normal1,Color1,Position2,Normal2,Color2….
SPODMesh->sVertex->pData is the offset of Position1 within pInterleaved
SPODMesh->sVertex->nStride distance in bytes from Position1 to Position2 within pInterleaved
SPODMesh->sNormals->pData is the offset of Normal1 within pInterleaved
SPODMesh->sNormals->nStride distance in bytes from Normal1 to Normal2 within pInterleaved
SPODMesh->sVtxColours->pData is the offset of Color1 within pInterleaved
SPODMesh->sVtxColours->nStride distance in bytes from Color1 to Color2 within pInterleaved
You can easily use this information to scan pInterleaved and retrieve color values as Ints.August 20, 2010 at 3:54 am #33623
Ok, that clears things up quite a bit.
unsigned int i;
for(i = 0; i < vCnt; ++i)
// Read the color vector
PVRTVertexRead(&v, mesh.pInterleaved + (size_t)mesh.sVtxColours.pData + i * mesh.sVtxColours.nStride, mesh.sVtxColours.eType, mesh.sVtxColours.n);
//check v values and read vertex positions if necessary/unique…
I checked the value of v and it actually works, just have to multiply with 255 to get the int value I used in 3dsmax. Awesome, thanks a lot for the help Warmi. It may not be an obvious way to get a path from 3dsmax to POD/iPhone but it once set up it’s actually quite practical. I can basically mark an edgeloop (though doesn’t need to be closed) of any mesh with a color in 3dsmax to make that end up as a spline/path in opengl.
JMan 2010-08-20 03:56:25