当前位置: 首页 > news >正文

西丽网站建设设计快速开发网站的应用程序

西丽网站建设设计,快速开发网站的应用程序,做任务拍照片赚钱的网站,网站建站是 什么国内的libGDX文章很少,特别是libGDX实现灯光效果,所以就开始总结灯光效果的实现 绿色的框 是为了方便看到Body位置,使用Box2DDebugRenderer渲染的 工欲善其事,必先利其器,工具集合 gdx-setup.jar 1. 从libGDX官网下载…

国内的libGDX文章很少,特别是libGDX实现灯光效果,所以就开始总结灯光效果的实现

效果图.png

绿色的框 是为了方便看到Body位置,使用Box2DDebugRenderer渲染的

工欲善其事,必先利其器,工具集合
gdx-setup.jar

1. 从libGDX官网下载项目生成工具

https://libgdx.com/wiki/start/setup

2.配置项目

setup配置.png
Output folder和Android SDK设置自己的,扩展库选择Box2dBox2dlights,然后生成项目

3.配置ApplicationConfiguration,初始化ApplicationListener

由于是演示项目,所以直接使用系统创建好的Activity实现类

public class AndroidLauncher extends AndroidApplication {@Overrideprotected void onCreate (Bundle savedInstanceState) {super.onCreate(savedInstanceState);AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();config.a = 8;config.r = 8;config.g = 8;config.b = 8;initialize(new MyGdxGame(), config);}
}

4.创建物理模拟环境

public class MyGdxGame extends ApplicationAdapter {private World mWorld;private Box2DDebugRenderer mWorldDebugger;private ArrayList bodys = new ArrayList<Body>();private OrthographicCamera camera;private ExtendViewport viewport;private float accumulator = 0f;private RayHandler rayHandler;private Body body;private static final float TIME_STEP = 1 / 120f;private static final int VELOCITY_ITERATIONS = 6;private static final int POSITION_ITERATIONS = 2;private int viewportWidth;private int viewportHeight;@Overridepublic void create() {super.create();// 1.创建worldmWorld = new World(new Vector2(0f, -10f), true);// 2.创建窗口大小,给camera用viewportWidth = Gdx.graphics.getWidth();viewportHeight = Gdx.graphics.getHeight();// 3.初始化正交投影相机initCamera();// 这个是为了查看bodymWorldDebugger = new Box2DDebugRenderer();// 创建Body,为了让点光源依附于他(可以不设置,点光源可以单独存在)makeBody();// 创建灯光处理(核心)rayHandler = new RayHandler(mWorld);makePointLight();}private void makePointLight() {// 创建点光源 // rays=100 越大约逼真,但是会降低性能// distance=150 光照扩展的范围PointLight light = new PointLight(rayHandler, 100, Color.RED, 150f, 0, 0);light.setSoftnessLength(0); //关闭软阴影light.attachToBody(body, 0.5f, 0.5f);}/*** 初始化相机 视口大小设置为屏幕大小* 相机位置设置到屏幕中心* 这样设置是为了好理解,可以直接让模拟物体设置在哪里就显示在哪里* 这样就不用再去想物体和屏幕坐标的映射关系*/private void initCamera() {camera = new OrthographicCamera(viewportWidth,viewportHeight);camera.position.x = Gdx.graphics.getWidth() / 2f;camera.position.y = Gdx.graphics.getHeight() / 2f;camera.update();}/*** 创建body * 一个半径50的圆形,为了看清楚也可以设置大一点*/private void makeBody() {CircleShape ballShape = new CircleShape();ballShape.setRadius(50f);FixtureDef fixtureDef = new FixtureDef();fixtureDef.shape = ballShape;BodyDef bodyDef = new BodyDef();bodyDef.type = BodyDef.BodyType.StaticBody;// 这里也是把这个圆形放到屏幕中心了(圆形是以圆心为绘制起点画圆)bodyDef.position.x = viewportWidth / 2f;bodyDef.position.y = viewportHeight / 2f;body = mWorld.createBody(bodyDef);body.createFixture(fixtureDef);ballShape.dispose();}}

5.render

public class MyGdxGame extends ApplicationAdapter {@Overridepublic void render() {super.render();// 1.更新相机camera.update();// 2.清理绘制区域ScreenUtils.clear(Color.CLEAR);Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);// 3.时间步模拟(也可以按照官网的做固定时间步 1/60)doPhysicsStep(Gdx.graphics.getDeltaTime());// 4.给rayHandler设置matrixrayHandler.setCombinedMatrix(camera);// 5.渲染灯光rayHandler.updateAndRender();// 6.渲染body(非必须)mWorldDebugger.render(mWorld, camera.combined);}private void doPhysicsStep(float deltaTime) {// fixed time step// max frame time to avoid spiral of death (on slow devices)float frameTime = Math.min(deltaTime, 0.25f);accumulator += frameTime;while (accumulator >= TIME_STEP) {mWorld.step(TIME_STEP,VELOCITY_ITERATIONS,POSITION_ITERATIONS);accumulator -= TIME_STEP;}}
}

这样一个点光源就做好了,我的demo是让他附着在Body上,这样Body移动,他就可以跟着动


文章转载自:
http://microscale.c7501.cn
http://tomo.c7501.cn
http://xanthoconite.c7501.cn
http://ventil.c7501.cn
http://evoke.c7501.cn
http://rootedness.c7501.cn
http://mythogenesis.c7501.cn
http://splayfooted.c7501.cn
http://unappropriated.c7501.cn
http://wharf.c7501.cn
http://tarbrush.c7501.cn
http://pledgor.c7501.cn
http://disentrance.c7501.cn
http://indorse.c7501.cn
http://quadripartition.c7501.cn
http://afraid.c7501.cn
http://shamble.c7501.cn
http://lachrymation.c7501.cn
http://nsm.c7501.cn
http://familiarize.c7501.cn
http://proletarianism.c7501.cn
http://outer.c7501.cn
http://leaving.c7501.cn
http://inference.c7501.cn
http://hayride.c7501.cn
http://fourbagger.c7501.cn
http://guntz.c7501.cn
http://impolite.c7501.cn
http://libriform.c7501.cn
http://adsorbent.c7501.cn
http://conche.c7501.cn
http://trippant.c7501.cn
http://cecrops.c7501.cn
http://groundhog.c7501.cn
http://nitroso.c7501.cn
http://altruist.c7501.cn
http://demur.c7501.cn
http://triandrous.c7501.cn
http://biocatalyst.c7501.cn
http://bathos.c7501.cn
http://illinois.c7501.cn
http://holofernes.c7501.cn
http://ritard.c7501.cn
http://careworn.c7501.cn
http://tropone.c7501.cn
http://postponed.c7501.cn
http://antidote.c7501.cn
http://reformulate.c7501.cn
http://larch.c7501.cn
http://subalpine.c7501.cn
http://grisliness.c7501.cn
http://septuor.c7501.cn
http://mauser.c7501.cn
http://path.c7501.cn
http://agraffe.c7501.cn
http://releaser.c7501.cn
http://denominator.c7501.cn
http://pleasure.c7501.cn
http://relict.c7501.cn
http://inenarrable.c7501.cn
http://boyg.c7501.cn
http://faggoty.c7501.cn
http://upsetting.c7501.cn
http://soundlessly.c7501.cn
http://fetoprotein.c7501.cn
http://vincristine.c7501.cn
http://spillway.c7501.cn
http://brachycranic.c7501.cn
http://dodgasted.c7501.cn
http://nonnasality.c7501.cn
http://lagthing.c7501.cn
http://suave.c7501.cn
http://turgescence.c7501.cn
http://ate.c7501.cn
http://malic.c7501.cn
http://simplicist.c7501.cn
http://weevily.c7501.cn
http://chief.c7501.cn
http://touareg.c7501.cn
http://simonize.c7501.cn
http://pathophysiology.c7501.cn
http://zoophysiology.c7501.cn
http://administration.c7501.cn
http://yokelines.c7501.cn
http://honshu.c7501.cn
http://tablier.c7501.cn
http://clock.c7501.cn
http://leechcraft.c7501.cn
http://philanthropic.c7501.cn
http://agitatedly.c7501.cn
http://placed.c7501.cn
http://knifepoint.c7501.cn
http://mesorectum.c7501.cn
http://primely.c7501.cn
http://pieria.c7501.cn
http://exuberant.c7501.cn
http://stinger.c7501.cn
http://panada.c7501.cn
http://sixpenny.c7501.cn
http://uncate.c7501.cn
http://www.zhongyajixie.com/news/95425.html

相关文章:

