Kaks wrote:Yep. Any resemblance between OOPlanetEntity.m & PlanetEntity.m is purely coincidental!
Well, not quite... The first was developed as a drop in replacement for the latter, so all the external methods need to be identical - until we wave goodbye to the old one, that is...
Mind you, if you think PlanetEntity is bad now, you should have seen rev2098! Ooh, that was a 'good' one!
Anyway, OOPlanetEntity contains the as-yet unfinished code, as Eric has already said.
Still, PlanetEntityDrawable, is a completely new and as yet unfinished beast, I expect a liberal amount of copy & paste 'goodness' was lavished on that one...
Yup - I got that far.
Here is my brutal cheat to load materials and shaders from planet info, currently only applies to the planet surface geometry.
Code: Select all
Index: src/Core/Entities/OOStellarBody.h
===================================================================
--- src/Core/Entities/OOStellarBody.h (revision 4809)
+++ src/Core/Entities/OOStellarBody.h (working copy)
@@ -32,7 +32,7 @@
#ifndef NEW_PLANETS
-#define NEW_PLANETS 0
+#define NEW_PLANETS 1
#endif
Index: src/Core/Entities/OOPlanetEntity.m
===================================================================
--- src/Core/Entities/OOPlanetEntity.m (revision 4809)
+++ src/Core/Entities/OOPlanetEntity.m (working copy)
@@ -45,6 +45,7 @@
#import "OOPlanetTextureGenerator.h"
#import "OOSingleTextureMaterial.h"
#import "OOShaderMaterial.h"
+#import "OOMaterialConvenienceCreators.h"
@interface OOPlanetEntity (Private)
@@ -78,7 +79,23 @@
if (self == nil) return nil;
scanClass = CLASS_NO_DRAW;
-
+ NSDictionary *materials = [dict oo_dictionaryForKey:@"materials"];
+ NSDictionary *shaders = [dict oo_dictionaryForKey:@"shaders"];
+ OOLog(@"new planets", @"Materials %@", materials);
+ OOLog(@"new planets", @"Shaders %@", shaders);
+
+
+ OOMaterial *planet_material = [OOMaterial materialWithName:@"planet_surface"
+ cacheKey:nil
+ materialDictionary:materials
+ shadersDictionary:shaders
+ macros:OODefaultShipShaderMacros()
+ bindingTarget:self
+ forSmoothedMesh:YES
+
+ ];
+ OOLog(@"new planets",@"OOMaterial %@", planet_material );
+
// Load random seed override.
NSString *seedStr = [dict oo_stringForKey:@"seed"];
if (seedStr != nil)
@@ -147,7 +164,11 @@
// EW: NO, setting orientation should be handled by the code that adds the planet, not by planetEntity itself.
// just start with a default value.
[_planetDrawable setRadius:collision_radius];
-
+ if ( planet_material != nil ) {
+ OOLog(@"new planets" , @"set planet material");
+ [_planetDrawable setMaterial:planet_material];
+ }
+
// set speed of rotation.
if ([dict objectForKey:@"rotational_velocity"])
{
@@ -499,6 +520,8 @@
OOTexture *normalMap = nil;
NSDictionary *macros = nil;
NSDictionary *materialDefaults = [ResourceManager materialDefaults];
+
+
#if OO_SHADERS
OOShaderSetting shaderLevel = [UNIVERSE shaderEffectsLevel];
Index: src/Core/Materials/OOTexture.m
===================================================================
--- src/Core/Materials/OOTexture.m (revision 4809)
+++ src/Core/Materials/OOTexture.m (working copy)
@@ -722,7 +722,7 @@
else if ([extractChannel isEqualToString:@"a"]) options |= kOOTextureExtractChannelA;
else
{
- OOLogWARN(@"texture.load.extractChannel.invalid", @"Unknown value \"%@\" for extract_channel (should be \"r\", \"g\", \"b\" or \"a\").", extractChannel);
+ OOLogWARN(@"texture.load.extractChannel.invalid", @"Unknown value \"%@\" for extract_channel in specifier \"%@\" (should be \"r\", \"g\", \"b\" or \"a\").", extractChannel,specifier);
}
}
}
And the planetinfo.plist from my testing OXP looks like
Code: Select all
{
"0 7" = {
description = "Lave is a testing planet.";
"percent_land" = "50";
"land_hsb_color" = "0.333 1.0 1.0";
"sea_hsb_color" = "0.667 0.7 0.6";
materials = {
planet_surface = {
diffuse_map = {
name = "ll_planet_surface_diffuse.png";
};
emission_map = {
name = "ll_planet_surface_emission.png";
};
normal_and_parallax_map = {
name = "ll_planet_surface_normpara.png";
};
specular_map = {
name = "ll_planet_surface_specular.png";
};
parallax_scale = "-0.02";
//parallax_bias = "-0.02";
specular_color = "1.0 1.0 1.0 1.0";
shininess = "10";
};
planet_atmosphere = {
diffuse_map = "planet_clouds.png";
};
};
/*
shaders =
{
planet_surface = {
shininess = 64;
specular_color = "( 1.0 , 1.0 , 1.0 , 0.5 )";
uniforms = {
uCubeMap = { type = texture; value = 0; };
uSpecularMap = { type = texture; value=1 };
uEmissionMap = { type = texture; value=2 };
uNormalMap = { type = texture ; value=3 };
uCloudMap = { type = texture ;value=4 };
//uParallaxScale = { type = float ; value=0.15 };
//uParallaxBias = { type = float ; value=0.0 };
};
fragment_shader = "cube_map_planet.fs";
vertex_shader = "ahruman_cube_map_test.vs";
textures =
(
{ name = "planet_surface_diffuse.png"; cube_map = yes; },
{ name = "planet_surface_specular.png"; cube_map = yes; },
{ name = "planet_surface_emission.png"; cube_map = yes; },
{ name = "planet_surface_normpara.png"; cube_map = no; },
{ name = "planet_clouds.png" ; cube_map = yes; },
);
};
planet_atmosphere =
{
vertex_shader = "SkyFromSpace.vertex";
fragment_shader = "SkyFromSpace.fragment";
uniforms =
{
};
};
};
*/
};
}
All currently unfinished.