Skip to content

Commit b3f1442

Browse files
committed
добавлен акшен для генерации тангентов старым способом
1 parent 854c7af commit b3f1442

9 files changed

Lines changed: 85 additions & 10 deletions

File tree

resources/messages/messages.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ModelFileEditorNodeTree=Structure
8181
ModelFileEditorProperties=Properties
8282
ModelFileEditorNodeMesh=Mesh
8383

84-
ModelNodeTreeActionMikktspaceTangentGenerator=Generate tangents
84+
ModelNodeTreeActionMikktspaceTangentGenerator=Generate tangents using Mikktspace algorithm
8585
ModelNodeTreeActionRemove=Remove
8686
ModelNodeTreeActionRename=Rename
8787
ModelNodeTreeActionOptimizeGeometry=Optimize geometry
@@ -94,6 +94,7 @@ ModelNodeTreeActionCreatePrimitiveBox=Box
9494
ModelNodeTreeActionCreatePrimitiveSphere=Sphere
9595
ModelNodeTreeActionCreatePrimitiveQuad=Quad
9696
ModelNodeTreeActionLoadModel=Load model
97+
ModelNodeTreeActionTangentGenerator=Generate tangents using normal algorithm
9798

9899
ModelPropertyCullHint=Cull Hint
99100
ModelPropertyShadowMode=Shadow mode

resources/messages/messages_ru.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ModelFileEditorNodeTree=Структура
8181
ModelFileEditorProperties=Свойства
8282
ModelFileEditorNodeMesh=Сетка
8383

84-
ModelNodeTreeActionMikktspaceTangentGenerator=Сгенерировать тангенты
84+
ModelNodeTreeActionMikktspaceTangentGenerator=Сгенерировать тангенты используя алгоритм Mikktspace
8585
ModelNodeTreeActionRemove=Удалить
8686
ModelNodeTreeActionRename=Переименовать
8787
ModelNodeTreeActionOptimizeGeometry=Оптимизировать геометрию
@@ -94,6 +94,7 @@ ModelNodeTreeActionCreatePrimitiveBox=Куб
9494
ModelNodeTreeActionCreatePrimitiveSphere=Сфера
9595
ModelNodeTreeActionCreatePrimitiveQuad=Плоскость
9696
ModelNodeTreeActionLoadModel=Загрузить модель
97+
ModelNodeTreeActionTangentGenerator=Сгенерировать тангенты используя обычный алгоритм
9798

9899
ModelPropertyCullHint=Cull Hint
99100
ModelPropertyShadowMode=Режим теней

