diff --git a/src/framework/AI/AStar.java b/src/framework/AI/AStar.java index 3fa1d7b..0dd8a5e 100644 --- a/src/framework/AI/AStar.java +++ b/src/framework/AI/AStar.java @@ -3,41 +3,41 @@ import java.util.*; /** - * A*�N���X�B + * A*クラス。 */ public class AStar { private LinkedList locationOpenList = new LinkedList(); private LinkedList locationClosedList = new LinkedList(); /** - * �ŒZ�o�H�T���B �ŒZ�o�H�̃��X�g��Ԃ����A���‚���Ȃ��ꍇnull��Ԃ��B - * start = goal�̏ꍇ��null��Ԃ��B - * �߂�l�ɂ�goal����start�̂P�‘O�܂Ōo�H�������̂ڂ������̂������Ă���Bstart�͓����Ă��Ȃ��B + * 最短経路探査。 最短経路のリストを返すか、見つからない場合nullを返す。 + * start = goalの場合もnullを返す。 + * 戻り値にはgoalからstartの1個前まで経路をさかのぼったものが入っている。startは入っていない。 */ public Plan getPath(Location startLocation, Location goalLocation) { - //�o���n�_�ƖړI�n�_�������Ȃ�null��Ԃ� + //出発地点と目的地点が同じならnullを返す if (startLocation.equals(goalLocation)) { return null; } - // ������ + // 初期化 locationOpenList = new LinkedList(); locationClosedList = new LinkedList(); - // �o���n�_��LocationOpenList�ɒlj����� + // 出発地点をLocationOpenListに追加する locationOpenList.add(startLocation); while (!locationOpenList.isEmpty()) { - // LocationOpenList�̍ŏ��X�R�A�̒n�_��curLocation�Ƃ��Ď��o�� + // LocationOpenListの最小スコアの地点をcurLocationとして取り出す Collections.sort(locationOpenList, new CostComparator()); Location curLocation = locationOpenList.removeFirst(); - // ���݂̒n�_���ړI�n�_�Ȃ�ΒT������ + // 現在の地点が目的地点ならば探査完了 if (curLocation.equals(goalLocation)) { LinkedList locationPath = new LinkedList(); - // �o���n�_�܂Œʂ����n�_��H�� + // 出発地点まで通った地点を辿る curLocation = goalLocation; while (!curLocation.equals(startLocation)) { locationPath.add(curLocation); @@ -46,24 +46,24 @@ return new Plan(locationPath); } - // ���݂̒n�_���ړI�n�_�łȂ��Ȃ�A���݂̒n�_��LocationClosedList�Ɉڂ� + // 現在の地点が目的地点でないなら、現在の地点をLocationClosedListに移す locationClosedList.add(curLocation); - // �אڂ���n�_�𒲂ׂ� + // 隣接する地点を調べる ArrayList neighbors = curLocation.getSuccessors(); - // �אڂ���n�_�̐������A���[�v + // 隣接する地点の数だけ、ループ for (int i = 0; i < neighbors.size(); i++) { - // �ʉ߂ł��A�e���X�g�ɓ����ĂȂ��Ȃ�R�X�g�����炢�A + // 通過でき、各リストに入ってないならコストをもらい、 if (!locationOpenList.contains(neighbors.get(i)) && !locationClosedList.contains(neighbors.get(i))) { - //�n�_�R�X�g�����߂� + //地点コストを求める //agent.getLocationCost((Location)neighbors.get(i), null, null, null); - //�p�X�R�X�g�����߂� + //パスコストを求める ((Location)neighbors.get(i)).calculatesCosts(curLocation, goalLocation); - // LocationOpenList�Ɉڂ� + // LocationOpenListに移す locationOpenList.add((Location) neighbors.get(i)); } } @@ -75,10 +75,10 @@ } // ------------------------------------------------------------------------------------------------------------------------------------------- - // �R�X�g�̏����\�[�g�̂��߂̃N���X����낤 + // コストの昇順ソートのためのクラスを作ろう /** - * �\�[�g�������N���X�B + * ソート条件式クラス。 */ class CostComparator implements Comparator { public int compare(Location n1, Location n2) { diff --git a/src/framework/AI/GeometryGraph.java b/src/framework/AI/GeometryGraph.java index d4b4f03..5aa8924 100644 --- a/src/framework/AI/GeometryGraph.java +++ b/src/framework/AI/GeometryGraph.java @@ -9,21 +9,21 @@ import framework.model3D.Position3D; public class GeometryGraph extends StateMachine { - // �R���X�g���N�^ + // コンストラクタ public GeometryGraph(Geometry g) { if (g instanceof IndexedTriangleArray) { IndexedTriangleArray ita = (IndexedTriangleArray) g; - // ita����states�Ƀf�[�^���������� - for (int i = 0; i < ita.getIndexCount() / 3; i++) {// �ʂ̐��������[�v + // itaからstatesにデータを書き込み + for (int i = 0; i < ita.getIndexCount() / 3; i++) {// 面の数だけループ Location e = new Location(i, ita); if (e.getNormal() != null) { states.add(e); } } - // �֘A�t�� + // 関連付け for (int i = 0; i < states.size(); i++) { setSuccessors(i, ita); } @@ -31,18 +31,18 @@ } - // �A���������֘A�t�� + // 連結成分を関連付け public void setSuccessors(int index, IndexedTriangleArray ita) { Location e = (Location)states.get(index); - // �T�� + // 探索 int[] List = new int[ita.getIndexCount()]; for (int i = 0; i < ita.getIndexCount(); i++) { List[i] = ita.getCoordinateIndex(i); } - // -1�ŏ����� + // -1で初期化 for (int i = 0; i < 3; i++) { e.successorIndex[i] = -1; e.IndexOfSharedEdge[i] = -1; @@ -51,8 +51,8 @@ int j = 0; for (int i = 0; i < states.size() * 3; i++) { - // System.out.println("indexList[0] ��List["+i+"] �̏ƍ�"); - // //////id�łk��������u�������ă��\�b�h�Ăяo�������Ȃ�? + // System.out.println("indexList[0] とList["+i+"] の照合"); + // //////idでListを置き換えてメソッド呼び出しを少なく? // int id = ita.getCoordinateIndex(i); if (e.indexList[0] == List[i]) { if (i % 3 == 0) { @@ -103,7 +103,7 @@ } for (int i = 0; i < states.size() * 3; i++) { - // System.out.println("indexList[1] ��List["+i+"] �̏ƍ�"); + // System.out.println("indexList[1] とList["+i+"] の照合"); if (e.indexList[1] == List[i]) { if (i % 3 == 0) { if (e.indexList[2] == List[i + 2]) { @@ -133,15 +133,15 @@ } } - // System.out.println("1�–ڂ�successor**"+successorIndex[0]+"***"); - // System.out.println("2�–ڂ�successor**"+successorIndex[1]+"***"); - // System.out.println("3�–ڂ�successor**"+successorIndex[2]+"***"); + // System.out.println("1つ目のsuccessor**"+successorIndex[0]+"***"); + // System.out.println("2つ目のsuccessor**"+successorIndex[1]+"***"); + // System.out.println("3つ目のsuccessor**"+successorIndex[2]+"***"); return; } - // �A�N�Z�b�T + // アクセッサ public ArrayList getStates() { return states; } diff --git a/src/framework/AI/IState.java b/src/framework/AI/IState.java index 4f181f6..31ecfdf 100644 --- a/src/framework/AI/IState.java +++ b/src/framework/AI/IState.java @@ -8,9 +8,9 @@ abstract void addSuccessor(IState s); /** - * �T�����̃m�[�h�擾�B + * 探査元のノード取得。 * @return - * �T�����̃m�[�h��Ԃ��B + * 探査元のノードを返す。 */ abstract IState getParent(); } diff --git a/src/framework/AI/Location.java b/src/framework/AI/Location.java index 83b90bc..f36e967 100644 --- a/src/framework/AI/Location.java +++ b/src/framework/AI/Location.java @@ -12,8 +12,8 @@ public int planeIndex; public int[] indexList = new int[3]; public int[] successorIndex = new int[100]; - public int numberOfSharedEdge;// ���L�ӂ̖{�� - public int[] IndexOfSharedEdge = new int[3];// ���L�ӂ̒��_�C���f�b�N�X + public int numberOfSharedEdge;// 共有辺の本数 + public int[] IndexOfSharedEdge = new int[3];// 共有辺の頂点インデックス private Point3d center; private Vector3d normal; @@ -22,13 +22,13 @@ private Location parentNode = null; private ArrayList successors = new ArrayList(); - // �e�X�g�p�̋�̃R���X�g���N�^ + // テスト用の空のコンストラクタ public Location(Point3d center) { this.center = center; normal = new Vector3d(0.0, 1.0, 0.0); } - // �R���X�g���N�^ + // コンストラクタ public Location(int index, IndexedTriangleArray ita) { planeIndex = index; @@ -44,13 +44,13 @@ ita.getCoordinate(indexList[1], p2); ita.getCoordinate(indexList[2], p3); - // ���S���W�̌v�Z + // 中心座標の計算 center = new Point3d((p1.getX() + p2.getX() + p3.getX()) / 3.0, (p1 .getY() + p2.getY() + p3.getY()) / 3.0, (p1.getZ() + p2.getZ() + p3 .getZ()) / 3.0); - // �@���x�N�g���̌v�Z + // 法線ベクトルの計算 p2.sub(p1); p3.sub(p1); Vector3d v2 = new Vector3d(p2); @@ -81,40 +81,40 @@ } /** - * �X�R�A�̎擾�B + * スコアの取得。 * - * @return �X�R�A��Ԃ��B + * @return スコアを返す。 */ public int getScore() { - // ��r�ɏ����_�����f������ׁA1000���|���Ă��� + // 比較に小数点も反映させる為、1000を掛けている return (int) ((cost + heuristicCost) * 1000); } /** - * �R�X�g�v�Z�ƒT�����m�[�h��ݒ�B + * コスト計算と探査元ノードを設定。 * * @param parentNode - * �T�����̃m�[�h�B + * 探査元のノード。 * @param goalNode - * �ړI�n�̃m�[�h�B + * 目的地のノード。 */ public void calculatesCosts(Location parentNode, Location goalNode) { - // �R�X�g�����Z + // コストを加算 cost = parentNode.cost + 1; // agent.getPathCost(parentNode, this, null, // null, null, null, null, null); - // //�q���[���X�e�B�b�N�R�X�g���v�Z + // //ヒューリスティックコストを計算 // disX = point.x - goalNode.point.x; // disY = point.y - goalNode.point.y; - // �q���[���X�e�B�b�N�R�X�g�̐M�����������ׁA3����1�ɂ��Ă��� + // ヒューリスティックコストの信頼性が薄い為、3分の1にしている heuristicCost = 0; - // �T�����m�[�h���L�^ + // 探査元ノードを記録 this.parentNode = parentNode; } // ///////// - // �A�N�Z�b�T// + // アクセッサ// // ///////// public int getPlaneIndex() { return planeIndex; diff --git a/src/framework/AI/Plan.java b/src/framework/AI/Plan.java index 35381fc..06860b2 100644 --- a/src/framework/AI/Plan.java +++ b/src/framework/AI/Plan.java @@ -8,11 +8,11 @@ import framework.model3D.Position3D; public class Plan { - private LinkedList path; // �v����e��\���p�X - private int currentLoc = 0; // �p�X��̌��݂� Location + private LinkedList path; // 計画内容を表すパス + private int currentLoc = 0; // パス上の現在の Location /** - * �����̒ʉߓ_�����Œv�� + * 複数の通過点を持つ計画 * @param locationPath */ public Plan(LinkedList locationPath) { @@ -21,7 +21,7 @@ } /** - * �X�^�[�g�ƃS�[�����_�C���N�g�Ɍ��Ԍv�� + * スタートとゴールをダイレクトに結ぶ計画 * @param start * @param goal */ @@ -33,8 +33,8 @@ } /** - * ���݂� Location ���擾���� - * @return�@���݂� Location, ���łɃS�[���ɒ����Ă���Ƃ��� null ��Ԃ� + * 現在の Location を取得する + * @return 現在の Location, すでにゴールに着いているときは null を返す */ public Location getCurrentLocation() { if (currentLoc <= 0) return null; @@ -42,8 +42,8 @@ } /** - * ���� Location ���擾���� - * @return�@���� Location, ���łɃS�[���ɒ����Ă���Ƃ��� null ��Ԃ� + * 次の Location を取得する + * @return 次の Location, すでにゴールに着いているときは null を返す */ public Location getNextLocation() { if (currentLoc <= 0) return null; @@ -51,9 +51,9 @@ } /** - * ���݂̍��W�l�����ɁA���݂� Location ���X�V���� - * @param position�@���݂̍��W�l - * @return�@�X�V���� --- true, �ȑO�̂܂� --- false + * 現在の座標値を元に、現在の Location を更新する + * @param position 現在の座標値 + * @return 更新した --- true, 以前のまま --- false */ public boolean updateCurrentLocation(Position3D position) { Vector3d toCurrentPosition = position.getVector3d(); @@ -65,7 +65,7 @@ toNextLocation.sub(curLocation.getCenter()); double distanceToNextLocation = toNextLocation.length(); if (distanceToCurrentPosition >= distanceToNextLocation) { - // ���� Location ��ʂ�߂����ꍇ + // 次の Location を通り過ぎた場合 currentLoc--; return true; } diff --git a/src/framework/RWT/RWTRenderer.java b/src/framework/RWT/RWTRenderer.java index 8abcfef..70025a2 100644 --- a/src/framework/RWT/RWTRenderer.java +++ b/src/framework/RWT/RWTRenderer.java @@ -22,7 +22,7 @@ } public void attachCamera(Camera3D camera) { - // onSurfaceCreated()����ɌĂ΂�� + // onSurfaceCreated()より先に呼ばれる this.camera = camera; viewer = new Viewer3D(camera); } @@ -59,7 +59,7 @@ } viewer.onDrawFrame(); - // 3D���f���̃����_�����O + // 3Dモデルのレンダリング gc3D.pushMatrix(); camera.getUniverse().render(viewer); gc3D.popMatrix(); diff --git a/src/framework/animation/Animation3D.java b/src/framework/animation/Animation3D.java index 7eac0d4..acef836 100644 --- a/src/framework/animation/Animation3D.java +++ b/src/framework/animation/Animation3D.java @@ -6,8 +6,8 @@ import framework.model3D.Quaternion3D; /** - * �K�w�����ꂽ�I�u�W�F�N�g�ɑ΂���A�j���[�V��������ێ�����i���i�P�ʂňʒu�A�����A�e�N�X�`�����A�j���[�V�����”\�j - * @author �V�c���� + * 階層化されたオブジェクトに対するアニメーション情報を保持する(部品単位で位置、向き、テクスチャをアニメーション可能) + * @author 新田直也 * */ public class Animation3D { @@ -36,11 +36,11 @@ public boolean progress(long interval) { if (maxKey == 0) - return true; // ��̃A�j���[�V�����̏ꍇ�������Ȃ� + return true; // 空のアニメーションの場合動かさない time += interval; // System.out.println(time + "/" + maxKey); if (time > maxKey) { - time = time % maxKey; // time���Ō�̗v�f��key�̒l�i�A�j���[�V�����̍Ō��key)�𒴂��Ă���ꍇ�At���Ō��key�̒l�imaxKey)�Ŋ������]��Ƃ��Đݒ肷�� + time = time % maxKey; // timeが最後の要素のkeyの値(アニメーションの最後のkey)を超えている場合、tを最後のkeyの値(maxKey)で割った余りとして設定する return false; } else return true; @@ -59,34 +59,34 @@ for (int i = 0; i < partList.size(); i++) { aroundKey = partList.get(i).getKey(time); - // �R�s�[�R���X�g���N�^�̍쐬 + // コピーコンストラクタの作成 q = null; p = null; tq = null; tp = null; if (aroundKey[0].getPosition() != null) { - p = new Position3D(aroundKey[0].getPosition()); // getPosition()���Q�Ƃ�Ԃ��̂ŃR�s�[���Ă���ύX + p = new Position3D(aroundKey[0].getPosition()); // getPosition()が参照を返すのでコピーしてから変更 } if (aroundKey[0].getQuaternion() != null) { - q = new Quaternion3D(aroundKey[0].getQuaternion()); // getQuaternion()���A�h���X�i�Q�Ɓj��Ԃ��̂ŁA�R�s�[�i�����j���쐬���Ă������ύX���Ă���B + q = new Quaternion3D(aroundKey[0].getQuaternion()); // getQuaternion()がアドレス(参照)を返すので、コピー(=q)を作成してそちらを変更している。 } if (aroundKey[0].getTexturePosition() != null) { - tp = new Position3D(aroundKey[0].getTexturePosition()); // getPosition()���Q�Ƃ�Ԃ��̂ŃR�s�[���Ă���ύX + tp = new Position3D(aroundKey[0].getTexturePosition()); // getPosition()が参照を返すのでコピーしてから変更 } if (aroundKey[0].getTextureQuaternion() != null) { - tq = new Quaternion3D(aroundKey[0].getTextureQuaternion()); // getQuaternion()���A�h���X�i�Q�Ɓj��Ԃ��̂ŁA�R�s�[�i�����j���쐬���Ă������ύX���Ă���B + tq = new Quaternion3D(aroundKey[0].getTextureQuaternion()); // getQuaternion()がアドレス(参照)を返すので、コピー(=q)を作成してそちらを変更している。 } - // time��key���̂��̂������ꍇ�i��Ԃ̌v�Z���s�v�ȏꍇ�j + // timeがkeyそのものだった場合(補間の計算が不要な場合) if (aroundKey[1] != null) { - // t1 ��t�̑O��key�iaroundKey[0]�j�̃X�J���[�{ + // t1 はtの前のkey(aroundKey[0])のスカラー倍 double t1 = aroundKey[1].key - time; - // t2 ��t�̌��key�iaroundKey[1]�j�̃X�J���[�{ + // t2 はtの後のkey(aroundKey[1])のスカラー倍 double t2 = time - aroundKey[0].key; double t3 = aroundKey[1].key - aroundKey[0].key; double timealpha = t2 / t3; - // time�ɑ΂���Quaternion��Position�̌v�Z + // timeに対するQuaternionとPositionの計算 if (p != null) { Position3D p2 = new Position3D(aroundKey[1].getPosition()); p.mul(t1 / t3).add(p2.mul(t2 / t3)); @@ -121,7 +121,7 @@ maxKey = getMaxKey(); } - // �A�j���[�V�������I���������𔻒肷�邽�߂�key�̍ő�l��T�����ĕԂ����\�b�h + // アニメーションが終了したかを判定するためにkeyの最大値を探索して返すメソッド private long getMaxKey() { long maxKey = 0; int i; diff --git a/src/framework/animation/DefaultPose3D.java b/src/framework/animation/DefaultPose3D.java index 0e4ac8d..37f6290 100644 --- a/src/framework/animation/DefaultPose3D.java +++ b/src/framework/animation/DefaultPose3D.java @@ -4,8 +4,8 @@ import framework.model3D.Object3D; /** - * ������Ԃ̎p�� - * @author �V�c���� + * 初期状態の姿勢 + * @author 新田直也 * */ public class DefaultPose3D extends Pose3D { diff --git a/src/framework/animation/KeyFrame.java b/src/framework/animation/KeyFrame.java index 333a390..ac13501 100644 --- a/src/framework/animation/KeyFrame.java +++ b/src/framework/animation/KeyFrame.java @@ -7,8 +7,8 @@ /** - * �A�j���[�V�������ŃL�[�t���[���P�ʂɒ�`�������i�L�[�l�j - * @author �V�c���� + * アニメーション中でキーフレーム単位に定義される情報(キー値) + * @author 新田直也 * */ public class KeyFrame { diff --git a/src/framework/animation/PartAnimation.java b/src/framework/animation/PartAnimation.java index 454158d..95c4b91 100644 --- a/src/framework/animation/PartAnimation.java +++ b/src/framework/animation/PartAnimation.java @@ -8,8 +8,8 @@ /** - * ���i�P�ʂ̃A�j���[�V��������ێ����� - * @author �V�c���� + * 部品単位のアニメーション情報を保持する + * @author 新田直也 * */ public class PartAnimation { @@ -36,21 +36,21 @@ return textureUnit; } - //�A�j���[�V�����̌o�ߎ��Ԃ̑O���key��KeyFrame�^�̔z��Ŏ擾���郁�\�b�h + //アニメーションの経過時間の前後のkeyをKeyFrame型の配列で取得するメソッド KeyFrame[] getKey(long t){ int i; KeyFrame[] aroundKey = new KeyFrame[2]; for(i=1;i GeometryUtility.TOLERANCE) { - // ������̖ʁi���n�ʁj�ɂԂ‚������A�܂��͐ڐG���Ă��鎞 + // 上向きの面(=地面)にぶつかった、または接触している時 if (cr.length <= GeometryUtility.TOLERANCE) { - // �n�ʂɏ���Ă��� + // 地面に乗っている if (!(mode instanceof ModeOnGround)) { - // �����Ă��Ē��x����� + // 落ちてきて丁度乗った mode = modeOnGround; ((ModeOnGround)mode).setNormal(cr.normal); onEndFall(); } } else { - // �n�ʂɂ߂荞�� - // 5.1. �����߂� + // 地面にめり込んだ + // 5.1. 押し戻す onIntersect(cr, interval); if (!(mode instanceof ModeOnGround)) { - // �����Ă��Ă߂荞�� - // 6. �n�ʃ��[�h�ɂ��� + // 落ちてきてめり込んだ + // 6. 地面モードにする mode = modeOnGround; ((ModeOnGround)mode).setNormal(cr.normal); onEndFall(); } else { - // �����Ă���r���ŁA�A�j���[�V�����̊֌W�ň�u�����߂荞�� - // �܂��́A�����Ă���r���ŎΖʂɍ����|������ + // 歩いている途中で、アニメーションの関係で一瞬だけめり込んだ + // または、歩いている途中で斜面に差し掛かった ((ModeOnGround)mode).setNormal(cr.normal); } } } else if (cr.normal.dot(PhysicsUtility.vertical) >= -GeometryUtility.TOLERANCE) { - // �����ǂɂ߂荞�� - // 5.1. �����߂� + // 垂直壁にめり込んだ + // 5.1. 押し戻す onIntersect(cr, interval); } else { - // ������Ԃ‚������A�܂��͐ڐG����(�����Ԃ‚���) + // 下からぶつかった、または接触した(頭をぶつけた) if (cr.length > GeometryUtility.TOLERANCE) { - // 5.1. �����߂� + // 5.1. 押し戻す onIntersect(cr, interval); } } cr = null; } else { - // �n�ʂƂԂ‚����Ă��ڐG���Ă����Ȃ��� - // 6. �������[�h�ɂ��� + // 地面とぶつかっても接触してもいない時 + // 6. 落下モードにする mode = modeFreeFall; } } @@ -134,66 +134,66 @@ forces.add(getGravity()); appPoints.add(getGravityCenter()); - // 1. �ʒu�𓮂��� + // 1. 位置を動かす ((Solid3D)body).move(interval, forces, appPoints); if (animation != null) { - // 2. �A�j���[�V���������s + // 2. アニメーションを実行 if (animation.progress(interval) == false) { onEndAnimation(); } - // 3. �p����ς��� + // 3. 姿勢を変える body.apply(animation.getPose(), false); } - // 4. �Փ˔��� + // 4. 衝突判定 CollisionResult cr = PhysicsUtility.doesIntersect((Solid3D)body, ground); - // 5. �Փˉ��� + // 5. 衝突応答 if (cr != null) { - // �\�����ɂԂ‚������A�܂��͐ڐG���Ă��鎞 + // 構造物にぶつかった、または接触している時 if (cr.normal.dot(PhysicsUtility.vertical) > GeometryUtility.TOLERANCE) { - // ������̖ʁi���n�ʁj�ɂԂ‚������A�܂��͐ڐG���Ă��鎞 + // 上向きの面(=地面)にぶつかった、または接触している時 if (cr.length <= GeometryUtility.TOLERANCE) { - // �n�ʂɏ���Ă��� + // 地面に乗っている if (!(mode instanceof ModeOnGround)) { - // �����Ă��Ē��x����� + // 落ちてきて丁度乗った mode = modeOnGround; ((ModeOnGround)mode).setNormal(cr.normal); onEndFall(); } } else { - // �n�ʂɂ߂荞�� - // 5.1. �����߂� + // 地面にめり込んだ + // 5.1. 押し戻す onIntersect(cr, interval); if (!(mode instanceof ModeOnGround)) { - // �����Ă��Ă߂荞�� - // 6. �n�ʃ��[�h�ɂ��� + // 落ちてきてめり込んだ + // 6. 地面モードにする mode = modeOnGround; ((ModeOnGround)mode).setNormal(cr.normal); onEndFall(); } else { - // �����Ă���r���ŁA�A�j���[�V�����̊֌W�ň�u�����߂荞�� - // �܂��́A�����Ă���r���ŎΖʂɍ����|������ + // 歩いている途中で、アニメーションの関係で一瞬だけめり込んだ + // または、歩いている途中で斜面に差し掛かった ((ModeOnGround)mode).setNormal(cr.normal); } } } else if (cr.normal.dot(PhysicsUtility.vertical) >= -GeometryUtility.TOLERANCE) { - // �����ǂɂ߂荞�� - // 5.1. �����߂� + // 垂直壁にめり込んだ + // 5.1. 押し戻す onIntersect(cr, interval); } else { - // ������Ԃ‚������A�܂��͐ڐG����(�����Ԃ‚���) + // 下からぶつかった、または接触した(頭をぶつけた) if (cr.length > GeometryUtility.TOLERANCE) { - // 5.1. �����߂� + // 5.1. 押し戻す onIntersect(cr, interval); } } cr = null; } else { - // �n�ʂƂԂ‚����Ă��ڐG���Ă����Ȃ��� - // 6. �������[�h�ɂ��� + // 地面とぶつかっても接触してもいない時 + // 6. 落下モードにする mode = modeFreeFall; } } @@ -207,8 +207,8 @@ } /** - * �w�肵�������Ɍ������� - * @param vec �V�������� + * 指定した方向に向かせる + * @param vec 新しい向き */ public void setDirection(Vector3d vec) { Vector3d v1 = new Vector3d(); @@ -228,8 +228,8 @@ } /** - * �w�肵�������Ɍ������� - * @param vec �V�������� + * 指定した方向に向かせる + * @param vec 新しい向き */ public void setDirection3D(Vector3d vec) { Vector3d v1 = new Vector3d(); @@ -253,8 +253,8 @@ } /** - * ���݌����Ă���������擾���� - * @return ���݂̌��� + * 現在向いている方向を取得する + * @return 現在の向き */ public Vector3d getDirection() { Vector3d dir = new Vector3d(direction); @@ -265,24 +265,24 @@ } /** - * �ړ����x�x�N�g����ݒ肷�� - * @param vel �V�����ړ����x�x�N�g�� + * 移動速度ベクトルを設定する + * @param vel 新しい移動速度ベクトル */ public void setVelocity(Velocity3D vel) { ((Solid3D)body).apply(vel, false); } /** - * �ړ����x�x�N�g�����擾���� - * @return ���݂̈ړ����x�x�N�g�� + * 移動速度ベクトルを取得する + * @return 現在の移動速度ベクトル */ public Velocity3D getVelocity() { return ((Solid3D)body).getVelocity(); } /** - * X���𒆐S�ɉ�]���� - * @param angle ��]�p�i�����v���, �P��:���W�A���j + * X軸を中心に回転する + * @param angle 回転角(反時計回り, 単位:ラジアン) */ public void rotX(double angle) { Quaternion3D curQuat = body.getQuaternion(); @@ -291,8 +291,8 @@ } /** - * Y���𒆐S�ɉ�]���� - * @param angle ��]�p�i�����v���, �P��:���W�A���j + * Y軸を中心に回転する + * @param angle 回転角(反時計回り, 単位:ラジアン) */ public void rotY(double angle) { Quaternion3D curQuat = body.getQuaternion(); @@ -301,8 +301,8 @@ } /** - * Z���𒆐S�ɉ�]���� - * @param angle ��]�p�i�����v���, �P��:���W�A���j + * Z軸を中心に回転する + * @param angle 回転角(反時計回り, 単位:ラジアン) */ public void rotZ(double angle) { Quaternion3D curQuat = body.getQuaternion(); @@ -311,38 +311,38 @@ } /** - * ������Ă���d�͂��擾���� - * @return �d�� + * 加わっている重力を取得する + * @return 重力 */ public Force3D getGravity() { return mode.getForce((Solid3D)body); } /** - * �d�S���擾���� - * @return �d�S�ʒu + * 重心を取得する + * @return 重心位置 */ public Position3D getGravityCenter() { return ((Solid3D)body).getGravityCenter(); } /** - * �n�ʂɏ���Ă����Ԃ��ۂ����擾���� - * @return true --- �n�ʂɏ���Ă���, false --- �n�ʂɏ���Ă��Ȃ��i�󒆂ɂ���j + * 地面に乗っている状態か否かを取得する + * @return true --- 地面に乗っている, false --- 地面に乗っていない(空中にいる) */ public boolean isOnGround() { return (mode instanceof ModeOnGround); } /** - * �n�ʁi�\�����j�ɗ��������u�ԂɌĂяo����� + * 地面(構造物)に落下した瞬間に呼び出される */ public abstract void onEndFall(); /** - * �n�ʁi�\�����j�ɏՓ˂����u�ԂɌĂяo����� - * @param normal --- �n�ʂ̖@�������x�N�g�� - * @param interval --- �O��̓��삩��̌o�ߎ��ԁi�~���b�P�ʁj + * 地面(構造物)に衝突した瞬間に呼び出される + * @param normal --- 地面の法線方向ベクトル + * @param interval --- 前回の動作からの経過時間(ミリ秒単位) */ public abstract void onIntersect(CollisionResult normal, long interval); diff --git a/src/framework/gameMain/Animatable.java b/src/framework/gameMain/Animatable.java index 8494de4..d247591 100644 --- a/src/framework/gameMain/Animatable.java +++ b/src/framework/gameMain/Animatable.java @@ -19,17 +19,17 @@ } /** - * �P�ʎ��Ԃ��Ƃ̓���i�A�j���[�V���������j - * @param interval --- �O��Ăяo���ꂽ�Ƃ�����̌o�ߎ��ԁi�~���b�P�ʁj + * 単位時間ごとの動作(アニメーション処理) + * @param interval --- 前回呼び出されたときからの経過時間(ミリ秒単位) */ public void motion(long interval) { if (animation != null) { - // 1. �A�j���[�V���������s + // 1. アニメーションを実行 if (animation.progress(interval) == false) { onEndAnimation(); } - // 2. �p����ς��� + // 2. 姿勢を変える body.apply(animation.getPose(), false); } } @@ -43,7 +43,7 @@ } /** - * �A�j���[�V�������I�����邽�тɌĂ΂�� + * アニメーションが終了するたびに呼ばれる */ public abstract void onEndAnimation(); diff --git a/src/framework/gameMain/OvergroundActor.java b/src/framework/gameMain/OvergroundActor.java index e8db7b6..c7a3ee4 100644 --- a/src/framework/gameMain/OvergroundActor.java +++ b/src/framework/gameMain/OvergroundActor.java @@ -11,8 +11,8 @@ import framework.physics.Velocity3D; /** - * �n�ʂ̏���ړ�������́i�W�����v�⎩�R���������邱�Ƃ��”\�j - * @author �V�c���� + * 地面の上を移動するもの(ジャンプや自由落下させることも可能) + * @author 新田直也 * */ public class OvergroundActor extends Actor { @@ -30,12 +30,12 @@ // } public void onIntersect(CollisionResult cr, long interval) { - // �߂荞�񂾂�i�߂荞�񂾖ʂ̖@�������Ɂj�����߂� + // めり込んだら(めり込んだ面の法線方向に)押し戻す Vector3d back = (Vector3d) cr.normal.clone(); back.scale(cr.length * 2.0); body.apply(new Position3D(body.getPosition3D().add(back)), false); - // ���x�̖ʂ̖@�������̐����� 0 �ɂ��� + // 速度の面の法線方向の成分を 0 にする Vector3d v = (Vector3d) ((Solid3D)body).getVelocity().getVector3d().clone(); double d = v.dot(cr.normal); v.scaleAdd(-d, cr.normal, v); diff --git a/src/framework/gameMain/RealTimeActivity.java b/src/framework/gameMain/RealTimeActivity.java index bc62dc9..cb6d0b5 100644 --- a/src/framework/gameMain/RealTimeActivity.java +++ b/src/framework/gameMain/RealTimeActivity.java @@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit; public abstract class RealTimeActivity extends Activity implements Runnable { - //�C���^�[�o���m�F�p�ϐ� + //インターバル確認用変数 private long interval = 15L; private long prevTime = 0L; @@ -43,7 +43,7 @@ schedule.shutdown(); } - //�J��Ԃ����s����镔�� + //繰り返し実行される部分 public void run(){ long interval; if (prevTime == 0L || fixedInterval) { @@ -57,6 +57,6 @@ update(interval); } - //interval�~���b�̃C���^�[�o���������Ē�����s + //intervalミリ秒のインターバルをおいて定期実行 protected abstract void update(long interval); } diff --git a/src/framework/model3D/BaseObject3D.java b/src/framework/model3D/BaseObject3D.java index daee1ad..da7e9ae 100644 --- a/src/framework/model3D/BaseObject3D.java +++ b/src/framework/model3D/BaseObject3D.java @@ -56,8 +56,8 @@ } /** - * �Փ˔���p�̃{�����[���i�|���S���Ƒe������p�̑��p���j���擾���� - * @return�@�Փ˔���p�̃{�����[���� + * 衝突判定用のボリューム(ポリゴンと粗い判定用の多角柱)を取得する + * @return 衝突判定用のボリューム列 */ public BoundingSurface[] getBoundingSurfaces() { if (boundingSurfaces == null) { @@ -66,9 +66,9 @@ ArrayList vertex3DList = null; if (node instanceof Box) { - // Box�̏ꍇ + // Boxの場合 Box box = ((Box)node); - // ���_����擾���� + // 頂点列を取得する vertex3DList = getVertexList(box.getShape(Box.BACK).getGeometry()); vertex3DList.addAll(getVertexList(box.getShape(Box.BOTTOM).getGeometry())); vertex3DList.addAll(getVertexList(box.getShape(Box.FRONT).getGeometry())); @@ -76,27 +76,27 @@ vertex3DList.addAll(getVertexList(box.getShape(Box.RIGHT).getGeometry())); vertex3DList.addAll(getVertexList(box.getShape(Box.TOP).getGeometry())); } else if (node instanceof Cylinder) { - // Cylinder�̏ꍇ + // Cylinderの場合 Cylinder cylinder = ((Cylinder)node); - // ���_����擾���� + // 頂点列を取得する vertex3DList = getVertexList(cylinder.getShape(Cylinder.BODY).getGeometry()); vertex3DList.addAll(getVertexList(cylinder.getShape(Cylinder.BOTTOM).getGeometry())); vertex3DList.addAll(getVertexList(cylinder.getShape(Cylinder.TOP).getGeometry())); } else if (node instanceof Cone) { - // Cone�̏ꍇ + // Coneの場合 Cone cone = ((Cone)node); - // ���_����擾���� + // 頂点列を取得する vertex3DList = getVertexList(cone.getShape(Cone.BODY).getGeometry()); vertex3DList.addAll(getVertexList(cone.getShape(Cone.CAP).getGeometry())); } else if (node instanceof Sphere) { - // Sphere�̏ꍇ + // Sphereの場合 Sphere sphere = ((Sphere)node); - // ���_����擾���� + // 頂点列を取得する vertex3DList = getVertexList(sphere.getShape(Sphere.BODY).getGeometry()); } else if (node instanceof Shape3D) { - // Shape3D�̏ꍇ + // Shape3Dの場合 Shape3D shape = (Shape3D)node; - // ���_����擾���� + // 頂点列を取得する vertex3DList = getVertexList(shape.getGeometry()); } if (vertex3DList == null) return null; @@ -123,29 +123,29 @@ ArrayList vertex3DList = new ArrayList(); double coordinate1[] = new double[3]; if (g instanceof IndexedTriangleArray) { - // IndexedTriangleArray �̏ꍇ + // IndexedTriangleArray の場合 IndexedTriangleArray triArray = (IndexedTriangleArray)g; - // �S���_��3D��̒��_��vertex3DList�ɓ���Ă����B + // 全頂点を3D上の頂点をvertex3DListに入れていく。 for (int i = 0; i < triArray.getIndexCount(); i++) { triArray.getCoordinates(triArray.getCoordinateIndex(i), coordinate1); vertex3DList.add(new Vector3d(coordinate1)); } } else if (g instanceof TriangleArray) { - // TriangleArray �̏ꍇ + // TriangleArray の場合 TriangleArray triArray = (TriangleArray)g; - // �S���_��3D��̒��_��vertex3DList�ɓ���Ă����B + // 全頂点を3D上の頂点をvertex3DListに入れていく。 for (int i = 0; i < triArray.getVertexCount(); i++) { triArray.getCoordinates(i, coordinate1); vertex3DList.add(new Vector3d(coordinate1)); } } else if (g instanceof IndexedTriangleStripArray) { - // IndexedTriangleStripArray �̏ꍇ + // IndexedTriangleStripArray の場合 IndexedTriangleStripArray triStripAttay = (IndexedTriangleStripArray)g; int stripVertexCounts[] = new int[triStripAttay.getNumStrips()]; triStripAttay.getStripIndexCounts(stripVertexCounts); - // �S���_��3D��̒��_��vertex3DList�ɓ���Ă��� + // 全頂点を3D上の頂点をvertex3DListに入れていく int index = 0; double coordinate2[] = new double[3]; double coordinate3[] = new double[3]; @@ -156,21 +156,21 @@ triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index+1), coordinate2); triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index+2), coordinate3); triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index+3), coordinate4); - vertex3DList.add(new Vector3d(coordinate1)); //1�‚߂̎O�p�` + vertex3DList.add(new Vector3d(coordinate1)); //1つめの三角形 vertex3DList.add(new Vector3d(coordinate2)); vertex3DList.add(new Vector3d(coordinate3)); - vertex3DList.add(new Vector3d(coordinate2)); //2�‚߂̎O�p�` + vertex3DList.add(new Vector3d(coordinate2)); //2つめの三角形 vertex3DList.add(new Vector3d(coordinate4)); vertex3DList.add(new Vector3d(coordinate3)); index += 2; } } } else if (g instanceof TriangleStripArray) { - // TriangleStripArray �̏ꍇ + // TriangleStripArray の場合 TriangleStripArray triStripAttay = (TriangleStripArray)g; int stripVertexCounts[] = new int[triStripAttay.getNumStrips()]; triStripAttay.getStripVertexCounts(stripVertexCounts); - // �S���_��3D��̒��_��vertex3DList�ɓ���Ă��� + // 全頂点を3D上の頂点をvertex3DListに入れていく int index = 0; double coordinate2[] = new double[3]; double coordinate3[] = new double[3]; @@ -181,27 +181,27 @@ triStripAttay.getCoordinates(index+1, coordinate2); triStripAttay.getCoordinates(index+2, coordinate3); triStripAttay.getCoordinates(index+3, coordinate4); - vertex3DList.add(new Vector3d(coordinate1)); //1�‚߂̎O�p�` + vertex3DList.add(new Vector3d(coordinate1)); //1つめの三角形 vertex3DList.add(new Vector3d(coordinate2)); vertex3DList.add(new Vector3d(coordinate3)); - vertex3DList.add(new Vector3d(coordinate2)); //2�‚߂̎O�p�` + vertex3DList.add(new Vector3d(coordinate2)); //2つめの三角形 vertex3DList.add(new Vector3d(coordinate4)); vertex3DList.add(new Vector3d(coordinate3)); index += 2; } } } else if (g instanceof IndexedTriangleFanArray) { - // IndexedTriangleFanArray �̏ꍇ + // IndexedTriangleFanArray の場合 IndexedTriangleFanArray triFanAttay = (IndexedTriangleFanArray)g; int stripVertexCounts[] = new int[triFanAttay.getNumStrips()]; triFanAttay.getStripIndexCounts(stripVertexCounts); - // �S���_��3D��̒��_��vertex3DList�ɓ���Ă��� + // 全頂点を3D上の頂点をvertex3DListに入れていく int index = 0; double coordinate2[] = new double[3]; double coordinate3[] = new double[3]; double coordinate4[] = null; for (int i = 0; i < triFanAttay.getNumStrips(); i++) { - triFanAttay.getCoordinates(triFanAttay.getCoordinateIndex(index), coordinate1); // ���S�_ + triFanAttay.getCoordinates(triFanAttay.getCoordinateIndex(index), coordinate1); // 中心点 triFanAttay.getCoordinates(triFanAttay.getCoordinateIndex(index+1), coordinate2); index += 2; for (int j = 2; j < stripVertexCounts[i]; j++) { @@ -216,17 +216,17 @@ } } } else if (g instanceof TriangleFanArray) { - // TriangleFanArray �̏ꍇ + // TriangleFanArray の場合 TriangleFanArray triFanAttay = (TriangleFanArray)g; int stripVertexCounts[] = new int[triFanAttay.getNumStrips()]; triFanAttay.getStripVertexCounts(stripVertexCounts); - // �S���_��3D��̒��_��vertex3DList�ɓ���Ă��� + // 全頂点を3D上の頂点をvertex3DListに入れていく int index = 0; double coordinate2[] = new double[3]; double coordinate3[] = new double[3]; double coordinate4[] = null; for (int i = 0; i < triFanAttay.getNumStrips(); i++) { - triFanAttay.getCoordinates(index, coordinate1); // ���S�_ + triFanAttay.getCoordinates(index, coordinate1); // 中心点 triFanAttay.getCoordinates(index + 1, coordinate2); index += 2; for (int j = 2; j < stripVertexCounts[i]; j++) { diff --git a/src/framework/model3D/BoundingSurface.java b/src/framework/model3D/BoundingSurface.java index e5fca61..c5620bc 100644 --- a/src/framework/model3D/BoundingSurface.java +++ b/src/framework/model3D/BoundingSurface.java @@ -12,7 +12,7 @@ public class BoundingSurface implements Cloneable { - private Bounds bounds = null; // �e���Փ˔���p�i�e���n�ʗp�j + private Bounds bounds = null; // 粗い衝突判定用(粗い地面用) private ArrayList children = new ArrayList(); private ArrayList vertexList = new ArrayList(); private static Vector4d plane[] = { new Vector4d(), new Vector4d(), new Vector4d(), @@ -76,9 +76,9 @@ } /** - * BoundingSphere�Ƃ̑e���Փ˔��� - * @param bs �Փ˔���̑Ώ� - * @return �Փ˂��Ă���BoundingSurface�̃��X�g�inull��Ԃ����Ƃ͂Ȃ��j + * BoundingSphereとの粗い衝突判定 + * @param bs 衝突判定の対象 + * @return 衝突しているBoundingSurfaceのリスト(nullを返すことはない) */ public ArrayList intersect(BoundingSphere bs) { ArrayList results = new ArrayList(); @@ -97,18 +97,18 @@ } /** - * OBB�Ƃ̏ڍׂȏՓ˔��� - * @param obb �Փ˔���̑Ώ� - * @return�@�Փ˔���̌��� + * OBBとの詳細な衝突判定 + * @param obb 衝突判定の対象 + * @return 衝突判定の結果 */ public CollisionResult intersect(OBB obb) { if (children == null || children.size() == 0) { - // �t�̏ꍇ�́A�ʃ|���S���𗧂��グ���������p�� + // 葉の場合は、凸ポリゴンを立ち上げた薄い多角柱 if (bounds instanceof BoundingPolytope) { ((BoundingPolytope)bounds).getPlanes(plane); - CollisionResult cr = obb.intersect(plane[0]); // obb����ʂ��܂ޖ������ʂƌ�����Ă��邩�H + CollisionResult cr = obb.intersect(plane[0]); // obbが底面を含む無限平面と交わっているか? if (cr != null) { - // �������ʂƌ�����Ă���ꍇ�A�������ʂƂ̏Փ˓_���ʃ|���S���̓����Ɉʒu���邩�H + // 無限平面と交わっている場合、無限平面との衝突点が凸ポリゴンの内部に位置するか? if (GeometryUtility.inside(vertexList, cr.collisionPoint.getVector3d(), cr.normal)) { return cr; } diff --git a/src/framework/model3D/ContainerModel.java b/src/framework/model3D/ContainerModel.java index a831eed..443adc0 100644 --- a/src/framework/model3D/ContainerModel.java +++ b/src/framework/model3D/ContainerModel.java @@ -3,8 +3,8 @@ import java3d.Transform3D; /** - * �q�������ƒ��f�� - * @author �V�c���� + * 子供を持つモデル + * @author 新田直也 * */ public class ContainerModel extends Model3D { diff --git a/src/framework/model3D/GeometryCollector.java b/src/framework/model3D/GeometryCollector.java index a4dfafe..e497aeb 100644 --- a/src/framework/model3D/GeometryCollector.java +++ b/src/framework/model3D/GeometryCollector.java @@ -10,7 +10,7 @@ public class GeometryCollector extends ObjectVisitor{ private int totalVertexCount = 0; private int totalIndexCount = 0; - private ArrayList geometryList = new ArrayList(); // �t�̂Ƃ��AGeometry��ۑ� + private ArrayList geometryList = new ArrayList(); // 葉のとき、Geometryを保存 private IndexedGeometryArray geometry = null; @Override @@ -29,7 +29,7 @@ public Geometry getGeometry(){ if (geometry == null) { - // ���X�g���̕����� Geometry ��1�‚ɂ܂Ƃ߂� + // リスト中の複数の Geometry を1つにまとめる int coordinateOfs = 0; int indexOfs = 0; double coodinates[] = new double[totalVertexCount * 3]; @@ -52,16 +52,16 @@ geometry.setCoordinates(0, coodinates); geometry.setCoordinateIndices(0, indicies); - // �d�����Ă��钸�_��1�‚ɂ܂Ƃ߂� + // 重複している頂点を1つにまとめる GeometryUtility.compressGeometry(geometry); -// // IndexedTriangleStripArray�@�ɕϊ��i�d�����Ă��钸�_��1�‚ɂ܂Ƃ߂邽�߁j +// // IndexedTriangleStripArray に変換(重複している頂点を1つにまとめるため) // GeometryInfo gi = new GeometryInfo(geometry); // Stripifier sf = new Stripifier(); // sf.stripify(gi); -// geometry = gi.getIndexedGeometryArray(); // IndexedTriangleStripArray ���Ԃ���� +// geometry = gi.getIndexedGeometryArray(); // IndexedTriangleStripArray が返される // -// // IndexedTriangleArray �ɕϊ��iGeometryGraph �� IndexedTriangleStripArray �ɖ��Ή��̂��߁j +// // IndexedTriangleArray に変換(GeometryGraph が IndexedTriangleStripArray に未対応のため) // if (geometry instanceof IndexedTriangleStripArray) { // int numStrips = ((IndexedTriangleStripArray)geometry).getNumStrips(); // int indexCounts[] = new int[numStrips]; diff --git a/src/framework/model3D/GeometryUtility.java b/src/framework/model3D/GeometryUtility.java index a899b42..d8eb29e 100644 --- a/src/framework/model3D/GeometryUtility.java +++ b/src/framework/model3D/GeometryUtility.java @@ -46,19 +46,19 @@ ArrayList vertex2Dlist, Vector3d axis) { int i = 0; double k = 0.0; - // System.out.println("point3�F"+axis); + // System.out.println("point3:"+axis); if (axis.x != 0 || axis.y != 0 || axis.z != 0) { axis.normalize(); } - // System.out.println("point3_1�F"+axis); + // System.out.println("point3_1:"+axis); ProjectionResult pr = new ProjectionResult(); for (i = 0; i < vertex2Dlist.size(); i++) { Vector3d p = vertex2Dlist.get(i); k = p.dot(axis); - // System.out.println("k�F"+k); - // System.out.println("point3�F"+axis); + // System.out.println("k:"+k); + // System.out.println("point3:"+axis); if (i == 0 || k >= pr.max) { pr.max = k; } else if (i == 0 || k <= pr.min) { @@ -68,7 +68,7 @@ return pr; } - // �ȉ��A���_�̕\���̔��胁�\�b�h + // 以下、頂点の表裏の判定メソッド public static boolean inside(Vector3d v, Vector4d plane) { // System.out.println("vertex:" + v.x + "," + v.y + "," + v.z); // System.out.println("plane:" + plane.x + "," + plane.y + "," + plane.z @@ -77,25 +77,25 @@ // Vector3d nv = (Vector3d)pv.clone(); // nv.scaleAdd(plane.w / pv.lengthSquared(),v); if (pv.dot(v) + plane.w <= TOLERANCE) { - // System.out.println("��������I�I"+nv.dot(pv)); + // System.out.println("内部判定!!"+nv.dot(pv)); pv = null; return true; } - // System.out.println("�O������I�I"+nv.dot(pv)); + // System.out.println("外部判定!!"+nv.dot(pv)); pv = null; return false; } /** - * 3�_��ʂ镽�ʂ��쐬����i�������Av1, v2, v3�̓��e��������������̂Œ��Ӂj + * 3点を通る平面を作成する(ただし、v1, v2, v3の内容が書き換えられるので注意) * * @param v1 - * --- 1�_�ڂ̍��W + * --- 1点目の座標 * @param v2 - * --- 2�_�ڂ̍��W + * --- 2点目の座標 * @param v3 - * --- 3�_�ڂ̍��W - * @return�@v1, v2, v3��ʂ镽�� + * --- 3点目の座標 + * @return v1, v2, v3を通る平面 */ public static Vector4d createPlane(Vector3d v1, Vector3d v2, Vector3d v3) { v2.sub(v1); @@ -107,15 +107,15 @@ /** * - * ���ʂƒ����̌�_�����߂� + * 平面と直線の交点を求める * * @param plane - * ���� + * 平面 * @param v1 - * ������̓_1 + * 直線上の点1 * @param v2 - * ������̓_2 - * @return ��_ + * 直線状の点2 + * @return 交点 */ public static Vector3d intersect(Vector4d plane, Vector3d v1, Vector3d v2) { Vector3d n = new Vector3d(plane.x, plane.y, plane.z); @@ -128,18 +128,18 @@ /** * - * �w�肳�ꂽ�_���ʃ|���S���̓����ɕ�܂���Ă��邩�H + * 指定された点が凸ポリゴンの内部に包含されているか? * * @param vertexList - * �ʃ|���S���̒��_�� + * 凸ポリゴンの頂点列 * @param point - * �w��_ - * @return true --- ��܂���Ă���, false --- ��܂���Ă��Ȃ� + * 指定点 + * @return true --- 包含されている, false --- 包含されていない */ public static boolean inside(ArrayList vertexList, Vector3d point, Vector3d normal) { boolean inside = true; for (int i = 0; i < vertexList.size(); i++) { - // �|���S���̊e�ӂɑ΂��ďՓ˓_���E�����������H + // ポリゴンの各辺に対して衝突点が右側か左側か? Vector3d center = (Vector3d) point.clone(); Vector3d v2 = (Vector3d) (vertexList.get((i + 1) % vertexList.size()).clone()); @@ -152,13 +152,13 @@ break; } } - // ���ׂĉE���A�܂��͂��ׂč����������ꍇ�A�ʃ|���S���̓����Ɉʒu�����ƍl���� + // すべて右側、またはすべて左側だった場合、凸ポリゴンの内部に位置したと考える return inside; } - // IndexedGeometryArray�̃C���f�b�N�X�̂����A�������W�������C���f�b�N�X��u�������� + // IndexedGeometryArrayのインデックスのうち、同じ座標をさすインデックスを置き換える public static void compressGeometry(IndexedGeometryArray g) { - // 1. Hashtable�����Ȃ���A������W���_�Q�̑�\representaion[]�����߂� + // 1. Hashtableを作りながら、同一座標頂点群の代表representaion[]を決める Hashtable> h = new Hashtable>(); Point3d p = new Point3d(); Point3d p2 = new Point3d(); @@ -173,12 +173,12 @@ vertexList = h.get(hashValue); - if (vertexList == null) {// hash�ɑΉ�����v�f���Ȃ��ꍇ - // Hashtable����� + if (vertexList == null) {// hashに対応する要素がない場合 + // Hashtableを作る vertexList = new ArrayList(); vertexList.add(i); h.put(hashValue, vertexList); - // representation[]����� + // representation[]を作る representation[i] = i; } else { boolean bFound = false; @@ -194,13 +194,13 @@ } if (!bFound) { vertexList.add(i); - // representation[]����� + // representation[]を作る representation[i] = i; } } } - // 2. index�̒u������ + // 2. indexの置き換え for (int i = 0; i < g.getIndexCount(); i++) { int newIndex = representation[g.getCoordinateIndex(i)]; g.setCoordinateIndex(i, newIndex); diff --git a/src/framework/model3D/ModelFactory.java b/src/framework/model3D/ModelFactory.java index 66fdaf6..a919c06 100644 --- a/src/framework/model3D/ModelFactory.java +++ b/src/framework/model3D/ModelFactory.java @@ -27,8 +27,8 @@ /** - * 3�������f���𐶐����邽�߂̃N���X - * @author �V�c���� + * 3次元モデルを生成するためのクラス + * @author 新田直也 * */ public class ModelFactory { @@ -36,10 +36,10 @@ public static final String OBJ_FILE_EXTENSION = ".obj"; /** - * 3�������f�����K�w�\���Ɗe���̖��̂ƂƂ��Ƀt�@�C������ǂݍ��� - * @param res ���\�[�X - * @param fileName �t�@�C���� - * @return �ǂݍ���3D���f�� + * 3次元モデルを階層構造と各部の名称とともにファイルから読み込む + * @param res リソース + * @param fileName ファイル名 + * @return 読み込んだ3Dモデル * @throws IOException * @throws ModelFileFormatException */ @@ -48,11 +48,11 @@ } /** - * 3�������f�����K�w�\���Ɗe���̖��̂ƂƂ��Ƀt�@�C������ǂݍ��� - * @param res ���\�[�X - * @param fileName �t�@�C���� - * @param ap 3D���f���ɓK�p����\�ʑ���(STL�t�@�C���̂�) - * @return �ǂݍ���3D���f�� + * 3次元モデルを階層構造と各部の名称とともにファイルから読み込む + * @param res リソース + * @param fileName ファイル名 + * @param ap 3Dモデルに適用する表面属性(STLファイルのみ) + * @return 読み込んだ3Dモデル * @throws IOException * @throws ModelFileFormatException */ @@ -61,39 +61,39 @@ } /** - * 3�������f�����K�w�\���Ɗe���̖��̂ƂƂ��Ƀt�@�C������ǂݍ��ށi�����e�N�X�`���̗L���̎w��t���j - * @param res ���\�[�X - * @param fileName �t�@�C���� - * @param ap 3D���f���ɓK�p����\�ʑ���(STL�t�@�C���̂�) - * @param bTransparent �����e�N�X�`�������邩�ۂ�(Android�p�ł͖��g�p) - * @param bCalcNormal �@���̍Čv�Z���s���� - * @return �ǂݍ���3D���f�� + * 3次元モデルを階層構造と各部の名称とともにファイルから読み込む(透明テクスチャの有無の指定付き) + * @param res リソース + * @param fileName ファイル名 + * @param ap 3Dモデルに適用する表面属性(STLファイルのみ) + * @param bTransparent 透明テクスチャがあるか否か(Android用では未使用) + * @param bCalcNormal 法線の再計算を行うか + * @return 読み込んだ3Dモデル * @throws IOException * @throws ModelFileFormatException */ public static Model3D loadModel(Resources res, String fileName, Appearance ap, boolean bTransparent, boolean bCalcNormal) throws IOException, ModelFileFormatException { if (fileName.toLowerCase().endsWith(STL_FILE_EXTENSION)) { - // STL�t�@�C���ǂݍ��� + // STLファイル読み込み return loadStlFile(res, fileName, ap, bCalcNormal); } else if (fileName.toLowerCase().endsWith(OBJ_FILE_EXTENSION)) { - // OBJ�t�@�C���ǂݍ��� + // OBJファイル読み込み return loadObjFile(res, fileName, bCalcNormal); } return null; } /** - * STL�t�@�C��(�A�X�L�[�A�o�C�i��)�̓ǂݍ��� - * @param res ���\�[�X - * @param fileName �t�@�C���� - * @param ap 3D���f���ɓK�p����\�ʑ��� - * @param bCalcNormal �@���̍Čv�Z���s���� - * @return �ǂݍ���3D���f�� + * STLファイル(アスキー、バイナリ)の読み込み + * @param res リソース + * @param fileName ファイル名 + * @param ap 3Dモデルに適用する表面属性 + * @param bCalcNormal 法線の再計算を行うか + * @return 読み込んだ3Dモデル * @throws IOException * @throws ModelFileFormatException */ public static Model3D loadStlFile(Resources res, String fileName, Appearance ap, boolean bCalcNormal) throws IOException, ModelFileFormatException { - // STL�t�@�C���ǂݍ��� + // STLファイル読み込み InputStream in = res.getAssets().open(fileName); BufferedInputStream bis = new BufferedInputStream(in); byte[] headerBin = new byte[80]; @@ -106,13 +106,13 @@ headerBin[5] == ' ') { bis.close(); - // STL�̓e�L�X�g�t�@�C�� + // STLはテキストファイル BufferedReader br = new BufferedReader(new InputStreamReader(in)); Model3D model = loadStlAsciiFile(br, ap, bCalcNormal); br.close(); return model; } else if (n == 80) { - // STL�̓o�C�i���t�@�C�� + // STLはバイナリファイル Model3D model = loadStlBinaryFile(bis, headerBin, ap, bCalcNormal); bis.close(); return model; @@ -121,7 +121,7 @@ } private static Model3D loadStlAsciiFile(BufferedReader br, Appearance ap, boolean bCalcNormal) throws IOException, ModelFileFormatException { - // �w�b�_�ǂݍ��� + // ヘッダ読み込み String header = br.readLine(); if (header == null) { br.close(); @@ -139,7 +139,7 @@ throw new ModelFileFormatException(); } - // Facet�ǂݍ��� + // Facet読み込み ArrayList verticies = new ArrayList(); String line; while ((line = br.readLine()) != null && !line.startsWith("endsolid ")) { @@ -182,11 +182,11 @@ throw new ModelFileFormatException(); } double[] vertex = new double[]{ - Double.parseDouble(data[1]), // X���W - Double.parseDouble(data[2]), // Y���W - Double.parseDouble(data[3]) // Z���W + Double.parseDouble(data[1]), // X座標 + Double.parseDouble(data[2]), // Y座標 + Double.parseDouble(data[3]) // Z座標 }; - verticies.add(vertex); // Z���W + verticies.add(vertex); // Z座標 } // endloop @@ -227,7 +227,7 @@ } private static Model3D loadStlBinaryFile(BufferedInputStream bis, byte[] header, Appearance ap, boolean bCalcNormal) throws IOException, ModelFileFormatException { - // Facet���ǂݍ��� + // Facet数読み込み Integer numTri = readInt(bis); if (numTri == null) { System.out.println("Expected vertex count"); @@ -235,7 +235,7 @@ throw new ModelFileFormatException(); } - // Facet�ǂݍ��� + // Facet読み込み ArrayList verticies = new ArrayList(); ArrayList normals = new ArrayList(); Vector3f[] vertex = new Vector3f[] { @@ -245,21 +245,21 @@ }; for (int n = 0; n < numTri; n++) { - Float nx = readFloat(bis); // �@��X���� + Float nx = readFloat(bis); // 法線X成分 if (nx == null) { System.out.println("Expected normal"); bis.close(); throw new ModelFileFormatException(); } - Float ny = readFloat(bis); // �@��Y���� + Float ny = readFloat(bis); // 法線Y成分 if (ny == null) { System.out.println("Expected normal"); bis.close(); throw new ModelFileFormatException(); } - Float nz = readFloat(bis); // �@��Z���� + Float nz = readFloat(bis); // 法線Z成分 if (nz == null) { System.out.println("Expected normal"); bis.close(); @@ -267,21 +267,21 @@ } for (int i = 0; i < 3; i++) { - Float x = readFloat(bis); // X���W + Float x = readFloat(bis); // X座標 if (x == null) { System.out.println("Expected vertex" + (i + 1)); bis.close(); throw new ModelFileFormatException(); } - Float y = readFloat(bis); // Y���W + Float y = readFloat(bis); // Y座標 if (y == null) { System.out.println("Expected vertex" + (i + 1)); bis.close(); throw new ModelFileFormatException(); } - Float z = readFloat(bis); // Z���W + Float z = readFloat(bis); // Z座標 if (z == null) { System.out.println("Expected vertex" + (i + 1)); bis.close(); @@ -326,11 +326,11 @@ } /** - * OBJ�t�@�C���̓ǂݍ��� - * @param res ���\�[�X - * @param fileName �t�@�C���� - * @param bCalcNormal �@���̍Čv�Z���s���� - * @return �ǂݍ���3D���f�� + * OBJファイルの読み込み + * @param res リソース + * @param fileName ファイル名 + * @param bCalcNormal 法線の再計算を行うか + * @return 読み込んだ3Dモデル * @throws IOException * @throws ModelFileFormatException */ @@ -358,17 +358,17 @@ line.trim(); String data[] = line.split(" "); if (data[0].equals("#")) { - // �R�����g + // コメント } else if (data[0].equals("mtllib")) { - // �ގ��t�@�C���̎w�� + // 材質ファイルの指定 String dir = new File(fileName).getParent(); String mtlFileName = line.substring(line.indexOf(" ") + 1); String mtlFilePath = new File(dir, mtlFileName).getPath(); appearances = loadMtlFile(res, mtlFilePath); } else if (data[0].equals("o")) { - // �I�u�W�F�N�g�̊J�n + // オブジェクトの開始 if (groups.size() > 0 || subGroups.size() > 0 || subGroupCoordinateIndicies.size() > 0) { - // �O�̃I�u�W�F�N�g�̃O���[�v�̎c��A�T�u�O���[�v�̎c��A�X�g���b�v�̎c���V�����I�u�W�F�N�g�Ƃ��Ēlj� + // 前のオブジェクトのグループの残り、サブグループの残り、ストリップの残りを新しいオブジェクトとして追加 Model3D newObject = createRemainingObject(objectName, groups, groupName, objCoordinates, objTexCoordinates, objNormals, subGroups, subGroupName, subGroupAp, subGroupCoordinateIndicies, subGroupTexCoordIndicies, subGroupNormalIndicies); @@ -382,9 +382,9 @@ } objectName = data[1]; } else if (data[0].equals("g")) { - // �O���[�v�̊J�n + // グループの開始 if (subGroups.size() > 0 || subGroupCoordinateIndicies.size() > 0) { - // �O�̃O���[�v�̃T�u�O���[�v�̎c��A�X�g���b�v�̎c���V�����O���[�v�Ƃ��Ēlj� + // 前のグループのサブグループの残り、ストリップの残りを新しいグループとして追加 Model3D newGroup = createRemainingGroup(groupName, objCoordinates, objTexCoordinates, objNormals, subGroups, subGroupName, subGroupAp, subGroupCoordinateIndicies, subGroupTexCoordIndicies, subGroupNormalIndicies); groups.add(newGroup); @@ -397,9 +397,9 @@ } groupName = data[1]; } else if (data[0].equals("usemtl")) { - // �ގ��̎g�p(�T�u�O���[�v�̊J�n) + // 材質の使用(サブグループの開始) if (subGroupCoordinateIndicies.size() > 0) { - // �O�̃T�u�O���[�v�̃X�g���b�v�̎c���V�����T�u�O���[�v�Ƃ��Ēlj� + // 前のサブグループのストリップの残りを新しいサブグループとして追加 Model3D newSubGroup = createRemainingSubGroup(objCoordinates, objTexCoordinates, objNormals, subGroupName, subGroupAp, subGroupCoordinateIndicies, subGroupTexCoordIndicies, subGroupNormalIndicies); subGroups.add(newSubGroup); @@ -413,9 +413,9 @@ throw new ModelFileFormatException(); } subGroupAp = appearances.get(data[1]); - subGroupName = groupName + "_" + data[1] + subGroups.size(); // ���T�u�O���[�v�̖��O���d�����Ȃ��悤�ɂ��鏈�� + subGroupName = groupName + "_" + data[1] + subGroups.size(); // ※サブグループの名前が重複しないようにする処理 } else if (data[0].equals("v")) { - // ���_���W�f�[�^ + // 頂点座標データ if (data.length < 4) { System.out.println("Expected vertex coordinate"); throw new ModelFileFormatException(); @@ -426,7 +426,7 @@ Vector3f v = new Vector3f(x, y, z); objCoordinates.add(v); } else if (data[0].equals("vt")) { - // �e�N�X�`�����W�f�[�^ + // テクスチャ座標データ if (data.length < 3) { System.out.println("Expected texture coordinate"); throw new ModelFileFormatException(); @@ -436,7 +436,7 @@ Vector2f v = new Vector2f(x, y); objTexCoordinates.add(v); } else if (data[0].equals("vn")) { - // �@���x�N�g���f�[�^ + // 法線ベクトルデータ if (data.length < 4) { System.out.println("Expected normal vector"); throw new ModelFileFormatException(); @@ -447,7 +447,7 @@ Vector3f v = new Vector3f(x, y, z); objNormals.add(v); } else if (data[0].equals("f")) { - // �|���S��(�X�g���b�v)�f�[�^ + // ポリゴン(ストリップ)データ if (data.length < 4) { System.out.println("At least 3 verticies are needed"); throw new ModelFileFormatException(); @@ -458,16 +458,16 @@ for (int n = 1; n < data.length; n++) { String elements[] = data[n].split("/"); if (elements.length >= 1) { - // ���_���W�C���f�b�N�X + // 頂点座標インデックス coordinateIndicies.add(Integer.parseInt(elements[0]) - 1); if (elements.length >= 2) { - // �e�N�X�`�����W�C���f�b�N�X + // テクスチャ座標インデックス if (elements[0].length() > 0) { - // "v//vn"�̏ꍇ�����邽�� + // "v//vn"の場合もあるため texCoordIndicies.add(Integer.parseInt(elements[1]) - 1); } if (elements.length >= 3) { - // �@���x�N�g���C���f�b�N�X + // 法線ベクトルインデックス normalIndicies.add(Integer.parseInt(elements[2]) - 1); } } @@ -479,9 +479,9 @@ } } - // �t�@�C���ǂݍ��݌�̏��� + // ファイル読み込み後の処理 if (groups.size() > 0 || subGroups.size() > 0 || subGroupCoordinateIndicies.size() > 0) { - // �X�g���b�v�̎c��A�T�u�O���[�v�̎c��A�O���[�v�̎c����Ō�̃I�u�W�F�N�g�Ƃ��Ēlj� + // ストリップの残り、サブグループの残り、グループの残りを最後のオブジェクトとして追加 Model3D newObject = createRemainingObject(objectName, groups, groupName, objCoordinates, objTexCoordinates, objNormals, subGroups, subGroupName, subGroupAp, subGroupCoordinateIndicies, subGroupTexCoordIndicies, subGroupNormalIndicies); @@ -497,22 +497,22 @@ System.out.println("No polygon is included"); throw new ModelFileFormatException(); } else if (groups.size() == 1) { - // �O���[�v��������‚̏ꍇ + // グループがただ一つの場合 return groups.get(0); } else { - // �I�u�W�F�N�g��������‚̏ꍇ + // オブジェクトがただ一つの場合 return objects.get(0); } } else { - // �I�u�W�F�N�g�������̏ꍇ + // オブジェクトが複数の場合 return new ContainerModel(fileName, (Model3D [])objects.toArray(new Model3D []{})); } } /** - * �O���[�v�̎c���V�����I�u�W�F�N�g�Ƃ��Ēlj� - * @param objectName �V�����I�u�W�F�N�g�̖��O - * @param groups�@�V�����I�u�W�F�N�g���\������O���[�v + * グループの残りを新しいオブジェクトとして追加 + * @param objectName 新しいオブジェクトの名前 + * @param groups 新しいオブジェクトを構成するグループ * @param groupName * @param groupCoordinates * @param groupTexCoordinates @@ -533,25 +533,25 @@ ArrayList> subGroupTexCoordIndicies, ArrayList> subGroupNormalIndicies) { if (subGroups.size() > 0 || subGroupCoordinateIndicies.size() > 0) { - // �X�g���b�v�̎c��A�T�u�O���[�v�̎c���V�����O���[�v�Ƃ��Ēlj� + // ストリップの残り、サブグループの残りを新しいグループとして追加 Model3D newGroup = createRemainingGroup(groupName, groupCoordinates, groupTexCoordinates, groupNormals, subGroups, subGroupName, subGroupAp, subGroupCoordinateIndicies, subGroupTexCoordIndicies, subGroupNormalIndicies); groups.add(newGroup); subGroups.clear(); } - // �O���[�v�̎c���V�����I�u�W�F�N�g�Ƃ��č쐬 + // グループの残りを新しいオブジェクトとして作成 Model3D newObject = new ContainerModel(objectName, (Model3D [])groups.toArray(new Model3D []{})); return newObject; } /** - * �T�u�O���[�v�̎c���V�����O���[�v�Ƃ��č쐬 - * @param groupName�@�V�����O���[�v�̖��O - * @param groupCoordinates�@���_���W�̒l�̃��X�g - * @param groupTexCoordinates�@�e�N�X�`�����W�̒l�̃��X�g - * @param groupNormals�@�@���x�N�g���̒l�̃��X�g - * @param subGroups �V�����O���[�v���\������T�u�O���[�v + * サブグループの残りを新しいグループとして作成 + * @param groupName 新しいグループの名前 + * @param groupCoordinates 頂点座標の値のリスト + * @param groupTexCoordinates テクスチャ座標の値のリスト + * @param groupNormals 法線ベクトルの値のリスト + * @param subGroups 新しいグループを構成するサブグループ * @param subGroupName * @param subGroupAp * @param subGroupCoordinateIndicies @@ -567,7 +567,7 @@ ArrayList> subGroupTexCoordIndicies, ArrayList> subGroupNormalIndicies) { if (subGroupCoordinateIndicies.size() > 0) { - // �X�g���b�v�̎c���V�����T�u�O���[�v�Ƃ��Ēlj� + // ストリップの残りを新しいサブグループとして追加 Model3D newSubGroup = createRemainingSubGroup(groupCoordinates, groupTexCoordinates, groupNormals, subGroupName, subGroupAp, subGroupCoordinateIndicies, subGroupTexCoordIndicies, subGroupNormalIndicies); subGroups.add(newSubGroup); @@ -576,20 +576,20 @@ subGroupNormalIndicies.clear(); } - // �T�u�O���[�v�̎c���V�����O���[�v�Ƃ��č쐬 + // サブグループの残りを新しいグループとして作成 return new ContainerModel(groupName, (Model3D [])subGroups.toArray(new Model3D []{})); } /** - * �X�g���b�v�̎c���V�����T�u�O���[�v�Ƃ��č쐬 + * ストリップの残りを新しいサブグループとして作成 * @param groupCoordinates * @param groupTexCoordinates * @param groupNormals - * @param subGroupName �V�����T�u�O���[�v�̖��O - * @param subGroupAp �V�����T�u�O���[�v�̕\�ʑ��� - * @param subGroupCoordinateIndicies�@���_���W�ւ̃C���f�b�N�X - * @param subGroupTexCoordIndicies �e�N�X�`�����W�ւ̃C���f�b�N�X - * @param subGroupNormalIndicies�@�@���x�N�g���ւ̃C���f�b�N�X + * @param subGroupName 新しいサブグループの名前 + * @param subGroupAp 新しいサブグループの表面属性 + * @param subGroupCoordinateIndicies 頂点座標へのインデックス + * @param subGroupTexCoordIndicies テクスチャ座標へのインデックス + * @param subGroupNormalIndicies 法線ベクトルへのインデックス * @return */ private static Model3D createRemainingSubGroup(ArrayList groupCoordinates, @@ -597,23 +597,23 @@ String subGroupName, Appearance subGroupAp, ArrayList> subGroupCoordinateIndicies, ArrayList> subGroupTexCoordIndicies, ArrayList> subGroupNormalIndicies) { - // �X�g���b�v�̎c���V�����T�u�O���[�v�Ƃ��č쐬 - // Geometry �̍쐬 + // ストリップの残りを新しいサブグループとして作成 + // Geometry の作成 GeometryArray geometry = createGeometryArray(groupCoordinates, groupTexCoordinates, groupNormals, subGroupCoordinateIndicies, subGroupTexCoordIndicies, subGroupNormalIndicies); - // Object3D �̍쐬 + // Object3D の作成 return new LeafModel(subGroupName, geometry, subGroupAp); } /** - * �X�g���b�v�̃C���f�b�N�X��񂩂�W�I���g���[���쐬 - * @param groupCoordinates ���_���W�̒l�̃��X�g - * @param groupTexCoordinates �e�N�X�`�����W�̒l�̃��X�g - * @param groupNormals �@���x�N�g���̒l�̃��X�g - * @param subGroupCoordinateIndicies ���_���W�ւ̃C���f�b�N�X - * @param subGroupTexCoordIndicies �e�N�X�`�����W�ւ̃C���f�b�N�X - * @param subGroupNormalIndicies �@���x�N�g���ւ̃C���f�b�N�X - * @return �쐬�����W�I���g���[ + * ストリップのインデックス情報からジオメトリーを作成 + * @param groupCoordinates 頂点座標の値のリスト + * @param groupTexCoordinates テクスチャ座標の値のリスト + * @param groupNormals 法線ベクトルの値のリスト + * @param subGroupCoordinateIndicies 頂点座標へのインデックス + * @param subGroupTexCoordIndicies テクスチャ座標へのインデックス + * @param subGroupNormalIndicies 法線ベクトルへのインデックス + * @return 作成したジオメトリー */ private static GeometryArray createGeometryArray( ArrayList groupCoordinates, @@ -768,10 +768,10 @@ } /** - * MTL�t�@�C���̓ǂݍ��� - * @param res ���\�[�X - * @param fileName �t�@�C���� - * @return�@�ގ�������\�ʑ����I�u�W�F�N�g�ւ̃}�b�s���O + * MTLファイルの読み込み + * @param res リソース + * @param fileName ファイル名 + * @return 材質名から表面属性オブジェクトへのマッピング * @throws IOException * @throws ModelFileFormatException */ @@ -846,7 +846,7 @@ System.out.println("Expected texture file's name"); throw new ModelFileFormatException(); } - // �e�N�X�`���t�@�C���ǂݍ��� + // テクスチャファイル読み込み try { String dir = new File(fileName).getParent(); String texFileName = line.substring(line.indexOf(" ") + 1); diff --git a/src/framework/model3D/OBB.java b/src/framework/model3D/OBB.java index d9743c6..8a075f4 100644 --- a/src/framework/model3D/OBB.java +++ b/src/framework/model3D/OBB.java @@ -71,10 +71,10 @@ } /** - * ���_�������ɖʂ���ы��E���ʑ̂𐶐����� + * 頂点情報を元に面および境界多面体を生成する */ public void createPlanes() { - // �ʂ̍쐬 + // 面の作成 Vector3d v1 = new Vector3d(); Vector3d v2 = new Vector3d(); Vector3d v3 = new Vector3d(); @@ -148,9 +148,9 @@ } /** - * ���ʂƂ̏Փ˔��� - * @param plane �Փ˔���̑ΏۂƂȂ镽�� - * @return �Փ˔���̌��ʁi�Փ˂��Ă��Ȃ��ꍇ��null�j + * 平面との衝突判定 + * @param plane 衝突判定の対象となる平面 + * @return 衝突判定の結果(衝突していない場合はnull) */ public CollisionResult intersect(Vector4d plane) { int i = 0; @@ -181,7 +181,7 @@ } if (!inside || !outside) { - // �S���_���O�����S���_�������̏ꍇ + // 全頂点が外側か全頂点が内側の場合 return null; } @@ -200,13 +200,13 @@ } /** - * OBB�Ƃ̏Փ˔��� - * @param o �Փ˔���̑ΏۂƂȂ�OBB - * @return �Փ˔���̌��ʁi�Փ˂��Ă��Ȃ��ꍇ��null�j + * OBBとの衝突判定 + * @param o 衝突判定の対象となるOBB + * @return 衝突判定の結果(衝突していない場合はnull) */ public CollisionResult intersect(OBB o) { - // o�̊e���_��this�̊e�ʂ̓����ɂ��邩�𒲂ׂ� - // i�F���_ j�F�� + // oの各頂点がthisの各面の内側にあるかを調べる + // i:頂点 j:面 for (int i = 0; i < o.vertexList.size(); i++) { for (int j = 0; j < plane.length; j++) { inside[i][j] = GeometryUtility.inside(o.vertexList.get(i), plane[j]); @@ -217,7 +217,7 @@ int count = 0; Vector3d center = new Vector3d(0, 0, 0); - // o�̊e���_��this�ɕ�܂���Ă��邩�H + // oの各頂点がthisに包含されているか? for (int v = 0; v < 8; v++) { boolean f1 = false; for (int p = 0; p < 6; p++) { @@ -235,7 +235,7 @@ } if (!collision) { - // �ӂ�����̖ʂƌ�����Ă��邩�H + // 辺が相手の面と交わっているか? for (int p = 0; p < 6; p++) { Vector3d intersection = null; for (int e = 0; e < 12; e++) { diff --git a/src/framework/model3D/Object3D.java b/src/framework/model3D/Object3D.java index 49f9f41..76894a8 100644 --- a/src/framework/model3D/Object3D.java +++ b/src/framework/model3D/Object3D.java @@ -69,7 +69,7 @@ pos.setTransform(defaultTransform); } - // �R�s�[�R���X�g���N�^ + // コピーコンストラクタ public Object3D(Object3D obj) { this.name = new String(obj.name); if (obj.position != null) { @@ -131,7 +131,7 @@ this.undoBuffer = new UndoBuffer(obj.undoBuffer); } - // �����𕡐�����i�N���[�������j + // 自分を複製する(クローンを作る) public Object3D duplicate() { Object3D obj = new Object3D(this); return obj; @@ -152,9 +152,9 @@ if (hasChildren()) return null; // if (!bLOD) { return (Node)center.getChild(0); - // TODO ������ + // TODO 未実装 // } else { -// // LOD �̏ꍇ +// // LOD の場合 // return lodNode.getSwitch(0).getChild(0); // } } @@ -163,9 +163,9 @@ if (hasChildren()) return null; // if (!bLOD) { return (Enumeration)center.getAllChildren(); - // TODO ������ + // TODO 未実装 // } else { -// // LOD �̏ꍇ +// // LOD の場合 // return lodNode.getSwitch(0).getAllChildren(); // } } @@ -199,7 +199,7 @@ scale.setTransform(trans); } - // �L�����N�^�[����]������ + // キャラクターを回転させる public void rotate(double vx, double vy, double vz, double a) { AxisAngle4d t = new AxisAngle4d(vx, vy, vz, a); Transform3D trans = new Transform3D(); @@ -214,12 +214,12 @@ p.applyTo(this); } -// undo����|�C���g��ݒ肷��B +// undoするポイントを設定する。 public void setUndoMark() { undoBuffer.setUndoMark(); } -// undo����B +// undoする。 public void undo() { Iterator iterator = undoBuffer.undo().iterator(); while (iterator.hasNext()) { @@ -228,7 +228,7 @@ } } - // object�Ɏq�������邩�ǂ����𒲂ׂ� + // objectに子供がいるかどうかを調べる public boolean hasChildren() { if (this.children != null && this.children.length > 0) return true; @@ -237,9 +237,9 @@ } /** - * ���i�I�u�W�F�N�g��T�� - * @param partName�@���i�� - * @return�@partName �����•��i�I�u�W�F�N�g + * 部品オブジェクトを探す + * @param partName 部品名 + * @return partName を持つ部品オブジェクト */ public Object3D getPart(String partName) { if (partName.equals(this.name)) return this; @@ -269,7 +269,7 @@ objectVisitor.postVisit(this); } - // Quaternion3D �� applyTo() �ȊO����͌Ă΂Ȃ����� + // Quaternion3D の applyTo() 以外からは呼ばないこと void setQuaternion(Quaternion3D quaternion) { this.quaternion = quaternion; rotate(quaternion.getQuat()); @@ -284,7 +284,7 @@ Node node = getPrimitiveNode(); if (node == null) return null; if (node instanceof Box) { - // Box�̏ꍇ + // Boxの場合 Box box = ((Box)node); double xDim = box.getXdimension(); double yDim = box.getYdimension(); @@ -298,7 +298,7 @@ new Vector3d(xDim, -yDim, zDim), new Vector3d(xDim, yDim, zDim)); } else if (node instanceof Cylinder) { - // Cylinder�̏ꍇ + // Cylinderの場合 Cylinder cylinder = ((Cylinder)node); double xDim = cylinder.getRadius(); double yDim = cylinder.getHeight() / 2; @@ -312,7 +312,7 @@ new Vector3d(xDim, -yDim, zDim), new Vector3d(xDim, yDim, zDim)); } else if (node instanceof Cone) { - // Cone�̏ꍇ + // Coneの場合 Cone cone = ((Cone)node); double xDim = cone.getRadius(); double yDim = cone.getHeight() / 2; @@ -326,7 +326,7 @@ new Vector3d(xDim, -yDim, zDim), new Vector3d(xDim, yDim, zDim)); } else if (node instanceof Sphere) { - // Sphere�̏ꍇ + // Sphereの場合 Sphere sphere = ((Sphere)node); double xDim = sphere.getRadius(); double yDim = sphere.getRadius(); @@ -341,14 +341,14 @@ new Vector3d(xDim, yDim, zDim)); } else { if (!(node instanceof Shape3D)) return null; - // Shape3D�̏ꍇ + // Shape3Dの場合 Shape3D shape = (Shape3D)node; double coordinate[] = new double[3]; - // OBB�̍쐬�ɗp���钸�_��̎擾 + // OBBの作成に用いる頂点列の取得 ArrayList vertex3DList = new ArrayList(); if (shape.getGeometry() instanceof IndexedGeometryArray) { - // IndexedGeometryArray�̏ꍇ + // IndexedGeometryArrayの場合 IndexedGeometryArray iga = (IndexedGeometryArray) shape.getGeometry(); for (int i = 0; i < iga.getIndexCount(); i++) { iga.getCoordinates(iga.getCoordinateIndex(i), coordinate); @@ -356,7 +356,7 @@ vertex3DList.add(p); } } else if (shape.getGeometry() instanceof GeometryStripArray) { - // GeometryStripArray�̏ꍇ + // GeometryStripArrayの場合 GeometryStripArray gsa = (GeometryStripArray) shape.getGeometry(); for (int i = 0; i < gsa.getVertexCount(); i++) { gsa.getCoordinates(i, coordinate); @@ -364,7 +364,7 @@ vertex3DList.add(p); } } else if (shape.getGeometry() instanceof TriangleArray) { - // TriangleArray�̏ꍇ + // TriangleArrayの場合 TriangleArray tra = (TriangleArray) shape.getGeometry(); for (int i = 0; i < tra.getVertexCount(); i++) { tra.getCoordinates(i, coordinate); @@ -374,16 +374,16 @@ } if (pattern == 0) { - // �ő�ʐϖ@ + // 最大面積法 Vector3d cv1 = new Vector3d(); Vector3d cv2 = new Vector3d(); double cvMax = 0.0; - Vector3d axis1 = new Vector3d(); // 3D���_���狁�߂��@���x�N�g�� - Vector3d axis2 = new Vector3d(); // 2D���_���狁�߂��@���x�N�g�� - Vector3d axis3 = new Vector3d(); // axis1,axis2�̊O�ς��狁�߂��@���x�N�g�� + Vector3d axis1 = new Vector3d(); // 3D頂点から求めた法線ベクトル + Vector3d axis2 = new Vector3d(); // 2D頂点から求めた法線ベクトル + Vector3d axis3 = new Vector3d(); // axis1,axis2の外積から求めた法線ベクトル - // �ʐς�3D���_���X�g���狁�߁A�@�������߂鏈�� + // 面積を3D頂点リストから求め、法線を求める処理 for (int i = 0; i < vertex3DList.size(); i += 3) { cv1.sub(vertex3DList.get(i + 2), vertex3DList.get(i)); cv2.sub(vertex3DList.get(i + 1), vertex3DList.get(i)); @@ -396,7 +396,7 @@ } ProjectionResult pr1 = GeometryUtility.projection3D(vertex3DList, axis1); - // �ӂ̂�2D���_���X�g���狁�߁A�@�������߂鏈�� + // 辺のを2D頂点リストから求め、法線を求める処理 for (int i = 0; i < pr1.vertexList.size() - 1; i++) { Vector3d cv = new Vector3d(); cv.sub(vertex3DList.get(i + 1), vertex3DList.get(i)); @@ -408,15 +408,15 @@ ProjectionResult pr2 = GeometryUtility.projection2D(pr1.vertexList, axis2); - // axis1,axis2�ŊO�ς�axis3�����߂�B + // axis1,axis2で外積でaxis3を求める。 axis3.cross(axis1, axis2); ProjectionResult pr3 = GeometryUtility.projection2D(pr1.vertexList, axis3); AxisResult ar = new AxisResult(axis1, axis2, axis3); - // ��������ő�ʐϖ@�ŋ��߂��_���擾���Ă������� + // ここから最大面積法で求めた点を取得していく処理 - // OBB�̐��� + // OBBの生成 obb = new OBB(); // No.1 @@ -490,7 +490,7 @@ ar.axis3.add(ar.axis1); obb.addVertex(ar.axis3); - // �ʂ���ы��E���ʑ̂̐��� + // 面および境界多面体の生成 obb.createPlanes(); } else { // AABB diff --git a/src/framework/model3D/ObjectVisitor.java b/src/framework/model3D/ObjectVisitor.java index 473174f..92f451b 100644 --- a/src/framework/model3D/ObjectVisitor.java +++ b/src/framework/model3D/ObjectVisitor.java @@ -5,30 +5,30 @@ import java3d.Transform3D; /** - * �I�u�W�F�N�g�̊K�w�\�����g���o�[�X����r�W�^�[ - * @author �V�c���� + * オブジェクトの階層構造をトラバースするビジター + * @author 新田直也 * */ public abstract class ObjectVisitor { /** - * ������K��ߓ_�܂ł̃p�X��ɑ��݂���ϊ��s�� + * 根から訪問節点までのパス上に存在する変換行列 */ protected ArrayList stackList = new ArrayList(); /* - * �ߓ_�i�I�u�W�F�N�g�j��K�₷�钼�O�ɌĂ΂�郁�\�b�h - * @param obj �K��ߓ_ + * 節点(オブジェクト)を訪問する直前に呼ばれるメソッド + * @param obj 訪問節点 */ public abstract void preVisit(Object3D obj); /** - * �ߓ_�i�I�u�W�F�N�g��K�₵������ɌĂ΂�郁�\�b�h�j - * @param obj �K��ߓ_ + * 節点(オブジェクトを訪問した直後に呼ばれるメソッド) + * @param obj 訪問節点 */ public abstract void postVisit(Object3D obj); /** - * 1�K�w�������Ƃ��ɕϊ��s��𑝂₷ - * @param obj�@�V�����K�₵���ߓ_ + * 1階層潜ったときに変換行列を増やす + * @param obj 新しく訪問した節点 */ protected void pushTransform(Object3D obj) { Transform3D transPos = new Transform3D(); @@ -46,7 +46,7 @@ } /** - *�@1�K�w���A�����Ƃ��ɕϊ��s��� ���炷 + * 1階層復帰したときに変換行列を 減らす */ protected void popTransform() { for (int i = 0; i < 4; i++) { diff --git a/src/framework/model3D/Placeable.java b/src/framework/model3D/Placeable.java index d7f1005..a7e0bc5 100644 --- a/src/framework/model3D/Placeable.java +++ b/src/framework/model3D/Placeable.java @@ -3,8 +3,8 @@ import java3d.TransformGroup; /** - * �z�u�ł�����̑S�� - * @author �V�c���� + * 配置できるもの全て + * @author 新田直也 * */ public interface Placeable { diff --git a/src/framework/model3D/Position3D.java b/src/framework/model3D/Position3D.java index 22d58a0..2b28e07 100644 --- a/src/framework/model3D/Position3D.java +++ b/src/framework/model3D/Position3D.java @@ -3,8 +3,8 @@ import java3d.Vector3d; /** - * ���W�l��\�� - * @author �V�c���� + * 座標値を表す + * @author 新田直也 * */ public class Position3D extends Property3D { @@ -12,14 +12,14 @@ private double y; private double z; - // �R���X�g���N�^ + // コンストラクタ public Position3D() { x = 0.0; y = 0.0; z = 0.0; } - // �R���X�g���N�^ + // コンストラクタ public Position3D(double px, double py, double pz) { x = px; y = py; @@ -32,12 +32,12 @@ z = v.z; } - // property3D�̒��ۃN���X�𖄂߂� + // property3Dの抽象クラスを埋める public void applyTo(Object3D o) { o.setPosition(this); } - // �R�s�[�R���X�g���N�^ + // コピーコンストラクタ public Position3D(Position3D p) { this.x = p.x; this.y = p.y; @@ -51,7 +51,7 @@ return this; } - // ���Z + // 加算 public Position3D add(double x, double y, double z) { this.x += x; this.y += y; @@ -59,7 +59,7 @@ return this; } - // ���Z + // 加算 public Position3D add(Position3D p) { this.x += p.x; this.y += p.y; @@ -67,7 +67,7 @@ return this; } - // ���Z + // 加算 public Position3D add(Vector3d v) { this.x += v.x; this.y += v.y; @@ -75,7 +75,7 @@ return this; } - // ���Z + // 減算 public Position3D sub(double x, double y, double z) { this.x -= x; this.y -= y; @@ -83,7 +83,7 @@ return this; } - // ���Z + // 減算 public Position3D sub(Position3D p) { this.x -= p.x; this.y -= p.y; @@ -91,7 +91,7 @@ return this; } - // ���Z + // 減算 public Position3D sub(Vector3d v) { this.x -= v.x; this.y -= v.y; @@ -99,7 +99,7 @@ return this; } - // �X�J���[�{ + // スカラー倍 public Position3D mul(double d) { this.x *= d; this.y *= d; diff --git a/src/framework/model3D/Quaternion3D.java b/src/framework/model3D/Quaternion3D.java index ebeb83f..0ac0ac9 100644 --- a/src/framework/model3D/Quaternion3D.java +++ b/src/framework/model3D/Quaternion3D.java @@ -7,7 +7,7 @@ public class Quaternion3D extends Property3D { private Quat4d quaternion; - // �R���X�g���N�^============================= + // コンストラクタ============================= public Quaternion3D() { AxisAngle4d aa = new AxisAngle4d(0.0, 0.0, 1.0, 0.0); quaternion = new Quat4d(); @@ -33,7 +33,7 @@ return quaternion; } - // �Q�b�^================================= + // ゲッタ================================= public double getX() { return quaternion.x; } @@ -61,7 +61,7 @@ return axisAngle; } - // �Z�b�^================================= + // セッタ================================= public Quaternion3D setQuaternion(double x, double y, double z, double w) { quaternion = new Quat4d(x, y, z, w); return this; diff --git a/src/framework/model3D/Terrain3D.java b/src/framework/model3D/Terrain3D.java index b897699..0d26e4a 100644 --- a/src/framework/model3D/Terrain3D.java +++ b/src/framework/model3D/Terrain3D.java @@ -38,10 +38,10 @@ int index = 0; for (int z = 0; z < meshZ; z++) { for (int x = 0; x < meshX; x++) { - // ���b�V�����ƂɎO�p�`��2�‚��� + // メッシュごとに三角形を2つづつ生成 if (z < meshZ - 1) { - // ���_���W�̐ݒ� - // ���_�̖@���x�N�g���̐ݒ� + // 頂点座標の設定 + // 頂点の法線ベクトルの設定 triStripAttay.setCoordinate(index, new Point3d(origin.getX() + sizeX * (double)x, origin.getY() + heightMap[z][x], @@ -114,10 +114,10 @@ double coordinate3[] = new double[3]; double coordinate4[] = new double[3]; - // GeometryArray�̏K�� + // GeometryArrayの習得 if (triStripAttay instanceof TriangleStripArray) { - // IndexedTriangleStripArray �̏ꍇ - // 8 x 8 ���b�V���P�ʂł܂Ƃ߂� + // IndexedTriangleStripArray の場合 + // 8 x 8 メッシュ単位でまとめる BoundingSurface surfaces[] = new BoundingSurface[((meshX + MESH_SIZE - 2) / MESH_SIZE) * ((meshZ + MESH_SIZE - 2) / MESH_SIZE)]; int n = 0; for (int j = 0; j < meshZ - 1; j += MESH_SIZE) { @@ -157,27 +157,27 @@ } } - // 1 x 1 ���b�V������BoundingSurface + // 1 x 1 メッシュ内のBoundingSurface Vector3d v1 = new Vector3d(coordinate1); Vector3d v2 = new Vector3d(coordinate2); Vector3d v3 = new Vector3d(coordinate3); Vector3d v4 = new Vector3d(coordinate4); BoundingSurface bSurface = new BoundingSurface(); - bSurface.addVertex((Vector3d)v1.clone()); //1�‚߂̎O�p�` + bSurface.addVertex((Vector3d)v1.clone()); //1つめの三角形 bSurface.addVertex((Vector3d)v2.clone()); bSurface.addVertex((Vector3d)v3.clone()); bSurface.setBounds(createBoundingPolytope(v1, v2, v3)); parent.addChild(bSurface, false); bSurface = new BoundingSurface(); - bSurface.addVertex((Vector3d)v2.clone()); //2�‚߂̎O�p�` + bSurface.addVertex((Vector3d)v2.clone()); //2つめの三角形 bSurface.addVertex((Vector3d)v4.clone()); bSurface.addVertex((Vector3d)v3.clone()); bSurface.setBounds(createBoundingPolytope(v2, v4, v3)); parent.addChild(bSurface, true); } } - // 8 x 8 ���b�V���P�ʂ�BoundingSurface + // 8 x 8 メッシュ単位のBoundingSurface triStripAttay.getCoordinates(j * meshX * 2 + i * 2, coordinate1); parent.setBounds(new BoundingBox(new Point3d(coordinate1[0], lowY, coordinate1[2]), new Point3d(coordinate4[0], highY, coordinate4[2]))); @@ -217,11 +217,11 @@ double x2 = x - (double)i * sizeX - origin.getX(); double z2 = z - (double)j * sizeZ - origin.getZ(); if (x2 < GeometryUtility.TOLERANCE || (meshZ - z2) / x2 > meshZ / meshX) { - // 1�‚߂̎O�p�`��ʂ�ꍇ + // 1つめの三角形を通る場合 Vector3d crossPoint = GeometryUtility.intersect(GeometryUtility.createPlane(v1, v2, v3), p1, p2); return crossPoint.getY(); } else { - // 2�‚߂̎O�p�`��ʂ�ꍇ + // 2つめの三角形を通る場合 Vector3d crossPoint = GeometryUtility.intersect(GeometryUtility.createPlane(v2, v4, v3), p1, p2); return crossPoint.getY(); } @@ -229,8 +229,8 @@ } // -// ********** IndexedTriangleStripArray ���g���o�[�W���� ********** -// (IndexedTriangleStripArray��p����ƃ�������ߖ�ł��邪�A�V�F�[�f�B���O���ł��Ȃ��̂Œ���) +// ********** IndexedTriangleStripArray を使うバージョン ********** +// (IndexedTriangleStripArrayを用いるとメモリを節約できるが、シェーディングができないので注意) // //public class Terrain3D extends BaseObject3D { // static final int MESH_SIZE = 8; @@ -262,12 +262,12 @@ // int index = 0, index2 = 0, i1, i2; // for (int z = 0; z < meshZ; z++) { // for (int x = 0; x < meshX; x++) { -// // ���_���W�̐ݒ� +// // 頂点座標の設定 // triStripAttay.setCoordinate(index, // new Point3d(origin.getX() + sizeX * (double)x, // origin.getY() + heightMap[z][x], // origin.getZ() + sizeZ * (double)z)); -// // ���_�̖@���x�N�g���̐ݒ� +// // 頂点の法線ベクトルの設定 // Vector3f normal = new Vector3f(); // if (x < meshX - 1) { // Vector3f xp = new Vector3f((float)sizeX, (float)(heightMap[z][x+1] - heightMap[z][x]), 0.0f); @@ -306,7 +306,7 @@ // normal.normalize(); // triStripAttay.setNormal(index, normal); // index++; -// // ���b�V�����ƂɎO�p�`��2�‚��� +// // メッシュごとに三角形を2つづつ生成 // if (z < meshZ - 1) { // i1 = z * meshX + x; // i2 = (z + 1) * meshX + x; @@ -335,10 +335,10 @@ // double coordinate3[] = new double[3]; // double coordinate4[] = new double[3]; // -// // GeometryArray�̏K�� +// // GeometryArrayの習得 // if (triStripAttay instanceof IndexedTriangleStripArray) { -// // IndexedTriangleStripArray �̏ꍇ -// // 8 x 8 ���b�V���P�ʂł܂Ƃ߂� +// // IndexedTriangleStripArray の場合 +// // 8 x 8 メッシュ単位でまとめる // BoundingSurface surfaces[] = new BoundingSurface[((meshX + MESH_SIZE - 2) / MESH_SIZE) * ((meshZ + MESH_SIZE - 2) / MESH_SIZE)]; // int n = 0; // for (int j = 0; j < meshZ - 1; j += MESH_SIZE) { @@ -378,27 +378,27 @@ // } // } // -// // 1 x 1 ���b�V������BoundingSurface +// // 1 x 1 メッシュ内のBoundingSurface // Vector3d v1 = new Vector3d(coordinate1); // Vector3d v2 = new Vector3d(coordinate2); // Vector3d v3 = new Vector3d(coordinate3); // Vector3d v4 = new Vector3d(coordinate4); // BoundingSurface bSurface = new BoundingSurface(); -// bSurface.addVertex((Vector3d)v1.clone()); //1�‚߂̎O�p�` +// bSurface.addVertex((Vector3d)v1.clone()); //1つめの三角形 // bSurface.addVertex((Vector3d)v2.clone()); // bSurface.addVertex((Vector3d)v3.clone()); // bSurface.setBounds(createBoundingPolytope(v1, v2, v3)); // parent.addChild(bSurface, false); // // bSurface = new BoundingSurface(); -// bSurface.addVertex((Vector3d)v2.clone()); //2�‚߂̎O�p�` +// bSurface.addVertex((Vector3d)v2.clone()); //2つめの三角形 // bSurface.addVertex((Vector3d)v4.clone()); // bSurface.addVertex((Vector3d)v3.clone()); // bSurface.setBounds(createBoundingPolytope(v2, v4, v3)); // parent.addChild(bSurface, true); // } // } -// // 8 x 8 ���b�V���P�ʂ�BoundingSurface +// // 8 x 8 メッシュ単位のBoundingSurface // triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(j * meshX * 2 + i * 2), coordinate1); // parent.setBounds(new BoundingBox(new Point3d(coordinate1[0], lowY, coordinate1[2]), // new Point3d(coordinate4[0], highY, coordinate4[2]))); @@ -438,11 +438,11 @@ // double x2 = x - (double)i * sizeX - origin.getX(); // double z2 = z - (double)j * sizeZ - origin.getZ(); // if (x2 < GeometryUtility.TOLERANCE || (meshZ - z2) / x2 > meshZ / meshX) { -// // 1�‚߂̎O�p�`��ʂ�ꍇ +// // 1つめの三角形を通る場合 // Vector3d crossPoint = GeometryUtility.intersect(GeometryUtility.createPlane(v1, v2, v3), p1, p2); // return crossPoint.getY(); // } else { -// // 2�‚߂̎O�p�`��ʂ�ꍇ +// // 2つめの三角形を通る場合 // Vector3d crossPoint = GeometryUtility.intersect(GeometryUtility.createPlane(v2, v4, v3), p1, p2); // return crossPoint.getY(); // } diff --git a/src/framework/model3D/Universe.java b/src/framework/model3D/Universe.java index df33ac3..55fe777 100644 --- a/src/framework/model3D/Universe.java +++ b/src/framework/model3D/Universe.java @@ -69,10 +69,10 @@ } /** - * �I�u�W�F�N�g��z�u���� + * オブジェクトを配置する * * @param obj - * �z�u����I�u�W�F�N�g + * 配置するオブジェクト */ public void place(Placeable obj) { if(obj instanceof Ground){ @@ -89,10 +89,10 @@ } /** - * ��Ŏ�菜����悤�ɃI�u�W�F�N�g��z�u���� + * 後で取り除けるようにオブジェクトを配置する * * @param obj - * �z�u����I�u�W�F�N�g + * 配置するオブジェクト */ public void placeDisplacable(Placeable obj) { placeDisplacable(obj.getTransformGroupToPlace()); @@ -103,10 +103,10 @@ } /** - * �����̒lj� + * 光源の追加 * * @param light - * �lj�������� + * 追加する光源 */ public void placeLight(Light light) { root.addChild(light); @@ -114,8 +114,8 @@ } /** - * �X�J�C�{�b�N�X�̒lj� - * @param skyBox �lj�����X�J�C�{�b�N�X + * スカイボックスの追加 + * @param skyBox 追加するスカイボックス */ public void placeSkyBox(BackgroundBox skyBox) { root.addChild(skyBox); @@ -123,10 +123,10 @@ } /** - * �I�u�W�F�N�g���”\�Ȃ�Ύ�菜�� + * オブジェクトを可能ならば取り除く * * @param obj - * ��菜���I�u�W�F�N�g + * 取り除くオブジェクト */ public void displace(Placeable obj) { displace(obj.getTransformGroupToPlace()); diff --git a/src/framework/physics/BoundingBoxVisitor.java b/src/framework/physics/BoundingBoxVisitor.java index 18847c5..93da37b 100644 --- a/src/framework/physics/BoundingBoxVisitor.java +++ b/src/framework/physics/BoundingBoxVisitor.java @@ -9,9 +9,9 @@ public class BoundingBoxVisitor extends ObjectVisitor { - private ArrayList obbList = new ArrayList(); // �S�\���v�f��OBB�̃��X�g - private ArrayList bsStack = new ArrayList(); // �I�u�W�F�N�g�̊K�w����BoundingSphere�̃X�^�b�N - private String partName = null; // ���i���w�肷��ꍇ�Ɏg�� + private ArrayList obbList = new ArrayList(); // 全構成要素のOBBのリスト + private ArrayList bsStack = new ArrayList(); // オブジェクトの階層毎のBoundingSphereのスタック + private String partName = null; // 部品を指定する場合に使う private boolean inPart = false; public BoundingBoxVisitor() { @@ -28,7 +28,7 @@ inPart = true; } if (obj.hasChildren() && obj.bs == null) { - // �q��������ꍇ�A���̊K�w�p��null��push���� + // 子供がいる場合、下の階層用にnullをpushする bsStack.add(null); } } @@ -36,7 +36,7 @@ public void postVisit(Object3D obj) { int pattern = 2; if (!obj.hasChildren()) { - // �t�̏ꍇ + // 葉の場合 OBB obb = obj.getOBB(pattern); if (obb != null) { if (obj.bs == null) { @@ -50,33 +50,33 @@ bs.transform(stackList.get(i)); } if (partName == null || partName.length() == 0 || inPart) { - obbList.add(obb); // Transform3D��K��������Bounds��boundsList�ɒlj� + obbList.add(obb); // Transform3Dを適応させたBoundsをboundsListに追加 int stackTop = bsStack.size() - 1; if (bs != null && stackTop >= 0) { if (bsStack.get(stackTop) == null) { - // ���̊K�w�̍ŏ��̃I�u�W�F�N�g�̏ꍇ�Anull��u������ + // その階層の最初のオブジェクトの場合、nullを置き換え bsStack.set(stackTop, bs); } else { - // ���̊K�w��2�Ԗڈȍ~�̃I�u�W�F�N�g�̏ꍇ�A���� + // その階層の2番目以降のオブジェクトの場合、結合 bsStack.get(stackTop).combine(bs); } } } } } else { - // �q��������ꍇ + // 子供がいる場合 int stackTop = bsStack.size() - 1; if (obj.bs == null) { - // ���̊K�w�̌������ʂ�pop���ė��p���� + // 下の階層の結合結果をpopして利用する obj.bs = bsStack.remove(stackTop); stackTop--; } if (obj.bs != null && stackTop >= 0) { if (bsStack.get(stackTop) == null) { - // ���̊K�w�̍ŏ��̃I�u�W�F�N�g�̏ꍇ�Anull��u������ + // その階層の最初のオブジェクトの場合、nullを置き換え bsStack.set(stackTop, obj.bs); } else { - // ���̊K�w��2�Ԗڈȍ~�̃I�u�W�F�N�g�̏ꍇ�A���� + // その階層の2番目以降のオブジェクトの場合、結合 bsStack.get(stackTop).combine(obj.bs); } } diff --git a/src/framework/physics/BoundingSurfaceVisitor.java b/src/framework/physics/BoundingSurfaceVisitor.java index 20c72cd..18bc798 100644 --- a/src/framework/physics/BoundingSurfaceVisitor.java +++ b/src/framework/physics/BoundingSurfaceVisitor.java @@ -8,8 +8,8 @@ import framework.model3D.ObjectVisitor; /** - * �n�ʂ̏Փ˔���p�̃{�����[���𐶐����邽�߂̃r�W�^�[ - * @author �V�c���� + * 地面の衝突判定用のボリュームを生成するためのビジター + * @author 新田直也 * */ public class BoundingSurfaceVisitor extends ObjectVisitor { @@ -27,14 +27,14 @@ public void postVisit(Object3D obj) { if (!obj.hasChildren()) { - // �t�̏ꍇ + // 葉の場合 BoundingSurface[] s = (BoundingSurface[]) obj.getBoundingSurfaces().clone(); for (int i = 0; i < s.length; i++) { s[i] = (BoundingSurface) s[i].clone(); for (int j = stackList.size() - 1; j >= 0; j--) { s[i].transform(stackList.get(j)); } - boundingSurfaceList.get(boundingSurfaceList.size() - 1).addChild(s[i], true); // Transform3D��K��������Bounds��surfaceList�ɒlj� + boundingSurfaceList.get(boundingSurfaceList.size() - 1).addChild(s[i], true); // Transform3Dを適応させたBoundsをsurfaceListに追加 } } else { BoundingSurface child = boundingSurfaceList.remove(boundingSurfaceList.size() - 1); diff --git a/src/framework/physics/Ground.java b/src/framework/physics/Ground.java index d7fb60e..a1ff721 100644 --- a/src/framework/physics/Ground.java +++ b/src/framework/physics/Ground.java @@ -9,13 +9,13 @@ /** - * �n�ʂȂǂ́i��{�I�ɓ����Ȃ��j�\������\���I�u�W�F�N�g - * @author �V�c���� + * 地面などの(基本的に動かない)構造物を表すオブジェクト + * @author 新田直也 * */ public class Ground implements Placeable { private BaseObject3D groundObj = null; - private BoundingSurface boundingSurface = null; // �Փ˔���p�{�����[���̃L���b�V�� + private BoundingSurface boundingSurface = null; // 衝突判定用ボリュームのキャッシュ public Ground(BaseObject3D obj) { groundObj = obj; @@ -36,18 +36,18 @@ } /** - * �Փ˔���p�̃{�����[�����擾���� - * @return �Փ˔���p�{�����[���i�K�w������Ă���ꍇ������j + * 衝突判定用のボリュームを取得する + * @return 衝突判定用ボリューム(階層化されている場合がある) */ BoundingSurface getBoundingSurface() { if (boundingSurface == null) { - // �L���b�V���ɉ����ς܂�Ă��Ȃ��ꍇ�̂݌v�Z���� + // キャッシュに何も積まれていない場合のみ計算する BoundingSurfaceVisitor surfaceVisitor = new BoundingSurfaceVisitor(); if (groundObj instanceof Object3D) { - // Object3D�̏ꍇ�K�w�\�������ǂ� + // Object3Dの場合階層構造をたどる ((Object3D)groundObj).accept(surfaceVisitor); } else { - // BaseObject3d�̏ꍇ�K�w�\�����Ȃ� + // BaseObject3dの場合階層構造がない surfaceVisitor.baseVisit(groundObj); } boundingSurface = surfaceVisitor.getBoundingSurface(); diff --git a/src/framework/physics/PhysicalSystem.java b/src/framework/physics/PhysicalSystem.java index 11bfb7f..6aa1999 100644 --- a/src/framework/physics/PhysicalSystem.java +++ b/src/framework/physics/PhysicalSystem.java @@ -11,13 +11,13 @@ public ArrayList objects = new ArrayList(); - // ���̂̑}�� + // 物体の挿入 public int add(Solid3D s) { objects.add(s); return objects.size() - 1; } - // ���̂̉^�� + // 物体の運動 public void motion(int id, long interval, Force3D f, Position3D appPoint, Ground ground) { ArrayList forces[] = new ArrayList[objects.size()]; ArrayList appPoints[] = new ArrayList[objects.size()]; @@ -26,119 +26,119 @@ appPoints[i] = new ArrayList(); } - // id�Ԗڂ̊O�͂̌v�Z + // id番目の外力の計算 forces[id].add(f); appPoints[id].add(appPoint); // objects.get(id).move(interval, f, appPoint); - double l; // �΂˂̐L�� + double l; // ばねの伸び - Force3D penalty = new Force3D(0.0, 0.0, 0.0); // �y�i���e�B�@�ɂ��y�i���e�B�̍�p�̗� + Force3D penalty = new Force3D(0.0, 0.0, 0.0); // ペナルティ法によるペナルティの作用の力 Force3D inversepenalty; // - // //�y�i���e�B�@�ɂ��y�i���e�B�̔���p�̗� + // //ペナルティ法によるペナルティの反作用の力 CollisionResult cr; Solid3D s; for (int n = 0; n < objects.size(); n++) { - // �d�͂̌v�Z + // 重力の計算 s = objects.get(n); forces[n].add(PhysicsUtility.getGravity(s)); appPoints[n].add(s.getGravityCenter()); // objects.get(n).move(interval, // PhysicsFacade.getGravity(objects.get(n)), -// objects.get(n).getGravityCenter()); // �d�͂̌v�Z - // �n�ʂƂ̓����蔻�� +// objects.get(n).getGravityCenter()); // 重力の計算 + // 地面との当たり判定 cr = PhysicsUtility.doesIntersect(s, ground); - // �n�ʂɕ��̂��߂荞��ł���ꍇ + // 地面に物体がめり込んでいる場合 if (cr != null) { - double gk = 5000.0; // �n�ʂł̂΂ˌW�� - double e = 1.0; // �n�ʂł̒��˕Ԃ莞�̒�R�W�� + double gk = 5000.0; // 地面でのばね係数 + double e = 1.0; // 地面での跳ね返り時の抵抗係数 double b = 300.0; l = cr.length; - // <��p�̗͂̌v�Z> - // �y�i���e�B�̕ϐ� + // <作用の力の計算> + // ペナルティの変数 // Vector3d v = cr.normal; // v.scale(gk * l); - // ��p�_�x�N�g���̍쐬 + // 作用点ベクトルの作成 Vector3d r = cr.collisionPoint.getVector3d(); - // (��p�_-�d�S)�x�N�g�� + // (作用点-重心)ベクトル r.sub(s.getGravityCenter().getVector3d()); - // �p���x�x�N�g���̍쐬 + // 角速度ベクトルの作成 Vector3d angVel = s.getAngularVelocity().getVector3d(); - // �p���x�x�N�g����(��p�_-�d�S)�x�N�g���̊O�όv�Z + // 角速度ベクトルと(作用点-重心)ベクトルの外積計算 angVel.cross(angVel, r); - // ���x�x�N�g��+�p���x�x�N�g����(��p�_-�d�S)�x�N�g���̊O�όv�Z + // 速度ベクトル+角速度ベクトルと(作用点-重心)ベクトルの外積計算 Vector3d relV = s.getVelocity().getVector3d(); - // ���Α��x�x�N�g���̍쐬 + // 相対速度ベクトルの作成 relV.add(angVel); Vector3d v = cr.normal; //System.out.println(r + "," + (gk * l) + "," + (- relV.dot(v) * b)); - // �y�i���e�B�̑傫������ + // ペナルティの大きさ決定 v.scale(gk * l - relV.dot(v) * b); penalty = new Force3D(v); - // ��p�̗͂ɂ��^�� + // 作用の力による運動 forces[n].add(penalty); appPoints[n].add(cr.collisionPoint); // objects.get(n).move(interval, penalty, cr.collisionPoint); } - // �n�ʂɕ��̂��߂荞��ł��Ȃ��ꍇ + // 地面に物体がめり込んでいない場合 else { } for (int m = 0; m < n; m++) { Solid3D s1 = objects.get(n); Solid3D s2 = objects.get(m); cr = PhysicsUtility.checkCollision(s1, null, s2, null); - // ���̂��߂荞��ł���ꍇ + // 物体がめり込んでいる場合 if (cr != null) { - double sk = 5000; // ���̂ł̂΂ˌW�� - double e = 0.2; // ���̂ł̒��˕Ԃ莞�̒�R�W�� + double sk = 5000; // 物体でのばね係数 + double e = 0.2; // 物体での跳ね返り時の抵抗係数 double b = 300.0; l = cr.length; - // <��p�̗͂̌v�Z> - // ��p�_�x�N�g���̍쐬 - // s1�Ɋւ���v�Z - // s1�̊p���x�x�N�g���̍쐬 + // <作用の力の計算> + // 作用点ベクトルの作成 + // s1に関する計算 + // s1の角速度ベクトルの作成 Vector3d r = cr.collisionPoint.getVector3d(); r.sub(s1.getGravityCenter().getVector3d()); Vector3d s1AngVel = s1.getAngularVelocity().getVector3d(); s1AngVel.cross(s1AngVel, r); - // s1�̑��x�x�N�g���̍쐬 + // s1の速度ベクトルの作成 Vector3d s1RelV = s1.getVelocity().getVector3d(); - // s1�̑��x�x�N�g��+s1�̊p���x�x�N�g����(��p�_-s1�̏d�S)�x�N�g���̊O�όv�Z + // s1の速度ベクトル+s1の角速度ベクトルと(作用点-s1の重心)ベクトルの外積計算 s1RelV.add(s1AngVel); - // s2�Ɋւ���v�Z - // s2�̊p���x�x�N�g���̍쐬 + // s2に関する計算 + // s2の角速度ベクトルの作成 r = cr.collisionPoint.getVector3d(); r.sub(s2.getGravityCenter().getVector3d()); Vector3d s2AngVel = s2.getAngularVelocity().getVector3d(); s2AngVel.cross(s2AngVel, r); - // s2�̑��x�x�N�g���̍쐬 + // s2の速度ベクトルの作成 Vector3d s2RelV = s2.getVelocity().getVector3d(); - // s2�̑��x�x�N�g��+s2�̊p���x�x�N�g����(��p�_-s2�̏d�S)�x�N�g���̊O�όv�Z + // s2の速度ベクトル+s2の角速度ベクトルと(作用点-s2の重心)ベクトルの外積計算 s2RelV.add(s2AngVel); - // ���Α��x�x�N�g���̍쐬 + // 相対速度ベクトルの作成 s1RelV.sub(s2RelV); - // �y�i���e�B�̑傫������ + // ペナルティの大きさ決定 Vector3d v = (Vector3d)cr.normal.clone(); //System.out.println(r + "," + (sk * l) + "," + (- relV.dot(v) * b)); v.scale(sk * l - s1RelV.dot(v) * b); penalty = new Force3D(v); - // ����p�̗͂̌v�Z + // 反作用の力の計算 v.scale(-1); inversepenalty = new Force3D(v); - // ��p�̗͂ɂ�镨�̂̈ړ� + // 作用の力による物体の移動 forces[n].add(penalty); appPoints[n].add(cr.collisionPoint); // s1.move(interval, penalty, cr.collisionPoint); - // ����p�̗͂ɂ�镨�̂̈ړ� + // 反作用の力による物体の移動 forces[m].add(inversepenalty); appPoints[m].add(cr.collisionPoint); // s2.move(interval, inversepenalty, cr.collisionPoint); } -// // ���̂��߂荞��ł��Ȃ��ꍇ +// // 物体がめり込んでいない場合 // else { // s2.move(interval, f, s2.getGravityCenter()); // s1.move(interval, f, s1.getGravityCenter()); diff --git a/src/framework/physics/PhysicsUtility.java b/src/framework/physics/PhysicsUtility.java index f95b48b..d4eda50 100644 --- a/src/framework/physics/PhysicsUtility.java +++ b/src/framework/physics/PhysicsUtility.java @@ -13,21 +13,21 @@ /** - * �������Z�̃R�A - * @author �V�c���� + * 物理演算のコア + * @author 新田直也 * */ public class PhysicsUtility { - public static final double GRAVITY = 9.8; // �d�͂̉����x + public static final double GRAVITY = 9.8; // 重力の加速度 public static final Vector3d horizon = new Vector3d(1.0, 0.0, 0.0); public static final Vector3d vertical = new Vector3d(0.0, 1.0, 0.0); public static Vector3d gravityDirection = new Vector3d(0.0, 1.0, 0.0); /** - * ���̂ɉ����d�͂����߂� - * @param body �Ώە��� - * @return body�ɉ����d�� + * 物体に加わる重力を求める + * @param body 対象物体 + * @return bodyに加わる重力 */ public static Force3D getGravity(Solid3D body) { return new Force3D(gravityDirection.x * -body.mass * GRAVITY, gravityDirection.y * -body.mass * GRAVITY, gravityDirection.z * -body.mass * GRAVITY); @@ -35,13 +35,13 @@ /** * @param v - * �F�P�ʃx�N�g���A���邢�̓[���x�N�g���������œn������ + * :単位ベクトル、あるいはゼロベクトルを引数で渡すこと */ public static void setGravityDirection(Vector3d v) { gravityDirection = new Vector3d(v.x, v.y, v.z); } - // ���[�����g�̌v�Z + // モーメントの計算 static Vector3d calcMoment(Force3D f, Position3D gravityCenter, Position3D applicationPoint) { Vector3d v1 = applicationPoint.getVector3d(); @@ -56,11 +56,11 @@ } /** - * ���̂̔����W������Փˎ��ɉ����͂����߂� - * @param interval �Փ˂��Ă��鎞�� - * @param nor ���̂��Ԃ‚������ʂ̕��x�N�g�� - * @param solid ���� - * @return �Փˎ��ɉ����� + * 物体の反発係数から衝突時に加わる力を求める + * @param interval 衝突している時間 + * @param nor 物体がぶつかった面の宝仙ベクトル + * @param solid 物体 + * @return 衝突時に加わる力 */ public static Force3D calcForce(long interval, Vector3d nor, Solid3D solid) { double f1 = 0.0; @@ -74,17 +74,17 @@ } /** - * ���̂ƒn�ʂƂ̏Փ˔��� - * @param obj ���� - * @param ground �n�� - * @return �Փˏ��inull�̂Ƃ��Փ˂Ȃ��j + * 物体と地面との衝突判定 + * @param obj 物体 + * @param ground 地面 + * @return 衝突情報(nullのとき衝突なし) */ public static CollisionResult doesIntersect(Solid3D obj, Ground ground) { if (ground == null) return null; CollisionResult cr = null; BoundingSurface boundingSurface = ground.getBoundingSurface(); - // BoundingSphere���g���đ�G�c�ɏՓ˔�����s�� + // BoundingSphereを使って大雑把に衝突判定を行う ArrayList boundingSurfaceList = null; if (obj.bs != null) { BoundingSphere bs = (BoundingSphere) (obj.bs.clone()); @@ -97,26 +97,26 @@ bs.transform(t3d); obj.pos.getTransform(t3d); bs.transform(t3d); - // �e���Փ˔�����s���i�ŏ�ʂ�BoundingSurface��BoundingSphere�̊ԂŁj + // 粗い衝突判定を行う(最上位のBoundingSurfaceとBoundingSphereの間で) boundingSurfaceList = boundingSurface.intersect(bs); bs = null; t3d = null; } if (obj.bs == null) { - // BoundingSphere ���܂�����Ă��ȂȂ������ꍇ�A - // �ڍׂȏՓ˔���̂��߂ɁA�ŏ�ʂ̑S BoundingSurface ���擾���� + // BoundingSphere がまだ作られていななかった場合、 + // 詳細な衝突判定のために、最上位の全 BoundingSurface を取得する if (boundingSurfaceList == null) boundingSurfaceList = new ArrayList(); boundingSurfaceList.add(boundingSurface); } if (boundingSurfaceList.size() > 0) { - // �e���Փ˔���ŏՓ˂��Ă����ꍇ�AOBB�̏W����p���Ă��ڂ����Փ˔�����s�� - // �iBoundingSphere ���܂�����Ă��Ȃ��ꍇ�AOBB �̍쐬�Ɠ����� BoundingSphere ���쐬�����j + // 粗い衝突判定で衝突していた場合、OBBの集合を用いてより詳しい衝突判定を行う + // (BoundingSphere がまだ作られていない場合、OBB の作成と同時に BoundingSphere を作成される) BoundingBoxVisitor obbVisitor = new BoundingBoxVisitor(); obj.accept(obbVisitor); for (int i = 0; i < obbVisitor.getObbList().size(); i++) { - // OBB�ƏՓ˔��������ꍇ�́A�n�ʂ𑽊p�`�̂܂܈��� + // OBBと衝突判定をする場合は、地面を多角形のまま扱う for (int j = 0; j < boundingSurfaceList.size(); j++) { cr = boundingSurfaceList.get(j).intersect(obbVisitor.getObbList().get(i)); if (cr != null) { @@ -130,21 +130,21 @@ } /** - * ���̓��m�̏Փ˔��� - * @param obj1 ����1 - * @param part1 ���肷�镨��1�̕����̖��� - * @param obj2 ����2 - * @param part2 ���肷�镨��2�̕����̖��� - * @return�@�Փˏ��inull�̂Ƃ��Փ˂Ȃ��j + * 物体同士の衝突判定 + * @param obj1 物体1 + * @param part1 判定する物体1の部分の名称 + * @param obj2 物体2 + * @param part2 判定する物体2の部分の名称 + * @return 衝突情報(nullのとき衝突なし) */ public static CollisionResult checkCollision(Object3D obj1, String part1, Object3D obj2, String part2) { CollisionResult cr = null; - // BoundingSphere���g���đ�G�c�ɏՓ˔�����s�� + // BoundingSphereを使って大雑把に衝突判定を行う boolean f = false; if (obj1.bs != null && obj2.bs != null) { - // sol1 �� BoundingSphere�@���v�Z + // sol1 の BoundingSphere を計算 BoundingSphere bs1 = (BoundingSphere) (obj1.bs.clone()); Transform3D t3d = new Transform3D(); obj1.center.getTransform(t3d); @@ -156,7 +156,7 @@ obj1.pos.getTransform(t3d); bs1.transform(t3d); - // sol2 �� BoundingSphere�@���v�Z + // sol2 の BoundingSphere を計算 BoundingSphere bs2 = (BoundingSphere) (obj2.bs.clone()); obj2.center.getTransform(t3d); bs2.transform(t3d); @@ -167,7 +167,7 @@ obj2.pos.getTransform(t3d); bs2.transform(t3d); - // BoundingSphere ���m�̏Փ˔��� + // BoundingSphere 同士の衝突判定 if (bs1.intersect(bs2)) { f = true; } diff --git a/src/framework/physics/Solid3D.java b/src/framework/physics/Solid3D.java index a5073e4..96edc31 100644 --- a/src/framework/physics/Solid3D.java +++ b/src/framework/physics/Solid3D.java @@ -10,8 +10,8 @@ import framework.model3D.Quaternion3D; /** - * �����I�ȐU�镑�������镨�́i���́j��\�� - * @author �V�c���� + * 物理的な振る舞いをする物体(剛体)を表す + * @author 新田直也 * */ public class Solid3D extends Object3D { @@ -22,7 +22,7 @@ public double mass = 10; private Inertia3D inertia = null; - // �R�s�[�R���X�g���N�^ + // コピーコンストラクタ public Solid3D(Object3D obj) { super(obj); velocity = new Velocity3D(); @@ -55,33 +55,33 @@ } /** - * �͊w�^���̌v�Z�i�����͂�1�‚̏ꍇ�j - * @param interval �P�ʎ��� - * @param f �� - * @param applicationPoint �͂̍�p�_ + * 力学運動の計算(加わる力が1つの場合) + * @param interval 単位時間 + * @param f 力 + * @param applicationPoint 力の作用点 */ public void move(long interval, Force3D f, Position3D applicationPoint) { - // ���[�����g�̌v�Z + // モーメントの計算 Vector3d moment = PhysicsUtility.calcMoment(f, getGravityCenter(), applicationPoint); moveSub(interval, f, moment); } /** - * �͊w�^���̌v�Z�i�����ɕ����̗͂������ꍇ�j - * @param interval �P�ʎ��� - * @param forces �́i�����j - * @param appPoints ���ꂼ��̗͂̍�p�_ + * 力学運動の計算(同時に複数の力が加わる場合) + * @param interval 単位時間 + * @param forces 力(複数) + * @param appPoints それぞれの力の作用点 */ public void move(long interval, ArrayList forces, ArrayList appPoints) { - // �d�S�ɉ����͂̍��v�����߂� + // 重心に加わる力の合計を求める Force3D f = new Force3D(0.0, 0.0, 0.0); for (int n = 0; n < forces.size(); n++) { f.add(forces.get(n)); } - // ���[�����g�̍��v���v�Z���� + // モーメントの合計を計算する Position3D gc = getGravityCenter(); Vector3d moment = new Vector3d(0.0, 0.0, 0.0); for (int n2 = 0; n2 < forces.size(); n2++) { @@ -91,22 +91,22 @@ } private void moveSub(long interval, Force3D f, Vector3d moment) { - // 1.�d�S�̉^���������i�j���[�g���������j - // �����x�A���x�v�Z - Vector3d deltaV = f.getVector3d(); // �̓x�N�g���̎擾 - deltaV.scale(1.0 / mass * ((double) interval / 1000.0)); // �����x���瑬�x�̍������v�Z - Velocity3D v = getVelocity().add(deltaV); // ���x�ɍ��������Z + // 1.重心の運動方程式(ニュートン方程式) + // 加速度、速度計算 + Vector3d deltaV = f.getVector3d(); // 力ベクトルの取得 + deltaV.scale(1.0 / mass * ((double) interval / 1000.0)); // 加速度から速度の差分を計算 + Velocity3D v = getVelocity().add(deltaV); // 速度に差分を加算 apply(v, false); - // �d�S�ʒu�v�Z - Vector3d deltaP = velocity.getVector3d(); // ���x�x�N�g���̎擾 + // 重心位置計算 + Vector3d deltaP = velocity.getVector3d(); // 速度ベクトルの取得 deltaP.scale(((double) interval / 1000.0)); - Position3D p = getPosition3D().add(deltaP); // �ʒu�ɍ��������Z + Position3D p = getPosition3D().add(deltaP); // 位置に差分を加算 apply(p, false); - // 2.�I�C���[�̊p�^�������� + // 2.オイラーの角運動方程式 - // �p�����x�A�p���x�v�Z + // 角加速度、角速度計算 AngularVelocity3D w = getAngularVelocity(); Vector3d deltaAngularV = new Vector3d( (moment.x + (inertia.iyy - inertia.izz) * w.getY() * w.getZ()) / inertia.ixx, @@ -116,14 +116,14 @@ w.add(deltaAngularV); apply(w, false); - // �p���x�ɂ���]�v�Z + // 角速度による回転計算 AxisAngle4d axisAngle = w.getAxisAngle4d(); axisAngle.angle *= ((double) interval / 1000.0); Quaternion3D q = getQuaternion().add(axisAngle); apply(q, false); } - // ��������� + // 複製を作る public Object3D duplicate() { Object3D copy = new Solid3D(this); return copy; @@ -147,12 +147,12 @@ return (AngularVelocity3D) angularvelocity.clone(); } - // Velocity3D �� applyTo �ȊO����͌Ă΂Ȃ����� + // Velocity3D の applyTo 以外からは呼ばないこと void setVelocity(Velocity3D v) { velocity = (Velocity3D) v.clone(); } - // AngularVelocity3D �� applyTo �ȊO����͌Ă΂Ȃ����� + // AngularVelocity3D の applyTo 以外からは呼ばないこと void setAngularVelocity(AngularVelocity3D w) { angularvelocity = (AngularVelocity3D) w.clone(); } diff --git a/src/framework/scenario/ScenarioManager.java b/src/framework/scenario/ScenarioManager.java index f6080a1..f70e6d2 100644 --- a/src/framework/scenario/ScenarioManager.java +++ b/src/framework/scenario/ScenarioManager.java @@ -36,7 +36,7 @@ builder.setErrorHandler(new DefaultHandler()); Document document = builder.parse(xmlFileName); - // �L����ԃ}�V���̍쐬�A��Ԃ̓o�^�A�C�x���g�̓o�^ + // 有限状態マシンの作成、状態の登録、イベントの登録 Hashtable allTrans = new Hashtable(); NodeList scenario = document.getChildNodes(); NodeList fsmNodes = scenario.item(0).getChildNodes(); @@ -77,7 +77,7 @@ } } - // ��ԑJ�ڂ�ݒ肷�� + // 状態遷移を設定する Set> allTransEntries = allTrans.entrySet(); Iterator> it = allTransEntries.iterator(); while (it.hasNext()) { diff --git a/src/framework/view3D/Camera3D.java b/src/framework/view3D/Camera3D.java index 53a162f..c7735fe 100644 --- a/src/framework/view3D/Camera3D.java +++ b/src/framework/view3D/Camera3D.java @@ -12,9 +12,9 @@ import framework.model3D.Universe; /** - * ��p�����@�\���t�����J����
- * ���_�A�����ΏہA�����̂���2�‚��w�肵�Ďg���B - * @author �V�c���� + * 画角調整機能が付いたカメラ
+ * 視点、注視対象、視線のうち2つを指定して使う。 + * @author 新田直也 * */ public class Camera3D { @@ -24,8 +24,8 @@ private Universe universe = null; - private double frontClipDistance = 0.5; // �f�v�X�o�b�t�@�����������߂��܂菬�����l�ɂł��Ȃ� - private double backClipDistance = 1000.0; // �f�v�X�o�b�t�@�����������߂��܂�傫���l�ɂł��Ȃ� + private double frontClipDistance = 0.5; // デプスバッファが小さいためあまり小さい値にできない + private double backClipDistance = 1000.0; // デプスバッファが小さいためあまり大きい値にできない private double fieldOfView = Math.PI / 2.0; private TransformGroup viewPlatformTransform = null; @@ -38,7 +38,7 @@ private Vector3d viewUp = null; private boolean fParallel = false; - // �ȉ��̕ϐ��͏ȃ��������̂��ߓ��� + // 以下の変数は省メモリ化のため導入 private Transform3D worldToView = new Transform3D(); private double matrix[] = new double[]{1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, @@ -56,10 +56,10 @@ } /** - * �J�����̒����_��lj����� + * カメラの注視点を追加する * * @param target - * �����_ + * 注視点 */ public void addTarget(Position3D target) { if (targetList == null) targetList = new ArrayList(); @@ -67,10 +67,10 @@ } /** - * �J�����̒����Ώۂ�lj����� + * カメラの注視対象を追加する * * @param target - * �����Ώ� + * 注視対象 */ public void addTarget(Object3D target) { if (targetObjList == null) targetObjList = new ArrayList(); @@ -78,10 +78,10 @@ } /** - * �J�����̒����Ώۂ�lj����� + * カメラの注視対象を追加する * * @param target - * �����Ώ� + * 注視対象 */ public void addTarget(Placeable target) { if (targetObjList == null) targetObjList = new ArrayList(); @@ -91,30 +91,30 @@ } /** - * �J�����̎��_��ݒ肷�� + * カメラの視点を設定する * * @param viewPoint - * ���_ + * 視点 */ public void setViewPoint(Position3D viewPoint) { this.viewPoint = viewPoint; } /** - * �J�����̎��_��ݒ肷�� + * カメラの視点を設定する * * @param viewPoint - * ���_�ƂȂ�I�u�W�F�N�g + * 視点となるオブジェクト */ public void setViewPoint(Object3D viewPointObj) { this.viewPointObj = viewPointObj; } /** - * �J�����̎��_��ݒ肷�� + * カメラの視点を設定する * * @param viewPoint - * ���_�ƂȂ�o�ꕨ + * 視点となる登場物 */ public void setViewPoint(Placeable viewPointActor) { if (viewPointActor.getBody() instanceof Object3D) { @@ -123,21 +123,21 @@ } /** - * ��O����̎����ɐݒ肷�� + * 手前からの視線に設定する */ public void setSideView() { viewLine = VIEW_FORWARD; } /** - * �ォ�猩���낵�������ɐݒ肷�� + * 上から見下ろした視線に設定する */ public void setTopView() { viewLine = VIEW_DOWN; } /** - * ������ݒ肷�� + * 視線を設定する */ public void setViewLine(Vector3d viewLine) { this.viewLine = viewLine; @@ -145,23 +145,23 @@ /** - * ����p��ݒ肷�� - * @param a ����p + * 視野角を設定する + * @param a 視野角 */ public void setFieldOfView(double a) { fieldOfView = a; } /** - * ����p���擾���� - * @return ����p + * 視野角を取得する + * @return 視野角 */ public double getFieldOfView() { return fieldOfView; } /** - * �t�����g�N���b�v������ݒ肷�� + * フロントクリップ距離を設定する * @param d */ public void setFrontClipDistance(double d) { @@ -169,15 +169,15 @@ } /** - * �t�����g�N���b�v�������擾���� - * @return �t�����g�N���b�v���� + * フロントクリップ距離を取得する + * @return フロントクリップ距離 */ public double getFrontClipDistance() { return frontClipDistance; } /** - * �o�b�N�N���b�v������ݒ肷�� + * バッククリップ距離を設定する * @param d */ public void setBackClipDistance(double d) { @@ -185,8 +185,8 @@ } /** - * �o�b�N�N���b�v�������擾���� - * @return �o�b�N�N���b�v���� + * バッククリップ距離を取得する + * @return バッククリップ距離 */ public double getBackClipDistance() { return backClipDistance; @@ -199,15 +199,15 @@ public Position3D getViewPoint() { if (viewPoint != null) return viewPoint; if (viewPointObj != null) return viewPointObj.getPosition3D(); - // ���_���ݒ肳��Ă��Ȃ��ꍇ + // 視点が設定されていない場合 Vector3d center = getTargetCenter(); if (center != null) { Vector3d vz = new Vector3d(); if (viewLine != null) { - // �����ΏۂƎ������ݒ肳��Ă���ꍇ + // 注視対象と視線が設定されている場合 vz.negate(viewLine); } else { - // �����Ώۂ݂̂��ݒ肳��Ă���ꍇ + // 注視対象のみが設定されている場合 vz.negate(VIEW_FORWARD); } Vector3d vx = new Vector3d(); @@ -220,7 +220,7 @@ } vy.cross(vz, vx); - // �����Ώۂ��牺���鋗�� + // 注視対象から下がる距離 if (cameraBack != null) { vx.scale(cameraBack.x); vy.scale(cameraBack.y); @@ -235,13 +235,13 @@ } return new Position3D(center); } - // ���_�������_���ݒ肳��Ă��Ȃ��ꍇ + // 視点も注視点も設定されていない場合 return new Position3D(); } public Vector3d getViewLine() { if (viewLine != null) { - // �������ݒ肳��Ă���ꍇ + // 視線が設定されている場合 return viewLine; } Vector3d center = getTargetCenter(); @@ -293,20 +293,20 @@ } /** - * �����Ώۂ⎋�_�̈ړ��A�����̕ω��ɔ�����p���� + * 注視対象や視点の移動、視線の変化に伴う画角調整 */ public void adjust(long interval) { - // �J�������W�n�ivx, vy, vz�j���v�Z���� + // カメラ座標系(vx, vy, vz)を計算する Vector3d vx = new Vector3d(), vy = new Vector3d(), vz = new Vector3d(); if (viewLine == null) { - // �������ݒ肳��Ă��Ȃ��ꍇ + // 視線が設定されていない場合 if ((viewPoint == null && viewPointObj == null) || ((targetObjList == null || targetObjList.size() == 0) && (targetList == null || targetList.size() == 0))) { - // ���_�܂��͒����Ώۂ��ݒ肳��Ă��Ȃ��ꍇ�A��O����̎����ɂ��� + // 視点または注視対象が設定されていない場合、手前からの視線にする vz.negate(VIEW_FORWARD); } else { - // �����Ώۂ̏d�S�𒍎��_�Ƃ��� + // 注視対象の重心を注視点とする Vector3d center = getTargetCenter(); if (center == null) center = new Vector3d(); if (viewPoint != null) { @@ -318,7 +318,7 @@ vz.negate(center); } } else { - // �������ݒ肳��Ă���ꍇ vz ���������� �Ƌt�����ɐݒ肷�� + // 視線が設定されている場合 vz を視線方向 と逆向きに設定する viewLine.normalize(); vz.negate(viewLine); } @@ -330,9 +330,9 @@ } vy.cross(vz, vx); - // ���E���W����J�������W�ւ̕ϊ����v�Z���� + // 世界座標からカメラ座標への変換を計算する if (viewPoint != null || viewPointObj != null) { - // ���_���ݒ肳��Ă���ꍇ + // 視点が設定されている場合 Vector3d vp; if (viewPoint != null) { vp = viewPoint.getVector3d(); @@ -347,20 +347,20 @@ worldToView.invert(); worldToView.setTranslation(vp); } else { - // ���_���ݒ肳��Ă��Ȃ��ꍇ�A�����ΏۂƎ�������i�J�������W�n��ł́j���_���t�v�Z���� + // 視点が設定されていない場合、注視対象と視線から(カメラ座標系上での)視点を逆計算する if ((targetObjList == null || targetObjList.size() == 0) - && (targetList == null || targetList.size() == 0)) return; // ���_�������Ώۂ��ݒ肳��Ă��Ȃ� + && (targetList == null || targetList.size() == 0)) return; // 視点も注視対象も設定されていない - // �����Ώۂ̒��S + // 注視対象の中心 Vector3d center = getTargetCenter(); - // �J�������W��ł̒����_�̍��W + // カメラ座標上での注視点の座標 Vector3d eye = new Vector3d(center.dot(vx), center.dot(vy), center.dot(vz)); if (cameraBack != null) { - // �J�����̈��� + // カメラの引き eye.add(cameraBack); } else { - // �����Ώۂ�����悤�ɃJ���������� + // 注視対象が入るようにカメラを引く double z = getStandBackDistance(vx, vy); eye.z += z; } @@ -440,7 +440,7 @@ public void setWorldToView(Position3D vp, Vector3d vl) { setViewPoint(vp); setViewLine(vl); - //������̃x�N�g���v�Z + //上方向のベクトル計算 Vector3d vy = new Vector3d(0, 1, 0); Vector3d vv = (Vector3d) vl.clone(); vv.cross(vy, vv); diff --git a/src/framework/view3D/Viewer3D.java b/src/framework/view3D/Viewer3D.java index 589bbeb..ecb99a3 100644 --- a/src/framework/view3D/Viewer3D.java +++ b/src/framework/view3D/Viewer3D.java @@ -48,12 +48,12 @@ @Override public void update(ArrayList lights, BackgroundBox skyBox) { - // �����̍X�V + // 光源の更新 if (this.lights != lights) { this.lights = lights; } - // �X�J�C�{�b�N�X�̍X�V + // スカイボックスの更新 if (this.skyBox != skyBox) { this.skyBox = skyBox; } diff --git a/src/java3d/AxisAngle4d.java b/src/java3d/AxisAngle4d.java index 3b8645d..0a4101e 100644 --- a/src/java3d/AxisAngle4d.java +++ b/src/java3d/AxisAngle4d.java @@ -7,14 +7,14 @@ public double z; static final double EPS = 1.0e-12; - // �R���X�g���N�^ + // コンストラクタ public AxisAngle4d() { x = 0.0; y = 0.0; z = 0.0; } - //�@�R���X�g���N�^ + // コンストラクタ public AxisAngle4d(double px, double py, double pz, double pa) { x = px; y = py; diff --git a/src/java3d/BoundingSphere.java b/src/java3d/BoundingSphere.java index 91b249c..28a770f 100644 --- a/src/java3d/BoundingSphere.java +++ b/src/java3d/BoundingSphere.java @@ -28,13 +28,13 @@ double d = center.distance(bs.center); if (d + r2 <= r1) { - // this �� bs ���܂���ꍇ�A�������Ȃ� + // this が bs を包含する場合、何もしない } else if (d + r1 < r2) { - // bs �� this ���܂���ꍇ�Abs���R�s�[ + // bs が this を包含する場合、bsをコピー this.radius = bs.radius; this.center.set(bs.center); } else { - // this �� �@bs �̂�������������܂��Ȃ��ꍇ + // this と  bs のいずれも他方を包含しない場合 this.radius = (r1 + r2 + d) / 2.0; double a1 = this.radius - r1; diff --git a/src/java3d/Bounds.java b/src/java3d/Bounds.java index 7c430cc..b162920 100644 --- a/src/java3d/Bounds.java +++ b/src/java3d/Bounds.java @@ -29,7 +29,7 @@ - // //�Z�H�m�F���\�b�h�Bradius(���a)�𗘗p�����~�̐ڐG�ł���Ɖ��肵�Ă݂�Ƃ������� + // //浸食確認メソッド。radius(半径)を利用した円の接触であると仮定してみるといいかも // public boolean intersect(BoundingSphere bs) { // // TODO Auto-generated method stub // return false; diff --git a/src/java3d/Box.java b/src/java3d/Box.java index 7783957..c5fa77a 100644 --- a/src/java3d/Box.java +++ b/src/java3d/Box.java @@ -39,7 +39,7 @@ 0, 0, 1, 0, 1, 1 , 0, 1, }; - // �e�ʂ̃W�I���g�����쐬 + // 各面のジオメトリを作成 TriangleFanArray frontGeom = new TriangleFanArray(4, TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2, new int[]{4}); @@ -59,7 +59,7 @@ TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2, new int[]{4}); - // ���_���W�̐ݒ� + // 頂点座標の設定 frontGeom.setCoordinate(0, coordinates[0]); frontGeom.setCoordinate(1, coordinates[1]); frontGeom.setCoordinate(2, coordinates[2]); @@ -90,7 +90,7 @@ bottomGeom.setCoordinate(2, coordinates[1]); bottomGeom.setCoordinate(3, coordinates[0]); - // �e�N�X�`�����W�̐ݒ� + // テクスチャ座標の設定 frontGeom.setTextureCoordinates(0, uv); backGeom.setTextureCoordinates(0, uv); rightGeom.setTextureCoordinates(0, uv); @@ -98,7 +98,7 @@ topGeom.setTextureCoordinates(0, uv); bottomGeom.setTextureCoordinates(0, uv); - // �@���̐ݒ� + // 法線の設定 float[] frontNorm = new float[]{0.0f, 0.0f, 1.0f}; frontGeom.setNormal(0, frontNorm); frontGeom.setNormal(1, frontNorm); @@ -135,7 +135,7 @@ bottomGeom.setNormal(2, bottomNorm); bottomGeom.setNormal(3, bottomNorm); - // �\�ʑ����̍쐬 + // 表面属性の作成 if (ap == null) { ap = new Appearance(); } @@ -148,7 +148,7 @@ Appearance ap6; Texture tex = ap.getTexture(); if (tex != null && tex instanceof TextureCubeMap) { - // GL10 �ł� GL_TEXTURE_CUBE_MAP ���g���Ȃ��̂ŁATextureCubeMap �̏ꍇ�� Texture2D �ɕ������� + // GL10 では GL_TEXTURE_CUBE_MAP が使えないので、TextureCubeMap の場合は Texture2D に分解する ap1 = (Appearance)ap.cloneNodeComponent(); ap2 = (Appearance)ap.cloneNodeComponent(); ap3 = (Appearance)ap.cloneNodeComponent(); @@ -183,7 +183,7 @@ ap1 = ap2 = ap3 = ap4 = ap5 = ap6 = ap; } - // �e�ʂ̍쐬 + // 各面の作成 frontShape = new Shape3D(frontGeom, ap1); backShape = new Shape3D(backGeom, ap2); rightShape = new Shape3D(rightGeom, ap3); diff --git a/src/java3d/Color3f.java b/src/java3d/Color3f.java index 6021db0..7442971 100644 --- a/src/java3d/Color3f.java +++ b/src/java3d/Color3f.java @@ -5,14 +5,14 @@ public float g; public float b; - // �R���X�g���N�^ + // コンストラクタ public Color3f() { r = 0.0f; g = 0.0f; b = 0.0f; } - // �R���X�g���N�^ + // コンストラクタ public Color3f(float pr, float pg, float pb) { r = pr; g = pg; diff --git a/src/java3d/Color4f.java b/src/java3d/Color4f.java index 4603d99..b2dc329 100644 --- a/src/java3d/Color4f.java +++ b/src/java3d/Color4f.java @@ -6,7 +6,7 @@ public float b; public float a; - // �R���X�g���N�^ + // コンストラクタ public Color4f() { r = 0.0f; g = 0.0f; @@ -14,7 +14,7 @@ a = 0.0f; } - // �R���X�g���N�^ + // コンストラクタ public Color4f(float pr, float pg, float pb, float pa) { r = pr; g = pg; diff --git a/src/java3d/Cone.java b/src/java3d/Cone.java index 641b30b..58c3d1c 100644 --- a/src/java3d/Cone.java +++ b/src/java3d/Cone.java @@ -26,13 +26,13 @@ float coordinates[][] = new float[xdivisions][3]; - for (int i = 0; i < xdivisions; i++) { // BOTTOM(���)�̓_��(x,y,z)���W + for (int i = 0; i < xdivisions; i++) { // BOTTOM(底面)の点の(x,y,z)座標 coordinates[i][0] = r * (float) Math.cos(2 * Math.PI * ((double)i / xdivisions)); coordinates[i][1] = -h / 2; coordinates[i][2] = r * (float) Math.sin(2 * Math.PI * ((double)i / xdivisions)); } - float coordinates_center[][] = new float[2][3];//���_��,��ʂ̒��S,�̍��W + float coordinates_center[][] = new float[2][3];//頂点と,底面の中心,の座標 coordinates_center[0][0] = 0; coordinates_center[0][1] = h / 2; coordinates_center[0][2] = 0; @@ -42,7 +42,7 @@ float uv[] = { 0, 0, 1, 0, 1, 1, 0, 1, }; - // �e�ʂ̃W�I���g�����쐬 + // 各面のジオメトリを作成 TriangleFanArray bodyGeom = new TriangleFanArray(xdivisions + 2, TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2, new int[] { xdivisions + 2 }); @@ -50,25 +50,25 @@ TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2, new int[] { xdivisions + 2 }); - // ���_���W�̐ݒ� - //���� + // 頂点座標の設定 + //側面 bodyGeom.setCoordinate(0,coordinates_center[0]); for (int i = 0; i < xdivisions; i++){ - bodyGeom.setCoordinate(i + 1, coordinates[i]); //�ォ�猩�Ĕ����v���̏� + bodyGeom.setCoordinate(i + 1, coordinates[i]); //上から見て反時計回りの順 } bodyGeom.setCoordinate(xdivisions + 1, coordinates[0]); - //��� + //底面 capGeom.setCoordinate(0,coordinates_center[1]); capGeom.setCoordinate(1, coordinates[0]); for (int i = 0; i < xdivisions; i++){ - capGeom.setCoordinate(i + 2, coordinates[xdivisions - i - 1]); //�ォ�猩�Ď��v���̏� + capGeom.setCoordinate(i + 2, coordinates[xdivisions - i - 1]); //上から見て時計回りの順 } - // �e�N�X�`�����W�̐ݒ� + // テクスチャ座標の設定 bodyGeom.setTextureCoordinates(0, uv); // capGeom.setTextureCoordinates(0, uv); - // �@���̐ݒ� + // 法線の設定 double theta; theta = Math.atan(h / r); for (int i = 0; i < xdivisions; i++) { @@ -85,13 +85,13 @@ capGeom.setNormal(i, bottomNorm); } - // �\�ʑ����̍쐬 + // 表面属性の作成 if (ap == null) { ap = new Appearance(); } setAppearance(ap); - // �e�ʂ̍쐬 //�S�ē����e�N�X�`���[(ap)��\��t���� + // 各面の作成 //全て同じテクスチャー(ap)を貼り付ける bodyShape = new Shape3D(bodyGeom, ap); capShape = new Shape3D(capGeom, ap); diff --git a/src/java3d/Cylinder.java b/src/java3d/Cylinder.java index 9a55fc6..f7aa4a6 100644 --- a/src/java3d/Cylinder.java +++ b/src/java3d/Cylinder.java @@ -31,7 +31,7 @@ float coordinates[][] = new float[xdivisions * 2][3]; - float coordinates_center[][] = new float[2][3];//��ʂƒ�ʂ̒��S�̍��W + float coordinates_center[][] = new float[2][3];//上面と底面の中心の座標 coordinates_center[0][0] = 0; coordinates_center[0][1] = h / 2; coordinates_center[0][2] = 0; @@ -39,12 +39,12 @@ coordinates_center[1][1] = -h / 2; coordinates_center[1][2] = 0; - for (int i = 0; i < xdivisions; i++) { // TOP(���)���̓_��(x,y,z)���W + for (int i = 0; i < xdivisions; i++) { // TOP(上面)側の点の(x,y,z)座標 coordinates[i][0] = r * (float) Math.cos(2 * Math.PI * ((double)i / xdivisions)); coordinates[i][1] = h / 2; coordinates[i][2] = r * (float) Math.sin(2 * Math.PI * ((double)i / xdivisions)); } - for (int i = 0; i < xdivisions; i++) { // BOTTOM(���)�̓_��(x,y,z)���W + for (int i = 0; i < xdivisions; i++) { // BOTTOM(底面)の点の(x,y,z)座標 coordinates[i + xdivisions][0] = r * (float) Math.cos(2 * Math.PI * ((double)i / xdivisions)); coordinates[i + xdivisions][1] = -h / 2; coordinates[i + xdivisions][2] = r * (float) Math.sin(2 * Math.PI * ((double)i / xdivisions)); @@ -52,7 +52,7 @@ float uv[] = { 0, 0, 1, 0, 1, 1, 0, 1, }; - // �e�ʂ̃W�I���g�����쐬 + // 各面のジオメトリを作成 IndexedTriangleStripArray bodyGeom = new IndexedTriangleStripArray(xdivisions * 2, IndexedTriangleStripArray.COORDINATES | IndexedTriangleStripArray.NORMALS | IndexedTriangleStripArray.TEXTURE_COORDINATE_2, xdivisions * 2 + 2, @@ -64,9 +64,9 @@ TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2, new int[] { xdivisions + 2 }); - // ���_���W�̐ݒ� - //���� - for (int i = 0; i < xdivisions; i++) { //��ʂ����ʂ֐����ɍ~��āA��ʂ����ʂ֎΂߂ɏ�鏇�ɍ��W��ݒ� + // 頂点座標の設定 + //側面 + for (int i = 0; i < xdivisions; i++) { //上面から底面へ垂直に降りて、底面から上面へ斜めに上る順に座標を設定 bodyGeom.setCoordinate(2 * i , coordinates[i]); bodyGeom.setCoordinate(2 * i + 1, coordinates[i + xdivisions]); } @@ -80,26 +80,26 @@ bodyGeom.setCoordinateIndices(0, coordinateIndices); - //��� + //上面 topGeom.setCoordinate(0,coordinates_center[0]); for(int i = 0; i < xdivisions; i++){ - topGeom.setCoordinate(i + 1, coordinates[i]); //�ォ�猩�Ĕ����v���̏� + topGeom.setCoordinate(i + 1, coordinates[i]); //上から見て反時計回りの順 } topGeom.setCoordinate(xdivisions + 1, coordinates[0]); - //��� + //底面 bottomGeom.setCoordinate(0,coordinates_center[1]); bottomGeom.setCoordinate(1, coordinates[xdivisions]); for(int i = 0; i < xdivisions; i++){ - bottomGeom.setCoordinate(i + 2, coordinates[2 * xdivisions - i - 1]); //�ォ�猩�Ď��v���̏� + bottomGeom.setCoordinate(i + 2, coordinates[2 * xdivisions - i - 1]); //上から見て時計回りの順 } - // �e�N�X�`�����W�̐ݒ� + // テクスチャ座標の設定 bodyGeom.setTextureCoordinates(0, uv); // topGeom.setTextureCoordinates(0, uv); bottomGeom.setTextureCoordinates(0, uv); - // �@���̐ݒ� + // 法線の設定 for (int i = 0; i < xdivisions * 2; i++) { float[] bodyNorm = new float[]{(float) Math.cos(Math.PI * ((double)i / xdivisions)),0.0f,(float) Math.sin(Math.PI * ((double)i / xdivisions))}; @@ -116,7 +116,7 @@ bottomGeom.setNormal(i, bottomNorm); } - // �\�ʑ����̍쐬 + // 表面属性の作成 if (ap == null) { ap = new Appearance(); } @@ -129,8 +129,8 @@ // Appearance ap6 = new Appearance(); // Texture tex = ap.getTexture(); // if (tex != null && tex instanceof TextureCubeMap) { - // GL10 �ł� GL_TEXTURE_CUBE_MAP ���g���Ȃ��̂ŁATextureCubeMap �̏ꍇ�� Texture2D - // �ɕ������� + // GL10 では GL_TEXTURE_CUBE_MAP が使えないので、TextureCubeMap の場合は Texture2D + // に分解する // ImageComponent ic1 = tex.getImage(TextureCubeMap.POSITIVE_Z); // Texture2D tex1 = new Texture2D(Texture2D.BASE_LEVEL, Texture2D.RGB, // ic1.width, ic1.height); @@ -162,7 +162,7 @@ // tex6.setImage(0, ic6); // ap6.setTexture(tex6); // } - // �e�ʂ̍쐬 //�S�ē����e�N�X�`���[(ap)��\��t���� + // 各面の作成 //全て同じテクスチャー(ap)を貼り付ける bodyShape = new Shape3D(bodyGeom, ap); topShape = new Shape3D(topGeom, ap); bottomShape = new Shape3D(bottomGeom, ap); diff --git a/src/java3d/Geometry.java b/src/java3d/Geometry.java index 7f95f97..5c55038 100644 --- a/src/java3d/Geometry.java +++ b/src/java3d/Geometry.java @@ -3,7 +3,7 @@ public abstract class Geometry extends NodeComponent { public static final int ALLOW_INTERSECT = 18; - // �R���X�g���N�^ + // コンストラクタ public Geometry() { } diff --git a/src/java3d/GeometryArray.java b/src/java3d/GeometryArray.java index 34f9371..cdb13f9 100644 --- a/src/java3d/GeometryArray.java +++ b/src/java3d/GeometryArray.java @@ -39,7 +39,7 @@ protected FloatBuffer normalBuffer = null; protected FloatBuffer uvBuffer = null; - // �R���X�g���N�^ + // コンストラクタ public GeometryArray(int vertexCount, int vertexFormat) { this.vertexCount = vertexCount; this.vertexFormat = vertexFormat; @@ -75,7 +75,7 @@ // this.texCoordSetMap = texCoordSetMap; // } - /** �I�u�W�F�N�g�̒��_�� */ + /** オブジェクトの頂点数 */ public int getVertexCount() { return vertexCount; } @@ -84,21 +84,21 @@ return vertexFormat; } - /** index�̒��_�̍��W��p�ɐV�����i�[���� */ + /** indexの頂点の座標をpに新しく格納する */ public void getCoordinate(int index, float[] p) { vertexBuffer.position(index * 3); vertexBuffer.get(p); vertexBuffer.position(0); } - /** index�̒��_�̍��W��p�ɐV�����i�[���� */ + /** indexの頂点の座標をpに新しく格納する */ public void getCoordinate(int index, double[] p) { p[0] = vertexBuffer.get(index * 3); p[1] = vertexBuffer.get(index * 3 + 1); p[2] = vertexBuffer.get(index * 3 + 2); } - /** index�̒��_�̍��W��p�ɐV�����i�[���� */ + /** indexの頂点の座標をpに新しく格納する */ public void getCoordinate(int index, Point3d p) { p.x = vertexBuffer.get(index * 3); p.y = vertexBuffer.get(index * 3 + 1); @@ -113,7 +113,7 @@ } } - /** index�̒��_�̖@����p�ɐV�����i�[���� */ + /** indexの頂点の法線をpに新しく格納する */ public void getNormal(int index, float[] p) { if (normalBuffer == null) return; normalBuffer .position(index * 3); @@ -121,7 +121,7 @@ normalBuffer .position(0); } - /** index�̒��_�̖@����p�ɐV�����i�[���� */ + /** indexの頂点の法線をpに新しく格納する */ public void getNormal(int index, Vector3f p) { if (normalBuffer == null) return; p.x = normalBuffer.get(index * 3); diff --git a/src/java3d/GraphicsContext3D.java b/src/java3d/GraphicsContext3D.java index ce359c6..6af24d8 100644 --- a/src/java3d/GraphicsContext3D.java +++ b/src/java3d/GraphicsContext3D.java @@ -39,15 +39,15 @@ public void init(GL10 gl) { this.gl = gl; - // �f�v�X�o�b�t�@�̃e�X�g�@�\��L���ɂ��� + // デプスバッファのテスト機能を有効にする gl.glEnable(GL10.GL_DEPTH_TEST); - // �A�ʏ����̓����ݒ� + // 陰面消去の動作を設定 gl.glDepthFunc(GL10.GL_LEQUAL); gl.glDepthMask(true); - // ���C�g��L���ɂ��� + // ライトを有効にする gl.glEnable(GL10.GL_LIGHTING); - // �ǂ̌������g�p���邩�w�� + // どの光源を使用するか指定 gl.glEnable(GL10.GL_LIGHT0); gl.glClearColor(0.0f,0.0f,0.0f,0.0f); @@ -59,20 +59,20 @@ if (!bFixAspect) { aspect = (float)width / (float)height; } - // �r���[�|�[�g�̐ݒ� + // ビューポートの設定 gl.glViewport(0, 0, width, height); - // �J�����̐ݒ� - gl.glMatrixMode(GL10.GL_PROJECTION); // �ˉe�ϊ� - gl.glLoadIdentity(); // ���W�̏����� - // ��p�̐ݒ� + // カメラの設定 + gl.glMatrixMode(GL10.GL_PROJECTION); // 射影変換 + gl.glLoadIdentity(); // 座標の初期化 + // 画角の設定 float fovy = (float)(Math.atan(Math.tan(fovx / 2.0) / aspect) / Math.PI * 360.0f); if(!fParallel){ GLU.gluPerspective(gl, - fovy, //Y�����̉�p - aspect, //�A�X�y�N�g�� - zNear, //�j�A�N���b�v - zFar);//�t�@�[�N���b�v + fovy, //Y方向の画角 + aspect, //アスペクト比 + zNear, //ニアクリップ + zFar);//ファークリップ }else{ float top = zNear * (float) Math.tan(fovy * (Math.PI / 360.0)); float bottom = -top; @@ -83,20 +83,20 @@ } public void update(float fovx, float zNear, float zFar, Position3D eye, Position3D center, Vector3d up, boolean fParallel) { - // �\����ʂƃf�v�X�o�b�t�@�̃N���A + // 表示画面とデプスバッファのクリア gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); - // �J�����̐ݒ� - gl.glMatrixMode(GL10.GL_PROJECTION); // �ˉe�ϊ� - gl.glLoadIdentity(); // ���W�̏����� - // ��p�̐ݒ� + // カメラの設定 + gl.glMatrixMode(GL10.GL_PROJECTION); // 射影変換 + gl.glLoadIdentity(); // 座標の初期化 + // 画角の設定 float fovy = (float)(Math.atan(Math.tan(fovx / 2.0) / aspect) / Math.PI * 360.0f); if (!fParallel) { GLU.gluPerspective(gl, - fovy, //Y�����̉�p - aspect, //�A�X�y�N�g�� - zNear, //�j�A�N���b�v - zFar);//�t�@�[�N���b�v + fovy, //Y方向の画角 + aspect, //アスペクト比 + zNear, //ニアクリップ + zFar);//ファークリップ } else { float top = zNear * (float) Math.tan(fovy * (Math.PI / 360.0)); float bottom = -top; @@ -104,12 +104,12 @@ float right = top * aspect; gl.glOrthof(left, right, bottom, top, zNear, zFar); } - // ���f���r���[�s��̎w�� + // モデルビュー行列の指定 gl.glMatrixMode(GL10.GL_MODELVIEW); - // ���W�̏����� + // 座標の初期化 gl.glLoadIdentity(); - // �J�����O���p�����[�^�̐ݒ� + // カメラ外部パラメータの設定 GLU.gluLookAt(gl, (float)eye.getX(), (float)eye.getY(), (float)eye.getZ(), (float)center.getX(), (float)center.getY(), (float)center.getZ(), @@ -135,7 +135,7 @@ public void updateLightState(Light l) { Integer i = lightRegistry.get(l); if (i == null) { - // Object3D�����ɔz�u����Ă�������ɑ΂��ẮA����������setLight()���Ă΂�Ȃ����� + // Object3D内部に配置されている光源に対しては、初期化時にsetLight()が呼ばれないため i = lightRegistry.size(); setLight(l, i); } @@ -167,7 +167,7 @@ this.appearance = appearance; Material material = appearance.getMaterial(); if (material != null) { - // �\�ʑ����̐ݒ� + // 表面属性の設定 gl.glMaterialfv(GL10.GL_FRONT, GL10.GL_DIFFUSE, material.diffuse, 0); gl.glMaterialfv(GL10.GL_FRONT, GL10.GL_AMBIENT, material.ambient, 0); gl.glMaterialfv(GL10.GL_FRONT, GL10.GL_SPECULAR, material.specular, 0); @@ -175,11 +175,11 @@ gl.glMaterialf(GL10.GL_FRONT, GL10.GL_SHININESS, material.shininess); } if (appearance.getTextureUnitCount() == 0) { - // �e�N�X�`�����j�b�g���g���Ă��Ȃ��ꍇ�i�ʏ�̃e�N�X�`���̏ꍇ�j + // テクスチャユニットを使っていない場合(通常のテクスチャの場合) Texture tex = appearance.getTexture(); if (tex != null) registerTexture(tex); } else { - // �e�N�X�`�����j�b�g���g���Ă���ꍇ + // テクスチャユニットを使っている場合 for (int n = 0; n < appearance.getTextureUnitCount(); n++) { TextureUnitState tus = appearance.getTextureUnitState(n); Texture tex = tus.getTexture(); @@ -193,13 +193,13 @@ private void registerTexture(Texture tex) { if (textureRegistry.get(tex) == null) { - // �e�N�X�`���̓o�^ + // テクスチャの登録 int[] textureId = new int[1]; gl.glGenTextures(1, textureId, 0); if (tex instanceof TextureCubeMap) { - // �����̃}�b�v�̏ꍇ(GL10�ł͑Ή����Ă��Ȃ�) + // 立方体マップの場合(GL10では対応していない) } else { - // �ʏ�̏ꍇ + // 通常の場合 gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId[0]); ImageComponent[] imageComponents = tex.getImages(); for (int level = 0; level < imageComponents.length; level++) { @@ -222,30 +222,30 @@ public void draw(Geometry g) { if (g == null) return; if (appearance.getTextureUnitCount() == 0) { - // �e�N�X�`�����j�b�g���g���Ă��Ȃ��ꍇ�i�ʏ�̃e�N�X�`���̏ꍇ�j + // テクスチャユニットを使っていない場合(通常のテクスチャの場合) Texture tex = appearance.getTexture(); if (tex != null) { gl.glEnable(GL10.GL_TEXTURE_2D); - gl.glBindTexture(GL10.GL_TEXTURE_2D, textureRegistry.get(tex)); // �e�N�X�`�����o�^����Ă��邱�Ƃ�O�� + gl.glBindTexture(GL10.GL_TEXTURE_2D, textureRegistry.get(tex)); // テクスチャが登録されていることを前提 TextureAttributes ta = appearance.getTextureAttributes(); if (ta != null) setTextureAttributes(ta); } } else { - // �e�N�X�`�����j�b�g���g���Ă���ꍇ + // テクスチャユニットを使っている場合 for (int n = 0; n < appearance.getTextureUnitCount(); n++) { TextureUnitState tus = appearance.getTextureUnitState(n); Texture tex = tus.getTexture(); if (tex != null) { gl.glActiveTexture(GL10.GL_TEXTURE0 + n); gl.glEnable(GL10.GL_TEXTURE_2D); - gl.glBindTexture(GL10.GL_TEXTURE_2D, textureRegistry.get(tex)); // �e�N�X�`�����o�^����Ă��邱�Ƃ�O�� + gl.glBindTexture(GL10.GL_TEXTURE_2D, textureRegistry.get(tex)); // テクスチャが登録されていることを前提 TextureAttributes ta = tus.getTextureAttributes(); if (ta != null) setTextureAttributes(ta); } } } if (g instanceof GeometryArray) { - // �o�b�t�@�̐ݒ� + // バッファの設定 gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); FloatBuffer vertexBuffer = ((GeometryArray)g).getVertexBuffer(); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer); @@ -268,7 +268,7 @@ gl.glTexCoordPointer(4, GL10.GL_FLOAT, 0, uvBuffer); } - // �W�I���g���̕`�� + // ジオメトリの描画 if (g instanceof TriangleArray) { TriangleArray ta = (TriangleArray)g; int vertexCount = ta.getVertexCount(); @@ -336,12 +336,12 @@ gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); } if (appearance.getTextureUnitCount() == 0) { - // �e�N�X�`�����j�b�g���g���Ă��Ȃ��ꍇ�i�ʏ�̃e�N�X�`���̏ꍇ�j + // テクスチャユニットを使っていない場合(通常のテクスチャの場合) if (appearance.getTexture() != null) { gl.glDisable(GL10.GL_TEXTURE_2D); } } else { - // �e�N�X�`�����j�b�g���g���Ă���ꍇ + // テクスチャユニットを使っている場合 for (int n = 0; n < appearance.getTextureUnitCount(); n++) { gl.glActiveTexture(GL10.GL_TEXTURE0 + n); gl.glDisable(GL10.GL_TEXTURE_2D); diff --git a/src/java3d/IndexedGeometryArray.java b/src/java3d/IndexedGeometryArray.java index d828390..8b4b710 100644 --- a/src/java3d/IndexedGeometryArray.java +++ b/src/java3d/IndexedGeometryArray.java @@ -11,7 +11,7 @@ protected ShortBuffer texCoordinateIndexBuffer = null; protected ShortBuffer normalIndexBuffer = null; - // �R���X�g���N�^ + // コンストラクタ public IndexedGeometryArray(int vertexCount, int vertexFormat, int indexCount) { super(vertexCount, vertexFormat); this.indexCount = indexCount; @@ -32,7 +32,7 @@ } } - /** �I�u�W�F�N�g�̃C���f�b�N�X�����擾���� */ + /** オブジェクトのインデックス数を取得する */ public int getIndexCount() { return indexCount; } diff --git a/src/java3d/Matrix3d.java b/src/java3d/Matrix3d.java index 8f3597f..0d639c9 100644 --- a/src/java3d/Matrix3d.java +++ b/src/java3d/Matrix3d.java @@ -11,7 +11,7 @@ public double m21; public double m22; - // �R���X�g���N�^ + // コンストラクタ public Matrix3d() { m00 = 0.0; m01 = 0.0; @@ -65,7 +65,7 @@ return new Matrix3d(m00, m01, m02, m10, m11, m12, m20, m21, m22); } - /** �e�v�f�ɑ��� */ + /** 各要素に足す */ public void add(Matrix3d m1) { this.m00 += m1.m00; this.m01 += m1.m01; @@ -78,7 +78,7 @@ this.m22 += m1.m22; } - /** ��‚̍s��̘a���i�[���� */ + /** 二つの行列の和を格納する */ public void add(Matrix3d m1, Matrix3d m2) { this.m00 = m1.m00 + m2.m00; this.m01 = m1.m01 + m2.m01; @@ -91,7 +91,7 @@ this.m22 = m1.m22 + m2.m22; } - /** x�������angle��] */ + /** x軸周りにangle回転 */ public void rotX(double angle) { double d1 = Math.sin(angle); double d2 = Math.cos(angle); @@ -106,7 +106,7 @@ m22 = d2; } - /** y�������angle��] */ + /** y軸周りにangle回転 */ public void rotY(double angle) { double d1 = Math.sin(angle); double d2 = Math.cos(angle); @@ -121,7 +121,7 @@ m22 = d2; } - /** z�������angle1��] */ + /** z軸周りにangle1回転 */ public void rotZ(double angle) { double d1 = Math.sin(angle); double d2 = Math.cos(angle); @@ -136,7 +136,7 @@ m22 = 1.0D; } - /** �����Ɉ����̍s����|�������̂��i�[���� */ + /** 自分に引数の行列を掛けたものを格納する */ public void mul(Matrix3d mat) { double t00 = m00 * mat.m00 + m01 * mat.m10 + m02 * mat.m20; double t01 = m00 * mat.m01 + m01 * mat.m11 + m02 * mat.m21; diff --git a/src/java3d/Matrix4d.java b/src/java3d/Matrix4d.java index e363d3d..69ef8b1 100644 --- a/src/java3d/Matrix4d.java +++ b/src/java3d/Matrix4d.java @@ -18,7 +18,7 @@ public double m32; public double m33; - // �R���X�g���N�^ + // コンストラクタ public Matrix4d() { m00 = 1.0; m01 = 0.0; @@ -102,7 +102,7 @@ this.m33 = m1.m33; } - /** �e�v�f�ɑ��� */ + /** 各要素に足す */ public void add(Matrix4d m1) { this.m00 += m1.m00; this.m01 += m1.m01; @@ -122,7 +122,7 @@ this.m33 += m1.m33; } - /** ��‚̍s��̘a���i�[���� */ + /** 二つの行列の和を格納する */ public void add(Matrix4d m1, Matrix4d m2) { this.m00 = m1.m00 + m2.m00; this.m01 = m1.m01 + m2.m01; @@ -142,7 +142,7 @@ this.m33 = m1.m33 + m2.m33; } - /** �����Ɉ����̍s����E����|�������̂��i�[���� */ + /** 自分に引数の行列を右から掛けたものを格納する */ public void mul(Matrix4d right) { double _m00 = m00 * right.m00 + m01 * right.m10 + m02 * right.m20 + m03 * right.m30; double _m01 = m00 * right.m01 + m01 * right.m11 + m02 * right.m21 + m03 * right.m31; @@ -205,7 +205,7 @@ return m11*m22*m33+m12*m23*m31+m13*m21*m32-m11*m23*m32-m12*m21*m33-m13*m22*m31; } - /** �s�񎮂����߂� */ + /** 行列式を求める */ public double determinant() { return m00 * determinant3x3(m11,m12,m13,m21,m22,m23,m31,m32,m33)- m01 * determinant3x3(m10,m12,m13,m20,m22,m23,m30,m32,m33)+ diff --git a/src/java3d/Point3d.java b/src/java3d/Point3d.java index 2fb163c..62f2195 100644 --- a/src/java3d/Point3d.java +++ b/src/java3d/Point3d.java @@ -2,7 +2,7 @@ public class Point3d extends Tuple3d { - // �R���X�g���N�^ + // コンストラクタ public Point3d() { this.x = 0; this.y = 0; @@ -57,7 +57,7 @@ this.z = v.z; } - /** �����̓_�Ƃ̋�����Ԃ� */ + /** 引数の点との距離を返す */ public double distance(Point3d p) { return Math.sqrt(distanceSquared(p)); } diff --git a/src/java3d/Point3f.java b/src/java3d/Point3f.java index 93e9241..7ba1f66 100644 --- a/src/java3d/Point3f.java +++ b/src/java3d/Point3f.java @@ -5,7 +5,7 @@ public float y; public float z; - // �R���X�g���N�^ + // コンストラクタ public Point3f() { this.x = 0; this.y = 0; @@ -54,7 +54,7 @@ this.z = v.z; } - /** �����̓_�Ƃ̋�����Ԃ� */ + /** 引数の点との距離を返す */ public double distance(Point3f p) { return Math.sqrt(distanceSquared(p)); } diff --git a/src/java3d/Quat4d.java b/src/java3d/Quat4d.java index 6f946d2..bbbce7e 100644 --- a/src/java3d/Quat4d.java +++ b/src/java3d/Quat4d.java @@ -18,7 +18,7 @@ return q; } - // �R���X�g���N�^ + // コンストラクタ public Quat4d() { x = 0.0; y = 0.0; @@ -26,7 +26,7 @@ w = 0.0; } - // �R���X�g���N�^ + // コンストラクタ public Quat4d(double px, double py, double pz, double pw) { double mag = 1.0/Math.sqrt(px*px+py*py+pz*pz+pw*pw); x = px*mag; diff --git a/src/java3d/Transform3D.java b/src/java3d/Transform3D.java index bc61c2e..27af5f0 100644 --- a/src/java3d/Transform3D.java +++ b/src/java3d/Transform3D.java @@ -60,12 +60,12 @@ this.mul(new Transform3D(this), t1); } - /** 4*4�s��̍s��Ԃ� */ + /** 4*4行列の行を返す */ private double[] row(int row, double[][] mat) { return new double[] {mat[row][0], mat[row][1], mat[row][2], mat[row][3]}; } - /** 4*4�s��̗��Ԃ� */ + /** 4*4行列の列を返す */ private double[] col(int col, double[][] mat) { return new double[] {mat[0][col], mat[1][col], mat[2][col], mat[3][col]}; } @@ -76,7 +76,7 @@ mat[2][3] = v.z; } - /** 4*4�̍s���16��1�����z��ŕԂ� */ + /** 4*4の行列を16の1次元配列で返す */ public float[] getMatrix() { float[] result = new float[16]; for (int i = 0; i < 4; i++) { @@ -87,7 +87,7 @@ return result; } - /** �Ίp�s����X�J���{���� */ + /** 対角行列をスカラ倍する */ public void setScale(double s) { for (int i = 0; i < 3; i++) { mat[i][i] = s; @@ -95,14 +95,14 @@ } } - /** �Ίp�s���vector�̐����{���� */ + /** 対角行列をvectorの成分倍する */ public void setScale(Vector3d vector3d) { scales[0] = mat[0][0] = vector3d.x; scales[1] = mat[1][1] = vector3d.y; scales[2] = mat[2][2] = vector3d.z; } - /** �C�ӂ̒P�ʃx�N�g���܂��ɉ�]���� */ + /** 任意の単位ベクトルまわりに回転する */ public void setRotation(AxisAngle4d t) { double vx = t.x; double vy = t.y; @@ -121,7 +121,7 @@ mat[2][2] = (Math.pow(vz, 2.0)) * (1 - cos) + cos; } - /** �C�ӂ̒P�ʃx�N�g���܂��ɉ�]���� */ + /** 任意の単位ベクトルまわりに回転する */ public void setRotation(Quat4d q) { // double vx = q.x; // double vy = q.y; @@ -226,7 +226,7 @@ mat[3][3] = 1.0; } - /** �����̐������i�[���� */ + /** 引数の成分を格納する */ public void get(Matrix4d mat4d) { mat4d.m00 = mat[0][0]; mat4d.m01 = mat[0][1]; @@ -335,7 +335,7 @@ // type = RIGID | CONGRUENT | AFFINE | ORTHO; } - /** Vector3d��Transform3d�ŕϊ����� */ + /** Vector3dをTransform3dで変換する */ public void transform(Vector3d v) { double vx = mat[0][0]*v.x + mat[0][1]*v.y + mat[0][2]*v.z;// + mat[0][3] * 1.0; double vy = mat[1][0]*v.x + mat[1][1]*v.y + mat[1][2]*v.z;// + mat[1][3] * 1.0; @@ -386,7 +386,7 @@ } /** - * ���ʂɑ΂��Ă����g���Ă͂����Ȃ� + * 平面に対してしか使ってはいけない * @param plane */ public void transform(Vector4d plane) { diff --git a/src/java3d/Vector2f.java b/src/java3d/Vector2f.java index b902008..d840a6c 100644 --- a/src/java3d/Vector2f.java +++ b/src/java3d/Vector2f.java @@ -4,13 +4,13 @@ public float x; public float y; - // �R���X�g���N�^ + // コンストラクタ public Vector2f() { x = 0.0f; y = 0.0f; } - // �R���X�g���N�^ + // コンストラクタ public Vector2f(float px, float py) { x = px; y = py; @@ -44,37 +44,37 @@ y = y / l; } - /** v1��v2�̘a���i�[���� */ + /** v1とv2の和を格納する */ public void add(Vector2f v1, Vector2f v2) { this.x = v1.x + v2.x; this.y = v1.y + v2.y; } - /** v1�Ƃ̘a���i�[���� */ + /** v1との和を格納する */ public void add(Vector2f v1) { this.x += v1.x; this.y += v1.y; } - /** v1��v2�̍����i�[���� */ + /** v1とv2の差を格納する */ public void sub(Vector2f v1, Vector2f v2) { this.x = v1.x - v2.x; this.y = v1.y - v2.y; } - /** v1�Ƃ̍����i�[���� */ + /** v1との差を格納する */ public void sub(Vector2f v1) { this.x -= v1.x; this.y -= v1.y; } - /** Vector3d���Z�b�g���� */ + /** Vector3dをセットする */ public void set(Vector2f v) { this.x = v.x; this.y = v.y; } - /** �����𔽓]���� */ + /** 符号を反転する */ public void negate() { this.x = -x; this.y = -y; diff --git a/src/java3d/Vector3d.java b/src/java3d/Vector3d.java index 1b8ed3c..77a3cb5 100644 --- a/src/java3d/Vector3d.java +++ b/src/java3d/Vector3d.java @@ -2,14 +2,14 @@ public class Vector3d extends Tuple3d { - // �R���X�g���N�^ + // コンストラクタ public Vector3d() { x = 0.0; y = 0.0; z = 0.0; } - // �R���X�g���N�^ + // コンストラクタ public Vector3d(double px, double py, double pz) { x = px; y = py; @@ -68,42 +68,42 @@ z = z / l; } - /** v1��v2�̘a���i�[���� */ + /** v1とv2の和を格納する */ public void add(Tuple3d v1, Tuple3d v2) { this.x = v1.x + v2.x; this.y = v1.y + v2.y; this.z = v1.z + v2.z; } - /** v1�Ƃ̘a���i�[���� */ + /** v1との和を格納する */ public void add(Tuple3d v1) { this.x += v1.x; this.y += v1.y; this.z += v1.z; } - /** v1��v2�̍����i�[���� */ + /** v1とv2の差を格納する */ public void sub(Tuple3d v1, Tuple3d v2) { this.x = v1.x - v2.x; this.y = v1.y - v2.y; this.z = v1.z - v2.z; } - /** v1�Ƃ̍����i�[���� */ + /** v1との差を格納する */ public void sub(Tuple3d v1) { this.x -= v1.x; this.y -= v1.y; this.z -= v1.z; } - /** Vector3d���Z�b�g���� */ + /** Vector3dをセットする */ public void set(Tuple3d v) { this.x = v.x; this.y = v.y; this.z = v.z; } - /** �����𔽓]���� */ + /** 符号を反転する */ public void negate() { this.x = -x; this.y = -y; diff --git a/src/java3d/Vector3f.java b/src/java3d/Vector3f.java index 168d1b9..ad8026c 100644 --- a/src/java3d/Vector3f.java +++ b/src/java3d/Vector3f.java @@ -5,14 +5,14 @@ public float y; public float z; - // �R���X�g���N�^ + // コンストラクタ public Vector3f() { x = 0.0f; y = 0.0f; z = 0.0f; } - // �R���X�g���N�^ + // コンストラクタ public Vector3f(float px, float py, float pz) { x = px; y = py; @@ -59,42 +59,42 @@ z = z / l; } - /** v1��v2�̘a���i�[���� */ + /** v1とv2の和を格納する */ public void add(Vector3f v1, Vector3f v2) { this.x = v1.x + v2.x; this.y = v1.y + v2.y; this.z = v1.z + v2.z; } - /** v1�Ƃ̘a���i�[���� */ + /** v1との和を格納する */ public void add(Vector3f v1) { this.x += v1.x; this.y += v1.y; this.z += v1.z; } - /** v1��v2�̍����i�[���� */ + /** v1とv2の差を格納する */ public void sub(Vector3f v1, Vector3f v2) { this.x = v1.x - v2.x; this.y = v1.y - v2.y; this.z = v1.z - v2.z; } - /** v1�Ƃ̍����i�[���� */ + /** v1との差を格納する */ public void sub(Vector3f v1) { this.x -= v1.x; this.y -= v1.y; this.z -= v1.z; } - /** Vector3d���Z�b�g���� */ + /** Vector3dをセットする */ public void set(Vector3f v) { this.x = v.x; this.y = v.y; this.z = v.z; } - /** �����𔽓]���� */ + /** 符号を反転する */ public void negate() { this.x = -x; this.y = -y; diff --git a/src/java3d/Vector4d.java b/src/java3d/Vector4d.java index 1ed7fd6..dc2f6e7 100644 --- a/src/java3d/Vector4d.java +++ b/src/java3d/Vector4d.java @@ -6,7 +6,7 @@ public double z; public double w; - // �R���X�g���N�^ + // コンストラクタ public Vector4d() { x = 0.0; y = 0.0; @@ -14,7 +14,7 @@ w = 0.0; } - // �R���X�g���N�^ + // コンストラクタ public Vector4d(double px, double py, double pz, double pw) { x = px; y = py; @@ -47,7 +47,7 @@ return new Vector4d(x, y, z, w); } - /** ��Βl��Ԃ� */ + /** 絶対値を返す */ final void absolute() { x = Math.abs(x); y = Math.abs(y); diff --git a/src/java3d/Vector4f.java b/src/java3d/Vector4f.java index 12ba388..7bb4a05 100644 --- a/src/java3d/Vector4f.java +++ b/src/java3d/Vector4f.java @@ -6,7 +6,7 @@ public float z; public float w; - // �R���X�g���N�^ + // コンストラクタ public Vector4f() { x = 0.0f; y = 0.0f; @@ -14,7 +14,7 @@ w = 0.0f; } - // �R���X�g���N�^ + // コンストラクタ public Vector4f(float px, float py, float pz, float pw) { x = px; y = py; @@ -47,7 +47,7 @@ return new Vector4f(x, y, z, w); } - /** ��Βl��Ԃ� */ + /** 絶対値を返す */ final void absolute() { x = Math.abs(x); y = Math.abs(y); diff --git a/src/sample/SampleGameActivity.java b/src/sample/SampleGameActivity.java index c85947b..e5a28e6 100644 --- a/src/sample/SampleGameActivity.java +++ b/src/sample/SampleGameActivity.java @@ -31,16 +31,16 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - //�‹��� + //環境光 AmbientLight amblight = new AmbientLight(new Color3f(1.0f, 1.0f, 1.0f)); // amblight.setInfluencingBounds(new BoundingSphere(new Point3d(), 10000.0)); universe.placeLight(amblight); - //���s���� + //平行光源 DirectionalLight dirlight = new DirectionalLight( - new Color3f(1.0f, 1.0f, 1.0f), //���̐F - new Vector3f(0.0f, -1.0f, -0.5f) //���̕����x�N�g�� + new Color3f(1.0f, 1.0f, 1.0f), //光の色 + new Vector3f(0.0f, -1.0f, -0.5f) //光の方向ベクトル ); // dirlight.setInfluencingBounds(new BoundingSphere(new Point3d(), 10000.0)); universe.placeLight(dirlight); diff --git a/src/test/TestDiceActivity.java b/src/test/TestDiceActivity.java index ae8668f..f7c0228 100644 --- a/src/test/TestDiceActivity.java +++ b/src/test/TestDiceActivity.java @@ -39,10 +39,10 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // 3D���f���̍쐬 + // 3Dモデルの作成 Universe universe = new Universe(); - // �T�C�R���̍쐬 + // サイコロの作成 Appearance ap1 = new Appearance(); TextureCubeMap tex1 = new TextureCubeMap(TextureCubeMap.BASE_LEVEL, TextureCubeMap.RGB, 0); TextureLoader loader = new TextureLoader(getResources(), R.drawable.dice_1, TextureLoader.BY_REFERENCE | TextureLoader.Y_UP); @@ -70,7 +70,7 @@ initTrans = new Transform3D(); obj1.rot.getTransform(initTrans); - // �n�ʂ̍쐬 + // 地面の作成 Appearance ap2 = new Appearance(); Material m = new Material(); m.setDiffuseColor(1.0f, 1.0f, 1.0f); @@ -88,12 +88,12 @@ universe.place(ground); physicalSystem.add(ground); - // �J�����̍쐬 + // カメラの作成 Camera3D camera = new Camera3D(universe); camera.setViewPoint(new Position3D(0.0, 30, -30.0)); camera.addTarget(diceObj); - // ��ʂƂ̊֘A�t�� + // 画面との関連付け RWTSurfaceView view = new RWTSurfaceView(this); view.attachCamera(camera); setContentView(view); diff --git a/src/test/TestLoadModelActivity.java b/src/test/TestLoadModelActivity.java index 197513a..a6d2506 100644 --- a/src/test/TestLoadModelActivity.java +++ b/src/test/TestLoadModelActivity.java @@ -54,9 +54,9 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // 3D���f���̍쐬 + // 3Dモデルの作成 - // �T�C�R���̍쐬 + // サイコロの作成 Appearance ap1 = new Appearance(); Material m = new Material(); m.setDiffuseColor(0.3f, 1.0f, 0.0f); @@ -90,7 +90,7 @@ actor = new OvergroundActor(obj1, null); universe.place(actor); - // �n�ʂ̍쐬 + // 地面の作成 Appearance ap2 = new Appearance(); Material m2 = new Material(); m2.setDiffuseColor(0.1f, 0.0f, 0.02f); @@ -111,16 +111,16 @@ Ground ground = new Ground(groundObj); universe.place(ground); - // �����̐ݒ� + // 光源の設定 universe.placeLight(new DirectionalLight(new Color3f(1.0f, 1.0f, 1.0f), new Vector3f(0.0f, -1.0f, -0.5f))); - // �J�����̐ݒ� + // カメラの設定 camera.setViewPoint(new Position3D(0.0, 100.0, 400.0)); camera.addTarget(actor); camera.setFrontClipDistance(1.0); camera.setBackClipDistance(10000.0); - // �t���[���̊Ԋu�ims�j + // フレームの間隔(ms) start(20); } diff --git a/src/test/TestUniverseActivity.java b/src/test/TestUniverseActivity.java index 2135e82..e90caba 100644 --- a/src/test/TestUniverseActivity.java +++ b/src/test/TestUniverseActivity.java @@ -44,9 +44,9 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // 3D���f���̍쐬 + // 3Dモデルの作成 - // �T�C�R���̍쐬 + // サイコロの作成 Appearance ap1 = new Appearance(); Material m = new Material(); m.setDiffuseColor(1.0f, 1.0f, 1.0f); @@ -72,7 +72,7 @@ OvergroundActor actor = new OvergroundActor(obj1, null); universe.place(actor); - // �n�ʂ̍쐬 + // 地面の作成 IndexedTriangleArray groundGeometry = new IndexedTriangleArray(4, IndexedTriangleArray.COORDINATES | IndexedTriangleArray.NORMALS, 6); groundGeometry.setCoordinate(0, new Point3d(-20.0, 0.0, -20.0)); @@ -100,11 +100,11 @@ // }; // universe.place(oga); - // �J�����̐ݒ� + // カメラの設定 camera.setViewPoint(new Position3D(0.0, 10.0, -20.0)); camera.addTarget(actor); - // �t���[���̊Ԋu�ims�j + // フレームの間隔(ms) start(20); }