Skip to content

Commit

Permalink
Merged pull requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
abeckus committed Mar 29, 2016
1 parent af1360d commit 46331a1
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 44 deletions.
Binary file modified CodeGenDom/OutBin/Atf.Core.dll
Binary file not shown.
Binary file modified CodeGenDom/OutBin/CodeGenDom.exe
Binary file not shown.
14 changes: 13 additions & 1 deletion LevelEditor/LevelEditorApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Windows.Forms;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Linq;

using Sce.Atf;
using Sce.Atf.Adaptation;
Expand Down Expand Up @@ -179,7 +180,18 @@ static void Main()
catalogs.Add(new AssemblyCatalog(stmPlgAssem));
}


// load all dlls in \MEFPlugin
string mefpluginDir = pluginDir + "\\MEFPlugin";
if (Directory.Exists(mefpluginDir))
{
var filepaths = Directory.GetFiles(mefpluginDir).Where(path => path.EndsWith(".dll"));
foreach (var filepath in filepaths)
{
Assembly filepathAssembly = Assembly.LoadFrom(filepath);
catalogs.Add(new AssemblyCatalog(filepathAssembly));
}
}

AggregateCatalog catalog = new AggregateCatalog(catalogs);


Expand Down
2 changes: 2 additions & 0 deletions LevelEditor/schemas/Schema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ private static void Initialize(Func<string, string, DomNodeType> getNodeType, Fu
billboardTestType.lockedAttribute = billboardTestType.Type.GetAttributeInfo("locked");
billboardTestType.transformationTypeAttribute = billboardTestType.Type.GetAttributeInfo("transformationType");
billboardTestType.intensityAttribute = billboardTestType.Type.GetAttributeInfo("intensity");
billboardTestType.colorAttribute = billboardTestType.Type.GetAttributeInfo("color");
billboardTestType.diffuseAttribute = billboardTestType.Type.GetAttributeInfo("diffuse");
billboardTestType.textureTransformAttribute = billboardTestType.Type.GetAttributeInfo("textureTransform");
billboardTestType.componentChild = billboardTestType.Type.GetChildInfo("component");
Expand Down Expand Up @@ -1206,6 +1207,7 @@ public static class billboardTestType
public static AttributeInfo lockedAttribute;
public static AttributeInfo transformationTypeAttribute;
public static AttributeInfo intensityAttribute;
public static AttributeInfo colorAttribute;
public static AttributeInfo diffuseAttribute;
public static AttributeInfo textureTransformAttribute;
public static ChildInfo componentChild;
Expand Down
3 changes: 3 additions & 0 deletions LevelEditor/schemas/level_editor.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -381,17 +381,20 @@
<xs:appinfo>
<LeGe.NativeType nativeName="BillboardGob"/>
<LeGe.NativeProperty name="intensity" nativeName="Intensity" nativeType="float" access="set"/>
<LeGe.NativeProperty name="color" nativeName="Color" nativeType="int" access="set"/>
<LeGe.NativeProperty name="diffuse" nativeName="Diffuse" nativeType="wchar_t*" access="set"/>
<LeGe.NativeProperty name="textureTransform" nativeName="TextureTransform" nativeType="Matrix" access="set"/>
<scea.dom.editors name="BillboardTest" category="Examples" menuText="Game Objects/BillboardTest" description="Test Billboard"/>
<scea.dom.editors.attribute category="Billboard" name="intensity" displayName="Intensity" description = "billboard intensity" />
<scea.dom.editors.attribute category="Billboard" name="color" displayName="Color" description="Billboard Color" editor="Sce.Atf.Controls.PropertyEditing.ColorPickerEditor,Atf.Gui.WinForms:true" converter="Sce.Atf.Controls.PropertyEditing.IntColorConverter" />
<scea.dom.editors.attribute category="Billboard" name="diffuse" displayName="Diffuse" description = "diffuse texture" editor="Sce.Atf.Controls.PropertyEditing.FileUriEditor,Atf.Gui.WinForms:Texture (*.png, *.dds, *.bmp, *.tga, *.tif)|*.png;*.dds;*.bmp;*.tga;*.tif" />
<scea.dom.editors.attribute category="Billboard" name="textureTransform" displayName="Texture Transform" description="Transform for texture coordinates" editor="Sce.Atf.Controls.PropertyEditing.NumericMatrixEditor,Atf.Gui.WinForms"/>
</xs:appinfo>
</xs:annotation>
<xs:complexContent>
<xs:extension base="gameObjectType" >
<xs:attribute name="intensity" type="xs:float" default="1"/>
<xs:attribute name="color" type="xs:int" default="-1"/>
<xs:attribute name="diffuse" type="xs:anyURI"/>
<xs:attribute name="textureTransform" type="matrixType" default="1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1"/>
</xs:extension>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,15 @@ void BillboardGob_Intensity_Set(ObjectGUID instanceId, void* data, int size)
instance->SetIntensity(localData);
}

