Another 4D viewer

Discuss interdimensional programming, Java applets and so forth.

Another 4D viewer

Postby Mrrl » Fri Nov 18, 2011 4:49 pm

I think, it's time to open a separate topic for the viewer.

Binaries for the viewer with three sample files may be found there: http://astr73.narod.ru/4DView/View4Dv4.zip
Source files: http://astr73.narod.ru/4DView/View4Dsrc.zip

Viewer is written in C# using OpenToolkit Library: http://www.opentk.com

Instructions are easy:
Run viewer, select File/Load item and load one of samles .txt files. Navigation is by mouse with Ctrl and Shift keys:

Let X be "left/right", Y - "up/down", Z - "ana/kata" and W - "forward/backward" directions.
Then:
Left Button: rotation of object in X/W and Y/W directions (3D rotatiion)
Shift+Left Button: rotation in X/Z and Y/Z directions (rotation of section space preserving direction of view)
Ctrl+Left Button Up/Down: Zoom In/Zoom Out
Ctrl+Left Button Left/Rigth: rotation of object in Z/W direction (rotation of section space along the sceen plane)
Right Button: rotation of camera in X/W and Y/W direction (rotate head in 3D)
Shift+Right Button: same as Shift+Left Button
Ctrl+Right Button Up/Down: Slide Forward/BackWard (don't use it! You'll be lost in no time. And directions are swapped now )
Ctrl+Right Button Left/Right: rotation of head in Z/W direction. It is the most easy way to see a sequence of parallel 3D sections of the object.

You may turn on and off 3D Seciton or 3D Projection of the scene. Also you may switch between wireframe and translucent mesh representations of the projection. Slide bar controls the level of projection transparency.

Now scenes are coded in text files. First goes number of vertices, then 4D coordinates of vertices (better to keep one vertex per line). Coordinates are integer! Consider them as microns :)
Next line contatins number of tetrahedral cells, and each of next lines contains 5 numbers: indexes of vertices of the tetrahedron (0-based) and hexadecimal color of cell (in format AARRGGBB). Now Alpha value is being ignored, but I'll activate it in next versions.
Cells are sensitive to the orientation, so be careful with them. If for some facet of the cell there is no pair in some other cell, it is considered as an "edge" of the surface and will always appear in the projection view.
Mrrl
Trionian
 
Posts: 165
Joined: Sun May 29, 2011 7:37 am

Re: Another 4D viewer

Postby Mrrl » Fri Nov 18, 2011 5:08 pm

quickfur wrote:Hmm. Perhaps the solution is to disable depth buffering, and make sure rendering is back-to-front?


No, I want to keep depth buffer for 3D section: opengl works better than me with depth.

This way, I can keep the 4D camera fixed, and then rotate the 3D camera to give the user a good view of the 3D structure seen by the 4D camera without changing the 4D viewpoint.


For that I have Shift key movements that keep camera position and W direction fixed, but run across x,y an z directions giving imperssion that you go around 4Der view. Interesting thing: both (x/w,y/w) and (x/z,y/z) types of rotations look like rotation of the solid body on 2D screen. But this body magically changes its shape when you switch between types of rotations. Like there are two depth functions for the same (x,y) scene.

What I did now for the output:
1) Split large rigdes to smaller triangles (not more than 0.03 radians) before output of the projection - my depth sorting works better in this case, there is just small garbage along edges
2) changed opengl coordinates (x,y,-w) for vertex in projection output to (x*(z/a+w)/w,y*(z/a+w)/w,-(z/a+w)), where a is the constant depending of 4Der angle of view (now I took a=10, but shall switch it to 2). So I use z as depth for projection and keep w as depth for section.
3) removed ridges of the concave biangles between cells from the output of projection. It is not enough (we still see contours that are hidden for 4Der by other objects).

Result is much better than it was before :)
Mrrl
Trionian
 
Posts: 165
Joined: Sun May 29, 2011 7:37 am

Re: Another 4D viewer

Postby quickfur » Fri Nov 18, 2011 5:50 pm

Hmm. Would depth sorting be easier if you clipped 4D surfaces that are not facing the 4D camera? At least for convex objects, that gets rid of intersecting ridges in the 3D projection, so you may be able to just sort by ridge centers.
quickfur
Pentonian
 
Posts: 2482
Joined: Thu Sep 02, 2004 11:20 pm
Location: The Great White North

Re: Another 4D viewer

Postby Mrrl » Sat Nov 19, 2011 3:43 pm

Three small videos from the viewer:

HCube: http://youtu.be/8YG-O8yKUPk
Puzzle: http://youtu.be/q7LMQatwNC0
Tiger: http://youtu.be/fkaI6meNiI0
Mrrl
Trionian
 
Posts: 165
Joined: Sun May 29, 2011 7:37 am

Re: Another 4D viewer

Postby quickfur » Sat Nov 19, 2011 5:19 pm

Wow!!!! Awesome videos!! I'm not sure the transparent renders are 100% correct, but I didn't see any obviously wrong parts.

And the tiger in animation!! I find the transparent render at the beginning the easiest to understand, actually, although it switched to a different rendering style shortly after. So basically it's a rolled torus extruded into a folded torus, right?
quickfur
Pentonian
 
Posts: 2482
Joined: Thu Sep 02, 2004 11:20 pm
Location: The Great White North

Re: Another 4D viewer

Postby quickfur » Sat Nov 19, 2011 5:23 pm

Also, in the hypercube animation, it looks like the cross sections are done with a hyperplane not perfectly perpendicular to the vertex? 'cos the sections look stretched.
quickfur
Pentonian
 
Posts: 2482
Joined: Thu Sep 02, 2004 11:20 pm
Location: The Great White North

Re: Another 4D viewer

Postby quickfur » Sat Nov 19, 2011 8:26 pm

BTW, what values did you use for the tiger's 3 radii? What are the "typical" values?
quickfur
Pentonian
 
Posts: 2482
Joined: Thu Sep 02, 2004 11:20 pm
Location: The Great White North

Re: Another 4D viewer

Postby Mrrl » Sat Nov 19, 2011 8:39 pm

I think, I've used R1=4, R2=3 for planar torus and r=1 for small radius.

And actual values for the viewer were R1=2e6, R2=1.5e6, r=5e5.
Mrrl
Trionian
 
Posts: 165
Joined: Sun May 29, 2011 7:37 am

Re: Another 4D viewer

Postby quickfur » Sat Nov 19, 2011 10:14 pm

Weird, I tried those values, but when projected the image is a thin 3D torus. It's very different from what is in your video. Maybe I got my parametric equations wrong?
quickfur
Pentonian
 
Posts: 2482
Joined: Thu Sep 02, 2004 11:20 pm
Location: The Great White North


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron