Archive: 3d model files -> render/triangle


16th April 2005 09:34 UTC

3d model files -> render/triangle
i made a little tool for converting wavefront .obj into a .gvm for use with the global variable manager (load/save) ape.

i chose .obj as its easy to read in and sketchup can export it

also there is a preset (very simple - 50/50 blended tris) showing a ~1500 poly model, its a simple model i've made its not meant to be a preset...

from the code you can see the megabuf structure used. the (currently) unused 1,2 and 3 slots are used to hold the face normal.

idiots may steal this triangle and use their own exported objs with it (its intentionally rubbish)

if you look at the code note that i shifted the model down cos i saved it 'not on the origin'. :p

use

objconv myobj.obj mygvm.gvm 0

0 is the offset for the data in megabuf (you can change this if you want multiple models for example)

example preset and model data attached:


16th April 2005 09:37 UTC

also here is the tool and a slightly updated global variable manager now with less crashes. but still no aperesize support on account of my lazyness and messy code. sorry tomy.

also sorry for two posts. its to dodge the filesize limit.


19th April 2005 18:39 UTC

lots of d/ls. but no feedback. any suggestions? want more formats? find any more bugs in the gvm ape?


19th April 2005 20:36 UTC

I downloaded it.... but I guess I didn't know what to do with it. :confused:
I thought I followed the instructions but when looking at the example, I'm presented with a blank screen.

No problems with the gvm. I love the newer option of being able to expand the code boxes. I only wish, as you said, that it was implemented with resize support.


20th April 2005 05:07 UTC

blank screen? thats odd

i've had all kinds of complaints that its broken in varying ways... problem is i cant fix anything without feedback :)

one thing that seems to fix it is to load one gvm preset then another then another... after three or four it seems to start working properly. i am still trying to fix it up a bit better... but i really cant work it out.

some presets seem to work always. specifically those that don't load on the first frame and use multiple loads seem to work okay all the time. :/

resize support will come when i work out the bugs


21st April 2005 06:43 UTC

Way cool, but it doesn't rotate so I can see the triangle "face"


21st April 2005 10:34 UTC

Again Matt your lack of reading, logical deduction and common sense have contributed towards another rubbish post.

It is rotating fine... but the data hasn't loaded properly...


30th April 2005 23:43 UTC

by using 'load once' the load problems seem to have disappeared...

this version uses the triangle z-buffer and back face culling to do a reasonable non-transparent render. it has some z-fighting because of the large size of some of the tris... this can be avoided in models by splitting up larger tris.

edit: you will need to add zbclear=1 to the triangle code (per frame)


1st May 2005 05:14 UTC

:) This brought a smile to my face. I wasn't expecting an actual plane.

I don't think this is what Tomy had in mind when he wrote the triangle, but who cares? It looks awesome!

I only wish I knew how to use triangle as well...:(


1st May 2005 06:04 UTC

well open up 3ds max... model a plane. export to alias/wavefront obj (you can get a plugin if its not a default cos i have that option) then steal the triangle above and compile a different gvm using objconv. :P

the idea of all this is that you dont have to be a frikkin genius to do some presets with 3d models.

about using the z-buffer with triangle tho... you need to subdivide the model to avoid z-fights like that plane gets... lots of small equilateral-ish triangles are ideal.


2nd May 2005 19:50 UTC

Originally posted by denkensiefursic
I don't think this is what Tomy had in mind when he wrote the triangle
uh, actually this was exactly what i had in mind when writing triangle.ape *g*

2nd May 2005 22:55 UTC

touché

what else is triangle ape for? making 2d triangles? pfft...

:p


3rd May 2005 04:50 UTC

Touché, indeed. I raise my drink to you, as it appears I am mistaken.


6th May 2005 16:27 UTC

Jheriko, which plugin did you use?
I already tried three, and non of them worked properly.
I end up with .gvm files that only have data on every 7th 8th and 9th line or so.


9th May 2005 07:25 UTC

which plugin to export obj i guess?

i used sketchup with the sketup obj exporter. it is important to set it to export to just triangles though... otherwise some tris will be missing... although i'm not sure thats what you mean. could you perhaps paste a little sample of the gvm to clarify the problem?


9th May 2005 14:21 UTC

Sure. The .obj file I used is also included in the zip.


9th May 2005 20:21 UTC

no normals are in that obj file. thats why some of the data lines are always zeros


10th May 2005 00:32 UTC

further to that... (shame i can't edit after several hours :p)

objconv averages vertex normals if they are given to create a face normal. so if you have vertex normals all over some curves (model packages often do this with curves) they will get 'flattened out' a bit.

Since the software triangle ape has no vertex blending there is no reason to have a normal for every vertex (makes big .gvm files too).


11th May 2005 19:11 UTC

I'm using autocad for rendering, then import it to 3ds max and export it as .obj. I suppose all dimensions should be smaller than 1 or does it autoresize the render to
< 1?


11th May 2005 20:26 UTC

it exports the coords in whatever scale you use in the editor. personally i just make the model then change the camera etc... to match the scale.


10th June 2005 16:33 UTC

For shylent,asdfg and whomever...

notes:

it makes an ini file on first run that you can edit to set options

format of gmegabuf entries is:

number of triangles
[normal]
vertices
[gloss maps etc... in the order they are in the ini file]

I think thats right, try it out, ask me on #avs or post here if it doesnt work for some reason or you need more details


15th June 2005 00:51 UTC

ewww, sections...
interleaved ftw!


15th June 2005 07:40 UTC

functional difference?

if anything doing in by 'sections' rather than 'interleave' makes it easier to manage optional material properties.


15th June 2005 14:38 UTC

I wrote that description in a hurry, it is interleaved, all the data for each triangle is saved seperately

[number of triangles]
// triangle 1
[normal x]
[normal y]
[normal z]
[vertex 1 x]
[vertex 1 y]
[vertex 1 z]
[vertex 2 x]
...
[vertex 3 z]
[diffuse red]
[diffuse green]
[diffuse blue]
[ambient red]
[ambient green]
...
// triangle 2
[normal x]
[normal y]
[normal z]
[vertex 1 x]
[vertex 1 y]
[vertex 1 z]
[vertex 2 x]
...
[vertex 3 z]
[diffuse red]
[diffuse green]
[diffuse blue]
[ambient red]
[ambient green]
...

etc....

incidentally I just checked the source code for Jet Wash so I could post an example of why its easiest this way... but it was saved on my desktop in a text file and I reformatted without saving it :(


15th June 2005 23:39 UTC

interleaved is faster


16th June 2005 01:03 UTC

The difference in speed is negligible, its more about design preference


16th June 2005 08:27 UTC

if you have 12 coords for a tri (normal xyz, vertex 1/2/3 xyz)

then interleaved is easy to code as 12*i+0, 12*i+1 etc for each component doing sections makes it annoying as you have to use sectionstart+i instead, 12*i+(1..12)+offset, storing the number of tris in offset, is normally how i do it. interleaving the triangle data and using sections (offset) to split the model into different materials.

i know using 1 triangle render is r33t but i just prefer editing the material in avs because when you can see it in the renderer moving around and being lit you can get a feel for the effects of the values you are putting in.

again... design preference rather than a speed thing, although it also keeps filesizes down a bit as the 'map' data is gone from the gvm files and in to the avs preset as a much smaller single assignment, rather than 100s.


16th June 2005 10:02 UTC

Originally posted by jheriko
i know using 1 triangle render is r33t but i just prefer editing the material in avs because when you can see it in the renderer moving around and being lit you can get a feel for the effects of the values you are putting in.
I cant edit those presets in AVS because I can't use the new AVSTrans (the old one causes infinate load times blah blah Im sure you know...) so that particular benefit is achedemic.

16th June 2005 12:59 UTC

let's say we have 8 properties for each vertex


interleaved:
index=pn*8+3; // can be optimized by counting with pn=pn+8;

sections:
index=pn+3*n; // can be optimized by having 7 variables in 'Frame' (offset1=1*n; offset2=2*n; offset3=3*n; ...)

16th June 2005 13:29 UTC

So I put the egg in my mouth... THEN I suck... oh ok.


16th June 2005 15:28 UTC

one advantage is that you dont need to set 7 variables to make it effective

the bigger advantage is that you can dynamically alter the triangle count