Merge branch 'master' of https://github.com/mono/CocosSharp
This commit is contained in:
Коммит
dcd563fdb5
|
@ -448,7 +448,7 @@ namespace CocosSharp
|
|||
scale9Image.AddChild(centre, 0, (int)Positions.Centre);
|
||||
|
||||
// Top
|
||||
top = new CCSprite(scale9Image.Texture, centerbounds);
|
||||
top = new CCSprite(scale9Image.Texture, centertopbounds);
|
||||
scale9Image.AddChild(top, 1, (int)Positions.Top);
|
||||
|
||||
// Bottom
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace CocosSharp
|
|||
static float defaultFieldOfView = (float)Math.PI / 3.0f;
|
||||
static float defaultAspectRatio = 1.0f;
|
||||
static CCNearAndFarClipping defaultNearAndFarOrthoClipping = new CCNearAndFarClipping (1024f, -1024f);
|
||||
static CCNearAndFarClipping defaultNearAndFarPerspClipping = new CCNearAndFarClipping (0.01f, 100f);
|
||||
static CCNearAndFarClipping defaultNearAndFarPerspClipping = new CCNearAndFarClipping (0.1f, 100f);
|
||||
|
||||
internal event EventHandler OnCameraVisibleBoundsChanged = delegate {};
|
||||
|
||||
|
|
|
@ -45,26 +45,12 @@ namespace CocosSharp
|
|||
{
|
||||
get
|
||||
{
|
||||
CCSprite spriteTarget = Target as CCSprite;
|
||||
gridTextureSizeInPixels = Target.Scene.VisibleBoundsScreenspace.Size;
|
||||
|
||||
if (spriteTarget != null && !spriteTarget.ContentSize.Equals (CCSize.Zero))
|
||||
{
|
||||
gridTextureSizeInPixels = spriteTarget.TextureRectInPixels.Size;
|
||||
gridTextureSizeInPoints = spriteTarget.ContentSize;
|
||||
|
||||
gridTexture = new CCTexture2D(
|
||||
(int)gridTextureSizeInPixels.Width, (int)gridTextureSizeInPixels.Height, CCSurfaceFormat.Color, true, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
gridTextureSizeInPixels = Target.Scene.Viewport.ViewportInPixels.Size;
|
||||
gridTextureSizeInPoints = Target.Layer.VisibleBoundsWorldspace.Size;
|
||||
}
|
||||
|
||||
gridRenderTexture = new CCRenderTexture(gridTextureSizeInPoints, gridTextureSizeInPixels);
|
||||
gridTexture = gridRenderTexture.Texture;
|
||||
gridTexture = new CCTexture2D(
|
||||
(int)gridTextureSizeInPixels.Width, (int)gridTextureSizeInPixels.Height, CCSurfaceFormat.Color, true, false);
|
||||
grid3D = new CCGrid3D (GridSize, gridTexture);
|
||||
|
||||
|
||||
grid3D.Scene = Scene;
|
||||
|
||||
return grid3D;
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace CocosSharp
|
|||
CCTexture2D gridTexture = new CCTexture2D(
|
||||
(int)gridTextureSizeInPixels.Width, (int)gridTextureSizeInPixels.Height, CCSurfaceFormat.Color, true, false);
|
||||
tiledGrid3D = new CCTiledGrid3D (GridSize, gridTexture);
|
||||
tiledGrid3D.Scene = Scene;
|
||||
tiledGrid3D.Scene = Target.Scene;
|
||||
return tiledGrid3D;
|
||||
}
|
||||
protected set
|
||||
|
|
|
@ -1476,11 +1476,6 @@ namespace CocosSharp
|
|||
child.ResetCleanState();
|
||||
}
|
||||
|
||||
// Try to setup defaults if need be
|
||||
if (child is CCLayer && this is CCScene &&
|
||||
(child.Camera == null || child.Camera.OrthographicViewSizeWorldspace == CCSize.Zero ))
|
||||
child.Camera = new CCCamera (this.Window.DesignResolutionSize);
|
||||
|
||||
// We want all our children to have the same layer as us
|
||||
// Set this before we call child.OnEnter
|
||||
child.Layer = this.Layer;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
namespace CocosSharp
|
||||
{
|
||||
|
@ -101,7 +102,7 @@ namespace CocosSharp
|
|||
Texture = texture;
|
||||
textureFlipped = flipped;
|
||||
CCSize texSize = texture.ContentSizeInPixels;
|
||||
Step = new CCPoint (texSize.Width / GridSize.X, texSize.Height / GridSize.Y);
|
||||
Step = new CCPoint ((float)Math.Ceiling(texSize.Width / GridSize.X), (float)Math.Ceiling(texSize.Height / GridSize.Y));
|
||||
}
|
||||
|
||||
#endregion Constructors
|
||||
|
|
|
@ -180,9 +180,9 @@ namespace CocosSharp
|
|||
for (int y = 0; y < GridSize.Y; y++)
|
||||
{
|
||||
float x1 = x * Step.X;
|
||||
float x2 = x1 + Step.X;
|
||||
float x2 = x == GridSize.X - 1 ? width : x1 + Step.X;
|
||||
float y1 = y * Step.Y;
|
||||
float y2 = y1 + Step.Y;
|
||||
float y2 = y == GridSize.Y - 1 ? height : y1 + Step.Y;
|
||||
|
||||
vertArray[index + 0].Vertices = new CCVertex3F(x1, y1, 0);
|
||||
vertArray[index + 1].Vertices = new CCVertex3F(x2, y1, 0);
|
||||
|
|
|
@ -168,8 +168,7 @@ namespace CocosSharp
|
|||
|
||||
if(Camera == null)
|
||||
{
|
||||
CCRect visibleBoundsScreenspace = Scene.VisibleBoundsScreenspace;
|
||||
Camera = new CCCamera(visibleBoundsScreenspace);
|
||||
Camera = new CCCamera (this.Window.DesignResolutionSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -233,9 +232,9 @@ namespace CocosSharp
|
|||
CCPoint bottomRightPoint = new CCPoint(bottomRight.X, bottomRight.Y);
|
||||
|
||||
visibleBoundsWorldspace = new CCRect(
|
||||
bottomLeftPoint.X, bottomLeftPoint.Y,
|
||||
(int)((bottomRightPoint.X - bottomLeftPoint.X)),
|
||||
(int)((topLeftPoint.Y - bottomLeftPoint.Y)));
|
||||
(float)Math.Round(bottomLeftPoint.X), (float)Math.Round(bottomLeftPoint.Y),
|
||||
(float)Math.Round(bottomRightPoint.X - bottomLeftPoint.X),
|
||||
(float)Math.Round(topLeftPoint.Y - bottomLeftPoint.Y));
|
||||
|
||||
anchorPointInPoints = new CCPoint(visibleBoundsWorldspace.Size.Width * AnchorPoint.X, visibleBoundsWorldspace.Size.Height * AnchorPoint.Y);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace CocosSharp
|
|||
public class CCLayerColor : CCLayer, ICCBlendable
|
||||
{
|
||||
|
||||
internal VertexPositionColor[] SquareVertices = new VertexPositionColor[4];
|
||||
internal VertexPositionColor[] SquareVertices = new VertexPositionColor[4];
|
||||
|
||||
#region Properties
|
||||
|
||||
|
@ -130,17 +130,17 @@ namespace CocosSharp
|
|||
|
||||
protected override void Draw()
|
||||
{
|
||||
if(Camera != null)
|
||||
{
|
||||
var drawManager = Window.DrawManager;
|
||||
if(Camera != null)
|
||||
{
|
||||
var drawManager = Window.DrawManager;
|
||||
|
||||
drawManager.TextureEnabled = false;
|
||||
drawManager.BlendFunc(BlendFunc);
|
||||
drawManager.DrawPrimitives(PrimitiveType.TriangleStrip, SquareVertices, 0, 2);
|
||||
drawManager.TextureEnabled = false;
|
||||
drawManager.BlendFunc(BlendFunc);
|
||||
drawManager.DrawPrimitives(PrimitiveType.TriangleStrip, SquareVertices, 0, 2);
|
||||
|
||||
drawManager.ViewMatrix = Camera.ViewMatrix;
|
||||
drawManager.ProjectionMatrix = Camera.ProjectionMatrix;
|
||||
}
|
||||
drawManager.ViewMatrix = Camera.ViewMatrix;
|
||||
drawManager.ProjectionMatrix = Camera.ProjectionMatrix;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -157,12 +157,20 @@ namespace CocosSharp
|
|||
void UpdateVerticesPosition()
|
||||
{
|
||||
CCSize contentSize = ContentSize;
|
||||
CCRect visibleBounds = VisibleBoundsWorldspace;
|
||||
|
||||
//1, 2, 3, 3
|
||||
SquareVertices[1].Position.X = contentSize.Width;
|
||||
SquareVertices[2].Position.Y = contentSize.Height;
|
||||
SquareVertices[3].Position.X = contentSize.Width;
|
||||
SquareVertices[3].Position.Y = contentSize.Height;
|
||||
SquareVertices[0].Position.X = visibleBounds.Origin.X;
|
||||
SquareVertices[0].Position.Y = visibleBounds.Origin.Y;
|
||||
|
||||
SquareVertices[1].Position.X = SquareVertices[0].Position.X + visibleBounds.Size.Width;
|
||||
SquareVertices[1].Position.Y = SquareVertices[0].Position.Y;
|
||||
|
||||
SquareVertices[2].Position.X = SquareVertices[0].Position.X;
|
||||
SquareVertices[2].Position.Y = SquareVertices[0].Position.Y + visibleBounds.Size.Height;
|
||||
|
||||
SquareVertices[3].Position.X = SquareVertices[0].Position.X + visibleBounds.Size.Width;
|
||||
SquareVertices[3].Position.Y = SquareVertices[0].Position.Y + visibleBounds.Size.Height;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -599,18 +599,18 @@ namespace CocosSharp
|
|||
{
|
||||
try
|
||||
{
|
||||
Clear(CCColor4B.Black, 1, 0);
|
||||
Clear(CCColor4B.Transparent, 1, 0);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
// no stencil buffer
|
||||
hasStencilBuffer = false;
|
||||
Clear(CCColor4B.Black);
|
||||
Clear(CCColor4B.Transparent);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Clear(CCColor4B.Black);
|
||||
Clear(CCColor4B.Transparent);
|
||||
}
|
||||
|
||||
DrawCount = 0;
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace tests
|
|||
{
|
||||
public class Shaky3DDemo : CCShaky3D
|
||||
{
|
||||
public Shaky3DDemo (float t) : base (t, new CCGridSize(15, 10), 5, true)
|
||||
public Shaky3DDemo (float t) : base (t, new CCGridSize(15, 10), 10, true)
|
||||
{
|
||||
// Testing of Properties
|
||||
// Range = 5;
|
||||
|
|
|
@ -53,21 +53,6 @@ namespace tests
|
|||
|
||||
CCRect visibleBounds = Layer.VisibleBoundsWorldspace;
|
||||
|
||||
CCCamera contentCamera = contentLayer.Camera;
|
||||
|
||||
contentCamera.Projection = CCCameraProjection.Projection3D;
|
||||
contentCamera.PerspectiveAspectRatio = 3.0f;
|
||||
|
||||
CCPoint3 cameraCenter = contentCamera.CenterInWorldspace;
|
||||
CCPoint3 cameraTarget = contentCamera.TargetInWorldspace;
|
||||
|
||||
float targeCenterLength = (cameraTarget - cameraCenter).Length;
|
||||
|
||||
|
||||
contentCamera.NearAndFarPerspectiveClipping = new CCNearAndFarClipping (0.15f, 100.0f);
|
||||
|
||||
contentCamera.PerspectiveFieldOfView = (float)Math.Atan(visibleBounds.Size.Height / (2.0f * targeCenterLength));
|
||||
|
||||
Schedule(checkAnim);
|
||||
|
||||
BaseNode.Position = windowSize.Center;
|
||||
|
|
Загрузка…
Ссылка в новой задаче