Skip to content

Commit

Permalink
Qubicle IO: throw if mixing different z-axis orientations formats
Browse files Browse the repository at this point in the history
Refs #31
  • Loading branch information
chrmoritz committed Feb 7, 2016
1 parent c7e22a0 commit 613aa50
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
20 changes: 12 additions & 8 deletions coffee/Qubicle.io.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class QubicleIO extends require('./IO.coffee!')
fra.onloadend = =>
@readFile fra.result, 1
if @loadingState++ == 2
@mirrorZ() if @zOriantation == 0
@mirrorZ() if @zOrientation == 0
callback(APpos)
console.log "reading alpha file with name: #{files.a.name}"
fra.readAsArrayBuffer files.a
Expand All @@ -26,7 +26,7 @@ class QubicleIO extends require('./IO.coffee!')
frt.onloadend = =>
@readFile frt.result, 2
if @loadingState++ == 2
@mirrorZ() if @zOriantation == 0
@mirrorZ() if @zOrientation == 0
callback(APpos)
console.log "reading type file with name: #{files.t.name}"
frt.readAsArrayBuffer files.t
Expand All @@ -37,26 +37,30 @@ class QubicleIO extends require('./IO.coffee!')
frs.onloadend = =>
@readFile frs.result, 3
if @loadingState++ == 2
@mirrorZ() if @zOriantation == 0
@mirrorZ() if @zOrientation == 0
callback(APpos)
console.log "reading specular file with name: #{files.s.name}"
frs.readAsArrayBuffer files.s
else
@loadingState++
if @loadingState == 3
@mirrorZ() if @zOriantation == 0
@mirrorZ() if @zOrientation == 0
callback(APpos)
console.log "reading file with name: #{files.m.name}"
fr.readAsArrayBuffer files.m

readFile: (ab, type) ->
console.log "file.byteLength: #{ab.byteLength}"
[version, colorFormat, zOriantation, compression, visabilityMask, matrixCount] = new Uint32Array ab.slice 0, 24
[version, colorFormat, zOrientation, compression, visabilityMask, matrixCount] = new Uint32Array ab.slice 0, 24
console.log "version: #{version} (expected 257 = 1.1.0.0 = current version)"
console.warn "Expected version 257 but found version: #{version} (May result in errors)" unless version == 257
console.log "color format: #{colorFormat} (0 for RGBA (recommended) or 1 for BGRA)"
console.log "z-axis oriantation: #{zOriantation} (0 for left, 1 for right handed (recommended))"
@zOriantation = zOriantation if type == 0
console.log "z-axis orientation: #{zOrientation} (0 for left, 1 for right handed (recommended))"
if type == 0
@zOrientation = zOrientation
else if @zOrientation != zOrientation
alert("Error: mixing different z-axis orientations formats (left / right handed) is not supported")
throw new Error "mixing different z-axis orientations formats (left / right handed) is not supported"
console.log "compression: #{compression} (0 for uncompressed, 1 for compressed with run length encoding (RLE))"
console.log "visability mask: #{visabilityMask} (should be 0 for encoded in A value, no partially visability)"
console.warn "partially visability not supported and will be ignored / handled as full visibility" unless visabilityMask == 0
Expand Down Expand Up @@ -205,7 +209,7 @@ class QubicleIO extends require('./IO.coffee!')
data = [
1, 1, 0, 0 # version: 1.1.0.0 (current)
0, 0, 0, 0 # color format: rgba
1, 0, 0, 0 # z-axis oriantation: right handed
1, 0, 0, 0 # z-axis orientation: right handed
+comp, 0, 0, 0 # compression: no (1, 0, 0, 0 for compressed)
0, 0, 0, 0 # visability mask: no partially visibility
1, 0, 0, 0 # matrix count: 1
Expand Down
24 changes: 12 additions & 12 deletions coffee/TroveCreationsLint.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ class TroveCreationsLint
}

validateMelee: ->
if @io.x > 10 or @io.y > 10 or @io.z > 35 # oriantation and dimension
if @io.x > 10 or @io.y > 10 or @io.z > 35 # orientation and dimension
if @io.z <= 10 and ((@io.x <= 35 and @io.y <= 10) or (@io.x <= 10 and @io.y <= 35))
return @errors.push {
title: 'Incorrect melee weapon model oriantation!'
title: 'Incorrect melee weapon model orientation!'
body: 'Your melee weapon model is incorrectly oriantated and will be thereby held in a wrong direction ingame.
Rotate it so that the tip of your weapon is facing the front!
Don\'t forget to fix this in your local files too before creating and submitting the .blueprint.'
Expand Down Expand Up @@ -232,10 +232,10 @@ class TroveCreationsLint
}

