Compare commits
	
		
			No commits in common. "a6e4e8547080fc2a654cf9eae2cb21a646b68723" and "29b1c78782a0613db3c19980edda2bb26ccc637a" have entirely different histories.
		
	
	
		
			a6e4e85470
			...
			29b1c78782
		
	
		| 
						 | 
					@ -245,25 +245,10 @@ public class WorldRep : IChunk
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var idx = (x + y * Width) * Bpp;
 | 
					                var idx = (x + y * Width) * Bpp;
 | 
				
			||||||
                var pLayer = Pixels[layer];
 | 
					                var pLayer = Pixels[layer];
 | 
				
			||||||
                switch (Bpp)
 | 
					                pLayer[idx] = (byte)Math.Clamp(pLayer[idx] + r, 0, 255);
 | 
				
			||||||
                {
 | 
					                pLayer[idx + 1] = (byte)Math.Clamp(pLayer[idx + 1] + g, 0, 255);
 | 
				
			||||||
                    // 1bpp isn't really supported (does nd dromed even produce it?)
 | 
					                pLayer[idx + 2] = (byte)Math.Clamp(pLayer[idx + 2] + b, 0, 255);
 | 
				
			||||||
                    case 2:
 | 
					                pLayer[idx + 3] = 255;
 | 
				
			||||||
                        var raw2 = pLayer[idx] + (pLayer[idx + 1] << 8);
 | 
					 | 
				
			||||||
                        var newR = (int)Math.Clamp((raw2 & 31) + r * 32f / 255f, 0, 31);
 | 
					 | 
				
			||||||
                        var newG = (int)Math.Clamp(((raw2 >> 5) & 31) + g * 32f / 255f, 0, 31);
 | 
					 | 
				
			||||||
                        var newB = (int)Math.Clamp(((raw2 >> 10) & 31) + b * 32f / 255f, 0, 31);
 | 
					 | 
				
			||||||
                        raw2 = newR + (newG << 5) + (newB << 10);
 | 
					 | 
				
			||||||
                        pLayer[idx] = (byte)(raw2 & 0xff);
 | 
					 | 
				
			||||||
                        pLayer[idx + 1] = (byte)((raw2 >> 8) & 0xff);
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    case 4:
 | 
					 | 
				
			||||||
                        pLayer[idx] = (byte)Math.Clamp(pLayer[idx] + b, 0, 255);
 | 
					 | 
				
			||||||
                        pLayer[idx + 1] = (byte)Math.Clamp(pLayer[idx + 1] + g, 0, 255);
 | 
					 | 
				
			||||||
                        pLayer[idx + 2] = (byte)Math.Clamp(pLayer[idx + 2] + r, 0, 255);
 | 
					 | 
				
			||||||
                        pLayer[idx + 3] = 255;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                _litLayers[layer] = true;
 | 
					                _litLayers[layer] = true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -286,7 +271,7 @@ public class WorldRep : IChunk
 | 
				
			||||||
                    c /= ratio;
 | 
					                    c /= ratio;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                AddLight(layer, x, y, c.X, c.Y, c.Z);
 | 
					                AddLight(layer, x, y, c.Z, c.Y, c.X);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            public void Reset(Vector3 ambientLight, bool hdr)
 | 
					            public void Reset(Vector3 ambientLight, bool hdr)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -218,19 +218,19 @@ public class LightMapper
 | 
				
			||||||
        var propModelName = _hierarchy.GetProperty<PropLabel>(id, "P$ModelName");
 | 
					        var propModelName = _hierarchy.GetProperty<PropLabel>(id, "P$ModelName");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        propLightColor ??= new PropLightColor { Hue = 0, Saturation = 0 };
 | 
					        propLightColor ??= new PropLightColor { Hue = 0, Saturation = 0 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        var baseLight = new Light
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Position = brush.position,
 | 
				
			||||||
 | 
					            SpotlightDir = -Vector3.UnitZ,
 | 
				
			||||||
 | 
					            SpotlightInnerAngle = -1.0f,
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // TODO: Also apply scale?
 | 
					        // TODO: Also apply scale?
 | 
				
			||||||
        var rot = Matrix4x4.Identity;
 | 
					        var rot = Matrix4x4.Identity;
 | 
				
			||||||
        rot *= Matrix4x4.CreateRotationX(float.DegreesToRadians(brush.angle.X));
 | 
					        rot *= Matrix4x4.CreateRotationX(float.DegreesToRadians(brush.angle.X));
 | 
				
			||||||
        rot *= Matrix4x4.CreateRotationY(float.DegreesToRadians(brush.angle.Y));
 | 
					        rot *= Matrix4x4.CreateRotationY(float.DegreesToRadians(brush.angle.Y));
 | 
				
			||||||
        rot *= Matrix4x4.CreateRotationZ(float.DegreesToRadians(brush.angle.Z));
 | 
					        rot *= Matrix4x4.CreateRotationZ(float.DegreesToRadians(brush.angle.Z));
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        var baseLight = new Light
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            Position = brush.position,
 | 
					 | 
				
			||||||
            SpotlightDir = Vector3.Transform(-Vector3.UnitZ, rot),
 | 
					 | 
				
			||||||
            SpotlightInnerAngle = -1.0f,
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (propModelName != null)
 | 
					        if (propModelName != null)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -126,17 +126,9 @@ public class MeshBuilder
 | 
				
			||||||
            var scale = scaleProp?.value ?? Vector3.One;
 | 
					            var scale = scaleProp?.value ?? Vector3.One;
 | 
				
			||||||
            var model = new ModelFile(modelPath);
 | 
					            var model = new ModelFile(modelPath);
 | 
				
			||||||
            pos -= model.Header.Center;
 | 
					            pos -= model.Header.Center;
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            var scalePart = Matrix4x4.CreateScale(scale);
 | 
					 | 
				
			||||||
            var rotPart = Matrix4x4.Identity;
 | 
					 | 
				
			||||||
            rotPart *= Matrix4x4.CreateRotationX(float.DegreesToRadians(rot.X));
 | 
					 | 
				
			||||||
            rotPart *= Matrix4x4.CreateRotationY(float.DegreesToRadians(rot.Y));
 | 
					 | 
				
			||||||
            rotPart *= Matrix4x4.CreateRotationZ(float.DegreesToRadians(rot.Z));
 | 
					 | 
				
			||||||
            var transPart = Matrix4x4.CreateTranslation(pos);
 | 
					 | 
				
			||||||
            var modelTrans = scalePart * rotPart * transPart;
 | 
					 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            // for each object modify the vertices
 | 
					            // for each object modify the vertices
 | 
				
			||||||
 | 
					            // TODO: Almost perfect transform!
 | 
				
			||||||
            // TODO: Handle nested sub objects
 | 
					            // TODO: Handle nested sub objects
 | 
				
			||||||
            foreach (var subObj in model.Objects)
 | 
					            foreach (var subObj in model.Objects)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					@ -148,8 +140,11 @@ public class MeshBuilder
 | 
				
			||||||
                    var objTrans = subObj.Transform;
 | 
					                    var objTrans = subObj.Transform;
 | 
				
			||||||
                    jointTrans = jointRot * objTrans;
 | 
					                    jointTrans = jointRot * objTrans;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                
 | 
					                var scalePart = Matrix4x4.CreateScale(scale);
 | 
				
			||||||
                var transform = jointTrans * modelTrans;
 | 
					                var rotPart = Matrix4x4.CreateFromYawPitchRoll(float.DegreesToRadians(rot.Y), float.DegreesToRadians(rot.X),
 | 
				
			||||||
 | 
					                    float.DegreesToRadians(rot.Z));
 | 
				
			||||||
 | 
					                var transPart = Matrix4x4.CreateTranslation(pos);
 | 
				
			||||||
 | 
					                var transform = jointTrans * scalePart * rotPart * transPart;
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                var start = subObj.PointIdx;
 | 
					                var start = subObj.PointIdx;
 | 
				
			||||||
                var end = start + subObj.PointCount;
 | 
					                var end = start + subObj.PointCount;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue