我正在使用基于纹理的DOT3照明来实现老式iPhone上的凹凸贴图,我想知道是否有一种偷偷摸摸的方式使它看起来正确,即使视点发生变化.
对于"真实"光照,法线通过逆模型 - 视图矩阵进行变换.使用基于纹理的DOT3照明,没有变换.
使用基于着色器的凹凸贴图,法线贴图位于切线空间中.使用DOT3照明时,法线贴图需要在眼睛空间中.只有当您有一个固定的视点,或者您的几何形状恰好是一个平面时,这是可以的.
我应该接受这个作为DOT3照明的另一个限制吗?既然它也无法处理镜面反射,我开始质疑它究竟是多么有用.
创建WCF项目时,默认成员文件只是普通的csharp类文件,而不是svc文件.WCF项目是否需要svc文件?什么时候应该使用它们?
让我们假设我的浏览器加载了iframe <iframe src="test.html">
我可以使用ajax将test.html的内容加载到主html页面的div中吗?
这个想法是我的解决方案,我实际上试图通过使ajax提交给远程主机来克服限制.计划是生成具有0大小的iframe的动态页面,该页面向远程主机发出报告请求.然后,在页面(&iframe内容)加载后,我将使用JS将iframe内容复制到div中.
提示表示赞赏,
谢谢你,马克西姆.
我经常发现自己想要编写如下的SQL查询:
SELECT body
FROM node_revisions
where vid = (SELECT vid
FROM node
WHERE nid = 4);
Run Code Online (Sandbox Code Playgroud)
我知道你可以做的有连接和东西,但它们似乎使事情变得更复杂.加入更好的方式吗?它效率更高吗?更容易理解?
如何为我的iPhone游戏正确校准加速度计?目前,当手机在平坦的表面上时,桨叶向左漂移.高通或低通滤波器不是可接受的解决方案,因为即使在低值和高值时我也需要完全控制桨.我知道Apple有BubbleLevel样本,但我觉得很难遵循......有人可以简化这个过程吗?
我的加速度计代码如下所示:
-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
float acelx = -acceleration.y;
float x = acelx*40;
Board *board = [Board sharedBoard];
AtlasSprite *paddle = (AtlasSprite *)[board.spriteManager getChildByTag:10];
if ( paddle.position.x > 0 && paddle.position.x < 480) {
paddle.position = ccp(paddle.position.x+x, paddle.position.y);
}
if ( paddle.position.x < 55 ) {
paddle.position = ccp(56, paddle.position.y);
}
if ( paddle.position.x > 435 ) {
paddle.position = ccp(434, paddle.position.y);
}
if ( paddle.position.x < 55 && x > 1 ) {
paddle.position = ccp(paddle.position.x+x, paddle.position.y); …Run Code Online (Sandbox Code Playgroud) 问题
我在一个简单的设置文件架构上使用Xsd2Code(一个用于XSD架构的.NET类生成器).出于某种原因,当我尝试使用内置LoadFromFile()或Deserialize()方法时,我得到一个似乎与xmlns我的XSD和XML文件中的属性相关的异常.如果我删除这些属性,则异常消失.(有关实际导致异常的代码的详细信息,请参阅下面的" 更新 ".)
XSD文件
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns="Myco.CLDatabaseBuilder.Models"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="Myco.CLDatabaseBuilder.Models"
elementFormDefault="qualified">
<xs:element name="Settings" type="Settings" />
<xs:complexType name="Settings">
<xs:sequence>
<xs:element name="SqlServerInstanceName" type="xs:string" />
<xs:element name="DatabaseName" type="xs:string" />
<xs:element name="RootDatabaseName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
XML文件(失败) - 当我尝试反序列化时,我得到一个异常
<?xml version="1.0" encoding="UTF-8"?>
<Settings
xmlns="Myco.CLDatabaseBuilder.Models"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="Myco.CLDatabaseBuilder.Models Settings.xsd">
<SqlServerInstanceName>SQLEXPRESS</SqlServerInstanceName>
<DatabaseName>CL</DatabaseName>
<RootDatabaseName>master</RootDatabaseName>
</Settings>
Run Code Online (Sandbox Code Playgroud)
XML文件(成功) - 反序列化工作正常
<?xml version="1.0" encoding="UTF-8"?>
<Settings
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="Myco.CLDatabaseBuilder.Models Settings.xsd">
<SqlServerInstanceName>SQLEXPRESS</SqlServerInstanceName>
<DatabaseName>CL</DatabaseName>
<RootDatabaseName>master</RootDatabaseName>
</Settings>
Run Code Online (Sandbox Code Playgroud)
异常详细信息 - 如果我运行"失败示例"会发生什么
A first chance exception of …Run Code Online (Sandbox Code Playgroud) 所以我使用此命令仅将某个目录中的txt文件复制到另一个目录
for /R c:\source %%f in (*.xml) do copy %%f x:\destination\
Run Code Online (Sandbox Code Playgroud)
但它只复制文本文件而没有名称中的空格,因此它复制test.txt但不复制2.txt.如何制作它以便用空格复制txt文件?
我目前收到此错误:
System.Data.SqlClient.SqlException:不允许新事务,因为会话中还有其他线程在运行.
在运行此代码时:
public class ProductManager : IProductManager
{
#region Declare Models
private RivWorks.Model.Negotiation.RIV_Entities _dbRiv = RivWorks.Model.Stores.RivEntities(AppSettings.RivWorkEntities_connString);
private RivWorks.Model.NegotiationAutos.RivFeedsEntities _dbFeed = RivWorks.Model.Stores.FeedEntities(AppSettings.FeedAutosEntities_connString);
#endregion
public IProduct GetProductById(Guid productId)
{
// Do a quick sync of the feeds...
SyncFeeds();
...
// get a product...
...
return product;
}
private void SyncFeeds()
{
bool found = false;
string feedSource = "AUTO";
switch (feedSource) // companyFeedDetail.FeedSourceTable.ToUpper())
{
case "AUTO":
var clientList = from a in _dbFeed.Client.Include("Auto") select a;
foreach (RivWorks.Model.NegotiationAutos.Client client in clientList)
{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Silverlight的ChildWindow对象进行确认对话.
理想情况下,我希望它能够工作MessageBox.Show(),整个应用程序停止,直到从用户收到输入.
例如:
for (int i = 0; i < 5; i++)
{
if (i==3 && MessageBox.Show("Exit early?",
"Iterator", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
break;
}
}
Run Code Online (Sandbox Code Playgroud)
如果用户点击OK,将停止迭代3 ...
但是,如果我要按照以下方式做某事:
ChildWindow confirm = new ChildWindow();
confirm.Title = "Iterator";
confirm.HasCloseButton = false;
Grid container = new Grid();
Button closeBtn = new Button();
closeBtn.Content = "Exit early";
closeBtn.Click += delegate { confirm.DialogResult = true; confirm.Close(); };
container.Children.Add(closeBtn);
Button continueBtn = new Button();
continueBtn.Content = "Continue!";
continueBtn.Click += delegate { …Run Code Online (Sandbox Code Playgroud) 在阅读了大量文章之后,我仍然不确定在与存储库交互时工作单元模式的职责.
存储库负责加载和保存聚合根实体,因此请考虑以下示例代码:
using(IUnitOfWork uow = container.CreateUnitOfWork())
{
Repository<ARoot> roots = container.GetRepository<ARoot>();
ARoot root = root.FindByName("ARoot");
root.Name = "ANewName";
roots.Save(root);
uow.Commit();
}
Run Code Online (Sandbox Code Playgroud)
工作单元接口将使用以下方法定义:
public interface IUnitOfWork
{
void Insert(object);
void Update(object);
void Delete(object);
void Commit();
void Rollback();
}
Run Code Online (Sandbox Code Playgroud)
可以说存储库是使用非常简单的SQL Mapper实现的,因此FindByName包含一些直接SQL来返回ARoot,Save实现是否如下所示:
public void Save(T entity)
{
IUnitOfWork uow = GetUnitOfWork();
// Tell the UOW we are updating this entity
uow.Update(entity);
}
Run Code Online (Sandbox Code Playgroud)
然后,工作单元提交代码将构造所有必需的SQL以将实体映射回数据库?
问题2)
如果我将聚合根添加到工作单元中,工作单元是否负责持久化根及其子工具,或者应该是存储库的Save方法将已更改的实体添加到工作单元中?例如
public void Save(T entity)
{
IUnitOfWork uow = GetUnitOfWork();
// Tell the UOW we are updating this entity …Run Code Online (Sandbox Code Playgroud) c# domain-driven-design repository unit-of-work repository-pattern
c# ×4
iphone ×2
ajax ×1
calibration ×1
childwindow ×1
cmd ×1
confirm ×1
dialog ×1
iframe ×1
iis ×1
javascript ×1
join ×1
opengl-es ×1
repository ×1
select ×1
silverlight ×1
sql ×1
transactions ×1
unit-of-work ×1
wcf ×1
xml ×1
xsd ×1
xss ×1