validateGun: ->
if @io.x > 5 or @io.y > 12 or @io.z > 5 # oriantation and dimension
if @io.x > 5 or @io.y > 12 or @io.z > 5 # orientation and dimension
if @io.y <= 5 and ((@io.x <= 12 and @io.z <= 5) or (@io.x <= 5 and @io.z <= 12))
return @errors.push {
title: 'Incorrect gun weapon model oriantation!'
title: 'Incorrect gun weapon model orientation!'
body: 'Your gun weapon model is incorrectly oriantated and will be thereby held in a wrong direction ingame.
Rotate it so that the muzzle is facing down! Check out the
<a href="http://trove.wikia.com/wiki/Gun_Weapon_Creation#Weapon_orientation" class="alert-link" target="_blank">gun
Expand Down Expand Up @@ -278,10 +278,10 @@ class TroveCreationsLint
}

validateStaff: ->
if @io.x > 12 or @io.y > 12 or @io.z > 35 # oriantation and dimension
if @io.x > 12 or @io.y > 12 or @io.z > 35 # orientation and dimension
if @io.z <= 12 and ((@io.x <= 35 and @io.y <= 12) or (@io.x <= 12 and @io.y <= 35))
return @errors.push {
title: 'Incorrect staff weapon model oriantation!'
title: 'Incorrect staff weapon model orientation!'
body: 'Your staff weapon model is incorrectly oriantated and will be thereby held in a wrong direction ingame.
Rotate it so that the tip of your weapon is facing the front!
Don\'t forget to fix this in your local files too before creating and submitting the .blueprint.'
Expand Down Expand Up @@ -330,10 +330,10 @@ class TroveCreationsLint
}

validateBow: ->
if @io.x > 3 or @io.y > 9 or @io.z > 21 # oriantation and dimension
if @io.x > 3 or @io.y > 9 or @io.z > 21 # orientation and dimension
if @io.z <= 9 and ((@io.x <= 21 and @io.y <= 9) or (@io.x <= 9 and @io.y <= 21))
return @errors.push {
title: 'Incorrect bow weapon model oriantation!'
title: 'Incorrect bow weapon model orientation!'
body: 'You bow weapon model is incorrectly oriantated and will be thereby held in a wrong direction ingame.
Rotate it so that the bowstring goes from back to front!
Don\'t forget to fix this in your local files too before creating and submitting the .blueprint.'
Expand Down Expand Up @@ -383,10 +383,10 @@ class TroveCreationsLint
}

validateSpear: ->
if @io.x > 11 or @io.y > 11 or @io.z > 45 # oriantation and dimension
if @io.x > 11 or @io.y > 11 or @io.z > 45 # orientation and dimension
if @io.z <= 11 and ((@io.x <= 45 and @io.y <= 11) or (@io.x <= 11 and @io.y <= 45))
return @errors.push {
title: 'Incorrect spear weapon model oriantation!'
title: 'Incorrect spear weapon model orientation!'
body: 'Your spear weapon model is incorrectly oriantated and will be thereby held in a wrong direction ingame.
Rotate it so that the tip/head of your weapon is facing the front!
Don\'t forget to fix this in your local files too before creating and submitting the .blueprint.'
Expand Down Expand Up @@ -467,7 +467,7 @@ class TroveCreationsLint
[ax, ay, az] = @io.getAttachmentPoint() # attachment point position
unless az == 0
return @errors.push {
title: 'Incorrect mask model oriantation!'
title: 'Incorrect mask model orientation!'
body: 'You mask model is incorrectly oriantated and will be thereby not weared correctly ingame.
Rotate it so that it is facing the front!
Don\'t forget to fix this in your local files too before creating and submitting the .blueprint.'
Expand Down Expand Up @@ -507,7 +507,7 @@ class TroveCreationsLint
[ax, ay, az] = @io.getAttachmentPoint() # attachment point position
unless ay == 0
return @errors.push {
title: 'Incorrect hat model oriantation!'
title: 'Incorrect hat model orientation!'
body: 'You hat model is incorrectly oriantated and will be thereby not weared correctly ingame.
Rotate it so that top of the hat is facing up!
Don\'t forget to fix this in your local files too before creating and submitting the .blueprint.'
Expand Down
2 changes: 1 addition & 1 deletion test/Qubicle.io.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe 'QubicleIO', ->
it 'should handle color format correctly', ->
io.addValues 0, 0, 0, 0, 32, 64, 128, 1
io.voxels.should.have.propertyByPath(0, 0, 0).with.properties({r: 128, g: 64, b: 32, a: 255, t: 0, s: 0})
it 'should handle zOriantation correctly'
it 'should handle zOrientation correctly'
describe 'addColorValues', ->
it 'should add color values correctly and set default values for other parameters', ->
io.addColorValues 0, 0, 0, 32, 64, 128
Expand Down

0 comments on commit 613aa50

Please # to comment.