public void Init() { _sceneEngineMock = new Mock<ISceneEngine>(); _materialsAssets = new List<Material>(); _sceneEngineMock.Setup(m => m.GetAssets<Material>()).Returns(_materialsAssets); _texture = new Texture(); _sceneEngineMock.Setup(m => m.LoadOrCreateTexture(It.IsAny<string>(), It.IsAny<string>())).Returns(_texture); _importer = new WavefrontFormatImporter(); }
public Form1() { InitializeComponent(); SharpGL.SceneGraph.Assets.Material SunMaterial = new SharpGL.SceneGraph.Assets.Material(); SharpGL.SceneGraph.Assets.Material EarthMaterial = new SharpGL.SceneGraph.Assets.Material(); SharpGL.SceneGraph.Assets.Material MoonMaterial = new SharpGL.SceneGraph.Assets.Material(); SharpGL.SceneGraph.Assets.Texture SunTexture = new SharpGL.SceneGraph.Assets.Texture(); SharpGL.SceneGraph.Assets.Texture EarthTexture = new SharpGL.SceneGraph.Assets.Texture(); SharpGL.SceneGraph.Assets.Texture MoonTexture = new SharpGL.SceneGraph.Assets.Texture(); OpenGLControl openglCtr = new SharpGL.OpenGLControl(); SunTexture.Create(openglCtr.OpenGL, "Sun.bmp"); OpenGLControl openglCtr1 = new SharpGL.OpenGLControl(); MoonTexture.Create(openglCtr1.OpenGL, "Moon.jpg"); OpenGLControl openglCtr2 = new SharpGL.OpenGLControl(); EarthTexture.Create(openglCtr2.OpenGL, "Earth.jpg"); //// texture1.Create(openglCtr.OpenGL, "Crate.bmp"); //// material.Texture = texture1; SunMaterial.Texture = SunTexture; Sun.TextureCoords = true; EarthMaterial.Texture = EarthTexture; Earth.TextureCoords = true; MoonMaterial.Texture = MoonTexture; Moon.TextureCoords = true; Light light = new Light() { On = true, Position = new Vertex(0, 0, 0), GLCode = OpenGL.GL_LIGHT1 }; sceneControl1.Scene.SceneContainer.AddChild(light); //SharpGL.OpenGL gl = this.sceneControl1.OpenGL; //texture.Create(gl, "Crate.bmp"); //texture.Bind(gl); //uint[] textureID = new uint[1]; //byte[] colors = new byte[256 * 256 * 4]; //gl.BindTexture(OpenGL.GL_TEXTURE_2D, textureID[0]); //gl.TexImage2D(OpenGL.GL_TEXTURE_2D, 0, (int)OpenGL.GL_TEXTURE, 256, 256, 50, OpenGL.GL_TEXTURE, OpenGL.GL_BYTE, colors); //// SunMaterial.Diffuse = Color.Orange; //EarthMaterial.Diffuse = Color.Cyan; //MoonMaterial.Diffuse = Color.Silver; ////SunMaterial.Ambient = Color.FromArgb(0, Color.Orange); //EarthMaterial.Ambient = Color.FromArgb(255, Color.Blue); //MoonMaterial.Ambient = Color.FromArgb(255, Color.Silver); SunMaterial.Texture = SunTexture; Sun.Material = SunMaterial; Moon.Material = MoonMaterial; Earth.Material = EarthMaterial; Earth.Radius = 2; Moon.Radius = 0.5; Sun.Radius = 4; sceneControl1.Scene.SceneContainer.AddChild(Earth); sceneControl1.Scene.SceneContainer.AddChild(Moon); sceneControl1.Scene.SceneContainer.AddChild(Sun); sceneControl1.Scene.RenderBoundingVolumes = !sceneControl1.Scene.RenderBoundingVolumes; }
public BuildingObjectLib3DS CreateBuildingModel() { BuildingObjectLib3DS Building; Hashtable Textures = new Hashtable(); Lib3dsMesh test = new Lib3dsMesh(); OpenGLControl openglCtr = new SharpGL.OpenGLControl(); foreach (Lib3dsMaterial material in MyModel.materials) { Texture texture = new Texture(); try { texture.Create(openglCtr.OpenGL, "..\\Model\\" + material.name + ".jpg"); Textures.Add(material.name, texture); } catch { // Do not find the texture file } } Building = new BuildingObjectLib3DS(null, BuildingObjectType.Building, 0, MyModel, Textures); foreach (Lib3dsMeshInstanceNode node in MyModel.nodes) { if (node.type != Lib3dsNodeType.LIB3DS_NODE_MESH_INSTANCE || node.childs == null) continue; Building.AddNewChild(node); } return Building; }
public void SetTexture(Bitmap bitmap) { ////TODO:如果用此方式,则必须先将此对象加入scene树,然后再调用Init //OpenGL gl = this.TraverseToRootElement().ParentScene.OpenGL; this.texture = new Texture(); this.texture.Create(gl, bitmap); //参数为GL_CLAMP,则缩限,所有大于1的纹理元素值置为1。所有小于0的纹理元素值置为0。 gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_S, OpenGL.GL_CLAMP); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_T, OpenGL.GL_CLAMP); }
public uint LoadGLTextures() // Load Bitmaps And Convert To Textures { OpenGL gl = openGLControl1.OpenGL; // We'll hitch a ride off the scene graph here. particleTexture = new Texture(); particleTexture.Create(gl, "Particle.png"); /*glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data); */ texture[0] = particleTexture.TextureName; return texture[0]; }
public Form1() { InitializeComponent(); OpenGL gl = sceneControl1.OpenGL; SharpGL.SceneGraph.Assets.Material SunMaterial = new SharpGL.SceneGraph.Assets.Material(); SharpGL.SceneGraph.Assets.Material EarthMaterial = new SharpGL.SceneGraph.Assets.Material(); SharpGL.SceneGraph.Assets.Material MoonMaterial = new SharpGL.SceneGraph.Assets.Material(); SharpGL.SceneGraph.Assets.Material MercuryMaterial = new SharpGL.SceneGraph.Assets.Material(); SharpGL.SceneGraph.Assets.Texture SunTexture = new SharpGL.SceneGraph.Assets.Texture(); SharpGL.SceneGraph.Assets.Texture EarthTexture = new SharpGL.SceneGraph.Assets.Texture(); SharpGL.SceneGraph.Assets.Texture MoonTexture = new SharpGL.SceneGraph.Assets.Texture(); SharpGL.SceneGraph.Assets.Texture MercuryTexture = new SharpGL.SceneGraph.Assets.Texture(); OpenGLControl openglCtr = new SharpGL.OpenGLControl(); SunTexture.Create(openglCtr.OpenGL, "Sun.jpg"); OpenGLControl openglCtr1 = new SharpGL.OpenGLControl(); MoonTexture.Create(openglCtr1.OpenGL, "Moon.jpg"); OpenGLControl openglCtr2 = new SharpGL.OpenGLControl(); EarthTexture.Create(openglCtr2.OpenGL, "Earth.jpg"); OpenGLControl openglCtr3 = new SharpGL.OpenGLControl(); MercuryTexture.Create(openglCtr2.OpenGL, "Mercury.jpg"); SunMaterial.Texture = SunTexture; Sun.TextureCoords = true; EarthMaterial.Texture = EarthTexture; Earth.TextureCoords = true; MoonMaterial.Texture = MoonTexture; Moon.TextureCoords = true; MercuryMaterial.Texture = MoonTexture; Mercury.TextureCoords = true; SunMaterial.Texture = SunTexture; Sun.Material = SunMaterial; Moon.Material = MoonMaterial; Earth.Material = EarthMaterial; Mercury.Material = MercuryMaterial; Earth.Radius = 2; Moon.Radius = 0.5; Sun.Radius = 4; Mercury.Radius = 0.7; sceneControl1.Scene.SceneContainer.AddChild(Earth); sceneControl1.Scene.SceneContainer.AddChild(Moon); sceneControl1.Scene.SceneContainer.AddChild(Sun); sceneControl1.Scene.SceneContainer.AddChild(Mercury); sceneControl1.Scene.RenderBoundingVolumes = !sceneControl1.Scene.RenderBoundingVolumes; Light light = new Light() { On = true, Position = new Vertex(0, 0, 0), GLCode = OpenGL.GL_LIGHT0 }; sceneControl1.Scene.SceneContainer.AddChild(light); }
public SpriteSheet(Texture texture) { tex = texture; texWidth = 0; texHeight = 0; }
public SpriteSheet() { tex = new Texture(); texWidth = 0; texHeight = 0; }
private void glcScene_OpenGLInitialized(object sender, EventArgs e) { OpenGL gl = glcScene.OpenGL; texrun = new Texture(); texrun.Create(gl, RRRR.Properties.Resources.Runner); texM = new Texture(); texM.Create(gl, RRRR.Properties.Resources.Walker_M); texF = new Texture(); texF.Create(gl, RRRR.Properties.Resources.Walker_F); texMFly = new Texture(); texMFly.Create(gl, RRRR.Properties.Resources.Walker_M_Flew); texFFly = new Texture(); texFFly.Create(gl, RRRR.Properties.Resources.Walker_F_Flew); player = new Player(0, 0, 0); walkers.Add(player); player.y = 0; texBuilding[0] = new Texture(); texBuilding[0].Create(gl, RRRR.Properties.Resources.apart_1); texBuilding[1] = new Texture(); texBuilding[1].Create(gl, RRRR.Properties.Resources.apart_2); texBuilding[2] = new Texture(); texBuilding[2].Create(gl, RRRR.Properties.Resources.apart_3); texBuilding[3] = new Texture(); texBuilding[3].Create(gl, RRRR.Properties.Resources.apart_4); texFloor1 = new Texture(); texFloor1.Create(gl, RRRR.Properties.Resources.block_0); texFloor2 = new Texture(); texFloor2.Create(gl, RRRR.Properties.Resources.block_1); texStart = new Texture(); texStart.Create(gl, RRRR.Properties.Resources.START); texCheck = new Texture(); texCheck.Create(gl, RRRR.Properties.Resources.checkpoint); }