├── .classpath ├── .project ├── LICENSE ├── README.md ├── lib ├── akjavalibbvh_140528.jar ├── akjavalibgwt-dep_140512.jar ├── akjavastatgwt_120820.jar └── akjavathreegwt_140604_for_r66.jar ├── src └── com │ └── akjava │ └── gwt │ └── bvhtools │ ├── BVHTools.gwt.xml │ └── client │ ├── BVHTools.java │ ├── file │ ├── BVHDataContainer.java │ ├── BVHDataListener.java │ ├── FileDataContainer.java │ ├── TextAreaDataContainer.java │ └── TextDataContainer.java │ ├── player │ ├── list │ │ ├── BVHFileWidget.java │ │ ├── DataListCell.java │ │ ├── FileCell.java │ │ └── FileRenderer.java │ └── resources │ │ ├── Bundles.java │ │ ├── boxsize.txt │ │ ├── small_cmu.txt │ │ └── standard_cmu.txt │ └── tools │ ├── AbstractTool.java │ ├── CalculateTool.java │ ├── MergeTool.java │ ├── MixTool.java │ ├── StripTool.java │ ├── TextTool.java │ └── ThinTool.java └── war ├── BVHTools.css ├── BVHTools.html ├── GWTBVH.html ├── WEB-INF ├── .gitignore ├── lib │ └── gwt-servlet.jar └── web.xml ├── bvhs └── 14 │ └── 14_08.bvh ├── icon.png ├── index.html ├── manifest.json ├── pose.bvh ├── pose_help.html ├── stats.min.js ├── three.min.js └── weight_help.html /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVHTools 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | com.google.gdt.eclipse.core.webAppProjectValidator 15 | 16 | 17 | 18 | 19 | com.google.gwt.eclipse.core.gwtProjectValidator 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | com.google.gwt.eclipse.core.gwtNature 27 | 28 | 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | 204 | 205 | BVH-Tools 206 | 207 | Copyright (C) 2011-2013 aki miyazaki akimisaki3@gmail.com 208 | 209 | Licensed under the Apache License, Version 2.0 (the "License"); 210 | you may not use this file except in compliance with the License. 211 | You may obtain a copy of the License at 212 | 213 | http://www.apache.org/licenses/LICENSE-2.0 214 | 215 | Unless required by applicable law or agreed to in writing, software 216 | distributed under the License is distributed on an "AS IS" BASIS, 217 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 218 | See the License for the specific language governing permissions and 219 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | GWT BVH Motion Creator 2 | === 3 | Current Status 2019 4 | ==== 5 | I switch Focus developing from GWT to Javascript 6 | 7 | below example is almost same(exclude BVH Export) 8 | https://akjava.github.io/ThreeCharacterExamples/WebContent/tools/bone/boneanimation/ 9 | 10 | Goal 11 | ==== 12 | Create tools to create motions/poses easily.*some apps are created.* 13 | 14 | Share free motions/poses.*not shared yet.* 15 | 16 | Release nice apps which use free motions/poses.*nothing released yet.* 17 | Projects 18 | -------- 19 | written by GWT/Java with three.js.Best works on Chrome Browser 20 | 21 | licensed under Apache2.0 22 | ###BVH Motion Tools 23 | repositoly is here [[Demo]](http://game.akjava.com/creator/) 24 | 25 | ![](http://www.akjava.com/img4/bvhtools.jpg) 26 | 27 | this project contain Bvh Player & Bvh Tools. 28 | 29 | ###Pose Editor 30 | [[Github]](https://github.com/akjava/BVH-Pose-Editor) [[WebApp]](http://game.akjava.com/poseeditor/) 31 | 32 | a tools create motion/pose with mouse. 33 | 34 | ###Model Weight 35 | 36 | [[Github]](https://github.com/akjava/GWTModelWeight) [[WebApp]](http://game.akjava.com/weight/weight.html) 37 | 38 | ![](http://www.akjava.com/img4/modelweight.jpg) 39 | 40 | modify weight/index bone-animation of three.js-json model-file. 41 | 42 | etc 43 | ---- 44 | included BVH files from CMU Graphics Lab Motion Capture Database 45 | https://sites.google.com/a/cgspeed.com/cgspeed/motion-capture/cmu-bvh-conversion 46 | 47 | English Web Site(old version) 48 | http://webgl.akjava.com 49 | 50 | Japanese Web Site(old version) 51 | http://webgl.akjava.com/bvh/bvh-motion-creator 52 | -------------------------------------------------------------------------------- /lib/akjavalibbvh_140528.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akjava/BVH-Motion-Creator/fc05cfb750d8edadb5ca94e369b55b9f8d121dfd/lib/akjavalibbvh_140528.jar -------------------------------------------------------------------------------- /lib/akjavalibgwt-dep_140512.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akjava/BVH-Motion-Creator/fc05cfb750d8edadb5ca94e369b55b9f8d121dfd/lib/akjavalibgwt-dep_140512.jar -------------------------------------------------------------------------------- /lib/akjavastatgwt_120820.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akjava/BVH-Motion-Creator/fc05cfb750d8edadb5ca94e369b55b9f8d121dfd/lib/akjavastatgwt_120820.jar -------------------------------------------------------------------------------- /lib/akjavathreegwt_140604_for_r66.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akjava/BVH-Motion-Creator/fc05cfb750d8edadb5ca94e369b55b9f8d121dfd/lib/akjavathreegwt_140604_for_r66.jar -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/BVHTools.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/BVHTools.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client; 2 | 3 | import java.io.IOException; 4 | import java.util.ArrayList; 5 | import java.util.Date; 6 | import java.util.HashMap; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | import com.akjava.bvh.client.BVH; 11 | import com.akjava.bvh.client.BVHMotion; 12 | import com.akjava.bvh.client.BVHNode; 13 | import com.akjava.bvh.client.BVHParser; 14 | import com.akjava.bvh.client.BVHParser.InvalidLineException; 15 | import com.akjava.bvh.client.BVHParser.ParserListener; 16 | import com.akjava.bvh.client.BVHWriter; 17 | import com.akjava.bvh.client.Channels; 18 | import com.akjava.bvh.client.NameAndChannel; 19 | import com.akjava.bvh.client.Vec3; 20 | import com.akjava.gwt.bvh.client.BoxData; 21 | import com.akjava.gwt.bvh.client.BoxDataParser; 22 | import com.akjava.gwt.bvh.client.poseframe.PoseEditorData; 23 | import com.akjava.gwt.bvh.client.poseframe.PoseFrameData; 24 | import com.akjava.gwt.bvh.client.threejs.AnimationBoneConverter; 25 | import com.akjava.gwt.bvh.client.threejs.BVHConverter; 26 | import com.akjava.gwt.bvhtools.client.file.BVHDataContainer; 27 | import com.akjava.gwt.bvhtools.client.file.BVHDataListener; 28 | import com.akjava.gwt.bvhtools.client.file.FileDataContainer; 29 | import com.akjava.gwt.bvhtools.client.file.TextDataContainer; 30 | import com.akjava.gwt.bvhtools.client.player.list.BVHFileWidget; 31 | import com.akjava.gwt.bvhtools.client.player.list.DataListCell; 32 | import com.akjava.gwt.bvhtools.client.player.list.DataListCell.ChangeSelectionListener; 33 | import com.akjava.gwt.bvhtools.client.player.list.DataListCell.DataListRenderer; 34 | import com.akjava.gwt.bvhtools.client.player.resources.Bundles; 35 | import com.akjava.gwt.bvhtools.client.tools.CalculateTool; 36 | import com.akjava.gwt.bvhtools.client.tools.MergeTool; 37 | import com.akjava.gwt.bvhtools.client.tools.MixTool; 38 | import com.akjava.gwt.bvhtools.client.tools.StripTool; 39 | import com.akjava.gwt.bvhtools.client.tools.TextTool; 40 | import com.akjava.gwt.bvhtools.client.tools.ThinTool; 41 | import com.akjava.gwt.html5.client.InputRangeWidget; 42 | import com.akjava.gwt.html5.client.download.HTML5Download; 43 | import com.akjava.gwt.html5.client.extra.HTML5Builder; 44 | import com.akjava.gwt.html5.client.file.File; 45 | import com.akjava.gwt.html5.client.file.FileUploadForm; 46 | import com.akjava.gwt.html5.client.file.FileUtils; 47 | import com.akjava.gwt.html5.client.file.ui.DropVerticalPanelBase; 48 | import com.akjava.gwt.lib.client.IStorageControler; 49 | import com.akjava.gwt.lib.client.LogUtils; 50 | import com.akjava.gwt.lib.client.StorageControler; 51 | import com.akjava.gwt.lib.client.StorageException; 52 | import com.akjava.gwt.three.client.gwt.animation.AnimationBone; 53 | import com.akjava.gwt.three.client.gwt.animation.AnimationBonesData; 54 | import com.akjava.gwt.three.client.gwt.materials.LineBasicMaterialParameter; 55 | import com.akjava.gwt.three.client.gwt.materials.MeshBasicMaterialParameter; 56 | import com.akjava.gwt.three.client.gwt.materials.MeshLambertMaterialParameter; 57 | import com.akjava.gwt.three.client.java.JClock; 58 | import com.akjava.gwt.three.client.java.ui.SimpleTabDemoEntryPoint; 59 | import com.akjava.gwt.three.client.java.utils.Object3DUtils; 60 | import com.akjava.gwt.three.client.js.THREE; 61 | import com.akjava.gwt.three.client.js.core.Geometry; 62 | import com.akjava.gwt.three.client.js.core.Object3D; 63 | import com.akjava.gwt.three.client.js.core.Projector; 64 | import com.akjava.gwt.three.client.js.lights.Light; 65 | import com.akjava.gwt.three.client.js.math.Euler; 66 | import com.akjava.gwt.three.client.js.math.Vector3; 67 | import com.akjava.gwt.three.client.js.objects.Line; 68 | import com.akjava.gwt.three.client.js.objects.Mesh; 69 | import com.akjava.gwt.three.client.js.renderers.WebGLRenderer; 70 | import com.akjava.lib.common.utils.Benchmark; 71 | import com.google.common.collect.Lists; 72 | import com.google.gwt.core.client.GWT; 73 | import com.google.gwt.core.client.JsArray; 74 | import com.google.gwt.dom.client.Style.Unit; 75 | import com.google.gwt.event.dom.client.ChangeEvent; 76 | import com.google.gwt.event.dom.client.ChangeHandler; 77 | import com.google.gwt.event.dom.client.ClickEvent; 78 | import com.google.gwt.event.dom.client.ClickHandler; 79 | import com.google.gwt.event.dom.client.DoubleClickEvent; 80 | import com.google.gwt.event.dom.client.DropEvent; 81 | import com.google.gwt.event.dom.client.DropHandler; 82 | import com.google.gwt.event.dom.client.MouseMoveEvent; 83 | import com.google.gwt.event.dom.client.MouseUpEvent; 84 | import com.google.gwt.event.dom.client.MouseUpHandler; 85 | import com.google.gwt.event.logical.shared.SelectionEvent; 86 | import com.google.gwt.event.logical.shared.SelectionHandler; 87 | import com.google.gwt.event.logical.shared.ValueChangeEvent; 88 | import com.google.gwt.event.logical.shared.ValueChangeHandler; 89 | import com.google.gwt.http.client.Request; 90 | import com.google.gwt.http.client.RequestBuilder; 91 | import com.google.gwt.http.client.RequestCallback; 92 | import com.google.gwt.http.client.RequestException; 93 | import com.google.gwt.http.client.Response; 94 | import com.google.gwt.http.client.URL; 95 | import com.google.gwt.i18n.client.DateTimeFormat; 96 | import com.google.gwt.resources.client.TextResource; 97 | import com.google.gwt.text.shared.Renderer; 98 | import com.google.gwt.user.client.Window; 99 | import com.google.gwt.user.client.ui.Anchor; 100 | import com.google.gwt.user.client.ui.Button; 101 | import com.google.gwt.user.client.ui.CheckBox; 102 | import com.google.gwt.user.client.ui.Frame; 103 | import com.google.gwt.user.client.ui.HorizontalPanel; 104 | import com.google.gwt.user.client.ui.Image; 105 | import com.google.gwt.user.client.ui.Label; 106 | import com.google.gwt.user.client.ui.ListBox; 107 | import com.google.gwt.user.client.ui.PopupPanel; 108 | import com.google.gwt.user.client.ui.ScrollPanel; 109 | import com.google.gwt.user.client.ui.TabLayoutPanel; 110 | import com.google.gwt.user.client.ui.TextBox; 111 | import com.google.gwt.user.client.ui.ValueListBox; 112 | import com.google.gwt.user.client.ui.VerticalPanel; 113 | import com.google.gwt.user.client.ui.Widget; 114 | 115 | /** 116 | * Entry point classes define onModuleLoad(). 117 | */ 118 | 119 | public class BVHTools extends SimpleTabDemoEntryPoint { 120 | private String version="5.1(for r66)"; 121 | public static DateTimeFormat dateFormat=DateTimeFormat.getFormat("yy/MM/dd HH:mm"); 122 | private static BVHTools bvhTools; 123 | public static BVHTools getInstance(){ 124 | return bvhTools; 125 | } 126 | final Projector projector=THREE.Projector(); 127 | @Override 128 | public void onMouseClick(ClickEvent event) { 129 | /* TODO future 130 | int x=event.getX(); 131 | int y=event.getY(); 132 | 133 | 134 | JsArray intersects=projector.gwtPickIntersects(event.getX(), event.getY(), screenWidth, screenHeight, camera,scene); 135 | 136 | for(int i=0;i boneSizeMap=new HashMap(); 164 | 165 | private Object3D rootGroup,boneContainer,backgroundContainer; 166 | 167 | private Map boxDatas; 168 | private VerticalPanel datasPanel; 169 | private IStorageControler storageControler; 170 | @Override 171 | public void initializeOthers(WebGLRenderer renderer) { 172 | LogUtils.log("BVHTools version:"+version); 173 | loadDefaultBVH("pose.bvh"); //i forgot what is this?maybe for some slow network 174 | storageControler = new StorageControler(); 175 | bvhTools=this; 176 | cameraY=10; 177 | defaultZoom=5; 178 | 179 | 180 | renderer.setClearColor(0, 0);//use transparent 181 | canvas.setBackground(0xcccccc); 182 | 183 | 184 | //boxDatas=new BoxDataParser().parse(Bundles.INSTANCE.boxsize().getText()); 185 | boxDatas=new HashMap(); 186 | 187 | scene.add(THREE.AmbientLight(0x888888)); 188 | Light pointLight = THREE.PointLight(0xffffff); 189 | pointLight.setPosition(0, 10, 300); 190 | scene.add(pointLight); 191 | 192 | doLoad("14_08"); 193 | 194 | rootGroup=THREE.Object3D(); 195 | scene.add(rootGroup); 196 | 197 | backgroundContainer=THREE.Object3D(); 198 | rootGroup.add(backgroundContainer); 199 | 200 | Geometry geo=THREE.PlaneGeometry(100, 100,20,20); 201 | Mesh mesh=THREE.Mesh(geo, THREE.MeshBasicMaterial().color(0x666666).wireFrame(true).build()); 202 | //mesh.setPosition(0, -17, 0); 203 | mesh.getRotation().set(Math.toRadians(-90), 0, 0,Euler.XYZ); 204 | backgroundContainer.add(mesh); 205 | 206 | boneContainer=THREE.Object3D(); 207 | rootGroup.add(boneContainer); 208 | /* 209 | BVHParser parser=new BVHParser(); 210 | //String singleBvh=Bundles.INSTANCE.single_basic().getText(); 211 | //String singleBvh=Bundles.INSTANCE.twolink_n_rz().getText(); 212 | //String singleBvh=Bundles.INSTANCE.twolink_full().getText(); 213 | //String singleBvh=Bundles.INSTANCE.fourlink_branch().getText(); 214 | String singleBvh=Bundles.INSTANCE.twelve01().getText(); 215 | try { 216 | jointMap=new HashMap(); 217 | bvh = parser.parse(singleBvh); 218 | BVHNode node=bvh.getHiearchy(); 219 | 220 | root=THREE.Object3D(); 221 | scene.add(root); 222 | doLog(root,node); 223 | 224 | // 225 | //jointMap.get("Hips").setRotation(Math.toRadians(7.1338),Math.toRadians(-1.8542),Math.toRadians( -7.8190)); 226 | 227 | //doPose(bvh,"-0.3899 17.5076 7.8007 0 0 0 0 0 0 -21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -16 0 0 21 0 0 11 0 0 0 -8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"); 228 | //doPose(bvh,"-0.3899 17.5076 7.8007 -7.8190 -1.8542 7.1338 0.0000 0.0000 0.0000 -20.0095 -34.8717 23.1818 0.0543 -1.5040 -4.1368 -5.1851 39.6153 -34.2618 0.1274 2.3012 6.3387 0.0000 0.0000 0.0000 27.9815 23.6282 8.6217 -0.0094 -0.6245 1.7162 0.4741 -16.6281 -18.3131 -0.0041 -0.4123 1.1330 4.5929 -0.1445 3.0131 1.7537 0.3513 -8.5234 -0.7284 -0.1282 -10.7842 -14.7495 -15.2891 1.4491 15.1151 -23.2999 16.3175 5.0944 -11.3477 8.3590 -0.0000 -0.0000 0.0000 -91.7499 11.2503 9.6316 11.7870 -19.4845 -2.0307 -0.0000 -0.0000 23.6415 17.7243 -7.2146 -2.2985 -7.1250 0.0000 -0.0000 -6.6264 22.4256 3.6210 -0.0000 -0.0000 0.0000 92.9366 -10.7837 -16.0742 -9.0830 15.2927 -1.2219 0.0000 0.0000 58.8395 3.1909 -29.5170 -1.5733 7.1250 -0.0000 -0.0000 36.2824 -55.5617 -10.3909"); 229 | //doPose(bvh,"-0.5011 17.6282 7.6163 -6.2586 -15.2051 5.4723 0.0000 0.0000 0.0000 -21.3981 -26.0192 22.4790 0.0292 -1.1029 -3.0320 -3.3535 38.5451 -41.4272 0.6169 5.0265 13.9840 0.0000 0.0000 0.0000 24.7397 22.1958 5.0034 -0.0966 -2.0046 5.5183 -0.3873 -3.4522 -13.5373 -0.2228 3.0387 -8.3865 3.1625 -2.9263 2.2948 2.9237 -3.5238 -7.9690 1.7270 -1.8496 -9.7328 3.3763 2.5058 -7.4595 13.0244 0.5160 17.4961 3.6704 1.4696 6.5682 -0.0000 0.0000 0.0000 -42.7751 -56.6315 -8.6834 50.4538 -53.1769 -26.5370 -0.0000 0.0000 -77.6575 14.7878 7.4808 1.9684 -7.1250 0.0000 -0.0000 -10.2345 37.5343 1.9047 -0.0000 0.0000 0.0000 76.3877 59.4476 93.5538 -141.2974 47.2822 -102.5201 0.0000 -0.0000 -31.1956 -12.8820 -58.8974 11.0797 7.1250 -0.0000 -0.0000 91.0580 -76.5215 -77.2227"); 230 | doPose(bvh,bvh.getMotion().getMotions().get(0)); 231 | Matrix4 mx=THREE.Matrix4(); 232 | mx.setRotationFromEuler(THREE.Vector3(Math.toRadians(23.1818),Math.toRadians(-34.8717),Math.toRadians(-20.0095)), "ZYX"); 233 | Vector3 rot=THREE.Vector3(0, 0, 0); 234 | rot.setRotationFromMatrix(mx); 235 | double x=Math.toDegrees(rot.getX()); 236 | double y=Math.toDegrees(rot.getY()); 237 | double z=Math.toDegrees(rot.getZ()); 238 | GWT.log(x+","+y+","+z); 239 | //jointMap.get("LeftUpLeg").setRotation(rot.getX(), rot.getY(), rot.getZ()); 240 | //jointMap.get("LeftUpLeg").setRotation(Math.toRadians(23.1818),Math.toRadians(-34.8717),Math.toRadians(-20.0095)); 241 | //jointMap.get("RightUpLeg").getRotation(Math.toRadians(23.1818),Math.toRadians(-34.8717),Math.toRadians(-20.0095)); 242 | } catch (InvalidLineException e) { 243 | log(e.getMessage()); 244 | e.printStackTrace(); 245 | } 246 | */ 247 | // ctime=System.currentTimeMillis(); 248 | 249 | tabPanel.addSelectionHandler(new SelectionHandler() { 250 | 251 | @Override 252 | public void onSelection(SelectionEvent event) { 253 | int selection=event.getSelectedItem(); 254 | if(selection==0){ 255 | stats.setVisible(true); 256 | showControl(); 257 | popupPanel.setVisible(true); 258 | }else{ 259 | stats.setVisible(false); 260 | hideControl(); 261 | popupPanel.setVisible(false); 262 | } 263 | } 264 | }); 265 | 266 | toolsPanel = new TabLayoutPanel(24,Unit.PX); 267 | tabPanel.add(toolsPanel,"Tools"); 268 | 269 | //data is not compatible anymore 270 | //createDataPanel(); 271 | 272 | //no need experimental 273 | //createExperimentalPanel(); 274 | 275 | new MergeTool(createTabVerticalPanel("Merge")); 276 | new ThinTool(createTabVerticalPanel("ThinOut")); 277 | new StripTool(createTabVerticalPanel("Strip")); 278 | new MixTool(createTabVerticalPanel("Mix")); 279 | new CalculateTool(createTabVerticalPanel("Calculate")); 280 | new TextTool(createTabVerticalPanel("Text")); 281 | 282 | updateDatasPanel(); 283 | } 284 | 285 | private void createExperimentalPanel(){ 286 | VerticalPanel expRoot=new VerticalPanel(); 287 | tabPanel.add(expRoot,"Experimental"); 288 | 289 | 290 | Frame doc1=new Frame("pose_help.html"); 291 | doc1.setSize("500px", "200px"); 292 | Button bt1=new Button("Open Pose Editor"); 293 | bt1.addClickHandler(new ClickHandler() { 294 | @Override 295 | public void onClick(ClickEvent event) { 296 | Window.open("pose.html", "posetool", null); 297 | } 298 | }); 299 | expRoot.add(doc1); 300 | expRoot.add(bt1); 301 | 302 | Frame doc=new Frame("weight_help.html"); 303 | doc.setSize("500px", "200px"); 304 | Button bt=new Button("Open Model Weight Tool"); 305 | bt.addClickHandler(new ClickHandler() { 306 | @Override 307 | public void onClick(ClickEvent event) { 308 | Window.open("weight.html", "weighttool", null); 309 | } 310 | }); 311 | expRoot.add(doc); 312 | expRoot.add(bt); 313 | } 314 | 315 | private void createDataPanel(){ 316 | VerticalPanel datasRoot=new VerticalPanel(); 317 | 318 | tabPanel.add(datasRoot,"Datas"); 319 | datasPanel = new VerticalPanel(); 320 | 321 | //datasPanel.setStyleName("debug"); 322 | ScrollPanel scroll=new ScrollPanel(datasPanel); 323 | scroll.setSize("550px", "400px"); 324 | 325 | HorizontalPanel control=new HorizontalPanel(); 326 | datasRoot.add(control); 327 | Button load=new Button("Load Checked Datas"); 328 | control.add(load); 329 | load.addClickHandler(new ClickHandler() { 330 | @Override 331 | public void onClick(ClickEvent event) { 332 | List datas=new ArrayList(); 333 | int size=datasPanel.getWidgetCount(); 334 | for(int i=0;i=0;i--){ 403 | String b64=storageControler.getValue(PoseEditorData.KEY_IMAGE+i,null); 404 | String json=storageControler.getValue(PoseEditorData.KEY_DATA+i,null); 405 | String head=storageControler.getValue(PoseEditorData.KEY_HEAD+i,null); 406 | if(b64!=null && json!=null){ 407 | DataPanel dp=new DataPanel(i,head,b64,json); 408 | //dp.setSize("200px", "200px"); 409 | datasPanel.add(dp); 410 | } 411 | } 412 | }catch (StorageException e) { 413 | Window.alert("faild getValue:"+e.getMessage()); 414 | } 415 | } 416 | 417 | public class DataPanel extends HorizontalPanel{ 418 | private int index; 419 | private String name; 420 | private long cdate; 421 | private String json; 422 | private CheckBox check; 423 | public DataPanel(final int ind,String head,String base64, String text){ 424 | json=text; 425 | this.index=ind; 426 | Image img=new Image(); 427 | img.setUrl(base64); 428 | 429 | 430 | String name_cdate[]=head.split("\t"); 431 | name=name_cdate[0]; 432 | cdate=(long)(Double.parseDouble(name_cdate[1])); 433 | 434 | String dlabel=dateFormat.format(new Date(cdate)); 435 | add(new Label(dlabel)); 436 | add(img); 437 | 438 | final Label nameLabel=new Label(name); 439 | nameLabel.setWidth("160px"); 440 | add(nameLabel); 441 | 442 | check = new CheckBox(); 443 | add(check); 444 | 445 | Button loadBt=new Button("Load"); 446 | add(loadBt); 447 | loadBt.addClickHandler(new ClickHandler() { 448 | 449 | @Override 450 | public void onClick(ClickEvent event) { 451 | 452 | PoseEditorData ped=getPoseEditorData(); 453 | 454 | 455 | if(ped!=null){ 456 | doLoadPoseEditorData(ped); 457 | }else{ 458 | //TODO error catch 459 | Window.alert("load faild"); 460 | } 461 | } 462 | }); 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | } 471 | public void setChecked(boolean bool){ 472 | check.setValue(bool); 473 | } 474 | public PoseEditorData getPoseEditorData(){ 475 | PoseEditorData ped=PoseEditorData.readData(json); 476 | if(ped!=null){ 477 | ped.setFileId(index); 478 | } 479 | return ped; 480 | } 481 | public boolean isChecked(){ 482 | return check.getValue(); 483 | } 484 | 485 | public String getJson(){ 486 | return json; 487 | } 488 | public String getName(){ 489 | return name; 490 | } 491 | 492 | 493 | protected void doLoadPoseEditorData(PoseEditorData ped) { 494 | 495 | 496 | 497 | //parseBVH(); 498 | 499 | TextDataContainer dataContainer=new TextDataContainer(name, convertPoseEditorDataToBVH(ped,bvhForData)); 500 | addBVHData(dataContainer); 501 | 502 | } 503 | 504 | 505 | } 506 | 507 | private VerticalPanel createTabVerticalPanel(String name){ 508 | VerticalPanel panel=new VerticalPanel(); 509 | toolsPanel.add(panel,name); 510 | return panel; 511 | } 512 | 513 | private void doRotation(Object3D target,String lastOrder){ 514 | //log(target.getName()+",order="+lastOrder+" "+ThreeLog.get(GWTThreeUtils.radiantToDegree(target.getRotation()))); 515 | target.getRotation().setOrder(lastOrder); 516 | /* 517 | Matrix4 mx=THREE.Matrix4(); 518 | mx.setRotationFromEuler(vec, lastOrder); 519 | vec.setRotationFromMatrix(mx);//in this here,miss rotation because of over 90? 520 | */ 521 | 522 | } 523 | /* 524 | private void doPose(BVH bvh,String line){ 525 | String[] tmp=line.split(" "); 526 | double[] vs=BVHParser.toDouble(tmp); 527 | Object3D oldTarget=null; 528 | String lastOrder=null; 529 | for(int i=0;i bones=boneConverter.convertJsonBone(bvh); 557 | AnimationBonesData ab=new AnimationBonesData(bones, null); 558 | ped.updateMatrix(ab);//current-bone 559 | 560 | BVH exportBVH=new BVH(); 561 | 562 | BVHConverter converter=new BVHConverter(); 563 | BVHNode node=converter.convertBVHNode(bones); 564 | 565 | exportBVH.setHiearchy(node); 566 | 567 | converter.setChannels(node,0,"XYZ"); //TODO support other order 568 | 569 | 570 | BVHMotion motion=new BVHMotion(); 571 | motion.setFrameTime(.25); 572 | 573 | for(PoseFrameData pose:ped.getPoseFrameDatas()){ 574 | double[] values=converter.angleAndMatrixsToMotion(pose.getAngleAndMatrixs(),BVHConverter.ROOT_POSITION_ROTATE_ONLY,"XYZ"); 575 | motion.add(values); 576 | } 577 | motion.setFrames(motion.getMotions().size());// 578 | 579 | exportBVH.setMotion(motion); 580 | //log("frames:"+exportBVH.getFrames()); 581 | BVHWriter writer=new BVHWriter(); 582 | 583 | String bvhText=writer.writeToString(exportBVH); 584 | return bvhText; 585 | } 586 | private void doPose(BVH bvh,double[] vs){ 587 | Object3D oldTarget=null; 588 | String lastOrder=null; 589 | for(int i=0;i jointMap; 637 | 638 | public Line createLine(Vec3 from,Vec3 to){ 639 | Geometry lineG = THREE.Geometry(); 640 | lineG.vertices().push(THREE.Vector3(from.getX(), from.getY(), from.getY())); 641 | lineG.vertices().push(THREE.Vector3(to.getX(), to.getY(), to.getZ())); 642 | Line line=THREE.Line(lineG, THREE.LineBasicMaterial(LineBasicMaterialParameter.create().color(0))); 643 | return line; 644 | } 645 | 646 | private List bodyMeshs=new ArrayList(); 647 | 648 | 649 | double baseBoneSize=0.4; 650 | String tmp=""; 651 | public void doJoint(Object3D parent,BVHNode pNode,BVHNode node){ 652 | 653 | 654 | if(pNode!=null){ 655 | LogUtils.log(pNode.getName()+","+node.getName()); 656 | }else{ 657 | LogUtils.log(null+","+node.getName()); 658 | } 659 | 660 | GWT.log(node.getName()+","+node.getOffset()+",endsite:"+node.getEndSite()); 661 | GWT.log(node.getChannels().toString()); 662 | 663 | Object3D group=THREE.Object3D(); 664 | Mesh mesh=THREE.Mesh(THREE.CubeGeometry(baseBoneSize,baseBoneSize,baseBoneSize), THREE.MeshLambertMaterial(MeshLambertMaterialParameter.create().color(0x00ff00))); 665 | group.add(mesh); 666 | mesh.setName(node.getName()); 667 | group.setName(node.getName()); 668 | //initial position 669 | group.setPosition(THREE.Vector3(node.getOffset().getX(), node.getOffset().getY(), node.getOffset().getZ())); 670 | jointMap.put(node.getName(), group); 671 | 672 | //create half 673 | Vector3 half=group.getPosition().clone(); 674 | if(half.getX()!=0 || half.getY()!=0 || half.getY()!=0){ 675 | half.divideScalar(2); 676 | //Mesh hmesh=THREE.Mesh(THREE.CubeGeometry(.2,.2,.2), THREE.MeshLambertMaterial().color(0xffffff).build()); 677 | Mesh halfMesh=THREE.Mesh(THREE.CylinderGeometry(baseBoneSize/4,baseBoneSize/4,baseBoneSize/2,6), THREE.MeshLambertMaterial(MeshLambertMaterialParameter.create().color(0xffffff))); 678 | 679 | halfMesh.setPosition(half); 680 | 681 | if(pNode!=null){ 682 | parent.add(halfMesh); 683 | bodyMeshs.add(halfMesh); 684 | 685 | } 686 | 687 | 688 | 689 | 690 | if(pNode!=null){ 691 | tmp+=pNode.getName()+",1,1,1\n"; 692 | 693 | 694 | //this is supported-bone structor. 695 | BoxData data=boxDatas.get(pNode.getName());// 696 | if(data!=null){ 697 | halfMesh.setScale(data.getScaleX(), data.getScaleY(), data.getScaleZ()); 698 | halfMesh.getRotation().setZ(Math.toRadians(data.getRotateZ())); 699 | } 700 | } 701 | 702 | 703 | } 704 | 705 | //line 706 | Line lineMesh=createLine(new Vec3(),node.getOffset()); 707 | 708 | if(pNode!=null){ 709 | parent.add(lineMesh); 710 | } 711 | 712 | if(node.getEndSite()!=null){ 713 | Mesh end=THREE.Mesh(THREE.CubeGeometry(baseBoneSize/4,baseBoneSize/4,baseBoneSize/4), THREE.MeshBasicMaterial(MeshBasicMaterialParameter.create().color(0x008800))); 714 | end.setPosition(THREE.Vector3(node.getEndSite().getX(), node.getEndSite().getY(), node.getEndSite().getZ())); 715 | group.add(end); 716 | Geometry lineG = THREE.Geometry(); 717 | lineG.vertices().push(THREE.Vector3(0, 0, 0)); 718 | lineG.vertices().push(THREE.Vector3(node.getEndSite().getX(), node.getEndSite().getY(), node.getEndSite().getZ())); 719 | Line line=THREE.Line(lineG, THREE.LineBasicMaterial(LineBasicMaterialParameter.create().color(0))); 720 | group.add(line); 721 | 722 | Vector3 half2=end.getPosition().clone(); 723 | if(half2.getX()!=0 || half2.getY()!=0 || half2.getY()!=0){ 724 | half2.divideScalar(2); 725 | //Mesh hmesh=THREE.Mesh(THREE.CubeGeometry(.1,.1,.1), THREE.MeshLambertMaterial().color(0xffffff).build()); 726 | Mesh hmesh=THREE.Mesh(THREE.CylinderGeometry(baseBoneSize/4,baseBoneSize/4,baseBoneSize/2,6), THREE.MeshLambertMaterial(MeshLambertMaterialParameter.create().color(0xffffff))); 727 | 728 | hmesh.setPosition(half2); 729 | group.add(hmesh); 730 | 731 | tmp+=node.getName()+",1,1,1\n"; 732 | 733 | //this is special treatment for bone. 734 | BoxData data=boxDatas.get(node.getName()); 735 | if(data!=null){ 736 | hmesh.setScale(data.getScaleX(), data.getScaleY(), data.getScaleZ()); 737 | } 738 | if(node.getName().equals("Head")){//why need this? 739 | // hmesh.getPosition().setZ(hmesh.getPosition().getZ()+0.5); 740 | } 741 | 742 | bodyMeshs.add(hmesh); 743 | 744 | } 745 | } 746 | parent.add(group); 747 | List joints=node.getJoints(); 748 | if(joints!=null){ 749 | for(BVHNode joint:joints){ 750 | doJoint(group,node,joint); 751 | } 752 | } 753 | 754 | } 755 | 756 | 757 | private Label loadingLabel=new Label(); 758 | private CheckBox translatePosition; 759 | private InputRangeWidget positionYRange; 760 | private InputRangeWidget meshScaleX; 761 | private InputRangeWidget meshScaleY; 762 | private InputRangeWidget meshScaleZ; 763 | private InputRangeWidget positionX; 764 | private InputRangeWidget positionY; 765 | private InputRangeWidget positionZ; 766 | private PopupPanel bottomPanel; 767 | protected boolean playing; 768 | private InputRangeWidget positionXRange; 769 | 770 | private InputRangeWidget positionZRange; 771 | 772 | private CheckBox drawBackground; 773 | 774 | private void loadBVH(String path){ 775 | Benchmark.start("load"); 776 | RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(path)); 777 | loadingLabel.setText("loading-data"); 778 | try { 779 | builder.sendRequest(null, new RequestCallback() { 780 | 781 | @Override 782 | public void onResponseReceived(Request request, Response response) { 783 | 784 | String bvhText=response.getText(); 785 | //log("loaded:"+Benchmark.end("load")); 786 | //useless spend allmost time with request and spliting. 787 | parseBVH(bvhText); 788 | loadingLabel.setText(""); 789 | } 790 | 791 | 792 | 793 | 794 | @Override 795 | public void onError(Request request, Throwable exception) { 796 | Window.alert("load faild:"); 797 | } 798 | }); 799 | } catch (RequestException e) { 800 | LogUtils.log(e.getMessage()); 801 | e.printStackTrace(); 802 | } 803 | } 804 | 805 | private void setEmptyBone(){ 806 | if(boneRoot!=null){ 807 | boneContainer.remove(boneRoot); 808 | } 809 | boneRoot=null; 810 | bvh=null; 811 | } 812 | 813 | //TODO can choose in preference 814 | private BVH bvhForData; 815 | private void loadDefaultBVH(final String path){ 816 | RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(path)); 817 | try { 818 | builder.sendRequest(null, new RequestCallback() { 819 | 820 | @Override 821 | public void onResponseReceived(Request request, Response response) { 822 | 823 | String bvhText=response.getText(); 824 | BVHParser parser=new BVHParser(); 825 | try { 826 | bvhForData= parser.parse(bvhText); 827 | } catch (InvalidLineException e) { 828 | LogUtils.log("invalid bvh:"+e.getMessage()); 829 | e.printStackTrace(); 830 | } 831 | } 832 | 833 | 834 | 835 | 836 | @Override 837 | public void onError(Request request, Throwable exception) { 838 | Window.alert("load faild:"+path); 839 | } 840 | }); 841 | } catch (RequestException e) { 842 | LogUtils.log(e.getMessage()); 843 | e.printStackTrace(); 844 | } 845 | } 846 | 847 | private void setBVH(BVH bv){ 848 | bvh=bv; 849 | bvh.setSkips(skipFrames); 850 | 851 | BVHNode node=bvh.getHiearchy(); 852 | 853 | if(boneRoot!=null){ 854 | boneContainer.remove(boneRoot); 855 | } 856 | boneRoot=THREE.Object3D(); 857 | boneContainer.add(boneRoot); 858 | 859 | //possible bone root is not 0 860 | boneRoot.setPosition(node.getOffset().getX(),node.getOffset().getY(),node.getOffset().getZ()); 861 | 862 | 863 | doJoint(boneRoot,null,node); 864 | //GWT.log(tmp); 865 | int poseIndex=0; 866 | GWT.log("f-size:"+bvh.getFrames()); 867 | if(ignoreFirst.getValue() && bvh.getFrames()>1){ 868 | poseIndex=1; 869 | } 870 | 871 | 872 | clock.update(); 873 | updatePoseIndex(poseIndex); 874 | doPose(bvh,bvh.getFrameAt(poseIndex)); 875 | currentFrameRange.setMax(bvh.getFrames()-1); 876 | } 877 | 878 | private void parseBVH(String bvhText){ 879 | final BVHParser parser=new BVHParser(); 880 | jointMap=new HashMap(); 881 | 882 | parser.parseAsync(bvhText, new ParserListener() { 883 | 884 | @Override 885 | public void onSuccess(BVH bv) { 886 | setBVH(bv); 887 | } 888 | 889 | @Override 890 | public void onFaild(String message) { 891 | LogUtils.log(message); 892 | } 893 | }); 894 | } 895 | 896 | /* timer style 897 | * parser.initialize(); 898 | bvhText=bvhText.replace("\r", ""); 899 | final String lines[]=bvhText.split("\n"); 900 | final int pLine=lines.length/20; 901 | Timer timer=new Timer(){ 902 | int index=0; 903 | boolean parsing; 904 | @Override 905 | public synchronized void run() { 906 | if(parsing){ 907 | return; 908 | } 909 | parsing=true; 910 | loadingLabel.setText(index+"/"+lines.length); 911 | GWT.log("called:"+index+","+pLine); 912 | try { 913 | parser.parseLines(lines, index, index+pLine); 914 | if(index>=lines.length){ 915 | //done 916 | bvh=parser.getBvh(); 917 | BVHNode node=bvh.getHiearchy(); 918 | 919 | if(root!=null){ 920 | scene.remove(root); 921 | } 922 | root=THREE.Object3D(); 923 | scene.add(root); 924 | doLog(root,node); 925 | 926 | doPose(bvh,bvh.getMotion().getMotions().get(0)); 927 | poseIndex=0; 928 | cancel(); 929 | }else{ 930 | index+=pLine; 931 | } 932 | } catch (InvalidLineException e) { 933 | log(e.getMessage()); 934 | } 935 | 936 | parsing=false; 937 | 938 | 939 | } 940 | 941 | }; 942 | timer.scheduleRepeating(20); 943 | */ 944 | 945 | private long getFrameTime(int index){ 946 | long time=(long) (bvh.getFrameTime()*index*1000); 947 | return time; 948 | } 949 | 950 | private double getPlaySpeed(){ 951 | String v=speedBox.getItemText(speedBox.getSelectedIndex()); 952 | double r=1; 953 | try{ 954 | r=Double.parseDouble(v.substring(2)); 955 | }catch(Exception e){} 956 | return r; 957 | } 958 | 959 | private double playSpeed=1; 960 | private void createBottomPanel(){ 961 | bottomPanel = new PopupPanel(); 962 | bottomPanel.setVisible(true); 963 | bottomPanel.setSize("650px", "40px"); 964 | VerticalPanel main=new VerticalPanel(); 965 | bottomPanel.add(main); 966 | bottomPanel.show(); 967 | 968 | 969 | HorizontalPanel upperPanel=new HorizontalPanel(); 970 | upperPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); 971 | main.add(upperPanel); 972 | upperPanel.add(new Label("Speed")); 973 | speedBox = new ListBox(); 974 | speedBox.addItem("x 0.25"); 975 | speedBox.addItem("x 0.5"); 976 | speedBox.addItem("x 1"); 977 | speedBox.addItem("x 2"); 978 | speedBox.addItem("x 4"); 979 | speedBox.addItem("x 10"); 980 | speedBox.setSelectedIndex(2); 981 | speedBox.addChangeHandler(new ChangeHandler() { 982 | 983 | @Override 984 | public void onChange(ChangeEvent event) { 985 | playSpeed=getPlaySpeed(); 986 | } 987 | }); 988 | upperPanel.add(speedBox); 989 | 990 | 991 | abLoopCheck = new CheckBox("A/B Loop"); 992 | upperPanel.add(abLoopCheck); 993 | 994 | 995 | 996 | final Button asA=new Button("A:"); 997 | asA.setWidth("60px"); 998 | upperPanel.add(asA); 999 | asA.addClickHandler(new ClickHandler() { 1000 | 1001 | @Override 1002 | public void onClick(ClickEvent event) { 1003 | aFrame=currentFrameRange.getValue(); 1004 | asA.setText("A:"+(aFrame+1)); 1005 | } 1006 | }); 1007 | 1008 | final Button asB=new Button("B:"); 1009 | asB.setWidth("60px"); 1010 | upperPanel.add(asB); 1011 | asB.addClickHandler(new ClickHandler() { 1012 | 1013 | @Override 1014 | public void onClick(ClickEvent event) { 1015 | bFrame=currentFrameRange.getValue(); 1016 | asB.setText("B:"+(bFrame+1)); 1017 | } 1018 | }); 1019 | 1020 | upperPanel.add(new Label("Skip every frame:")); 1021 | final TextBox skipFrameBox=new TextBox(); 1022 | skipFrameBox.setWidth("40px"); 1023 | upperPanel.add(skipFrameBox); 1024 | 1025 | Button updateSkipBt=new Button("Update skips"); 1026 | upperPanel.add(updateSkipBt); 1027 | updateSkipBt.addClickHandler(new ClickHandler() { 1028 | 1029 | @Override 1030 | public void onClick(ClickEvent event) { 1031 | String v=skipFrameBox.getValue(); 1032 | 1033 | int sp=0; 1034 | try{ 1035 | sp=Integer.parseInt(v); 1036 | }catch(Exception e){ 1037 | } 1038 | setBvhSkips(sp); 1039 | } 1040 | }); 1041 | 1042 | 1043 | HorizontalPanel pPanel=new HorizontalPanel(); 1044 | main.add(pPanel); 1045 | pPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); 1046 | 1047 | 1048 | 1049 | 1050 | 1051 | 1052 | playing=true; 1053 | final Button playButton=new Button("Play"); 1054 | playButton.setEnabled(false); 1055 | final Button stopButton=new Button("Stop"); 1056 | 1057 | playButton.addClickHandler(new ClickHandler() { 1058 | 1059 | @Override 1060 | public void onClick(ClickEvent event) { 1061 | clock.update(); 1062 | //ctime=System.currentTimeMillis()-getFrameTime(); 1063 | playing=true; 1064 | playButton.setEnabled(false); 1065 | stopButton.setEnabled(true); 1066 | 1067 | } 1068 | }); 1069 | pPanel.add(playButton); 1070 | 1071 | 1072 | stopButton.addClickHandler(new ClickHandler() { 1073 | 1074 | @Override 1075 | public void onClick(ClickEvent event) { 1076 | playing=false; 1077 | playButton.setEnabled(true); 1078 | stopButton.setEnabled(false); 1079 | } 1080 | }); 1081 | 1082 | pPanel.add(stopButton); 1083 | 1084 | final Button prevButton=new Button("Prev"); 1085 | 1086 | prevButton.addClickHandler(new ClickHandler() { 1087 | @Override 1088 | public void onClick(ClickEvent event) { 1089 | int c=currentFrameRange.getValue(); 1090 | c--; 1091 | /* 1092 | if(c==0 && ignoreFirst.getValue()){ 1093 | c=1; 1094 | }*/ 1095 | 1096 | if(c<0){ 1097 | c=0; 1098 | } 1099 | currentFrameRange.setValue(c); 1100 | updatePoseIndex(currentFrameRange.getValue()); 1101 | } 1102 | }); 1103 | 1104 | pPanel.add(prevButton); 1105 | 1106 | final Button nextButton=new Button("Next"); 1107 | nextButton.addClickHandler(new ClickHandler() { 1108 | @Override 1109 | public void onClick(ClickEvent event) { 1110 | int c=currentFrameRange.getValue(); 1111 | c++; 1112 | if(c>=bvh.getFrames()){ 1113 | c=bvh.getFrames()-1; 1114 | } 1115 | currentFrameRange.setValue(c); 1116 | updatePoseIndex(currentFrameRange.getValue()); 1117 | } 1118 | }); 1119 | 1120 | pPanel.add(nextButton); 1121 | 1122 | 1123 | 1124 | 1125 | currentFrameRange = InputRangeWidget.createInputRange(0,1000,0); 1126 | currentFrameRange.setWidth("420px"); 1127 | pPanel.add(currentFrameRange); 1128 | 1129 | currentFrameRange.addMouseUpHandler(new MouseUpHandler() { 1130 | 1131 | @Override 1132 | public void onMouseUp(MouseUpEvent event) { 1133 | 1134 | updatePoseIndex(currentFrameRange.getValue()); 1135 | } 1136 | }); 1137 | 1138 | currentFrameLabel = new Label(); 1139 | pPanel.add(currentFrameLabel); 1140 | 1141 | super.leftBottom(bottomPanel); 1142 | } 1143 | private int aFrame; 1144 | private int bFrame; 1145 | 1146 | 1147 | private int skipFrames; 1148 | 1149 | private CheckBox drawMesh; 1150 | private void setBvhSkips(int skips){ 1151 | //TODO 1152 | //set global for newload 1153 | skipFrames=skips; 1154 | //set current bvh 1155 | bvh.setSkips(skips); 1156 | 1157 | updatePoseIndex(0); 1158 | currentFrameRange.setMax(bvh.getFrames()-1); 1159 | //update labels 1160 | } 1161 | private JsArray lastSelectedFiles; 1162 | 1163 | private BVHDataListener bvhDataListener; 1164 | @Override 1165 | public void createControl(DropVerticalPanelBase parent) { 1166 | bvhDataListener=new BVHDataListener() { 1167 | 1168 | @Override 1169 | public void dataLoaded(String text) { 1170 | parseBVH(text); 1171 | } 1172 | }; 1173 | parent.add(loadingLabel); 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | parent.add(new Label("Load BVH File")); 1181 | final FileUploadForm file=new FileUploadForm(); 1182 | file.setAccept(".bvh"); 1183 | 1184 | file.getFileUpload().setHeight("50px"); 1185 | file.getFileUpload().getElement().setAttribute("multiple", "multiple"); 1186 | 1187 | 1188 | parent.addDropHandler(new DropHandler() { 1189 | @Override 1190 | public void onDrop(DropEvent event) { 1191 | event.preventDefault(); 1192 | //final FileReader reader=FileReader.createFileReader(); 1193 | lastSelectedFiles=FileUtils.transferToFile(event.getNativeEvent()); 1194 | 1195 | FileDataContainer firstOne=null; 1196 | for(int i=0;i(new DataListRenderer(){ 1303 | @Override 1304 | public Widget createWidget(BVHDataContainer data,DataListCell dataList) { 1305 | 1306 | return new BVHFileWidget(data,dataList); 1307 | }}); 1308 | dataListCell.setHeight("60px"); 1309 | parent.add(dataListCell); 1310 | dataListCell.setListener(new ChangeSelectionListener() { 1311 | @Override 1312 | public void onChangeSelection(BVHDataContainer data) { 1313 | 1314 | /* 1315 | final FileReader reader=FileReader.createFileReader(); 1316 | reader.setOnLoad(new FileHandler() { 1317 | @Override 1318 | public void onLoad() { 1319 | parseBVH(reader.getResultAsString()); 1320 | } 1321 | }); 1322 | reader.readAsText(data,"utf-8"); 1323 | */ 1324 | data.readText(bvhDataListener); 1325 | } 1326 | }); 1327 | HorizontalPanel dataControls=new HorizontalPanel(); 1328 | parent.add(dataControls); 1329 | Button remove=new Button("Remove"); 1330 | remove.addClickHandler(new ClickHandler() { 1331 | 1332 | @Override 1333 | public void onClick(ClickEvent event) { 1334 | if(bvhFileList.size()==0){ 1335 | return; 1336 | } 1337 | BVHDataContainer file=dataListCell.getSelection(); 1338 | int index=bvhFileList.indexOf(file); 1339 | bvhFileList.remove(file); 1340 | if(index>=bvhFileList.size()){ 1341 | index=0; 1342 | } 1343 | dataListCell.setDatas(bvhFileList); 1344 | if(bvhFileList.size()!=0){ 1345 | dataListCell.setSelection(bvhFileList.get(index)); 1346 | }else{ 1347 | setEmptyBone(); 1348 | } 1349 | } 1350 | }); 1351 | dataControls.add(remove); 1352 | 1353 | Button removeAll=new Button("Remove All"); 1354 | removeAll.addClickHandler(new ClickHandler() { 1355 | 1356 | @Override 1357 | public void onClick(ClickEvent event) { 1358 | if(bvhFileList.size()==0){ 1359 | return; 1360 | } 1361 | bvhFileList.clear(); 1362 | dataListCell.setDatas(bvhFileList); 1363 | setEmptyBone(); 1364 | 1365 | } 1366 | }); 1367 | dataControls.add(removeAll); 1368 | 1369 | Button reload=new Button("Reload"); 1370 | reload.addClickHandler(new ClickHandler() { 1371 | 1372 | @Override 1373 | public void onClick(ClickEvent event) { 1374 | 1375 | doReload(); 1376 | 1377 | } 1378 | }); 1379 | dataControls.add(reload); 1380 | 1381 | 1382 | 1383 | drawMesh = new CheckBox("Draw Body Mesh"); 1384 | parent.add(drawMesh); 1385 | drawMesh.setValue(true); 1386 | drawMesh.addClickHandler(new ClickHandler() { 1387 | 1388 | @Override 1389 | public void onClick(ClickEvent event) { 1390 | doChangeVisibleBodyMesh(); 1391 | } 1392 | }); 1393 | 1394 | drawBackground = new CheckBox("Draw Background"); 1395 | parent.add(drawBackground); 1396 | drawBackground.setValue(true); 1397 | 1398 | 1399 | translatePosition = new CheckBox("Translate Position"); 1400 | parent.add(translatePosition); 1401 | translatePosition.setValue(true); 1402 | translatePosition.addClickHandler(new ClickHandler() { 1403 | 1404 | @Override 1405 | public void onClick(ClickEvent event) { 1406 | updatePoseIndex(currentFrameRange.getValue()); 1407 | } 1408 | }); 1409 | 1410 | ignoreFirst = new CheckBox("Ignore First Frame(Usually Pose)"); 1411 | ignoreFirst.setValue(false);//only cmu 1412 | parent.add(ignoreFirst); 1413 | 1414 | 1415 | 1416 | HorizontalPanel h1=new HorizontalPanel(); 1417 | 1418 | rotationRange = InputRangeWidget.createInputRange(-180,180,0); 1419 | parent.add(HTML5Builder.createRangeLabel("X-Rotate:", rotationRange)); 1420 | parent.add(h1); 1421 | h1.add(rotationRange); 1422 | Button reset=new Button("Reset"); 1423 | reset.addClickHandler(new ClickHandler() { 1424 | @Override 1425 | public void onClick(ClickEvent event) { 1426 | rotationRange.setValue(0); 1427 | } 1428 | }); 1429 | h1.add(reset); 1430 | 1431 | HorizontalPanel h2=new HorizontalPanel(); 1432 | 1433 | rotationYRange = InputRangeWidget.createInputRange(-180,180,0); 1434 | parent.add(HTML5Builder.createRangeLabel("Y-Rotate:", rotationYRange)); 1435 | parent.add(h2); 1436 | h2.add(rotationYRange); 1437 | Button reset2=new Button("Reset"); 1438 | reset2.addClickHandler(new ClickHandler() { 1439 | @Override 1440 | public void onClick(ClickEvent event) { 1441 | rotationYRange.setValue(0); 1442 | } 1443 | }); 1444 | h2.add(reset2); 1445 | 1446 | 1447 | HorizontalPanel h3=new HorizontalPanel(); 1448 | rotationZRange = InputRangeWidget.createInputRange(-180,180,0); 1449 | parent.add(HTML5Builder.createRangeLabel("Z-Rotate:", rotationZRange)); 1450 | parent.add(h3); 1451 | h3.add(rotationZRange); 1452 | Button reset3=new Button("Reset"); 1453 | reset3.addClickHandler(new ClickHandler() { 1454 | @Override 1455 | public void onClick(ClickEvent event) { 1456 | rotationZRange.setValue(0); 1457 | } 1458 | }); 1459 | h3.add(reset3); 1460 | 1461 | HorizontalPanel h4=new HorizontalPanel(); 1462 | positionXRange = InputRangeWidget.createInputRange(-50,50,0); 1463 | parent.add(HTML5Builder.createRangeLabel("X-Position:", positionXRange)); 1464 | parent.add(h4); 1465 | h4.add(positionXRange); 1466 | Button reset4=new Button("Reset"); 1467 | reset4.addClickHandler(new ClickHandler() { 1468 | @Override 1469 | public void onClick(ClickEvent event) { 1470 | positionXRange.setValue(0); 1471 | } 1472 | }); 1473 | h4.add(reset4); 1474 | 1475 | HorizontalPanel h5=new HorizontalPanel(); 1476 | positionYRange = InputRangeWidget.createInputRange(-50,50,0); 1477 | parent.add(HTML5Builder.createRangeLabel("Y-Position:", positionYRange)); 1478 | parent.add(h5); 1479 | h5.add(positionYRange); 1480 | Button reset5=new Button("Reset"); 1481 | reset5.addClickHandler(new ClickHandler() { 1482 | @Override 1483 | public void onClick(ClickEvent event) { 1484 | positionYRange.setValue(0); 1485 | } 1486 | }); 1487 | h5.add(reset5); 1488 | 1489 | HorizontalPanel h6=new HorizontalPanel(); 1490 | positionZRange = InputRangeWidget.createInputRange(-50,50,0); 1491 | parent.add(HTML5Builder.createRangeLabel("Z-Position:", positionZRange)); 1492 | parent.add(h6); 1493 | h6.add(positionZRange); 1494 | Button reset6=new Button("Reset"); 1495 | reset6.addClickHandler(new ClickHandler() { 1496 | @Override 1497 | public void onClick(ClickEvent event) { 1498 | positionZRange.setValue(0); 1499 | } 1500 | }); 1501 | h6.add(reset6); 1502 | 1503 | /* 1504 | Button launchPose=new Button("Launch Pose Editor"); 1505 | parent.add(launchPose); 1506 | launchPose.addClickHandler(new ClickHandler() { 1507 | 1508 | @Override 1509 | public void onClick(ClickEvent event) { 1510 | Window.open("pose.html", "posetool", null); 1511 | } 1512 | }); 1513 | */ 1514 | 1515 | List boneSizes=Lists.newArrayList(0.1,0.2,0.4,0.8,1.0,2.0); 1516 | ValueListBox boneSizeListBox=new ValueListBox(new Renderer() { 1517 | 1518 | @Override 1519 | public String render(Double object) { 1520 | return String.valueOf(object); 1521 | } 1522 | 1523 | @Override 1524 | public void render(Double object, Appendable appendable) throws IOException { 1525 | // TODO Auto-generated method stub 1526 | 1527 | } 1528 | }); 1529 | boneSizeListBox.setValue(baseBoneSize); 1530 | boneSizeListBox.setAcceptableValues(boneSizes); 1531 | boneSizeListBox.addValueChangeHandler(new ValueChangeHandler() { 1532 | @Override 1533 | public void onValueChange(ValueChangeEvent event) { 1534 | baseBoneSize=event.getValue(); 1535 | setBVH(bvh);//re-set 1536 | } 1537 | }); 1538 | 1539 | HorizontalPanel jointSizesPanel=new HorizontalPanel(); 1540 | jointSizesPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); 1541 | jointSizesPanel.add(new Label("Joint-Size")); 1542 | jointSizesPanel.add(boneSizeListBox); 1543 | parent.add(jointSizesPanel); 1544 | 1545 | List presets=Lists.newArrayList(null,Bundles.INSTANCE.standard_cmu(),Bundles.INSTANCE.small_cmu()); 1546 | 1547 | ValueListBox presetBox=new ValueListBox(new Renderer() { 1548 | 1549 | @Override 1550 | public String render(TextResource object) { 1551 | if(object==null){ 1552 | return "no use"; 1553 | }else{ 1554 | return object.getName(); 1555 | } 1556 | //return null; 1557 | } 1558 | 1559 | @Override 1560 | public void render(TextResource object, Appendable appendable) throws IOException { 1561 | // TODO Auto-generated method stub 1562 | 1563 | } 1564 | }); 1565 | 1566 | presetBox.addValueChangeHandler(new ValueChangeHandler() { 1567 | 1568 | @Override 1569 | public void onValueChange(ValueChangeEvent event) { 1570 | if(event.getValue()==null){ 1571 | boxDatas=new HashMap(); 1572 | }else{ 1573 | boxDatas=new BoxDataParser().parse(event.getValue().getText()); 1574 | } 1575 | 1576 | setBVH(bvh);//re-set 1577 | } 1578 | 1579 | }); 1580 | 1581 | presetBox.setAcceptableValues(presets); 1582 | 1583 | HorizontalPanel presetPanel=new HorizontalPanel(); 1584 | presetPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); 1585 | presetPanel.add(new Label("Joint-Preset")); 1586 | presetPanel.add(presetBox); 1587 | parent.add(presetPanel); 1588 | 1589 | HorizontalPanel screenshotPanel=new HorizontalPanel(); 1590 | screenshotPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); 1591 | parent.add(screenshotPanel); 1592 | 1593 | screenshotContainer = new HorizontalPanel(); 1594 | 1595 | Button screenShot=new Button("Screenshot",new ClickHandler() { 1596 | @Override 1597 | public void onClick(ClickEvent event) { 1598 | reserveScreenShot=true; 1599 | } 1600 | }); 1601 | screenshotPanel.add(screenShot); 1602 | screenshotPanel.add(screenshotContainer); 1603 | 1604 | createBottomPanel(); 1605 | showControl(); 1606 | } 1607 | private boolean reserveScreenShot; 1608 | 1609 | public class TextResourceAndName{ 1610 | TextResource resource; 1611 | public TextResource getResource() { 1612 | return resource; 1613 | } 1614 | public void setResource(TextResource resource) { 1615 | this.resource = resource; 1616 | } 1617 | public String getName() { 1618 | return name; 1619 | } 1620 | public void setName(String name) { 1621 | this.name = name; 1622 | } 1623 | String name; 1624 | } 1625 | 1626 | protected void doReload() { 1627 | LogUtils.log(lastSelectedFiles); 1628 | if(lastSelectedFiles==null){ 1629 | return; 1630 | } 1631 | //bvhFileList.clear(); 1632 | FileDataContainer firstOne=null; 1633 | for(int i=0;ibvhFileList.size()-1){ 1659 | index=0; 1660 | } 1661 | dataListCell.setSelection(bvhFileList.get(index)); 1662 | } 1663 | 1664 | protected void doLoad(String itemText) { 1665 | String[] g_n=itemText.split("_"); 1666 | loadBVH("bvhs/"+g_n[0]+"/"+itemText+".bvh"); 1667 | } 1668 | 1669 | private InputRangeWidget rotationRange; 1670 | private InputRangeWidget rotationYRange; 1671 | private InputRangeWidget rotationZRange; 1672 | 1673 | Object3D boneRoot; 1674 | 1675 | 1676 | private BVH bvh; 1677 | private CheckBox ignoreFirst; 1678 | 1679 | //private long ctime; 1680 | private InputRangeWidget currentFrameRange; 1681 | private Label currentFrameLabel; 1682 | //private int poseIndex; 1683 | 1684 | private void updatePoseIndex(int index){ 1685 | if(index>=bvh.getFrames()){ 1686 | if(bvh.getFrames()!=1){//1 frame pose usually happen 1687 | LogUtils.log("invalid frame at:"+index+" of "+bvh.getFrames()); 1688 | } 1689 | return; 1690 | } 1691 | //poseIndex=index; 1692 | currentFrameRange.setValue(index); 1693 | currentFrameLabel.setText((index+1)+"/"+bvh.getFrames()); 1694 | doPose(bvh,bvh.getFrameAt(index)); 1695 | } 1696 | 1697 | JClock clock=new JClock(); 1698 | private List bvhFileList=new ArrayList(); 1699 | //private CellList bvhCellList; 1700 | //private SingleSelectionModel fileSelectionModel; 1701 | private DataListCell dataListCell; 1702 | 1703 | 1704 | private int currentLoop=0; 1705 | private ListBox loopTime; 1706 | 1707 | private ListBox speedBox; 1708 | private long remainTime; 1709 | 1710 | private CheckBox abLoopCheck; 1711 | 1712 | private TabLayoutPanel toolsPanel; 1713 | private HorizontalPanel screenshotContainer; 1714 | @Override 1715 | protected void beforeUpdate(WebGLRenderer renderer) { 1716 | 1717 | 1718 | //camera.getPosition().incrementX((mouseX - camera.getPosition().getX() ) * 0.05); 1719 | //camera.getPosition().incrementY((-mouseY - camera.getPosition().getY() ) * 0.05); 1720 | 1721 | //validate ab-check 1722 | boolean abLoop=abLoopCheck.getValue(); 1723 | if(abLoop && bvh!=null){ 1724 | if(aFrame>=bFrame){ 1725 | abLoopCheck.setValue(false); 1726 | } 1727 | if(aFrame>bvh.getFrames()-1 || bFrame>bvh.getFrames()-1){ 1728 | abLoopCheck.setValue(false); 1729 | } 1730 | } 1731 | 1732 | 1733 | Object3DUtils.setVisibleAll(backgroundContainer, drawBackground.getValue()); 1734 | //backgroundContainer.setVisible(); 1735 | 1736 | boneContainer.setPosition(positionXRange.getValue(), positionYRange.getValue(), positionZRange.getValue()); 1737 | 1738 | if(rootGroup!=null){ 1739 | String lastOrder=rootGroup.getRotation().getOrder(); 1740 | rootGroup.getRotation().set(Math.toRadians(rotationRange.getValue()),Math.toRadians(rotationYRange.getValue()),Math.toRadians(rotationZRange.getValue()),lastOrder); 1741 | } 1742 | 1743 | if(bvh!=null){ 1744 | if(playing){ 1745 | long last=clock.delta()+remainTime; 1746 | double ftime=(bvh.getFrameTime()*1000/playSpeed); 1747 | 1748 | if(ftime==0){ 1749 | return; //somehow frame become strange 1750 | } 1751 | int frame=(int) (last/ftime); 1752 | remainTime=(long) (last-(ftime*frame)); 1753 | // log(""+frame); 1754 | //GWT.log(ftime+","+frame+","+remainTime); 1755 | int minFrame=0; 1756 | int maxFrame=bvh.getFrames(); 1757 | 1758 | if(abLoop){ 1759 | minFrame=aFrame; 1760 | maxFrame=bFrame; 1761 | } 1762 | 1763 | if(frame>0){ 1764 | int index=currentFrameRange.getValue()+frame; 1765 | 1766 | 1767 | 1768 | boolean overLoop=index>=maxFrame; 1769 | 1770 | index=(index-minFrame)%(maxFrame-minFrame); 1771 | index+=minFrame; 1772 | 1773 | if(ignoreFirst.getValue() && index==0 &&minFrame==0){ 1774 | index=1; 1775 | } 1776 | 1777 | updatePoseIndex(index); 1778 | 1779 | 1780 | if(overLoop && bvhFileList.size()>1 && !abLoop){ 1781 | //next Frame 1782 | try{ 1783 | int maxLoop=Integer.parseInt(loopTime.getItemText(loopTime.getSelectedIndex())); 1784 | //log("maxloop:"+maxLoop); 1785 | if(maxLoop>0){ 1786 | currentLoop++; 1787 | if(currentLoop>=maxLoop){ 1788 | currentLoop=0; 1789 | doNextMotion(); 1790 | } 1791 | } 1792 | 1793 | }catch(Exception e){} 1794 | } 1795 | 1796 | 1797 | 1798 | 1799 | 1800 | } 1801 | /* 1802 | double delta=(double)(System.currentTimeMillis()-ctime)/1000; 1803 | delta%=bvh.getMotion().getDuration(); 1804 | poseIndex = (int) (delta/bvh.getMotion().getFrameTime()); 1805 | */ 1806 | } 1807 | 1808 | } 1809 | 1810 | if(reserveScreenShot){//get renderer before clear; 1811 | doScreenshot(); 1812 | reserveScreenShot=false; 1813 | } 1814 | } 1815 | 1816 | private void doScreenshot(){ 1817 | screenshotContainer.clear(); 1818 | canvas.getRenderer().render(scene, camera);//do render here 1819 | String url=canvas.getRenderer().gwtPngDataUrl(); 1820 | Anchor anchor=HTML5Download.get().generateBase64DownloadLink(url, "image/png", "screenshot.png", "download", true); 1821 | screenshotContainer.add(anchor); 1822 | } 1823 | 1824 | public void addBVHData(BVHDataContainer dataContainer){ 1825 | 1826 | if(!existsBVHData(dataContainer)){ 1827 | bvhFileList.add(dataContainer); 1828 | } 1829 | 1830 | dataListCell.setDatas(bvhFileList); 1831 | dataListCell.setSelection(dataContainer); 1832 | tabPanel.selectTab(0); 1833 | } 1834 | 1835 | public void addBVHDatas(List dataContainers){ 1836 | 1837 | for(BVHDataContainer dataContainer:dataContainers){ 1838 | if(!existsBVHData(dataContainer)){ 1839 | bvhFileList.add(dataContainer); 1840 | } 1841 | } 1842 | 1843 | dataListCell.setDatas(bvhFileList); 1844 | dataListCell.setSelection(dataContainers.get(0)); 1845 | tabPanel.selectTab(0); 1846 | } 1847 | private boolean existsBVHData(BVHDataContainer dataContainer){ 1848 | for(BVHDataContainer container:bvhFileList){ 1849 | if(container.getName().equals(dataContainer.getName())){ 1850 | return true; 1851 | } 1852 | } 1853 | return false; 1854 | } 1855 | 1856 | @Override 1857 | public void resized(int width, int height) { 1858 | super.resized(width, height); 1859 | leftBottom(bottomPanel); 1860 | } 1861 | @Override 1862 | public String getHtml(){ 1863 | return "BVH Motion Creator ver."+version+"
"+super.getHtml()+". Sample BVH File from CMU Graphics Lab Motion Capture Database.
More Infomation click https://github.com/akjava/BVH-Motion-Creator"; 1864 | } 1865 | 1866 | @Override 1867 | public String getTabTitle() { 1868 | return "BVH Player"; 1869 | } 1870 | 1871 | 1872 | 1873 | 1874 | @Override 1875 | public void onDoubleClick(DoubleClickEvent event) { 1876 | // TODO Auto-generated method stub 1877 | 1878 | } 1879 | 1880 | 1881 | 1882 | 1883 | 1884 | } -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/file/BVHDataContainer.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.file; 2 | 3 | public interface BVHDataContainer { 4 | public String getName(); 5 | public void readText(BVHDataListener listener); 6 | } 7 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/file/BVHDataListener.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.file; 2 | 3 | public interface BVHDataListener { 4 | public void dataLoaded(String text); 5 | } 6 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/file/FileDataContainer.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.file; 2 | 3 | import com.akjava.gwt.html5.client.file.File; 4 | import com.akjava.gwt.html5.client.file.FileHandler; 5 | import com.akjava.gwt.html5.client.file.FileReader; 6 | 7 | public class FileDataContainer implements BVHDataContainer{ 8 | private File file; 9 | public FileDataContainer(File file){ 10 | this.file=file; 11 | } 12 | @Override 13 | public String getName() { 14 | return file.getFileName(); 15 | } 16 | 17 | @Override 18 | public void readText(final BVHDataListener listener) { 19 | final FileReader reader=FileReader.createFileReader(); 20 | reader.setOnLoad(new FileHandler() { 21 | @Override 22 | public void onLoad() { 23 | listener.dataLoaded(reader.getResultAsString()); 24 | } 25 | }); 26 | reader.readAsText(file,"utf-8"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/file/TextAreaDataContainer.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.file; 2 | 3 | import com.google.gwt.user.client.ui.TextArea; 4 | 5 | public class TextAreaDataContainer implements BVHDataContainer{ 6 | private String name; 7 | private TextArea textArea; 8 | public TextAreaDataContainer(String name,TextArea textArea){ 9 | this.name=name; 10 | this.textArea=textArea; 11 | } 12 | @Override 13 | public String getName() { 14 | return name; 15 | } 16 | 17 | @Override 18 | public void readText(BVHDataListener listener) { 19 | listener.dataLoaded(textArea.getText()); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/file/TextDataContainer.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.file; 2 | 3 | 4 | public class TextDataContainer implements BVHDataContainer{ 5 | private String name; 6 | private String json; 7 | public TextDataContainer(String name,String json){ 8 | this.name=name; 9 | this.json=json; 10 | } 11 | @Override 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | @Override 17 | public void readText(BVHDataListener listener) { 18 | listener.dataLoaded(json); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/player/list/BVHFileWidget.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.player.list; 2 | 3 | import com.akjava.gwt.bvhtools.client.file.BVHDataContainer; 4 | import com.akjava.gwt.html5.client.file.File; 5 | import com.google.gwt.event.dom.client.ClickEvent; 6 | import com.google.gwt.event.dom.client.ClickHandler; 7 | import com.google.gwt.user.client.ui.HorizontalPanel; 8 | import com.google.gwt.user.client.ui.Label; 9 | 10 | public class BVHFileWidget extends HorizontalPanel { 11 | private BVHDataContainer file; 12 | private DataListCell dataList; 13 | public BVHFileWidget(BVHDataContainer f,DataListCell data){ 14 | this.file=f; 15 | this.dataList=data; 16 | Label label=new Label(file.getName()); 17 | 18 | label.setStylePrimaryName("bvhlabel"); 19 | add(label); 20 | label.addClickHandler(new ClickHandler() { 21 | 22 | @Override 23 | public void onClick(ClickEvent event) { 24 | dataList.setSelection(file); 25 | } 26 | }); 27 | } 28 | public BVHDataContainer getFile(){ 29 | return file; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/player/list/DataListCell.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.player.list; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.akjava.gwt.lib.client.widget.cell.util.WidgetUtils; 7 | import com.google.gwt.user.client.ui.ScrollPanel; 8 | import com.google.gwt.user.client.ui.VerticalPanel; 9 | import com.google.gwt.user.client.ui.Widget; 10 | 11 | //this is easy to scroll than CellList system 12 | //use cell list 13 | public class DataListCell extends ScrollPanel{ 14 | List datas=new ArrayList(); 15 | T selected; 16 | private VerticalPanel panel; 17 | 18 | DataListRenderer renderer; 19 | private String styleName="selected"; 20 | private ChangeSelectionListener listener; 21 | public ChangeSelectionListener getListener() { 22 | return listener; 23 | } 24 | 25 | 26 | public void setListener(ChangeSelectionListener listener) { 27 | this.listener = listener; 28 | } 29 | 30 | 31 | public DataListCell(DataListRenderer renderer){ 32 | panel=new VerticalPanel(); 33 | this.renderer=renderer; 34 | setWidget(panel); 35 | } 36 | 37 | 38 | public void setDatas(List datas){ 39 | this.datas=datas; 40 | updateWidget(); 41 | } 42 | 43 | public T getSelection(){ 44 | return selected; 45 | } 46 | public void setSelection(T data){ 47 | this.selected=data; 48 | int csize=panel.getWidgetCount(); 49 | for(int i=0;i { 76 | public Widget createWidget(T data,DataListCell dataList); 77 | } 78 | public interface ChangeSelectionListener{ 79 | public void onChangeSelection(T data); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/player/list/FileCell.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.player.list; 2 | 3 | import com.akjava.gwt.html5.client.file.File; 4 | import com.google.gwt.cell.client.AbstractSafeHtmlCell; 5 | import com.google.gwt.safehtml.shared.SafeHtml; 6 | import com.google.gwt.safehtml.shared.SafeHtmlBuilder; 7 | import com.google.gwt.text.shared.SafeHtmlRenderer; 8 | 9 | public class FileCell extends AbstractSafeHtmlCell{ 10 | 11 | public FileCell(){ 12 | super(FileRenderer.getInstance()); 13 | } 14 | public FileCell(SafeHtmlRenderer renderer) { 15 | super(renderer); 16 | } 17 | 18 | @Override 19 | protected void render(com.google.gwt.cell.client.Cell.Context context, 20 | SafeHtml value, SafeHtmlBuilder sb) { 21 | if (value != null) { 22 | sb.append(value); 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/player/list/FileRenderer.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.player.list; 2 | 3 | import com.akjava.gwt.html5.client.file.File; 4 | import com.google.gwt.safehtml.shared.SafeHtml; 5 | import com.google.gwt.safehtml.shared.SafeHtmlBuilder; 6 | import com.google.gwt.safehtml.shared.SafeHtmlUtils; 7 | import com.google.gwt.text.shared.SafeHtmlRenderer; 8 | 9 | public class FileRenderer implements SafeHtmlRenderer{ 10 | 11 | private static FileRenderer instance; 12 | 13 | public static FileRenderer getInstance() { 14 | if (instance == null) { 15 | instance = new FileRenderer(); 16 | } 17 | return instance; 18 | } 19 | @Override 20 | public SafeHtml render(File object) { 21 | return (object == null) ? SafeHtmlUtils.EMPTY_SAFE_HTML : SafeHtmlUtils.fromString(object.getFileName()); 22 | } 23 | 24 | @Override 25 | public void render(File object, SafeHtmlBuilder builder) { 26 | builder.append(SafeHtmlUtils.fromString(object.getFileName())); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/player/resources/Bundles.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.player.resources; 2 | 3 | import com.google.gwt.core.client.GWT; 4 | import com.google.gwt.resources.client.ClientBundle; 5 | import com.google.gwt.resources.client.TextResource; 6 | 7 | public interface Bundles extends ClientBundle { 8 | public static Bundles INSTANCE=GWT.create(Bundles.class); 9 | 10 | @Source("standard_cmu.txt") 11 | TextResource standard_cmu(); 12 | TextResource small_cmu(); 13 | } 14 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/player/resources/boxsize.txt: -------------------------------------------------------------------------------- 1 | LHipJoint,14,6,9 2 | LeftUpLeg,8.5,35,6,21 3 | LeftLeg,6.5,32,5,21 4 | LeftFoot,4.5,2.5,8,21 5 | RHipJoint,14,6,9 6 | RightUpLeg,8.5,35,6,-21 7 | RightLeg,6.5,32,5,-21 8 | RightFoot,4.5,2.5,8,-21 9 | LowerBack,20,9,8 10 | Spine,28,9,8 11 | Neck,6,6,5 12 | Neck1,6,5,5 13 | Head,12,13,12 14 | LeftShoulder,12,5,8 15 | LeftArm,25,5,5 16 | LeftForeArm,16,4,4 17 | LeftFingerBase,1,2,3 18 | LeftHandIndex1,1,2,2 19 | LThumb,1,1,1 20 | RightShoulder,12,5,8 21 | RightArm,25,5,5 22 | RightForeArm,16,4,4 23 | RightFingerBase,1,2,3 24 | RightHandIndex1,1,2,2 25 | RThumb,1,1,1 -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/player/resources/small_cmu.txt: -------------------------------------------------------------------------------- 1 | LHipJoint,1.4,.6,.9 2 | LeftUpLeg,.85,3.5,.6,.21 3 | LeftLeg,.65,3.2,.5,.21 4 | LeftFoot,.45,.25,.8,.21 5 | RHipJoint,.14,.6,.9 6 | RightUpLeg,.85,3.5,.6,-.21 7 | RightLeg,.65,3.2,.5,-.21 8 | RightFoot,.45,.25,.8,-.21 9 | LowerBack,.20,.9,.8 10 | Spine,2.8,.9,.8 11 | Neck,.6,.6,.5 12 | Neck1,.6,.5,.5 13 | Head,1.2,1.3,1.2 14 | LeftShoulder,1.2,.5,.8 15 | LeftArm,2.5,.5,.5 16 | LeftForeArm,1.6,.4,.4 17 | LeftFingerBase,.1,.2,.3 18 | LeftHandIndex1,.1,.2,.2 19 | LThumb,.1,.1,.1 20 | RightShoulder,1.2,.5,.8 21 | RightArm,2.5,.5,.5 22 | RightForeArm,1.6,.4,.4 23 | RightFingerBase,.1,.2,.3 24 | RightHandIndex1,.1,.2,.2 25 | RThumb,.1,.1,.1 -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/player/resources/standard_cmu.txt: -------------------------------------------------------------------------------- 1 | LHipJoint,14,6,9 2 | LeftUpLeg,8.5,35,6,21 3 | LeftLeg,6.5,32,5,21 4 | LeftFoot,4.5,2.5,8,21 5 | RHipJoint,14,6,9 6 | RightUpLeg,8.5,35,6,-21 7 | RightLeg,6.5,32,5,-21 8 | RightFoot,4.5,2.5,8,-21 9 | LowerBack,20,9,8 10 | Spine,28,9,8 11 | Neck,6,6,5 12 | Neck1,6,5,5 13 | Head,12,13,12 14 | LeftShoulder,12,5,8 15 | LeftArm,25,5,5 16 | LeftForeArm,16,4,4 17 | LeftFingerBase,1,2,3 18 | LeftHandIndex1,1,2,2 19 | LThumb,1,1,1 20 | RightShoulder,12,5,8 21 | RightArm,25,5,5 22 | RightForeArm,16,4,4 23 | RightFingerBase,1,2,3 24 | RightHandIndex1,1,2,2 25 | RThumb,1,1,1 -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/tools/AbstractTool.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.tools; 2 | 3 | import com.akjava.gwt.bvhtools.client.BVHTools; 4 | import com.akjava.gwt.bvhtools.client.file.TextAreaDataContainer; 5 | import com.google.gwt.event.dom.client.ClickEvent; 6 | import com.google.gwt.event.dom.client.ClickHandler; 7 | import com.google.gwt.user.client.ui.Button; 8 | import com.google.gwt.user.client.ui.TextArea; 9 | import com.google.gwt.user.client.ui.VerticalPanel; 10 | 11 | public abstract class AbstractTool { 12 | protected VerticalPanel panel; 13 | protected TextAreaDataContainer bvhContainer; 14 | 15 | public AbstractTool(VerticalPanel panel){ 16 | this.panel=panel; 17 | } 18 | public Button createPlayButton(String name,final TextArea textArea){ 19 | 20 | if(bvhContainer==null){ 21 | bvhContainer=new TextAreaDataContainer(name,textArea); 22 | } 23 | Button play=new Button("Play"); 24 | play.addClickHandler(new ClickHandler() { 25 | 26 | @Override 27 | public void onClick(ClickEvent event) { 28 | if(textArea.getText().isEmpty()){ 29 | return;//do nothing 30 | } 31 | BVHTools.getInstance().addBVHData(bvhContainer); 32 | } 33 | }); 34 | return play; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/tools/CalculateTool.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.tools; 2 | 3 | import java.util.ArrayList; 4 | import java.util.LinkedHashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import com.akjava.bvh.client.BVH; 9 | import com.akjava.bvh.client.BVHMotion; 10 | import com.akjava.bvh.client.BVHNode; 11 | import com.akjava.bvh.client.BVHParser; 12 | import com.akjava.bvh.client.BVHParser.InvalidLineException; 13 | import com.akjava.bvh.client.Channels; 14 | import com.akjava.bvh.client.NameAndChannel; 15 | import com.akjava.gwt.html5.client.file.File; 16 | import com.akjava.gwt.html5.client.file.FileHandler; 17 | import com.akjava.gwt.html5.client.file.FileReader; 18 | import com.akjava.gwt.html5.client.file.FileUploadForm; 19 | import com.akjava.gwt.html5.client.file.FileUtils; 20 | import com.akjava.gwt.lib.client.LogUtils; 21 | import com.akjava.gwt.lib.client.widget.cell.SimpleCellTable; 22 | import com.google.gwt.core.client.GWT; 23 | import com.google.gwt.core.client.JsArray; 24 | import com.google.gwt.event.dom.client.ChangeEvent; 25 | import com.google.gwt.event.dom.client.ChangeHandler; 26 | import com.google.gwt.user.cellview.client.CellTable; 27 | import com.google.gwt.user.cellview.client.TextColumn; 28 | import com.google.gwt.user.client.ui.ScrollPanel; 29 | import com.google.gwt.user.client.ui.TextArea; 30 | import com.google.gwt.user.client.ui.VerticalPanel; 31 | 32 | public class CalculateTool { 33 | private VerticalPanel panel; 34 | public CalculateTool(VerticalPanel panel){ 35 | this.panel=panel; 36 | 37 | 38 | 39 | final FileUploadForm upload=new FileUploadForm(); 40 | upload.getFileUpload().getElement().setAttribute("multiple", "multiple"); 41 | upload.getFileUpload().addChangeHandler(new ChangeHandler() { 42 | 43 | @Override 44 | public void onChange(ChangeEvent event) { 45 | JsArray files=FileUtils.toFile(event.getNativeEvent()); 46 | 47 | setFile(files); 48 | upload.reset(); 49 | } 50 | }); 51 | panel.add(upload); 52 | 53 | ScrollPanel scroll=new ScrollPanel(); 54 | scroll.setSize("1020px", "500px"); 55 | panel.add(scroll); 56 | table = new SimpleCellTable(16) { 57 | @Override 58 | public void addColumns(CellTable table) { 59 | TextColumn nameColumn = new TextColumn() { 60 | public String getValue(ResultData data) { 61 | return data.getName(); 62 | } 63 | }; 64 | table.addColumn(nameColumn,"Bone-Name"); 65 | 66 | TextColumn xmin = new TextColumn() { 67 | public String getValue(ResultData data) { 68 | return ""+Math.toDegrees(data.getMinX()); 69 | } 70 | }; 71 | table.addColumn(xmin,"X-Min"); 72 | TextColumn xmax = new TextColumn() { 73 | public String getValue(ResultData data) { 74 | return ""+Math.toDegrees(data.getMaxX()); 75 | } 76 | }; 77 | table.addColumn(xmax,"X-Max"); 78 | 79 | TextColumn ymin = new TextColumn() { 80 | public String getValue(ResultData data) { 81 | return ""+Math.toDegrees(data.getMinY()); 82 | } 83 | }; 84 | table.addColumn(ymin,"Y-Min"); 85 | TextColumn ymax = new TextColumn() { 86 | public String getValue(ResultData data) { 87 | return ""+Math.toDegrees(data.getMaxY()); 88 | } 89 | }; 90 | table.addColumn(ymax,"Y-Max"); 91 | 92 | TextColumn zmin = new TextColumn() { 93 | public String getValue(ResultData data) { 94 | return ""+Math.toDegrees(data.getMinZ()); 95 | } 96 | }; 97 | table.addColumn(zmin,"Z-Min"); 98 | TextColumn zmax = new TextColumn() { 99 | public String getValue(ResultData data) { 100 | return ""+Math.toDegrees(data.getMaxZ()); 101 | } 102 | }; 103 | table.addColumn(zmax,"Z-Max"); 104 | } 105 | }; 106 | //panel.add(table); 107 | scroll.setWidget(table); 108 | 109 | //BVH 110 | //select all 111 | /* 112 | HorizontalPanel buttons=new HorizontalPanel(); 113 | panel.add(buttons); 114 | buttons.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); 115 | buttons.setWidth("400px"); 116 | Button selectAll=new Button("Select Text"); 117 | buttons.add(selectAll); 118 | textArea = new TextArea(); 119 | textArea.setSize("400px", "250px"); 120 | textArea.setReadOnly(true); 121 | panel.add(textArea); 122 | selectAll.addClickHandler(new ClickHandler() { 123 | @Override 124 | public void onClick(ClickEvent event) { 125 | textArea.selectAll(); 126 | } 127 | }); 128 | */ 129 | } 130 | 131 | 132 | private class ResultData{ 133 | private String name; 134 | public ResultData(String name){ 135 | this.name=name; 136 | } 137 | public String getName() { 138 | return name; 139 | } 140 | public void setName(String name) { 141 | this.name = name; 142 | } 143 | public double getMinX() { 144 | return minX; 145 | } 146 | public void setMinX(double minX) { 147 | if(this.minX==null){ 148 | this.minX = minX; 149 | }else{ 150 | if(minXthis.maxX){ 163 | this.maxX=maxX; 164 | } 165 | } 166 | } 167 | public double getMinY() { 168 | return minY; 169 | } 170 | public void setMinY(double minY) { 171 | if(this.minY==null){ 172 | this.minY = minY; 173 | }else{ 174 | if(minYthis.maxY){ 188 | this.maxY=maxY; 189 | } 190 | } 191 | } 192 | public double getMinZ() { 193 | return minZ; 194 | } 195 | public void setMinZ(double minZ) { 196 | if(this.minZ==null){ 197 | this.minZ = minZ; 198 | }else{ 199 | if(minZthis.maxZ){ 212 | this.maxZ=maxZ; 213 | } 214 | } 215 | } 216 | private Double minX; 217 | private Double maxX; 218 | private Double minY; 219 | private Double maxY; 220 | private Double minZ; 221 | private Double maxZ; 222 | } 223 | 224 | 225 | private SimpleCellTable table; 226 | 227 | 228 | Map resultMap; 229 | private TextArea textArea; 230 | private BVH bvhFile; 231 | private void parseBVH(String bvhText){ 232 | BVHParser parser=new BVHParser(); 233 | try { 234 | BVH bvh=parser.parse(bvhText); 235 | GWT.log("parsed"); 236 | //calcurate 237 | //List datas=new ArrayList(); 238 | 239 | 240 | if(resultMap==null){ 241 | resultMap=new LinkedHashMap(); 242 | addMap(bvh.getHiearchy()); 243 | bvhFile=bvh; 244 | } 245 | 246 | 247 | BVHMotion motion=bvh.getMotion(); 248 | GWT.log("motion:"+motion.size()); 249 | for(int i=0;i result=new ArrayList(); 255 | for(String name:resultMap.keySet()){ 256 | result.add(resultMap.get(name)); 257 | } 258 | GWT.log("set data"); 259 | table.setData(result); 260 | 261 | } catch (InvalidLineException e) { 262 | // TODO Auto-generated catch block 263 | e.printStackTrace(); 264 | } 265 | } 266 | private void addMap(BVHNode node){ 267 | resultMap.put(node.getName(), new ResultData(node.getName())); 268 | for(BVHNode child:node.getJoints()){ 269 | addMap(child); 270 | } 271 | } 272 | private void setFile(JsArray files){ 273 | GWT.log("set-file:"+files.get(0)); 274 | 275 | 276 | 277 | List fileList=new ArrayList(); 278 | for(int i=0;i files){ 286 | final FileReader reader=FileReader.createFileReader(); 287 | reader.setOnLoad(new FileHandler() { 288 | @Override 289 | public void onLoad() { 290 | LogUtils.log("load-file"); 291 | parseBVH(reader.getResultAsString()); 292 | if(files.size()>0){ 293 | reader.readAsText(files.remove(0),"utf-8"); 294 | }else{ 295 | updateBVH(); 296 | } 297 | } 298 | }); 299 | reader.readAsText(files.remove(0),"utf-8"); 300 | } 301 | 302 | 303 | 304 | 305 | protected void updateBVH() { 306 | //TODO future 307 | } 308 | private void doMotion(BVH bvh,double[] vs){ 309 | GWT.log("domotion:"); 310 | ResultData oldTarget=null; 311 | String lastOrder=null; 312 | for(int i=0;i files=FileUtils.toFile(event.getNativeEvent()); 43 | 44 | setFile(files); 45 | upload.reset(); 46 | } 47 | }); 48 | panel.add(upload); 49 | 50 | skipFirst = new CheckBox("Skip First frame after second bvh"); 51 | skipFirst.setValue(true); 52 | panel.add(skipFirst); 53 | 54 | HorizontalPanel buttons=new HorizontalPanel(); 55 | panel.add(buttons); 56 | buttons.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); 57 | buttons.setWidth("400px"); 58 | Button selectAll=new Button("Select Text"); 59 | buttons.add(selectAll); 60 | textArea = new TextArea(); 61 | 62 | textArea.setSize("400px", "100px"); 63 | textArea.setReadOnly(true); 64 | //textArea.setStylePrimaryName("nowrap"); ,wrap replace some char and make a problem 65 | panel.add(textArea); 66 | selectAll.addClickHandler(new ClickHandler() { 67 | @Override 68 | public void onClick(ClickEvent event) { 69 | textArea.selectAll(); 70 | } 71 | }); 72 | 73 | panel.add(createPlayButton("Merged Data", textArea)); 74 | } 75 | 76 | 77 | 78 | 79 | 80 | 81 | List bvhList; 82 | 83 | private TextArea textArea; 84 | 85 | private CheckBox skipFirst; 86 | 87 | private void parseBVH(String bvhText){ 88 | BVHParser parser=new BVHParser(); 89 | try { 90 | BVH bvh=parser.parse(bvhText); 91 | GWT.log("parsed"); 92 | //calcurate 93 | //List datas=new ArrayList(); 94 | 95 | 96 | 97 | bvhList.add(bvh); 98 | 99 | 100 | } catch (InvalidLineException e) { 101 | // TODO Auto-generated catch block 102 | e.printStackTrace(); 103 | } 104 | } 105 | 106 | private void setFile(JsArray files){ 107 | GWT.log("set-file:"+files.get(0)); 108 | 109 | bvhList=new ArrayList(); 110 | 111 | 112 | List fileList=new ArrayList(); 113 | for(int i=0;i files){ 121 | final FileReader reader=FileReader.createFileReader(); 122 | reader.setOnLoad(new FileHandler() { 123 | @Override 124 | public void onLoad() { 125 | parseBVH(reader.getResultAsString()); 126 | if(files.size()>0){ 127 | File f=files.remove(0); 128 | 129 | reader.readAsText(f,"utf-8"); 130 | }else{//last 131 | doAllFileAction(); 132 | } 133 | } 134 | }); 135 | reader.readAsText(files.remove(0),"utf-8"); 136 | } 137 | 138 | 139 | private boolean skipFirstValue; 140 | 141 | protected void doAllFileAction() { 142 | skipFirstValue=skipFirst.getValue(); 143 | BVH result=new BVH(); 144 | result.setMotion(new BVHMotion()); 145 | result.getMotion().setFrameTime(bvhList.get(0).getFrameTime()); 146 | result.setHiearchy(bvhList.get(0).getHiearchy()); 147 | 148 | for(BVH bvh:bvhList){ 149 | BVHMotion motion=bvh.getMotion(); 150 | boolean first=true; 151 | for(double[] mvalue:motion.getMotions()){ 152 | 153 | if(first){ 154 | first=false; 155 | if(skipFirstValue){ 156 | continue; 157 | } 158 | 159 | } 160 | result.getMotion().add(mvalue); 161 | } 162 | } 163 | 164 | result.getMotion().syncFrames(); 165 | 166 | BVHWriter writer=new BVHWriter(); 167 | 168 | String text=writer.writeToString(result); 169 | textArea.setText(text); 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/tools/MixTool.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.tools; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import com.akjava.bvh.client.BVH; 9 | import com.akjava.bvh.client.BVHMotion; 10 | import com.akjava.bvh.client.BVHNode; 11 | import com.akjava.bvh.client.BVHParser; 12 | import com.akjava.bvh.client.BVHParser.InvalidLineException; 13 | import com.akjava.bvh.client.BVHWriter; 14 | import com.akjava.bvh.client.NameAndChannel; 15 | import com.akjava.gwt.html5.client.file.File; 16 | import com.akjava.gwt.html5.client.file.FileHandler; 17 | import com.akjava.gwt.html5.client.file.FileReader; 18 | import com.akjava.gwt.html5.client.file.FileUploadForm; 19 | import com.akjava.gwt.html5.client.file.FileUtils; 20 | import com.akjava.gwt.lib.client.LogUtils; 21 | import com.google.gwt.core.client.JsArray; 22 | import com.google.gwt.event.dom.client.ChangeEvent; 23 | import com.google.gwt.event.dom.client.ChangeHandler; 24 | import com.google.gwt.event.dom.client.ClickEvent; 25 | import com.google.gwt.event.dom.client.ClickHandler; 26 | import com.google.gwt.user.client.ui.Button; 27 | import com.google.gwt.user.client.ui.CheckBox; 28 | import com.google.gwt.user.client.ui.FileUpload; 29 | import com.google.gwt.user.client.ui.HorizontalPanel; 30 | import com.google.gwt.user.client.ui.Label; 31 | import com.google.gwt.user.client.ui.ScrollPanel; 32 | import com.google.gwt.user.client.ui.TextArea; 33 | import com.google.gwt.user.client.ui.VerticalPanel; 34 | 35 | public class MixTool extends AbstractTool{ 36 | 37 | private File firstFile,secondFile; 38 | 39 | private CheckBox loopShort; 40 | public MixTool(VerticalPanel panel){ 41 | super(panel); 42 | 43 | 44 | final FileUploadForm upload=new FileUploadForm(); 45 | upload.getFileUpload().getElement().setAttribute("multiple", "multiple"); 46 | upload.getFileUpload().addChangeHandler(new ChangeHandler() { 47 | 48 | @Override 49 | public void onChange(ChangeEvent event) { 50 | JsArray files=FileUtils.toFile(event.getNativeEvent()); 51 | 52 | setFile(files,true); 53 | upload.reset(); 54 | } 55 | }); 56 | panel.add(upload); 57 | 58 | final FileUploadForm upload2=new FileUploadForm(); 59 | //upload.getElement().setAttribute("multiple", "multiple"); 60 | upload2.getFileUpload().addChangeHandler(new ChangeHandler() { 61 | 62 | @Override 63 | public void onChange(ChangeEvent event) { 64 | JsArray files=FileUtils.toFile(event.getNativeEvent()); 65 | 66 | setFile(files,false); 67 | upload2.reset(); 68 | } 69 | }); 70 | panel.add(upload2); 71 | HorizontalPanel labels=new HorizontalPanel(); 72 | panel.add(labels); 73 | firstFileName=new Label(); 74 | firstFileName.setWidth("200px"); 75 | labels.add(firstFileName); 76 | secondFileName=new Label(); 77 | secondFileName.setWidth("200px"); 78 | labels.add(secondFileName); 79 | 80 | keepShort = new CheckBox("max frame is same as shorter one"); 81 | keepShort.setValue(true); 82 | panel.add(keepShort); 83 | 84 | loopShort = new CheckBox("loop shorter one"); 85 | loopShort.setValue(true); 86 | panel.add(loopShort); 87 | 88 | panel.add(new Label("Use BVH1 checks")); 89 | ScrollPanel scroll=new ScrollPanel(); 90 | scroll.setSize("400px", "200px"); 91 | boneCheckPanel=new VerticalPanel(); 92 | scroll.setWidget(boneCheckPanel); 93 | panel.add(scroll); 94 | 95 | mixButton = new Button("Mix"); 96 | 97 | mixButton.addClickHandler(new ClickHandler() { 98 | 99 | @Override 100 | public void onClick(ClickEvent event) { 101 | doMix(); 102 | } 103 | }); 104 | mixButton.setVisible(false); 105 | panel.add(mixButton); 106 | 107 | warnLabel = new Label("Error.bvh1 and bvh2 must have same bones"); 108 | panel.add(warnLabel); 109 | warnLabel.setVisible(false); 110 | 111 | HorizontalPanel buttons=new HorizontalPanel(); 112 | panel.add(buttons); 113 | buttons.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); 114 | buttons.setWidth("400px"); 115 | Button selectAll=new Button("Select Text"); 116 | buttons.add(selectAll); 117 | textArea = new TextArea(); 118 | 119 | textArea.setSize("400px", "100px"); 120 | textArea.setReadOnly(true); 121 | //textArea.setStylePrimaryName("nowrap"); ,wrap replace some char and make a problem 122 | panel.add(textArea); 123 | selectAll.addClickHandler(new ClickHandler() { 124 | @Override 125 | public void onClick(ClickEvent event) { 126 | textArea.selectAll(); 127 | } 128 | }); 129 | 130 | panel.add(createPlayButton("MixedData", textArea)); 131 | } 132 | 133 | private Map useMap=new HashMap(); 134 | 135 | VerticalPanel boneCheckPanel; 136 | 137 | 138 | protected void doMix() { 139 | BVH bvh1=bvhs.get(0); 140 | BVH bvh2=bvhs.get(1); 141 | 142 | BVH result=new BVH(); 143 | result.setHiearchy(bvh1.getHiearchy()); 144 | BVHMotion motion=new BVHMotion(); 145 | motion.setFrameTime(bvh1.getFrameTime()); 146 | result.setMotion(motion); 147 | 148 | int length=bvh1.getFrames(); 149 | if(bvh2.getFrames()>length){ 150 | if(!keepShort.getValue()){ 151 | length=bvh2.getFrames(); 152 | } 153 | }else{ 154 | if(keepShort.getValue()){ 155 | length=bvh2.getFrames(); 156 | } 157 | } 158 | 159 | List channel=bvh1.getNameAndChannels(); 160 | 161 | for(int i=0;i1){ 169 | int f=(i-bvh1.getFrames())%(bvh1.getFrames()-1);//skip first; 170 | value1=bvh1.getFrameAt(f+1); 171 | }else{ 172 | value1=new double[channel.size()]; 173 | } 174 | } 175 | 176 | if(i1){ 180 | int f=(i-bvh2.getFrames())%(bvh2.getFrames()-1);//skip first; 181 | value2=bvh2.getFrameAt(f+1); 182 | }else{ 183 | value2=new double[channel.size()]; 184 | } 185 | } 186 | 187 | double[] values=new double[channel.size()]; 188 | for(int j=0;j files,boolean isFirst){ 235 | 236 | LogUtils.log("file-size:"+files.length()); 237 | if(isFirst){ 238 | firstFile=files.get(0); 239 | if(files.length()>1){ 240 | secondFile=files.get(1); 241 | } 242 | }else{ 243 | secondFile=files.get(0); 244 | } 245 | 246 | 247 | updateLabel(); 248 | if(firstFile!=null && secondFile!=null){ 249 | loadFiles(); 250 | } 251 | 252 | } 253 | 254 | private void updateLabel(){ 255 | if(firstFile!=null){ 256 | firstFileName.setText(firstFile.getFileName()); 257 | } 258 | if(secondFile!=null){ 259 | secondFileName.setText(secondFile.getFileName()); 260 | } 261 | } 262 | private Label firstFileName,secondFileName; 263 | private List bvhs; 264 | private Label warnLabel; 265 | private Button mixButton; 266 | private void loadFiles(){ 267 | bvhs=new ArrayList(); 268 | final List files=new ArrayList(); 269 | files.add(firstFile); 270 | files.add(secondFile); 271 | final FileReader reader=FileReader.createFileReader(); 272 | reader.setOnLoad(new FileHandler() { 273 | @Override 274 | public void onLoad() { 275 | parseBVH(reader.getResultAsString()); 276 | if(files.size()>0){ 277 | File f=files.remove(0); 278 | reader.readAsText(f,"utf-8"); 279 | }else{//last 280 | 281 | doAllFileAction(); 282 | } 283 | } 284 | }); 285 | reader.readAsText(files.remove(0),"utf-8"); 286 | } 287 | 288 | 289 | 290 | 291 | protected void doAllFileAction() { 292 | //doStrip(); 293 | //check same and 294 | boolean same=isSameNode(bvhs.get(0), bvhs.get(1)); 295 | if(!same){ 296 | warnLabel.setVisible(true); 297 | mixButton.setVisible(false); 298 | }else{ 299 | warnLabel.setVisible(false); 300 | mixButton.setVisible(true); 301 | } 302 | useMap.clear(); 303 | //create check 304 | boneCheckPanel.clear(); 305 | BVH bvh=bvhs.get(0); 306 | for(BVHNode node:bvh.getNodeList()){ 307 | final CheckBox check=new CheckBox(); 308 | check.setText(node.getName()); 309 | check.addClickHandler(new ClickHandler() { 310 | 311 | @Override 312 | public void onClick(ClickEvent event) { 313 | if(check.getValue()){ 314 | useMap.put(check.getText(), true); 315 | }else{ 316 | useMap.put(check.getText(), false); 317 | } 318 | } 319 | }); 320 | check.setValue(true); 321 | useMap.put(node.getName(), true); 322 | boneCheckPanel.add(check); 323 | } 324 | } 325 | public static boolean isSameNode(BVH bvh1,BVH bvh2){ 326 | boolean same=true; 327 | List node1=bvh1.getNodeList(); 328 | List node2=bvh2.getNodeList(); 329 | if(node1.size()!=node2.size()){ 330 | return false; 331 | } 332 | for(int i=0;i files=FileUtils.toFile(event.getNativeEvent()); 45 | 46 | setFile(files); 47 | upload.reset(); 48 | } 49 | }); 50 | panel.add(upload); 51 | 52 | keepFirst = new CheckBox("keep first frame(usually pose frame)"); 53 | keepFirst.setValue(true); 54 | panel.add(keepFirst); 55 | 56 | Button restrip=new Button("Re Strip"); 57 | 58 | restrip.addClickHandler(new ClickHandler() { 59 | 60 | @Override 61 | public void onClick(ClickEvent event) { 62 | doStrip(); 63 | } 64 | }); 65 | panel.add(restrip); 66 | 67 | 68 | HorizontalPanel buttons=new HorizontalPanel(); 69 | panel.add(buttons); 70 | buttons.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); 71 | buttons.setWidth("400px"); 72 | Button selectAll=new Button("Select Text"); 73 | buttons.add(selectAll); 74 | textArea = new TextArea(); 75 | 76 | textArea.setSize("400px", "100px"); 77 | textArea.setReadOnly(true); 78 | //textArea.setStylePrimaryName("nowrap"); ,wrap replace some char and make a problem 79 | panel.add(textArea); 80 | selectAll.addClickHandler(new ClickHandler() { 81 | @Override 82 | public void onClick(ClickEvent event) { 83 | textArea.selectAll(); 84 | } 85 | }); 86 | 87 | panel.add(createPlayButton("Striped Data", textArea)); 88 | 89 | } 90 | 91 | 92 | 93 | 94 | 95 | 96 | protected void doStrip() { 97 | BVH bvh=bvhList.get(0); 98 | BVHMotion motion=new BVHMotion(); 99 | motion.setFrameTime(bvh.getFrameTime()); 100 | double[] value=bvh.getFrameAt(0); 101 | if(!keepFirst.getValue()){ 102 | for(int i=0;i bvhList; 126 | 127 | private TextArea textArea; 128 | 129 | private CheckBox keepFirst; 130 | 131 | private void parseBVH(String bvhText){ 132 | BVHParser parser=new BVHParser(); 133 | try { 134 | BVH bvh=parser.parse(bvhText); 135 | GWT.log("parsed"); 136 | //calcurate 137 | //List datas=new ArrayList(); 138 | 139 | 140 | 141 | bvhList.add(bvh); 142 | 143 | 144 | } catch (InvalidLineException e) { 145 | // TODO Auto-generated catch block 146 | e.printStackTrace(); 147 | } 148 | } 149 | 150 | private void setFile(JsArray files){ 151 | GWT.log("set-file:"+files.get(0)); 152 | 153 | bvhList=new ArrayList(); 154 | 155 | 156 | List fileList=new ArrayList(); 157 | for(int i=0;i files){ 165 | final FileReader reader=FileReader.createFileReader(); 166 | reader.setOnLoad(new FileHandler() { 167 | @Override 168 | public void onLoad() { 169 | parseBVH(reader.getResultAsString()); 170 | if(files.size()>0){ 171 | File f=files.remove(0); 172 | 173 | reader.readAsText(f,"utf-8"); 174 | }else{//last 175 | doAllFileAction(); 176 | } 177 | } 178 | }); 179 | reader.readAsText(files.remove(0),"utf-8"); 180 | } 181 | 182 | 183 | 184 | 185 | protected void doAllFileAction() { 186 | doStrip(); 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/tools/TextTool.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.tools; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.akjava.bvh.client.BVH; 7 | import com.akjava.bvh.client.BVHMotion; 8 | import com.akjava.bvh.client.BVHParser; 9 | import com.akjava.bvh.client.BVHParser.InvalidLineException; 10 | import com.akjava.bvh.client.BVHWriter; 11 | import com.akjava.gwt.bvhtools.client.BVHTools; 12 | import com.akjava.gwt.bvhtools.client.file.TextAreaDataContainer; 13 | import com.akjava.gwt.html5.client.file.File; 14 | import com.akjava.gwt.html5.client.file.FileHandler; 15 | import com.akjava.gwt.html5.client.file.FileReader; 16 | import com.akjava.gwt.html5.client.file.FileUploadForm; 17 | import com.akjava.gwt.html5.client.file.FileUtils; 18 | import com.google.gwt.core.client.GWT; 19 | import com.google.gwt.core.client.JsArray; 20 | import com.google.gwt.event.dom.client.ChangeEvent; 21 | import com.google.gwt.event.dom.client.ChangeHandler; 22 | import com.google.gwt.event.dom.client.ClickEvent; 23 | import com.google.gwt.event.dom.client.ClickHandler; 24 | import com.google.gwt.user.client.ui.Button; 25 | import com.google.gwt.user.client.ui.CheckBox; 26 | import com.google.gwt.user.client.ui.FileUpload; 27 | import com.google.gwt.user.client.ui.HorizontalPanel; 28 | import com.google.gwt.user.client.ui.Label; 29 | import com.google.gwt.user.client.ui.TextArea; 30 | import com.google.gwt.user.client.ui.VerticalPanel; 31 | 32 | public class TextTool extends AbstractTool{ 33 | 34 | public TextTool(VerticalPanel panel){ 35 | super(panel); 36 | 37 | 38 | final FileUploadForm upload=new FileUploadForm(); 39 | //upload.getElement().setAttribute("multiple", "multiple"); 40 | upload.getFileUpload().addChangeHandler(new ChangeHandler() { 41 | 42 | @Override 43 | public void onChange(ChangeEvent event) { 44 | JsArray files=FileUtils.toFile(event.getNativeEvent()); 45 | 46 | setFile(files); 47 | upload.reset(); 48 | } 49 | }); 50 | panel.add(upload); 51 | 52 | 53 | /* 54 | Button restrip=new Button("Re Strip"); 55 | 56 | restrip.addClickHandler(new ClickHandler() { 57 | 58 | @Override 59 | public void onClick(ClickEvent event) { 60 | doText(); 61 | } 62 | }); 63 | panel.add(restrip); 64 | */ 65 | 66 | 67 | HorizontalPanel buttons=new HorizontalPanel(); 68 | panel.add(buttons); 69 | buttons.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); 70 | buttons.setWidth("400px"); 71 | //Button selectAll=new Button("Select Text"); 72 | // buttons.add(selectAll); 73 | textArea = new TextArea(); 74 | 75 | textArea.setSize("400px", "300px"); 76 | //textArea.setReadOnly(true); 77 | //textArea.setStylePrimaryName("nowrap"); ,wrap replace some char and make a problem 78 | panel.add(textArea); 79 | /* 80 | selectAll.addClickHandler(new ClickHandler() { 81 | @Override 82 | public void onClick(ClickEvent event) { 83 | textArea.selectAll(); 84 | } 85 | }); 86 | */ 87 | 88 | panel.add(createPlayButton("Striped Data", textArea)); 89 | 90 | } 91 | 92 | 93 | 94 | 95 | 96 | 97 | protected void doText() { 98 | BVH bvh=bvhList.get(0); 99 | 100 | 101 | BVHWriter writer=new BVHWriter(); 102 | 103 | String text=writer.writeToString(bvh); 104 | textArea.setText(text); 105 | } 106 | 107 | 108 | 109 | 110 | 111 | 112 | List bvhList; 113 | 114 | private TextArea textArea; 115 | 116 | 117 | 118 | private void parseBVH(String bvhText){ 119 | BVHParser parser=new BVHParser(); 120 | try { 121 | BVH bvh=parser.parse(bvhText); 122 | GWT.log("parsed"); 123 | //calcurate 124 | //List datas=new ArrayList(); 125 | 126 | 127 | 128 | bvhList.add(bvh); 129 | 130 | 131 | } catch (InvalidLineException e) { 132 | // TODO Auto-generated catch block 133 | e.printStackTrace(); 134 | } 135 | } 136 | 137 | private void setFile(JsArray files){ 138 | GWT.log("set-file:"+files.get(0)); 139 | 140 | bvhList=new ArrayList(); 141 | 142 | 143 | List fileList=new ArrayList(); 144 | for(int i=0;i files){ 152 | final FileReader reader=FileReader.createFileReader(); 153 | reader.setOnLoad(new FileHandler() { 154 | @Override 155 | public void onLoad() { 156 | parseBVH(reader.getResultAsString()); 157 | if(files.size()>0){ 158 | File f=files.remove(0); 159 | 160 | reader.readAsText(f,"utf-8"); 161 | }else{//last 162 | doAllFileAction(); 163 | } 164 | } 165 | }); 166 | reader.readAsText(files.remove(0),"utf-8"); 167 | } 168 | 169 | 170 | 171 | 172 | protected void doAllFileAction() { 173 | doText(); 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /src/com/akjava/gwt/bvhtools/client/tools/ThinTool.java: -------------------------------------------------------------------------------- 1 | package com.akjava.gwt.bvhtools.client.tools; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.akjava.bvh.client.BVH; 7 | import com.akjava.bvh.client.BVHMotion; 8 | import com.akjava.bvh.client.BVHParser; 9 | import com.akjava.bvh.client.BVHParser.InvalidLineException; 10 | import com.akjava.bvh.client.BVHWriter; 11 | import com.akjava.gwt.html5.client.file.File; 12 | import com.akjava.gwt.html5.client.file.FileHandler; 13 | import com.akjava.gwt.html5.client.file.FileReader; 14 | import com.akjava.gwt.html5.client.file.FileUploadForm; 15 | import com.akjava.gwt.html5.client.file.FileUtils; 16 | import com.google.gwt.core.client.GWT; 17 | import com.google.gwt.core.client.JsArray; 18 | import com.google.gwt.event.dom.client.ChangeEvent; 19 | import com.google.gwt.event.dom.client.ChangeHandler; 20 | import com.google.gwt.event.dom.client.ClickEvent; 21 | import com.google.gwt.event.dom.client.ClickHandler; 22 | import com.google.gwt.user.client.ui.Button; 23 | import com.google.gwt.user.client.ui.CheckBox; 24 | import com.google.gwt.user.client.ui.FileUpload; 25 | import com.google.gwt.user.client.ui.HorizontalPanel; 26 | import com.google.gwt.user.client.ui.Label; 27 | import com.google.gwt.user.client.ui.ListBox; 28 | import com.google.gwt.user.client.ui.TextArea; 29 | import com.google.gwt.user.client.ui.TextBox; 30 | import com.google.gwt.user.client.ui.VerticalPanel; 31 | 32 | public class ThinTool extends AbstractTool{ 33 | 34 | private Label logLabel; 35 | public ThinTool(VerticalPanel panel){ 36 | super(panel); 37 | 38 | 39 | final FileUploadForm upload=new FileUploadForm(); 40 | //upload.getElement().setAttribute("multiple", "multiple"); 41 | upload.getFileUpload().addChangeHandler(new ChangeHandler() { 42 | 43 | @Override 44 | public void onChange(ChangeEvent event) { 45 | JsArray files=FileUtils.toFile(event.getNativeEvent()); 46 | 47 | setFile(files); 48 | upload.reset(); 49 | } 50 | }); 51 | panel.add(upload); 52 | 53 | HorizontalPanel valuePanel=new HorizontalPanel(); 54 | 55 | panel.add(valuePanel); 56 | valuePanel.add(new Label("thin out by")); 57 | thinSize = new TextBox(); 58 | thinSize.setText("10");//default 59 | thinSize.setWidth("60px"); 60 | valuePanel.add(thinSize); 61 | final ListBox values=new ListBox(); 62 | values.addItem("1"); 63 | values.addItem("2"); 64 | values.addItem("5"); 65 | values.addItem("10"); 66 | values.addItem("25"); 67 | values.addItem("50"); 68 | values.addItem("100"); 69 | values.addItem("1000"); 70 | values.setSelectedIndex(3); 71 | values.addChangeHandler(new ChangeHandler() { 72 | @Override 73 | public void onChange(ChangeEvent event) { 74 | thinSize.setText(values.getValue(values.getSelectedIndex())); 75 | } 76 | }); 77 | valuePanel.add(new Label("preset")); 78 | valuePanel.add(values); 79 | 80 | 81 | Button rethin=new Button("Re Thin out"); 82 | 83 | rethin.addClickHandler(new ClickHandler() { 84 | 85 | @Override 86 | public void onClick(ClickEvent event) { 87 | doThinOut(); 88 | } 89 | }); 90 | panel.add(rethin); 91 | 92 | logLabel=new Label(); 93 | panel.add(logLabel); 94 | 95 | HorizontalPanel buttons=new HorizontalPanel(); 96 | panel.add(buttons); 97 | buttons.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); 98 | buttons.setWidth("400px"); 99 | Button selectAll=new Button("Select Text"); 100 | buttons.add(selectAll); 101 | textArea = new TextArea(); 102 | 103 | 104 | 105 | textArea.setSize("400px", "100px"); 106 | textArea.setReadOnly(true); 107 | //textArea.setStylePrimaryName("nowrap"); ,wrap replace some char and make a problem 108 | panel.add(textArea); 109 | selectAll.addClickHandler(new ClickHandler() { 110 | @Override 111 | public void onClick(ClickEvent event) { 112 | textArea.selectAll(); 113 | } 114 | }); 115 | 116 | panel.add(createPlayButton("ThinOuted Data", textArea)); 117 | } 118 | 119 | 120 | 121 | 122 | 123 | 124 | List bvhList; 125 | 126 | private TextArea textArea; 127 | 128 | private CheckBox skipFirst; 129 | 130 | private void parseBVH(String bvhText){ 131 | BVHParser parser=new BVHParser(); 132 | try { 133 | BVH bvh=parser.parse(bvhText); 134 | GWT.log("parsed"); 135 | //calcurate 136 | bvhList.add(bvh); 137 | 138 | 139 | } catch (InvalidLineException e) { 140 | // TODO Auto-generated catch block 141 | e.printStackTrace(); 142 | } 143 | } 144 | 145 | private void setFile(JsArray files){ 146 | GWT.log("set-file:"+files.get(0)); 147 | 148 | bvhList=new ArrayList(); 149 | 150 | 151 | List fileList=new ArrayList(); 152 | for(int i=0;i files){ 160 | final FileReader reader=FileReader.createFileReader(); 161 | reader.setOnLoad(new FileHandler() { 162 | @Override 163 | public void onLoad() { 164 | parseBVH(reader.getResultAsString()); 165 | if(files.size()>0){ 166 | File f=files.remove(0); 167 | 168 | reader.readAsText(f,"utf-8"); 169 | }else{//last 170 | doAllFileAction(); 171 | } 172 | } 173 | }); 174 | reader.readAsText(files.remove(0),"utf-8"); 175 | } 176 | 177 | private void doThinOut(){ 178 | 179 | int skips=1; 180 | try{ 181 | skips=Integer.parseInt(thinSize.getValue()); 182 | }catch(Exception e){} 183 | 184 | BVH bvh=bvhList.get(0); 185 | bvh.setSkips(skips); 186 | BVHWriter writer=new BVHWriter(); 187 | 188 | String text=writer.writeToString(bvh); 189 | textArea.setText(text); 190 | 191 | logLabel.setText("from "+bvh.getMotion().getFrames()+" to "+bvh.getFrames()); 192 | } 193 | 194 | 195 | 196 | private TextBox thinSize; 197 | 198 | protected void doAllFileAction() { 199 | doThinOut(); 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /war/BVHTools.css: -------------------------------------------------------------------------------- 1 | /** Add css rules here for your application. */ 2 | 3 | 4 | /** Example rules used by the template application (remove for your app) */ 5 | h1 { 6 | font-size: 2em; 7 | font-weight: bold; 8 | color: #777777; 9 | margin: 40px 0px 70px; 10 | text-align: center; 11 | } 12 | 13 | .sendButton { 14 | display: block; 15 | font-size: 16pt; 16 | } 17 | 18 | /** Most GWT widgets already have a style name defined */ 19 | .gwt-DialogBox { 20 | width: 400px; 21 | } 22 | 23 | .dialogVPanel { 24 | margin: 5px; 25 | } 26 | 27 | .serverResponseLabelError { 28 | color: red; 29 | } 30 | 31 | /** Set ids using widget.getElement().setId("idOfElement") */ 32 | #closeButton { 33 | margin: 15px 6px 6px; 34 | } 35 | 36 | .fileborder{ 37 | border:inset 1px #aaaaaa; 38 | } 39 | .selected{ 40 | background: #ccccff; 41 | } 42 | 43 | .bvhlabel { cursor: pointer } 44 | -------------------------------------------------------------------------------- /war/BVHTools.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /war/GWTBVH.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /war/WEB-INF/.gitignore: -------------------------------------------------------------------------------- 1 | /deploy 2 | -------------------------------------------------------------------------------- /war/WEB-INF/lib/gwt-servlet.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akjava/BVH-Motion-Creator/fc05cfb750d8edadb5ca94e369b55b9f8d121dfd/war/WEB-INF/lib/gwt-servlet.jar -------------------------------------------------------------------------------- /war/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | BVHTools.html 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /war/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akjava/BVH-Motion-Creator/fc05cfb750d8edadb5ca94e369b55b9f8d121dfd/war/icon.png -------------------------------------------------------------------------------- /war/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | BVH Motion Creator 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /war/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BVH Player", 3 | "description": "Model Weight Editor", 4 | "version": "1.0.1", 5 | "app": { 6 | "launch": { 7 | "local_path": "index.html" 8 | } 9 | }, 10 | "icons": { 11 | "128": "icon.png" 12 | }, 13 | "permissions": [ 14 | "unlimitedStorage" 15 | ] 16 | } -------------------------------------------------------------------------------- /war/pose.bvh: -------------------------------------------------------------------------------- 1 | HIERARCHY 2 | ROOT Hips 3 | { 4 | OFFSET 0 0 0 5 | CHANNELS 6 Xposition Yposition Zposition Zrotation Yrotation Xrotation 6 | JOINT LHipJoint 7 | { 8 | OFFSET 0 0 0 9 | CHANNELS 3 Zrotation Yrotation Xrotation 10 | JOINT LeftUpLeg 11 | { 12 | OFFSET 1.48061 -1.808 0.67318 13 | CHANNELS 3 Zrotation Yrotation Xrotation 14 | JOINT LeftLeg 15 | { 16 | OFFSET 2.63258 -7.23296 0 17 | CHANNELS 3 Zrotation Yrotation Xrotation 18 | JOINT LeftFoot 19 | { 20 | OFFSET 2.54779 -7 0 21 | CHANNELS 3 Zrotation Yrotation Xrotation 22 | JOINT LeftToeBase 23 | { 24 | OFFSET 0.23067 -0.63376 2.12161 25 | CHANNELS 3 Zrotation Yrotation Xrotation 26 | End Site 27 | { 28 | OFFSET 0 0 1.11 29 | } 30 | } 31 | } 32 | } 33 | } 34 | } 35 | JOINT RHipJoint 36 | { 37 | OFFSET 0 0 0 38 | CHANNELS 3 Zrotation Yrotation Xrotation 39 | JOINT RightUpLeg 40 | { 41 | OFFSET -1.48061 -1.808 0.67318 42 | CHANNELS 3 Zrotation Yrotation Xrotation 43 | JOINT RightLeg 44 | { 45 | OFFSET -2.63258 -7.23296 0 46 | CHANNELS 3 Zrotation Yrotation Xrotation 47 | JOINT RightFoot 48 | { 49 | OFFSET -2.54779 -7 0 50 | CHANNELS 3 Zrotation Yrotation Xrotation 51 | JOINT RightToeBase 52 | { 53 | OFFSET -0.23067 -0.63376 2.12161 54 | CHANNELS 3 Zrotation Yrotation Xrotation 55 | End Site 56 | { 57 | OFFSET 0 0 1.11 58 | } 59 | } 60 | } 61 | } 62 | } 63 | } 64 | JOINT LowerBack 65 | { 66 | OFFSET 0 0 0 67 | CHANNELS 3 Zrotation Yrotation Xrotation 68 | JOINT Spine 69 | { 70 | OFFSET -0.02108 2.07573 -0.16981 71 | CHANNELS 3 Zrotation Yrotation Xrotation 72 | JOINT Spine1 73 | { 74 | OFFSET 0.0507 2.08439 -0.03141 75 | CHANNELS 3 Zrotation Yrotation Xrotation 76 | JOINT Neck 77 | { 78 | OFFSET 0 0 0 79 | CHANNELS 3 Zrotation Yrotation Xrotation 80 | JOINT Neck1 81 | { 82 | OFFSET -0.10731 1.60408 0.3137 83 | CHANNELS 3 Zrotation Yrotation Xrotation 84 | JOINT Head 85 | { 86 | OFFSET 0.08411 1.65679 -0.30822 87 | CHANNELS 3 Zrotation Yrotation Xrotation 88 | End Site 89 | { 90 | OFFSET 0.03911 1.69149 -0.14146 91 | } 92 | } 93 | } 94 | } 95 | JOINT LeftShoulder 96 | { 97 | OFFSET 0 0 0 98 | CHANNELS 3 Zrotation Yrotation Xrotation 99 | JOINT LeftArm 100 | { 101 | OFFSET 2.65 0.73219 -0.54694 102 | CHANNELS 3 Zrotation Yrotation Xrotation 103 | JOINT LeftForeArm 104 | { 105 | OFFSET 4.33589 0 0 106 | CHANNELS 3 Zrotation Yrotation Xrotation 107 | JOINT LeftHand 108 | { 109 | OFFSET 3.64134 0 0 110 | CHANNELS 3 Zrotation Yrotation Xrotation 111 | JOINT LeftFingerBase 112 | { 113 | OFFSET 0 0 0 114 | CHANNELS 3 Zrotation Yrotation Xrotation 115 | JOINT LeftHandIndex1 116 | { 117 | OFFSET 0.73481 0 0 118 | CHANNELS 3 Zrotation Yrotation Xrotation 119 | End Site 120 | { 121 | OFFSET 0.59242 0 0 122 | } 123 | } 124 | } 125 | JOINT LThumb 126 | { 127 | OFFSET 0 0 0 128 | CHANNELS 3 Zrotation Yrotation Xrotation 129 | End Site 130 | { 131 | OFFSET 0.60147 0 0.60147 132 | } 133 | } 134 | } 135 | } 136 | } 137 | } 138 | JOINT RightShoulder 139 | { 140 | OFFSET 0 0 0 141 | CHANNELS 3 Zrotation Yrotation Xrotation 142 | JOINT RightArm 143 | { 144 | OFFSET -2.65 0.73219 -0.54694 145 | CHANNELS 3 Zrotation Yrotation Xrotation 146 | JOINT RightForeArm 147 | { 148 | OFFSET -4.33589 0 0 149 | CHANNELS 3 Zrotation Yrotation Xrotation 150 | JOINT RightHand 151 | { 152 | OFFSET -3.64134 0 0 153 | CHANNELS 3 Zrotation Yrotation Xrotation 154 | JOINT RightFingerBase 155 | { 156 | OFFSET 0 0 0 157 | CHANNELS 3 Zrotation Yrotation Xrotation 158 | JOINT RightHandIndex1 159 | { 160 | OFFSET -0.73481 0 0 161 | CHANNELS 3 Zrotation Yrotation Xrotation 162 | End Site 163 | { 164 | OFFSET -0.59242 0 0 165 | } 166 | } 167 | } 168 | JOINT RThumb 169 | { 170 | OFFSET 0 0 0 171 | CHANNELS 3 Zrotation Yrotation Xrotation 172 | End Site 173 | { 174 | OFFSET -0.60147 0 0.60147 175 | } 176 | } 177 | } 178 | } 179 | } 180 | } 181 | } 182 | } 183 | } 184 | } 185 | MOTION 186 | Frames: 1 187 | Frame Time: 0.0083333 188 | 3.0615 17.3489 -3.5799 0 0 0 0 0 0 -21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -16 0 0 21 0 0 11 0 0 0 -8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /war/pose_help.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
 4 | Pose Editor is Creating BVH Motion App.
 5 | 
 6 | Easy to Create Motion with IK-Bone
 7 | English Info
 8 | Japanese Info
 9 | 
10 | 11 | -------------------------------------------------------------------------------- /war/stats.min.js: -------------------------------------------------------------------------------- 1 | // stats.js - http://github.com/mrdoob/stats.js 2 | var Stats=function(){var l=Date.now(),m=l,g=0,n=Infinity,o=0,h=0,p=Infinity,q=0,r=0,s=0,f=document.createElement("div");f.id="stats";f.addEventListener("mousedown",function(b){b.preventDefault();t(++s%2)},!1);f.style.cssText="width:80px;opacity:0.9;cursor:pointer";var a=document.createElement("div");a.id="fps";a.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#002";f.appendChild(a);var i=document.createElement("div");i.id="fpsText";i.style.cssText="color:#0ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px"; 3 | i.innerHTML="FPS";a.appendChild(i);var c=document.createElement("div");c.id="fpsGraph";c.style.cssText="position:relative;width:74px;height:30px;background-color:#0ff";for(a.appendChild(c);74>c.children.length;){var j=document.createElement("span");j.style.cssText="width:1px;height:30px;float:left;background-color:#113";c.appendChild(j)}var d=document.createElement("div");d.id="ms";d.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#020;display:none";f.appendChild(d);var k=document.createElement("div"); 4 | k.id="msText";k.style.cssText="color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px";k.innerHTML="MS";d.appendChild(k);var e=document.createElement("div");e.id="msGraph";e.style.cssText="position:relative;width:74px;height:30px;background-color:#0f0";for(d.appendChild(e);74>e.children.length;)j=document.createElement("span"),j.style.cssText="width:1px;height:30px;float:left;background-color:#131",e.appendChild(j);var t=function(b){s=b;switch(s){case 0:a.style.display= 5 | "block";d.style.display="none";break;case 1:a.style.display="none",d.style.display="block"}};return{REVISION:11,domElement:f,setMode:t,begin:function(){l=Date.now()},end:function(){var b=Date.now();g=b-l;n=Math.min(n,g);o=Math.max(o,g);k.textContent=g+" MS ("+n+"-"+o+")";var a=Math.min(30,30-30*(g/200));e.appendChild(e.firstChild).style.height=a+"px";r++;b>m+1E3&&(h=Math.round(1E3*r/(b-m)),p=Math.min(p,h),q=Math.max(q,h),i.textContent=h+" FPS ("+p+"-"+q+")",a=Math.min(30,30-30*(h/100)),c.appendChild(c.firstChild).style.height= 6 | a+"px",m=b,r=0);return b},update:function(){l=this.end()}}}; 7 | -------------------------------------------------------------------------------- /war/weight_help.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
 4 | Model Weight Tool is Skining BVH & Three.js Model 
 5 | 
 6 | this tool can create model for Pose Editor
 7 | the format is same as SkinnedMesh but it not work perfectlly yet.
 8 | 
 9 | Japanese Info
10 | 
11 | 
12 | 13 | --------------------------------------------------------------------------------