這是一個以Visual C++、XNA、3ds Max、DirectX9、Unity為主的部落格,主要內容是我在各討論網站的問與答,還包含我的技術性文章,大部分都附有完整程式碼,其他還有關於語音辨識與影像處理的程式,遊戲攻略、圖學與電腦技巧的相關資料。
這是一個以Visual C++、XNA、3ds Max、DirectX9、Unity為主的部落格,主要內容是我在各討論網站的問與答,還包含我的技術性文章,大部分都附有完整程式碼,其他還有關於語音辨識與影像處理的程式,遊戲攻略、圖學與電腦技巧的相關資料。
custom effect兩個方法都可以,後者比較簡潔
//method1
myEffect.Parameters["World"].SetValue(myWorld);
myEffect.Parameters["View"].SetValue(myView);
myEffect.Parameters["Projection"].SetValue(myProjection);
foreach (ModelMesh mesh in myModell.Meshes)
{
foreach (ModelMeshPart meshPart in mesh.MeshParts)
{
graphics.GraphicsDevice.Indices = meshPart.IndexBuffer;
graphics.GraphicsDevice.SetVertexBuffer(meshPart.VertexBuffer);
foreach (EffectPass currentPass in myEffect.CurrentTechnique.Passes)
{
currentPass.Apply();
graphics.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, meshPart.NumVertices, meshPart.StartIndex, meshPart.PrimitiveCount);
}
}
}
//method2
myEffect.Parameters["World"].SetValue(myWorld);
myEffect.Parameters["View"].SetValue(myView);
myEffect.Parameters["Projection"].SetValue(myProjection);
foreach (ModelMesh mesh in myModell.Meshes)
{
foreach (ModelMeshPart part in mesh.MeshParts)
{
part.Effect = myEffect;
}
mesh.Draw();
}
reference: custom effect with mesh Draw
iOS SDK 開發範例大全 (The iOS 5 Developer's Cookbook Core Concepts and Essential Recipes for iOS Programmers, 3-e)
精通 Objective-C 程式設計, 4-e (Programming in Objective-C, 4-e)
百變CG 電繪職人技
Q:
I want to draw a quad with red color, but xna always show the white quad. Does
somebody know how to solve this problem?
| 1 | VertexPositionColor[] hpVertex; |
| 2 | VertexBuffer hpVertexBuffer; |
| 3 | BasicEffect hpBasicEffect; |
| 4 | |
| 5 | Init |
| 6 | hpBasicEffect = new BasicEffect(device); |
| 7 | |
| 8 | float hpHeight = 0.20f; |
| 9 | float hpWidth = 1.0f; |
| 10 | |
| 11 | hpVertex = new VertexPositionColor[4]; |
| 12 | |
| 13 | hpVertex[0] = new VertexPositionColor(new Vector3(0.0f, hpHeight, 0.0f), Color.Red); |
| 14 | hpVertex[1] = new VertexPositionColor(new Vector3(hpWidth, hpHeight, 0.0f), Color.Red); |
| 15 | hpVertex[2] = new VertexPositionColor(new Vector3(0.0f, 0.0f, 0.0f), Color.Red); |
| 16 | hpVertex[3] = new VertexPositionColor(new Vector3(hpWidth, 0.0f, 0.0f), Color.Red); |
| 17 | |
| 18 | hpVertexBuffer = new VertexBuffer(device, VertexPositionColor.VertexDeclaration, 4, BufferUsage.WriteOnly); |
| 19 | hpVertexBuffer.SetData (hpVertex, 0, hpVertex.Length); |
| 20 | |
| 21 | Draw |
| 22 | |
| 23 | hpBasicEffect.World = Matrix.Identity; |
| 24 | hpBasicEffect.View = camera.view; |
| 25 | hpBasicEffect.Projection = camera.projection; |
| 26 | |
| 27 | foreach (EffectPass currentPass in hpBasicEffect.CurrentTechnique.Passes) |
| 28 | { |
| 29 | currentPass.Apply(); |
| 30 | |
| 31 | device.SetVertexBuffer(hpVertexBuffer); |
| 32 | device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); |
| 33 | } |
A:
try adding this in Init
and if you still get white, make sure the lighting is off
hpBasicEffect.LightingEnabled = false;
Q:
Thanks! My problem is solved. But I have another problem.
If I enable
lighting, like hpBasicEffect.LightingEnabled = true; , and then XNA will crash
at Line 10 and appears the error message as below:
The current vertex
declaration does not include all the elements required by the current vertex
shader.
Does somebody meet the situation and solve it?
| 1 | foreach (EffectPass currentPass in hpBasicEffect.CurrentTechnique.Passes) |
| 2 | { |
| 3 | currentPass.Apply(); |
| 4 | |
| 5 | device.SetVertexBuffer(hpVertexBuffer); |
| 6 | device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); |
| 7 | |
| 8 | } |
| 9 | |
| 10 | spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); |
A:
If you enable lighting your vertex data has to include normals. VertexPositionColor does not, hence the error.
安琪拉-心地善良的女孩,卻因為想獲得永恆的生命,而背叛自己的良心,化身為正義的天使--西卡莉,其實真實的面目是個吸取靈魂的惡魔。影響她心智的東西就是"光水晶",由於這是一種完全正義意識的礦物,過度地視惡如仇,不容許有任何錯誤產生,所以使用者會有一種將世界所有惡的事物剷除的使命。

20120408 低模型面數

20120409 拆UV,剩下半邊頭髮

20120411 移除頭髮多餘的面,並重拆UV


20120414 上色,prototype的模型我必須耐心地做完,把程式寫完,再看看是否可以加面數,現在先用最低規格製作,動畫到位就可以了

安裝步驟
1.應用程式的未知來源要打開
2.到Market下載AndExplorer
3.將編譯好的APK檔透過檔案總管放到手機的SD Card空間
4.開啟AndExplorer安裝APK
如果遇到APP無法關閉,請先按下Home Button,先到Market下載Advanced Task Killer ,選取要移除的APP,然後移除
PS: