Mercurial > hg > Members > e085737 > sample
comparison Pants_FPS/resources/SceneGraphRoot.js @ 17:bf87fe5a9797
ver3
author | <e085737> |
---|---|
date | Fri, 10 Dec 2010 20:19:03 +0900 |
parents | 9367d87879ee |
children | 931ad40d56f5 |
comparison
equal
deleted
inserted
replaced
16:9367d87879ee | 17:bf87fe5a9797 |
---|---|
11 | 11 |
12 position_xyz = new Array(0, 0, 0) | 12 position_xyz = new Array(0, 0, 0) |
13 aim_xyz = new Array(0 ,0, 1) | 13 aim_xyz = new Array(0 ,0, 1) |
14 eye_xyz = new Array(0, -1, 0) | 14 eye_xyz = new Array(0, -1, 0) |
15 this.sg_src = new Array() | 15 this.sg_src = new Array() |
16 this.camera = null | |
16 | 17 |
17 angleRate_xyz = new Array(1, 0, 0) | 18 angleRate_xyz = new Array(1, 0, 0) |
18 | 19 |
19 //cnt = 0 | 20 //cnt = 0 |
20 } | 21 } |
50 | 51 |
51 return src | 52 return src |
52 } | 53 } |
53 | 54 |
54 | 55 |
55 SceneGraphRoot.prototype.createSceneGraph2 = function(name){ | |
56 if(name < 0){ | |
57 alert("error: createSceneGraph(name): name object not found.") | |
58 return null | |
59 } | |
60 | |
61 for(num in sg_src){ | |
62 if(name == sg_src[num].name){ | |
63 var src = new SceneGraph(name) | |
64 } | |
65 } | |
66 | |
67 return src | |
68 } | |
69 | |
70 | |
71 SceneGraphRoot.prototype.createSceneGraph3 = function(){ | 56 SceneGraphRoot.prototype.createSceneGraph3 = function(){ |
72 var p = new SceneGraph() | 57 var p = new SceneGraph() |
73 | 58 |
74 p.sgroot = this | 59 p.sgroot = this |
75 | 60 |
92 return sg_src[name] | 77 return sg_src[name] |
93 } | 78 } |
94 } | 79 } |
95 return -1 | 80 return -1 |
96 } | 81 } |
82 | |
83 | |
84 SceneGraphRoot.prototype.setCamera = function(sgroot, node){ | |
85 this.camera = node | |
86 } | |
87 | |
88 | |
89 | |
90 SceneGraphRoot.prototype.getCamera = function(ctx, node){ | |
91 if(node.mat != null){ | |
92 ctx.perspectiveMatrix = new J3DIMatrix4() | |
93 node.mat.getAsArrayMatrix(ctx.perspectiveMatrix.$matrix) | |
94 }else{ | |
95 ctx.perspectiveMatrix = new J3DIMatrix4() | |
96 } | |
97 | |
98 ctx.perspectiveMatrix.perspective(45, width/height, 1, 10000); | |
99 ctx.perspectiveMatrix.rotate(cameraAngle_xyz[0],0,1,0) | |
100 ctx.perspectiveMatrix.rotate(cameraAngle_xyz[1], angleRate_xyz[0], 0, angleRate_xyz[2]) | |
101 | |
102 | |
103 ctx.perspectiveMatrix.lookat(position_xyz[0],position_xyz[1],position_xyz[2], aim_xyz[0], aim_xyz[1], aim_xyz[2], 0, -1, 0); | |
104 //ctx.perspectiveMatrix.lookat( 0, 0, 0, 0, 0, 1, 0, -1, 0); | |
105 } | |
106 | |
107 | |
108 | |
109 | |
97 | 110 |
98 | 111 |
99 SceneGraphRoot.prototype.getController = function(){ | 112 SceneGraphRoot.prototype.getController = function(){ |
100 var left_push = currentlyPressedKeys[37] /* ← */ | 113 var left_push = currentlyPressedKeys[37] /* ← */ |
101 var down_push = currentlyPressedKeys[40] /* ↓ */ | 114 var down_push = currentlyPressedKeys[40] /* ↓ */ |