* Proper equals/hashCode methods in OgreMaterialKey/OgreMeshKey
* Formatting in MaterialExtensionSet git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9305 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
f844ca429f
commit
90f32dc703
@ -66,6 +66,36 @@ public class OgreMeshKey extends ModelKey {
|
|||||||
this.materialName = materialName;
|
this.materialName = materialName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final OgreMeshKey other = (OgreMeshKey) obj;
|
||||||
|
if (!super.equals(other)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.materialList != other.materialList && (this.materialList == null || !this.materialList.equals(other.materialList))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ((this.materialName == null) ? (other.materialName != null) : !this.materialName.equals(other.materialName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 5;
|
||||||
|
hash = 31 * hash + (super.hashCode());
|
||||||
|
hash = 31 * hash + (this.materialList != null ? this.materialList.hashCode() : 0);
|
||||||
|
hash = 31 * hash + (this.materialName != null ? this.materialName.hashCode() : 0);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
public MaterialList getMaterialList() {
|
public MaterialList getMaterialList() {
|
||||||
return materialList;
|
return materialList;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.jme3.scene.plugins.ogre.matext;
|
package com.jme3.scene.plugins.ogre.matext;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -42,44 +41,46 @@ import java.util.List;
|
|||||||
* {@link OgreMaterialKey}s used.
|
* {@link OgreMaterialKey}s used.
|
||||||
*/
|
*/
|
||||||
public class MaterialExtensionSet {
|
public class MaterialExtensionSet {
|
||||||
private HashMap<String, MaterialExtension> extensions
|
|
||||||
= new HashMap<String, MaterialExtension>();
|
private HashMap<String, MaterialExtension> extensions = new HashMap<String, MaterialExtension>();
|
||||||
private HashMap<String, List<String>> nameMappings = new HashMap<String, List<String>>();
|
private HashMap<String, List<String>> nameMappings = new HashMap<String, List<String>>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new material extension to the set of extensions.
|
* Adds a new material extension to the set of extensions.
|
||||||
|
*
|
||||||
* @param extension The {@link MaterialExtension} to add.
|
* @param extension The {@link MaterialExtension} to add.
|
||||||
*/
|
*/
|
||||||
public void addMaterialExtension(MaterialExtension extension){
|
public void addMaterialExtension(MaterialExtension extension) {
|
||||||
extensions.put(extension.getBaseMaterialName(), extension);
|
extensions.put(extension.getBaseMaterialName(), extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link MaterialExtension} for a given Ogre3D base
|
* Returns the {@link MaterialExtension} for a given Ogre3D base material
|
||||||
* material name.
|
* name.
|
||||||
*
|
*
|
||||||
* @param baseMatName The ogre3D base material name.
|
* @param baseMatName The ogre3D base material name.
|
||||||
* @return {@link MaterialExtension} that is set, or null if not set.
|
* @return {@link MaterialExtension} that is set, or null if not set.
|
||||||
*/
|
*/
|
||||||
public MaterialExtension getMaterialExtension(String baseMatName){
|
public MaterialExtension getMaterialExtension(String baseMatName) {
|
||||||
return extensions.get(baseMatName);
|
return extensions.get(baseMatName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an alternative name for a material
|
* Adds an alternative name for a material
|
||||||
|
*
|
||||||
* @param name The material name to be found in a .mesh.xml file
|
* @param name The material name to be found in a .mesh.xml file
|
||||||
* @param alias The material name to be found in a .material file
|
* @param alias The material name to be found in a .material file
|
||||||
*/
|
*/
|
||||||
public void setNameMapping(String name, String alias){
|
public void setNameMapping(String name, String alias) {
|
||||||
List<String> list = nameMappings.get(name);
|
List<String> list = nameMappings.get(name);
|
||||||
if(list==null){
|
if (list == null) {
|
||||||
list = new ArrayList<String>();
|
list = new ArrayList<String>();
|
||||||
nameMappings.put(name, list);
|
nameMappings.put(name, list);
|
||||||
}
|
}
|
||||||
list.add(alias);
|
list.add(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getNameMappings(String name){
|
public List<String> getNameMappings(String name) {
|
||||||
return nameMappings.get(name);
|
return nameMappings.get(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,42 +29,69 @@
|
|||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.jme3.scene.plugins.ogre.matext;
|
package com.jme3.scene.plugins.ogre.matext;
|
||||||
|
|
||||||
import com.jme3.asset.AssetKey;
|
import com.jme3.asset.AssetKey;
|
||||||
import com.jme3.material.MaterialList;
|
import com.jme3.material.MaterialList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>OgreMaterialKey</code> allows specifying material extensions,
|
* <code>OgreMaterialKey</code> allows specifying material extensions, which map
|
||||||
* which map from Ogre3D base materials to jME3 materials
|
* from Ogre3D base materials to jME3 materials
|
||||||
*/
|
*/
|
||||||
public class OgreMaterialKey extends AssetKey<MaterialList> {
|
public class OgreMaterialKey extends AssetKey<MaterialList> {
|
||||||
|
|
||||||
private MaterialExtensionSet matExts;
|
private MaterialExtensionSet matExts;
|
||||||
|
|
||||||
public OgreMaterialKey(String name){
|
public OgreMaterialKey(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OgreMaterialKey(){
|
public OgreMaterialKey() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final OgreMaterialKey other = (OgreMaterialKey) obj;
|
||||||
|
if (!super.equals(other)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.matExts != other.matExts && (this.matExts == null || !this.matExts.equals(other.matExts))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 5;
|
||||||
|
hash = 71 * hash + (super.hashCode());
|
||||||
|
hash = 71 * hash + (this.matExts != null ? this.matExts.hashCode() : 0);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the {@link MaterialExtensionSet} to use for mapping
|
* Set the {@link MaterialExtensionSet} to use for mapping base materials to
|
||||||
* base materials to jME3 matdefs when loading.
|
* jME3 matdefs when loading. Set to
|
||||||
* Set to <code>null</code> to disable this functionality.
|
* <code>null</code> to disable this functionality.
|
||||||
*
|
*
|
||||||
* @param matExts The {@link MaterialExtensionSet} to use
|
* @param matExts The {@link MaterialExtensionSet} to use
|
||||||
*/
|
*/
|
||||||
public void setMaterialExtensionSet(MaterialExtensionSet matExts){
|
public void setMaterialExtensionSet(MaterialExtensionSet matExts) {
|
||||||
this.matExts = matExts;
|
this.matExts = matExts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link MaterialExtensionSet} previously set using
|
* Returns the {@link MaterialExtensionSet} previously set using
|
||||||
* {@link OgreMaterialKey#setMaterialExtensionSet(com.jme3.scene.plugins.ogre.matext.MaterialExtensionSet) } method.
|
* {@link OgreMaterialKey#setMaterialExtensionSet(com.jme3.scene.plugins.ogre.matext.MaterialExtensionSet)
|
||||||
|
* } method.
|
||||||
|
*
|
||||||
* @return the {@link MaterialExtensionSet}
|
* @return the {@link MaterialExtensionSet}
|
||||||
*/
|
*/
|
||||||
public MaterialExtensionSet getMaterialExtensionSet() {
|
public MaterialExtensionSet getMaterialExtensionSet() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user