Agilis, Newbie Posted: 13 September 2011 06:17 PM Total Posts: 18
Hello everyone,
I may be criticized for asking this but it’s mainly because as a programmer first, an artist, barely, second, I’m trying to understand 3D using books that teach artists how to program, but do not teach programmers how to do art. That being said…
I have a scene set up where I can toggle between a Sphere and a Cube. The Cube is 256 x 256 x 256 pixels. The Sphere’s radius is 128, making the diameter 256. All things equal, when I switch between my Sphere and Cube, the Cube dwarfs the Sphere which means it’s huge compared to the Sphere. I cannot for the life of me find out the answer as to why, either because I’m googling the wrong terms, or the terms I’m being returned by Google are terms I’m not familiar with.
The texture I’m using is 256 x 256 and wraps the Cube perfectly. The texture when applied to the Sphere is just stretched and doesn’t tile at all well. The segments w and h of my Sphere are 36 and 18 respectively.
I appreciate any help as always and thanks for your time.
- Rick
Alejandro Santander, Administrator Posted: 13 September 2011 07:31 PM Total Posts: 414
[ # 1 ]
Hey Rick,
If you create a sphere of radius 128 and a cube of dimensions 256, they should be the same size or occupy the same bounding volume. So you must be doing something wrong in your code if you get that.
Would you care to share your code or the compiled swf?
Agilis, Newbie Posted: 13 September 2011 09:38 PM Total Posts: 18
[ # 2 ]
Thanks Alejandro for your reply. That what I thought but as far as I know, I’m doing everything right. Here’s the code, please keep in mind I can’t paste all of it. But the relevant portions is below.
Please keep in mind this is being done in Flash Builder.
I alternate between the Sphere and Cube using 2 Radio buttons tied to the same group. When initialized, the Sphere is created by default. As I switch between the 2, I can without a doubt notice that the Sphere is smaller than the Cube. Using a width of 200 for the Cube nets me a size close to the Sphere.
My camera is using values that I thought would get me a representation of the size compared to PhotoShop.
Again any help or suggestions are more than welcome. Thank you for your time.
- Rick
Agilis, Newbie Posted: 22 September 2011 06:03 PM Total Posts: 18
[ # 3 ]
Finally got back to trying to figure out this issue and figured out why my sphere was not the same size as my cube.
If you have a 256px cube, and you try to use a radius of 128 for a sphere, the sphere ends end up being smaller than the cube. I’m not 100% sure why this is, but in order to make the sphere the same size as the cube, take the hypotenuse of the cube, which is ~362 and divide that in half and use that number as the sphere’s radius which is 181.
Now the sphere and the cube are the same size.
80prozent, Sr. Member Posted: 22 September 2011 06:19 PM Total Posts: 430
[ # 4 ]
hi
to me this sounds like an issue related to bounding box of cube vs bounding box of sphere.
if you rotate a sphere in any direction, its bounding box will stay the same size. if you rotate a cube (256x256x256) 45 degrees on the y-axis you end up with a larger bounding box (362 x 362 x 256).
dont know if this is any help, just something i realised reading your post.
Agilis, Newbie Posted: 22 September 2011 06:31 PM Total Posts: 18
[ # 5 ]
Thank you for your insight. My goal was to place a cube with no rotation (‘bottom’ is parallel to the ‘floor’) to be the same size as the sphere, or vice versa. I didn’t think it would be as hard as it was.
All the math I’ve been learning says that if you have a 256 x 256 cube, and talk half of that to be the radius of the sphere, the objects should be roughly the same size. But in this engine, it’s way off. At least now I know why.
Thanks again and appreciate your input.
80prozent, Sr. Member Posted: 22 September 2011 06:58 PM Total Posts: 430
[ # 6 ]
i dont know if the infos in my previous post are right….
i just tested a sphere with radius 100 against a cube with width/height/depth=200, and it appears just like you would expect…same size.
so there must be some error in your code thats switching between sphere and cube.
Agilis, Newbie Posted: 22 September 2011 07:03 PM Total Posts: 18
[ # 7 ]
I’m using Away3D 3.6… what version are you using? Also, how did you do your test?
My sphere is created using this criteria:
sphere = new Sphere();
sphere.name = “sphere”;
// Create a single sphere
sphere.radius = 181;
sphere.segmentsW = 36;
sphere.segmentsH = 18;
My Cube is created using this criteria:
cube = new Cube();
cube.name = “cube”;
// Create a single cube
cube.width = cube.height = cube.depth = 256;
I found the zoom and distance to create almost the identical size that I would see if I was using PhotoShop if the camera was facing one of the cube’s faces.
80prozent, Sr. Member Posted: 22 September 2011 07:15 PM Total Posts: 430
[ # 8 ]
oh shit.
didnt checked the softwareversion (again).
i am using away3d 4 so all i said so far will not be much help to you
sorry for that.
i really need to get used to check software-version before starting talking nonsense :(
ive got no away3d 3.6 ready to compile right now, so i cant repeat my tests with this version, altough your code to create cube/sphere seems ok to me.
i dont really understand what you mean with photoshop view.
maybe you just need to view your scene through a orthographic lens (no perspektive distortion at all - like top/right/left/bottom views in 3d applications)
Agilis, Newbie Posted: 22 September 2011 07:48 PM Total Posts: 18
[ # 9 ]
Not a problem. I appreciated the conversation. Seems Away4D does it correctly and 3.6 does not.
Agilis, Newbie Posted: 22 September 2011 08:56 PM Total Posts: 18
[ # 10 ]
I’m not sure how to configure a camera that shows an orthogonal view. How would I do that so I would be able to see the object flat, similar to how I would view a 2D representation of my object in Photoshop?
80prozent, Sr. Member Posted: 22 September 2011 09:06 PM Total Posts: 430
[ # 11 ]
i cannot test this (got no 3.6 right now) but i believe to create a orthogonal lens, you create a Camera3d and set its lens.
yourCamera.lens=new OrthogonalLens();
should work.
Agilis, Newbie Posted: 22 September 2011 09:52 PM Total Posts: 18
[ # 12 ]
Thanks for your help. I did as you suggested but now my problem is, the object in my scene is too small to see.
camera = new Camera3D();
camera.lens = new OrthogonalLens();
camera.zoom = 1;
My object is almost a pixel in size.
80prozent, Sr. Member Posted: 22 September 2011 10:28 PM Total Posts: 430
[ # 13 ]
sorry, i never used the ortogonal lens myself…
i think you should try adjusting the zoom, or if thats not working on ortogonal lenses you need to position the camera closer to your object.