//-----------------------------------------------------------------------------
void BillboardGob_Color_Set(ObjectGUID instanceId, void* data, int size)
{
assert((data && size > 0) || (!data && size == 0));
BillboardGob* instance = reinterpret_cast<BillboardGob*>(instanceId);
int localData = *reinterpret_cast<int*>(data);
instance->SetColor(localData);
}

//-----------------------------------------------------------------------------
void BillboardGob_Diffuse_Set(ObjectGUID instanceId, void* data, int size)
{
Expand Down Expand Up @@ -1221,6 +1230,7 @@ void InitGobBridge(GobBridge& bridge)

bridge.RegisterObject( "BillboardGob", &BillboardGob_Create );
bridge.RegisterProperty( "BillboardGob", "Intensity", &BillboardGob_Intensity_Set, NULL );
bridge.RegisterProperty( "BillboardGob", "Color", &BillboardGob_Color_Set, NULL );
bridge.RegisterProperty( "BillboardGob", "Diffuse", &BillboardGob_Diffuse_Set, NULL );
bridge.RegisterProperty( "BillboardGob", "TextureTransform", &BillboardGob_TextureTransform_Set, NULL );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ void BillboardGob::SetupRenderable(RenderableNode* r, RenderContext* context)
billboard = scaleM * b;
}

m_intensity = clamp(m_intensity, 0.0f, 1.0f);
PrimitiveShapeGob::SetupRenderable(r, context);
r->WorldXform = billboard;
r->diffuse = float4(m_intensity, m_intensity, m_intensity, m_intensity);

float3 color = m_color.xyz() * m_intensity;
color = saturate(color);
r->diffuse = float4(color,m_color.w);
// special case compute AABB
m_localBounds = AABB(float3(-0.5f,-0.5f,-0.5f),float3(0.5f,0.5f,0.5f));
m_bounds = m_localBounds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#pragma once
#include "PrimitiveShapeGob.h"
#include "../VectorMath/V3dMath.h"