src/com/ss/editor/Editor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public void simpleInitApp() {
241241

242242
ExecutorManager.getInstance();
243243

244-
final UbuntuCursorProvider cursorDisplayProvider = new UbuntuCursorProvider(this, this.assetManager, inputManager);
244+
final UbuntuCursorProvider cursorDisplayProvider = new UbuntuCursorProvider(this, assetManager, inputManager);
245245

246246
for (final CursorType type : CursorType.values()) {
247247
cursorDisplayProvider.setup(type);
@@ -250,7 +250,7 @@ public void simpleInitApp() {
250250
flyCam.setDragToRotate(true);
251251
flyCam.setEnabled(false);
252252

253-
postProcessor = new FilterPostProcessor(this.assetManager);
253+
postProcessor = new FilterPostProcessor(assetManager);
254254
postProcessor.initialize(renderManager, viewPort);
255255

256256
if (editorConfig.isFXAA()) {
@@ -265,6 +265,8 @@ public void simpleInitApp() {
265265
postProcessor.addFilter(filter);
266266
}
267267

268+
// postProcessor.addFilter(new ToneMapFilter());
269+
268270
viewPort.addProcessor(postProcessor);
269271

270272
InitializeManager.register(ResourceManager.class);

src/com/ss/editor/Messages.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public class Messages {
106106
public static final String MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE_SPHERE;
107107
public static final String MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE_QUAD;
108108
public static final String MODEL_NODE_TREE_ACTION_LOAD_MODEL;
109+
public static final String MODEL_NODE_TREE_ACTION_TANGENT_GENERATOR;
109110

110111
public static final String MODEL_PROPERTY_CULL_HINT;
111112
public static final String MODEL_PROPERTY_SHADOW_MODE;
@@ -152,7 +153,6 @@ public class Messages {
152153
public static final String EMPTY_MODEL_CREATOR_DESCRIPTION;
153154
public static final String EMPTY_MODEL_CREATOR_TITLE;
154155

155-
156156
static {
157157

158158
final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME, ResourceControl.getInstance());
@@ -253,6 +253,7 @@ public class Messages {
253253
MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE_SPHERE = bundle.getString("ModelNodeTreeActionCreatePrimitiveSphere");
254254
MODEL_NODE_TREE_ACTION_CREATE_PRIMITIVE_QUAD = bundle.getString("ModelNodeTreeActionCreatePrimitiveQuad");
255255
MODEL_NODE_TREE_ACTION_LOAD_MODEL = bundle.getString("ModelNodeTreeActionLoadModel");
256+
MODEL_NODE_TREE_ACTION_TANGENT_GENERATOR = bundle.getString("ModelNodeTreeActionTangentGenerator");
256257

257258
MODEL_PROPERTY_CULL_HINT = bundle.getString("ModelPropertyCullHint");
258259
MODEL_PROPERTY_SHADOW_MODE = bundle.getString("ModelPropertyShadowMode");

src/com/ss/editor/ui/component/editor/impl/model/ModelFileEditor.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,15 @@ private void processChangedFile(final FileChangedEvent event) {
152152
final Path file = event.getFile();
153153
final String extension = FileUtils.getExtension(file);
154154

155-
if (!extension.endsWith(FileExtensions.JME_MATERIAL)) {
156-
return;
155+
if (extension.endsWith(FileExtensions.JME_MATERIAL)) {
156+
updateMaterial(file);
157157
}
158+
}
159+
160+
/**
161+
* Процесс обновления материала.
162+
*/
163+
private void updateMaterial(final Path file) {
158164

159165
final Path assetFile = EditorUtil.getAssetFile(file);
160166
final String assetPath = EditorUtil.toAssetPath(assetFile);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.ss.editor.ui.control.model.tree.action;
2+
3+
import com.jme3.scene.Geometry;
4+
import com.ss.editor.Messages;
5+
import com.ss.editor.model.tool.TangentGenerator;
6+
import com.ss.editor.ui.control.model.tree.ModelNodeTree;
7+
import com.ss.editor.ui.control.model.tree.node.ModelNode;
8+
9+
/**
10+
* Реализация действия по генерации тангетов используя старый алгоритм.
11+
*
12+
* @author Ronn
13+
*/
14+
public class TangentGeneratorAction extends AbstractNodeAction {
15+
16+
public TangentGeneratorAction(final ModelNodeTree nodeTree, final ModelNode<?> node) {
17+
super(nodeTree, node);
18+
}
19+
20+
@Override
21+
protected String getName() {
22+
return Messages.MODEL_NODE_TREE_ACTION_TANGENT_GENERATOR;
23+
}
24+
25+
@Override
26+
protected void process() {
27+
28+
final ModelNode<?> node = getNode();
29+
final Geometry element = (Geometry) node.getElement();
30+
31+
TangentGenerator.useStandardGenerator(element, false);
32+
33+
final ModelNodeTree nodeTree = getNodeTree();
34+
nodeTree.notifyChanged(node);
35+
}
36+
}

src/com/ss/editor/ui/control/model/tree/node/GeometryModelNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.ss.editor.ui.control.model.tree.ModelNodeTree;
88
import com.ss.editor.ui.control.model.tree.action.MikktspaceTangetGeneratorAction;
99
import com.ss.editor.ui.control.model.tree.action.RenameNodeAction;
10+
import com.ss.editor.ui.control.model.tree.action.TangentGeneratorAction;
1011

1112
import javafx.collections.ObservableList;
1213
import javafx.scene.control.Menu;
@@ -57,7 +58,7 @@ public Array<ModelNode<?>> getChildren() {
5758
public void fillContextMenu(final ModelNodeTree nodeTree, final ObservableList<MenuItem> items) {
5859

5960
final Menu toolActions = new Menu(Messages.MODEL_NODE_TREE_ACTION_TOOLS);
60-
toolActions.getItems().addAll(new MikktspaceTangetGeneratorAction(nodeTree, this));
61+
toolActions.getItems().addAll(new TangentGeneratorAction(nodeTree, this), new MikktspaceTangetGeneratorAction(nodeTree, this));
6162

6263
items.add(toolActions);
6364
items.add(new RenameNodeAction(nodeTree, this));

src/com/ss/editor/ui/tooltip/ImageChannelPreview.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ private ImageView getRedView() {
171171
*/
172172
public void showImage(final Path file) {
173173

174-
final Image image = file == null? null : IMAGE_MANAGER.getTexturePreview(file, 120, 120);
174+
final Image image = file == null ? null : IMAGE_MANAGER.getTexturePreview(file, 120, 120);
175175

176-
if (file == null|| image.getWidth() != 120) {
176+
if (file == null || image.getWidth() != 120) {
177177

178178
final ImageView redView = getRedView();
179179
redView.setImage(null);

src/com/ss/editor/util/EditorUtil.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.ss.editor.util;
22

3+
import com.jme3.asset.AssetKey;
34
import com.jme3.material.Material;
45
import com.jme3.math.Vector2f;
56
import com.jme3.math.Vector3f;
@@ -135,6 +136,32 @@ public static void addGeometryWithMaterial(final Spatial spatial, final Array<Ge
135136
}
136137
}
137138

139+
/**
140+
* Сбор всех объектов использующих указанный asset path.
141+
*/
142+
public static void addSpatialWithAssetPath(final Spatial spatial, final Array<Spatial> container, final String assetPath) {
143+
144+
if (StringUtils.isEmpty(assetPath)) {
145+
return;
146+
}
147+
148+
final AssetKey key = spatial.getKey();
149+
150+
if (key != null && StringUtils.equals(key.getName(), assetPath)) {
151+
container.add(spatial);
152+
}
153+
154+
if (!(spatial instanceof Node)) {
155+
return;
156+
}
157+
158+
final Node node = (Node) spatial;
159+
160+
for (final Spatial children : node.getChildren()) {
161+
addSpatialWithAssetPath(children, container, assetPath);
162+
}
163+
}
164+
138165
/**
139166
* Сбор всей геометрии.
140167
*/

0 commit comments

Comments
 (0)