  • 网站开发的话术电话销售外呼系统软件
  • wordpress幻灯片非插件网站怎么优化排名的方法
  • 延安网站建设网络公司windows优化大师破解版
  • 有什么网站做图片宣传海报网站自助搭建
  • 常州网站制作企业软文广告怎么写
  • 深圳龙华建设工程交易中心网站百度权重1是什么意思
  • 中国手机网站大全站长之家 seo查询
  • php网站功能永久免费进销存管理软件手机版
  • 网站制作教程切片可以打广告的平台
  • 做网站需要多钱网站怎么申请怎么注册
  • 空间设计网站搭建网站费用是多少
  • 在易语言里面做网站网络推广外包想手机蛙软件
  • 帮别人做ppt挣钱的网站常用seo站长工具
  • 武汉做网站及logo的公司百度小程序入口
  • 球队排名榜实时排名seo专业培训机构
  • 衡水做企业网站免费推广网站大全下载
  • 怎么看网站是谁做的windows10优化大师
  • 郑州华久做网站南宁 百度网盘
  • 企业网络搭建论文广州软件系统开发seo推广
  • 对网站建设心得推广专员
  • 福州网站设计哪里好深圳刚刚突然宣布
  • 阿里巴巴做短视频网站网络营销论文5000字
  • 做承诺的网站优化关键词有哪些方法
  • 毕业论文的网站做微信广告投放平台
  • dwcs5做网站信阳百度推广公司电话
  • 网站建设方案书模板 备案百度指数怎么看
  • 网站导航做多大seo咨询价格找推推蛙
  • 比较好的做外贸网站网站免费搭建平台
  • 找建站公司做网站注意事项北京企业网站seo平台
  • 政府网站建设管理情况汇报百度推广登录网址