namespace LvEdEngine
{
Expand All @@ -15,7 +16,10 @@ namespace LvEdEngine
// push Renderable nodes
virtual void GetRenderables(RenderableNodeCollector* collector, RenderContext* context);
virtual void SetupRenderable(RenderableNode* r, RenderContext* context);
void SetIntensity(float intensity){m_intensity = intensity;};
void SetIntensity(float intensity)
{
m_intensity = clamp(intensity, 0.0f, 1.0f);
};
protected:
float m_intensity;
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void BillboardShader::Draw(const RenderableNode& r)

Matrix::Transpose(r.WorldXform,m_cbPerDraw.Data.worldXform);
Matrix::Transpose(r.TextureXForm, m_cbPerDraw.Data.textureXForm);
m_cbPerDraw.Data.intensity = r.diffuse.x;
m_cbPerDraw.Data.color = r.diffuse;
m_cbPerDraw.Update(dc);

ID3D11ShaderResourceView* diffuseMap[1] = {NULL};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ class BillboardShader : public Shader
{
Matrix worldXform;
Matrix textureXForm;
float intensity;
float3 pad;
float4 color; // alpha is not used.
};

ID3D11VertexShader* m_vertexShader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ void TextureLib::InitInstance(ID3D11Device* device)
{
s_Inst = new TextureLib();
Imple* pImple = s_Inst->m_pImple;
pImple->m_defaultTextures[TextureType::DIFFUSE] = CreateCheckerboardTexture2D(device, 128, 128, 0xFF404040, 0xFF808080, false,true);


pImple->m_defaultTextures[TextureType::DIFFUSE] = CreateCheckerboardTexture2D(device, 128, 128, 0xFF404040, 0xFF808080, false, true);
pImple->m_defaultTextures[TextureType::DIFFUSE]->SetTextureType(TextureType::DIFFUSE);

pImple->m_defaultTextures[TextureType::Cubemap] = CreateCheckerboardTexture2D(device, 128, 128, 0xff000040, 0xff000080, true);
Expand All @@ -98,56 +98,68 @@ void TextureLib::InitInstance(ID3D11Device* device)
pImple->m_defaultTextures[TextureType::LIGHT] = CreateSolidTexture2D(device, 8, 8, 0xFFFFFFFF);
pImple->m_defaultTextures[TextureType::LIGHT]->SetTextureType(TextureType::LIGHT);

pImple->m_defaultTextures[TextureType::SPEC] = CreateSolidTexture2D(device, 8, 8, 0xFF000000);
pImple->m_defaultTextures[TextureType::SPEC] = CreateSolidTexture2D(device, 8, 8, 0xFF000000);
pImple->m_defaultTextures[TextureType::SPEC]->SetTextureType(TextureType::SPEC);

pImple->m_defaultTextures[TextureType::BlankMask] = CreateSolidTexture2D(device, 4, 4, 0x00);
pImple->m_defaultTextures[TextureType::BlankMask]->SetTextureType(TextureType::BlankMask);

pImple->m_defaultTextures[TextureType::FullMask] = CreateSolidTexture2D(device, 4, 4, 0xFFFFFFFF);
pImple->m_defaultTextures[TextureType::FullMask]->SetTextureType(TextureType::FullMask);

pImple->m_whiteTexture = CreateSolidTexture2D(device, 8, 8, 0xFFFFFFFF);

typedef std::pair<std::wstring, Texture*> NameTexPair;

const wchar_t* resName = L"Light.png";
const wchar_t* resType = L"Texture";
HRESULT hr = E_FAIL;

Texture* tex = NULL;
ID3D11Resource* dxresource = NULL;
ID3D11ShaderResourceView* dxTexView = NULL;
uint32_t resSize = 0;
uint8_t* data = (uint8_t*)ResUtil::LoadResource(resType, resName,&resSize);
hr = CreateWICTextureFromMemory( device,
NULL,
data,
resSize,
&dxresource,
&dxTexView);
free(data);
if (!Logger::IsFailureLog(hr, L"Error loading %s\n", resName))
{
D3D11_RESOURCE_DIMENSION resDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
dxresource->GetType( &resDim );
assert( resDim == D3D11_RESOURCE_DIMENSION_TEXTURE2D);
ID3D11Texture2D* dxTex = NULL;
hr = dxresource->QueryInterface( __uuidof(ID3D11Texture2D), (void**) &dxTex );
dxresource->Release();
assert(dxTex);
tex = new Texture(dxTex,dxTexView);
auto insertResult = pImple->m_textures.insert(NameTexPair(resName,tex));
assert(insertResult.second);
}
// load embedded textures, i.e. textures that are embedded resources
// open resource.rc in a text editor for info
LoadEmbeddedTexture(device, L"Light.png");

}

void TextureLib::DestroyInstance(void)
{
SAFE_DELETE(s_Inst);
}


// ----------------------------------------------------------------------------------------------
Texture* TextureLib::LoadEmbeddedTexture(ID3D11Device* device, const wchar_t* name)
{
assert(s_Inst != NULL);
Imple* pImple = s_Inst->m_pImple;

typedef std::pair<std::wstring, Texture*> NameTexPair;
const wchar_t* resType = L"Texture";
HRESULT hr = E_FAIL;

Texture* tex = NULL;
ID3D11Resource* dxresource = NULL;
ID3D11ShaderResourceView* dxTexView = NULL;
uint32_t resSize = 0;
uint8_t* data = (uint8_t*)ResUtil::LoadResource(resType, name, &resSize);
hr = CreateWICTextureFromMemory(device,
NULL,
data,
resSize,
&dxresource,
&dxTexView);
free(data);
if (!Logger::IsFailureLog(hr, L"Error loading %s\n", name))
{
D3D11_RESOURCE_DIMENSION resDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
dxresource->GetType(&resDim);
assert(resDim == D3D11_RESOURCE_DIMENSION_TEXTURE2D);
ID3D11Texture2D* dxTex = NULL;
hr = dxresource->QueryInterface(__uuidof(ID3D11Texture2D), (void**)&dxTex);
dxresource->Release();
assert(dxTex);
tex = new Texture(dxTex, dxTexView);
auto insertResult = pImple->m_textures.insert(NameTexPair(name, tex));
assert(insertResult.second);
}
return tex;
}

// ----------------------------------------------------------------------------------------------
static Texture* CreateCheckerboardTexture2D(ID3D11Device* device, int w, int h, uint32_t color1, uint32_t color2,bool cubemap, bool useSRGBView)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class TextureLib : public NonCopyable
Texture* GetWhite();
Texture* GetByName(const wchar_t* name);
static Texture* CreateSolidTexture2D(ID3D11Device* device, int w, int h, uint32_t color);
static Texture* LoadEmbeddedTexture(ID3D11Device* device, const wchar_t* name);

private:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cbuffer ConstantBufferPerDraw : register( b1 )
{
float4x4 world;
float4x4 textureTrans;
float intensity; // 0 to 1
float4 color;
};


Expand Down Expand Up @@ -71,6 +71,6 @@ float4 PSMain( PS_INPUT input ) : SV_TARGET
{
float4 fc = diffuseTex.Sample( diffuseSampler, input.tex0 );
clip(fc.a - 0.5);
fc.xyz = fc.xyz * intensity;
fc.xyz = fc.xyz * color.xyz;
return fc;
}

0 comments on commit 46331a1

Please sign in to comment.