|
Post by sbehnke on Jul 9, 2019 3:53:13 GMT
|
|
|
Post by sbehnke on Jul 9, 2019 4:12:26 GMT
Clearly I'm applying the transforms incorrectly, or this file uses defines that I don't yet make use of.
|
|
|
Post by Jamis on Jul 9, 2019 4:21:45 GMT
Sadly, there is no formal definition for the YAML format I'm using. :/ I've been nagged by a few people to put one together, and I definitely _intend_ to do so, but it won't happen this week (flying to Cali for work) or the next (moving house!). Keep bugging me...I'll make some time as soon as I can.
|
|
|
Post by chrisd on Jul 17, 2019 2:20:22 GMT
Clearly I'm applying the transforms incorrectly, or this file uses defines that I don't yet make use of. You are probably applying transforms in reverse order. It should be a simple fix to reverse them. I originally had something like the first line below (marked WRONG), and objects showed up in weird locations. Then I fixed it to be more like the second line, and everything worked. (Though less interesting!)
Shape s = getShape(); Transform originalTransform = s.getTransform(); s.setTransform(originalTransform.multiply(Matrix.newScaling(x, y, z)); // WRONG! s.setTransform(Matrix.newScaling(x, y, z).multiply(originalTransform); I just used an existing library to read in the file, then parsed its data structures to create the scene and objects. It's a bit of a challenge and the code isn't particularly elegant, but once it comes together, it becomes very convenient for designing scenes. I have gone back and replaced all of the original exercises that I had coded up with YAML versions. For example: # A re-creation of the Putting It Together scene from Chapter 7 - Putting It Together
- add: camera width: 100 height: 50 field-of-view: 1.0471975511965977461542144610932 from: [ 0, 1.5, -5 ] to: [ 0, 1, 0 ] up: [ 0, 1, 0 ]
- add: light at: [ -10, 10, -10 ] intensity: [ 1, 1, 1 ]
- define: floor-material value: color: [ 1, 0.9, 0.9 ] specular: 0 ambient: 0.3
- define: large-green-material value: color: [ 0.5, 1, 0.1 ] diffuse: 0.7 specular: 0.3
- define: small-green-material value: color: [ 0.1, 1, 0.5 ] diffuse: 0.7 specular: 0.3
- define: smallest-material value: color: [ 1, 0.8, 0.1 ] diffuse: 0.7 specular: 0.3
# FLOOR - a flattened sphere - add: sphere material: floor-material transform: - [ scale, 10, 0.01, 10 ]
# LEFT WALL - a flattened sphere - add: sphere material: floor-material transform: - [ scale, 10, 0.01, 10 ] - [ rotate-x, 1.5707963267948966192313216916398 ] # pi/2 - [ rotate-y, -0.78539816339744830961566084581988 ] # -pi/4 - [ translate, 0, 0, 5 ]
# RIGHT WALL - a flattened sphere - add: sphere material: floor-material transform: - [ scale, 10, 0.01, 10 ] - [ rotate-x, 1.5707963267948966192313216916398 ] # pi/2 - [ rotate-y, 0.78539816339744830961566084581988 ] # pi/4 - [ translate, 0, 0, 5 ]
# LARGE GREEN SPHERE - add: sphere material: large-green-material transform: - [ translate, -0.5, 1, 0.5 ]
# SMALL GREEN SPHERE - add: sphere material: small-green-material transform: - [ scale, 0.5, 0.5, 0.5 ] - [ translate, 1.5, 0.5, -0.5 ]
# SMALLEST SPHERE - add: sphere material: smallest-material transform: - [ scale, 0.33, 0.33, 0.33 ] - [ translate, -1.5, 0.33, -0.75 ]
|
|
|
Post by sbehnke on Jul 17, 2019 4:11:53 GMT
Oh, thanks! I did get all that working. I think I have most of the yaml parsing working correctly now. I’ll give your Yaml file a try tomorrow and see what I render. I know I’ve gotten the reflection/refraction scene working fine, the cube scene, and the CSG for the orrey bonus chapter texture mapping loads as well. I’m still working through an issue with my triangles though for more complex shapes but I think I’m loading the obj files successfully as well from the bounding boxes sample chapter.
|
|