瀏覽代碼

cleanup old unused hmd props

ncannasse 7 年之前
父節點
當前提交
6fdeb1d5f1
共有 7 個文件被更改,包括 8 次插入97 次删除
  1. 1 1
      h3d/scene/World.hx
  2. 1 40
      hxd/fmt/fbx/HMDOut.hx
  3. 0 20
      hxd/fmt/hmd/Data.hx
  4. 0 6
      hxd/fmt/hmd/Dump.hx
  5. 1 18
      hxd/fmt/hmd/Library.hx
  6. 2 7
      hxd/fmt/hmd/Reader.hx
  7. 3 5
      hxd/fmt/hmd/Writer.hx

+ 1 - 1
h3d/scene/World.hx

@@ -220,7 +220,7 @@ class World extends Object {
 		m.blend = getBlend(rt);
 		m.killAlpha = null;
 		m.mat = mat;
-		m.culling = mat.culling != None;
+		m.culling = true;
 		m.updateBits();
 		textures.set(texturePath, m);
 		return m;

+ 1 - 40
hxd/fmt/fbx/HMDOut.hx

@@ -527,7 +527,6 @@ class HMDOut extends BaseLibrary {
 					hasNormalMap = m.normalMap != null;
 					continue;
 				}
-				var hasHeapsProps = false;
 				var mat = new Material();
 				mid = d.materials.length;
 				mids.push(mid);
@@ -535,9 +534,7 @@ class HMDOut extends BaseLibrary {
 				d.materials.push(mat);
 
 				mat.name = m.getName();
-				mat.culling = Back; // don't use FBX Culling infos (OFF by default)
 				mat.blendMode = null;
-				mat.flags = Material.DEFAULT_FLAGS;
 
 				// if there's a slight amount of opacity on the material
 				// it's usually meant to perform additive blending on 3DSMax
@@ -547,38 +544,7 @@ class HMDOut extends BaseLibrary {
 					case "Opacity":
 						var v = pval.toFloat();
 						if( v < 1 && v > 0.98 && mat.blendMode == null ) mat.blendMode = Add;
-					case pname:
-						if( StringTools.startsWith(pname, "3dsMax|heaps|_") ) {
-							hasHeapsProps = true;
-							switch( pname.substr(14) ) {
-							case "blend":
-								mat.blendMode = ([null, None, Alpha, Add, SoftAdd] : Array<h2d.BlendMode>)[pval.toInt() - 1];
-							case "shadows":
-								switch( pval.toInt() ) {
-								case 2:
-									mat.flags.unset(CastShadows);
-									mat.flags.unset(ReceiveShadows);
-								case 3:
-									mat.flags.unset(CastShadows);
-								case 4:
-									mat.flags.unset(ReceiveShadows);
-								}
-							case "lighting":
-								if( pval.toInt() == 0 ) mat.flags.unset(HasLighting);
-							case "twoSided":
-								if( pval.toInt() == 1 ) mat.culling = None;
-							case "killAlpha":
-								if( pval.toInt() == 1 ) mat.killAlpha = 1;
-							case "killAlphaThreshold":
-								if( mat.killAlpha != null ) mat.killAlpha = pval.toFloat();
-							case "decal":
-								if( pval.toInt() == 1 ) mat.flags.set(IsVolumeDecal);
-							case "wrap":
-								if( pval.toInt() == 1 ) mat.flags.set(TextureWrap);
-							case name:
-								throw "Unknown heaps property " + name;
-							}
-						}
+					default:
 					}
 				}
 
@@ -616,10 +582,6 @@ class HMDOut extends BaseLibrary {
 					}
 				}
 
-				if( hasHeapsProps ) {
-					if( mat.props == null ) mat.props = [];
-					mat.props.push(HasMaterialFlags);
-				}
 				if( mat.blendMode == null ) mat.blendMode = None;
 			}
 
