![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 3
![]() |
cool
![]() |
|
|
|
|
|
#22 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
Would anyone mind making a simple 3d model for me to test it on?
Keeping in mind that Turing only has 256 colors to work with. |
|
|
|
|
|
#23 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 3
![]() |
In what format would you like it? Do you want a simple pyramid, or something more advanced?
|
|
|
|
|
|
#24 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
I'd like it in the format of the x, y, z, r, g, b values for all the surface pixels. Complexity of the actual image doesn't matter.
|
|
|
|
|
|
#25 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 3
![]() |
i'm sorry, that will be too much work then :o don't have an exporter to such a format..
|
|
|
|
|
|
#26 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
Doesn't the program you are using tell you the x, y, z values of each surface pixel? Then if I had the picture I could figure out the 8-bit colors with Python.
|
|
|
|
|
|
#27 |
|
Expert Programmer
|
I'm not too sure what your asking for. What file format are you looking for?
EDIT: post 666 ![]()
__________________
Join us at #programmingforums @ irc.freenode.net! My software never has bugs. It just develops random features.
|
|
|
|
|
|
#28 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
I'm not asking for a file format. I'm asking for the pixel information.
![]() If I just have a picture file, that's no good. I can't be bothered to determine all the z values of each pixel, or search through all the perspectives and do the same. |
|
|
|
|
|
#29 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
Okayyy then. Turns out that program was complete crap, it only looked like it was rotating properly, until I tried to make it do a full 360 turn.
So I scanned through a couple google pages, and found out you're supposed to do 3d rotations with 3 different matrxies: Rx, Ry, and Rz. I have no clue what the hell matrixes are, so I just made up my own way of rotating. I create a circle where the center is the middle of the object. Then for each (x,y) on the object, the arctangent is found (in relation to the circle), then converted to radians. Then the degree of rotation is added to the angle, which is converted back using sin() and cos() to extract new x and y values. Then this patterns is repeated twice more with 2 different circles representing the other axis combinations ([x,z],[y,z]). It works beautifully. Even if it has been done before, I'm still happy because I figured it out on my own (same with the projection plane). It seems like that's the way 2d rotation would be done, so I found it quite apparent to do the same with 3d. Here are the algorithms: function flatten_object (vectors : array 1 .. points of array 1 .. 3
of real, scale : int) : array 1 .. points of array 1 .. 3 of real
var new_vectors : array 1 .. points of array 1 .. 3 of real
for point : 1 .. points
for i : 1 .. 3
new_vectors (point) (i) := round (vectors (point) (i) * scale
/ (vectors (point) (3) + scale))
end for
end for
result new_vectors
end flatten_object
function rotate (temp_vectors : array 1 .. points of array 1 .. 3 of
real, rotX, rotY, rotZ : int, center : array 1 .. 3 of int) : array
1 .. points of array 1 .. 3 of real
var vectors : array 1 .. points of array 1 .. 3 of real := temp_vectors
var new_vectors : array 1 .. points of array 1 .. 3 of real
const pi := 3.1415926538
var degree, radius, rad : real
var s : array 1 .. 3 of
record
a : int
b : int
c : int
d : int
e : int
end record
s (1).a := 1
s (1).b := 2
s (1).c := 3
s (1).d := 2
s (1).e := rotX
s (2).a := 2
s (2).b := 3
s (2).c := 1
s (2).d := 3
s (2).e := rotY
s (3).a := 1
s (3).b := 3
s (3).c := 2
s (3).d := 3
s (3).e := rotZ
for se : 1 .. 3
for point : 1 .. points
vectors (point) (s (se).a) -= center (s (se).a)
vectors (point) (s (se).b) -= center (s (se).b)
degree := arctan (vectors (point) (s (se).a) /
vectors (point) (s (se).b)) / pi * 180
rad := (degree + s (se).e) * pi / 180
radius := sqrt (vectors (point) (s (se).a) ** 2 +
vectors (point) (s (se).b) ** 2)
new_vectors (point) (s (se).a) := sin (rad) * radius +
center (s (se).a)
new_vectors (point) (s (se).b) := cos (rad) * radius +
center (s (se).b)
if vectors (point) (s (se).d) < 0 then
new_vectors (point) (s (se).a) := -
new_vectors (point) (s (se).a)
new_vectors (point) (s (se).b) := -
new_vectors (point) (s (se).b)
end if
new_vectors (point) (s (se).c) := vectors (point) (s (se).c)
end for
vectors := new_vectors
end for
result vectors
end rotateAnd here's an interactive demonstration of the program: http://1v7.com/drsane/cube.exe Sometimes an optical illusion occurs and the cube appears to have inverted. It looks messed. |
|
|
|
|
|
#30 |
|
Professional Programmer
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 3
![]() |
Wow that's awesome!
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|