Topic: 3D representation of a graph with maratis

Hi maratis users wink

for one of my university project, I had to do a program that can store the differents points (representing the places of a ski resort) and the roads that link the points together.

all the informations is contain in a file like this one :

5 // nb points
1    villaroger    1200    // name of the points / altitude    
2    2    1425        
3    3    2135        
4    4    2458        
5    aiguille-rouge    3226            
3 // nb edges
1    aiguille-rouge    TPH    2    5 // name of the edge / type of the edge / index of the start point / index of the end point
2    aiguille-rouge1    N    5    4
3    aiguille-rouge2    N    4    3

The final purpose is to apply a shortest path algorithm on any of two points of the graph, so i decided to use maratis for a 3d graphical representation of the graph

controls :
-> z,q,s,d : move in the scene (free flight code supply by anaël)
-> maj : display the points name
-> left click : select first point - second point
-> right click : erase the selection

the source code of the project is contain in the folder, if someone is interested wink

Have fun with maratis !

https://www.dropbox.com/s/528kbh3nt4evrpi/published.zip

http://img15.hostingpics.net/pics/410985ensemble.png

http://img15.hostingpics.net/pics/442877shortest.png

Last edited by Alinor (2013-11-25 22:53:41)

Re: 3D representation of a graph with maratis

It's good to see this type of use for Maratis. I am checking it out!

I couldn't close the window. Perhaps add a key event for escaping?

Last edited by Tutorial Doctor (2013-11-25 00:28:55)

Re: 3D representation of a graph with maratis

nice !

Re: 3D representation of a graph with maratis

I couldn't close the window. Perhaps add a key event for escaping?

Yes, That would be a good improvement, but in fact I have no idea how to do this ^^

Thanks for your comments wink

Last edited by Alinor (2013-11-25 18:28:12)

Re: 3D representation of a graph with maratis

Alinor wrote:

I couldn't close the window. Perhaps add a key event for escaping?

Yes, That would be a good improvement, but in fact I have no idea how to do this ^^

Thanks for your comments wink

In  a lua script all you would have to do is:

function onSceneUpdate()

if isKeyPressed("Q") then quit() end

end

Re: 3D representation of a graph with maratis

thanks wink

Re: 3D representation of a graph with maratis

Pretty cool ! By the way, what have you used to make the spheres looks like that ? i like that look !

Re: 3D representation of a graph with maratis

It looks like a sphere with a ramp material (gradient material).

You could do a 2 frame material animation to change the color (this is what I did for the light bulbs I posted that change color). This way you can just set a frame for the material to change the color of the bulb with code.

Re: 3D representation of a graph with maratis

Pretty cool ! By the way, what have you used to make the spheres looks like that ? i like that look !

Like Tutorial Doctor say, it's ramp material using the reverse scalar product between the normal of the face and the position of the camera, like this higher is the scalar product, lower is the the value.
after I multiply the value and the MaterialEmit.

fragment shader:

    vec3 N = normalize(normal);
    float v = dot(normalize(-position), N);
    
    v = 2.0/pow((1+v), 4.5); // you can change 2.0 with what you want to play on the contrast
    gl_FragColor = vec4(MaterialEmit*v, 1.0);

Last edited by Alinor (2013-11-28 12:25:23)

Re: 3D representation of a graph with maratis

Thanks guys wink gonna make some experiments with this