@@ -652,7 +614,6 @@ class HMDOut extends BaseLibrary {
 			if( mids.length == 0 ) {
 				var mat = new Material();
 				mat.blendMode = None;
-				mat.culling = Back;
 				mat.name = "default";
 				var mid = d.materials.length;
 				d.materials.push(mat);

+ 0 - 20
hxd/fmt/hmd/Data.hx

@@ -40,7 +40,6 @@ typedef Index<T> = Int;
 
 enum Property<T> {
 	CameraFOVY( v : Float ) : Property<Float>;
-	HasMaterialFlags;
 	HasExtraTextures;
 }
 
@@ -119,33 +118,14 @@ class Geometry {
 	}
 }
 
-enum MaterialFlag {
-	HasLighting;
-	CastShadows;
-	ReceiveShadows;
-	TextureWrap;
-	IsVolumeDecal;
-}
-
 class Material {
 
-	public static var DEFAULT_FLAGS = {
-		var f = new haxe.EnumFlags();
-		f.set(HasLighting);
-		f.set(CastShadows);
-		f.set(ReceiveShadows);
-		f;
-	}
-
 	public var name : String;
 	public var props : Properties;
 	public var diffuseTexture : Null<String>;
 	public var specularTexture : Null<String>;
 	public var normalMap : Null<String>;
 	public var blendMode : h3d.mat.BlendMode;
-	public var culling : h3d.mat.Data.Face;
-	public var killAlpha : Null<Float>;
-	public var flags : haxe.EnumFlags<MaterialFlag>;
 
 	public function new() {
 	}

+ 0 - 6
hxd/fmt/hmd/Dump.hx

@@ -54,22 +54,16 @@ class Dump {
 			prefix = "";
 		}
 		if( h.geometries.length > 0 ) add('');
-		var flags = MaterialFlag.createAll();
 		for( k in 0...h.materials.length ) {
 			var m = h.materials[k];
 			add('@$k MATERIAL');
 			prefix += "\t";
 			if( m.name != null ) add('Name : ${m.name}');
 			add('Blend : ${m.blendMode}');
-			add('Cull : ${m.culling}');
 			if( m.diffuseTexture != null ) add('Texture : ${m.diffuseTexture}');
 			if( m.specularTexture != null ) add('Specular : ${m.specularTexture}');
 			if( m.normalMap != null ) add('Normal : ${m.normalMap}');
-			if( m.killAlpha != null ) add('KillAlpha : ${m.killAlpha}');
 			addProps(m.props);
-			for( f in flags )
-				if( m.flags.has(f) )
-					add(f);
 			prefix = "";
 		}
 		if( h.materials.length > 0 ) add('');

+ 1 - 18
hxd/fmt/hmd/Library.hx

@@ -260,7 +260,7 @@ class Library {
 
 	function makeMaterial( model : Model, mid : Int, loadTexture : String -> h3d.mat.Texture ) {
 		var m = header.materials[mid];
-		var mat = new h3d.mat.Material();
+		var mat = h3d.mat.MaterialSetup.current.createMaterial();
 		mat.name = m.name;
 		if( m.diffuseTexture != null ) {
 			mat.texture = loadTexture(m.diffuseTexture);
@@ -271,23 +271,6 @@ class Library {
 		if( m.normalMap != null )
 			mat.normalMap = loadTexture(m.normalMap);
 		mat.blendMode = m.blendMode;
-		mat.mainPass.culling = m.culling;
-		if( m.killAlpha != null ) {
-			var t = mat.mainPass.getShader(h3d.shader.Texture);
-			t.killAlpha = true;
-			t.killAlphaThreshold = m.killAlpha;
-		}
-		if( m.props != null && m.props.indexOf(HasMaterialFlags) >= 0 ) {
-			if( m.flags.has(HasLighting) ) mat.mainPass.enableLights = true;
-			if( m.flags.has(CastShadows) ) mat.castShadows = true;
-			if( m.flags.has(ReceiveShadows) ) mat.receiveShadows = true;
-			if( m.flags.has(IsVolumeDecal) ) {
-				var s = h3d.mat.Defaults.makeVolumeDecal(header.geometries[model.geometry].bounds);
-				mat.mainPass.addShader(s);
-			}
-			if( m.flags.has(TextureWrap) )
-				mat.texture.wrap = Repeat;
-		}
 		return mat;
 	}
 

+ 2 - 7
hxd/fmt/hmd/Reader.hx

@@ -17,8 +17,6 @@ class Reader {
 		switch( i.readByte() ) {
 		case 0:
 			return CameraFOVY(i.readFloat());
-		case 1:
-			return HasMaterialFlags;
 		case 2:
 			return HasExtraTextures;
 		case unk:
@@ -142,11 +140,8 @@ class Reader {
 			m.name = readName();
 			m.diffuseTexture = readName();
 			m.blendMode = BLEND[i.readByte()];
-			m.culling = CULLING[i.readByte()];
-			m.killAlpha = i.readFloat();
-			if( m.killAlpha == 1 ) m.killAlpha = null;
-			if( m.props != null && m.props.indexOf(HasMaterialFlags) >= 0 )
-				m.flags = haxe.EnumFlags.ofInt(i.readInt32());
+			i.readByte(); // old culling = 1
+			i.readFloat(); // old killalpha = 1
 			if( m.props != null && m.props.indexOf(HasExtraTextures) >= 0 ) {
 				m.specularTexture = readName();
 				m.normalMap = readName();

+ 3 - 5
hxd/fmt/hmd/Writer.hx

@@ -15,7 +15,7 @@ class Writer {
 		switch( p ) {
 		case CameraFOVY(v):
 			out.writeFloat(v);
-		case HasMaterialFlags, HasExtraTextures:
+		case HasExtraTextures:
 		}
 	}
 
@@ -132,10 +132,8 @@ class Writer {
 			writeName(m.name);
 			writeName(m.diffuseTexture);
 			out.writeByte(m.blendMode.getIndex());
-			out.writeByte(m.culling.getIndex());
-			writeFloat(m.killAlpha == null ? 1 : m.killAlpha);
-			if( m.props != null && m.props.indexOf(HasMaterialFlags) >= 0 )
-				out.writeInt32(m.flags.toInt());
+			out.writeByte(1); // old culling back
+			writeFloat(1); // old killalpha
 			if( m.props != null && m.props.indexOf(HasExtraTextures) >= 0 ) {
 				writeName(m.specularTexture);
 				writeName(m.normalMap);