当前位置: 首页>>代码示例>>Java>>正文


Java ModelBuilder.createSphere方法代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.utils.ModelBuilder.createSphere方法的典型用法代码示例。如果您正苦于以下问题:Java ModelBuilder.createSphere方法的具体用法?Java ModelBuilder.createSphere怎么用?Java ModelBuilder.createSphere使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.graphics.g3d.utils.ModelBuilder的用法示例。


在下文中一共展示了ModelBuilder.createSphere方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
@Override
public void create () {
	ModelBuilder builder = new ModelBuilder();
	sphere = builder.createSphere(2f, 2f, 2f, 16, 16, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)),
		Usage.Position | Usage.Normal);
	// cam = new PerspectiveCamera(45, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	cam = new OrthographicCamera(45, 45 * (Gdx.graphics.getWidth() / (float)Gdx.graphics.getHeight()));

	cam.near = 1;
	cam.far = 200;

	Random rand = new Random();
	for (int i = 0; i < instances.length; i++) {
		pos.set(rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * 100 - rand.nextFloat() * 100,
			rand.nextFloat() * -100 - 3);
		instances[i] = new ModelInstance(sphere, pos);
	}
	modelBatch = new ModelBatch();

	batch = new SpriteBatch();
	font = new BitmapFont();
	// Gdx.graphics.setVSync(true);
	// Gdx.app.log("CullTest", "" + Gdx.graphics.getBufferFormat().toString());
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:25,代码来源:CullTest.java

示例2: TranslateTool

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
public TranslateTool(ProjectManager projectManager, GameObjectPicker goPicker, ToolHandlePicker handlePicker,
        ModelBatch batch, CommandHistory history) {

    super(projectManager, goPicker, handlePicker, batch, history);

    ModelBuilder modelBuilder = new ModelBuilder();

    Model xHandleModel = modelBuilder.createArrow(0, 0, 0, 1, 0, 0, ARROW_CAP_SIZE, ARROW_THIKNESS, ARROW_DIVISIONS,
            GL20.GL_TRIANGLES, new Material(ColorAttribute.createDiffuse(COLOR_X)),
            VertexAttributes.Usage.Position);
    Model yHandleModel = modelBuilder.createArrow(0, 0, 0, 0, 1, 0, ARROW_CAP_SIZE, ARROW_THIKNESS, ARROW_DIVISIONS,
            GL20.GL_TRIANGLES, new Material(ColorAttribute.createDiffuse(COLOR_Y)),
            VertexAttributes.Usage.Position);
    Model zHandleModel = modelBuilder.createArrow(0, 0, 0, 0, 0, 1, ARROW_CAP_SIZE, ARROW_THIKNESS, ARROW_DIVISIONS,
            GL20.GL_TRIANGLES, new Material(ColorAttribute.createDiffuse(COLOR_Z)),
            VertexAttributes.Usage.Position);
    Model xzPlaneHandleModel = modelBuilder.createSphere(1, 1, 1, 20, 20,
            new Material(ColorAttribute.createDiffuse(COLOR_XZ)), VertexAttributes.Usage.Position);

    xHandle = new TranslateHandle(X_HANDLE_ID, xHandleModel);
    yHandle = new TranslateHandle(Y_HANDLE_ID, yHandleModel);
    zHandle = new TranslateHandle(Z_HANDLE_ID, zHandleModel);
    xzPlaneHandle = new TranslateHandle(XZ_HANDLE_ID, xzPlaneHandleModel);
    handles = new TranslateHandle[] { xHandle, yHandle, zHandle, xzPlaneHandle };

    gameObjectModifiedEvent = new GameObjectModifiedEvent(null);
}
 
开发者ID:mbrlabs,项目名称:Mundus,代码行数:28,代码来源:TranslateTool.java

示例3: DevelopmentPlacementRenderer

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
public DevelopmentPlacementRenderer() {
	ModelBuilder modelBuilder = new ModelBuilder();
	cursorModel = modelBuilder.createSphere(1f, 1f, 1f, 8, 8, new Material(), VertexAttributes.Usage.Position
			| VertexAttributes.Usage.ColorUnpacked
			| VertexAttributes.Usage.Normal);

	cursorModelInstance = new ModelInstance(cursorModel);
}
 
开发者ID:aphex-,项目名称:Alien-Ark,代码行数:9,代码来源:DevelopmentPlacementRenderer.java

示例4: create

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
@Override
public void create () {
	super.create();
	environment.clear();
	environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.2f, 0.2f, 0.2f, 1.0f));
	environment.add(dirLight = new DirectionalLight().set(0.8f, 0.2f, 0.2f, -1f, -2f, -0.5f));
	environment.add(pointLight = new PointLight().set(0.2f, 0.8f, 0.2f, 0f, 0f, 0f, 100f));

	ModelBuilder mb = new ModelBuilder();
	lightModel = mb.createSphere(1, 1, 1, 10, 10, new Material(ColorAttribute.createDiffuse(1, 1, 1, 1)), Usage.Position);
	lightModel.nodes.get(0).parts.get(0).setRenderable(pLight = new Renderable());
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:13,代码来源:LightsTest.java

示例5: Rocket

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
public Rocket() {
	// init graphic
	ModelLoader loader = new ObjLoader();
	model = loader.loadModel(Gdx.files.internal("models/rocket.obj"), new ObjLoader.ObjLoaderParameters(true));
	rocketModelInstance = new ModelInstance(model);


	ModelBuilder modelBuilder = new ModelBuilder();
	final long attributes = VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal;

	// damage shield
	Material shieldMaterial = new Material();
	shieldMaterial.set(ColorAttribute.createDiffuse(0, 0.3f, 1, 0.5f));
	shieldMaterial.set(ColorAttribute.createSpecular(1, 1, 1, 1f));
	shieldMaterial.set(new BlendingAttribute(1f));
	Model shieldModel = modelBuilder.createSphere(4, 4, 4, 32, 32, shieldMaterial, attributes);
	shieldModelInstance = new ModelInstance(shieldModel);

	Material tractorBeamMaterial = new Material();
	tractorBeamMaterial.set(ColorAttribute.createDiffuse(0, 0, 1, 1));
	tractorBeamMaterial.set(ColorAttribute.createSpecular(1, 1, 1, 1f));
	tractorBeamMaterial.set(new BlendingAttribute(0.1f));
	Model tractorBeamModel = modelBuilder.createSphere(5, 5, 5, 32, 32, tractorBeamMaterial, attributes);
	tractorBeamModelInstance = new ModelInstance(tractorBeamModel);


	// init physic
	//BoundingBox boundingBox = new BoundingBox();
	//model.calculateBoundingBox(boundingBox);
	//btCollisionShape shape = new btBoxShape(boundingBox.getDimensions(new Vector3()).scl(0.5f));
	btCollisionShape shape = new btBoxShape(new Vector3(1, 1, 1));

	rocketModelInstance.transform.setToRotation(0, 0, 1, 0);
	rocketModelInstance.transform.trn(START_POSITION);
	float mass = 1;
	addRigidBody(shape, mass, SpaceShipProperties.properties.getLandslide(), CollisionTypes.ROCKET.mask,
			new RocketMotionState(rocketModelInstance.transform));
	rigidBodyList.get(0).setActivationState(4); // disable deactivation
	rigidBodyList.get(0).setLinearVelocity(tmpMovement.set(getDirection()).nor().scl(
			SpaceShipProperties.properties.getEnginePower()));

	thrustSound = App.audioController.getSound("thrust.wav");
	if (App.config.playAudio) {
		thrustSound.loop();
		thrustSound.play();
	}
}
 
开发者ID:aphex-,项目名称:Alien-Ark,代码行数:48,代码来源:Rocket.java

示例6: create

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
@Override
    public void create() {
        debrisInstance = new ArrayList<ModelInstance>();
        casketInstance = new ArrayList<ModelInstance>();
        debris = Main.getDebris();
        casket = debris.subList(0, 100);

        light = new DirectionalLight().set(222f, 222f, 222f, 300f, 300f, 300f);
        enviroment = new Environment();
        enviroment.set(new ColorAttribute(ColorAttribute.AmbientLight, 2.4f, 3.4f, 2.4f, 3f));
        enviroment.add(light);

        modelBatch = new ModelBatch();

        cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
//        cam.rotate(90, 0, 0, 1);
        cam.position.set(50f, 50f,50f);
        cam.lookAt(0, 0, 0);
        cam.near = 1f;
        cam.far = 4000f;
        cam.update();

        ModelBuilder modelBuilder = new ModelBuilder();
        ObjLoader loader = new ObjLoader();
        model = loader.loadModel(Gdx.files.internal("textures/Earth.obj"));
        //
//        model = modelBuilder.createSphere(128f, 128f, 128f, 20, 20,
//                new Material(ColorAttribute.AmbientAlias),
//                VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal | VertexAttributes.Usage.TextureCoordinates);
        instance = new ModelInstance(model);
        instance.transform.scale(128, 128, 128);
        instance.transform.rotate(1, 0, 0, 180);
        instance.transform.rotate(0, 0, 1, 90);

        space = loader.loadModel(Gdx.files.internal("textures/space/spacesphere.obj"));
        spaceInstance = new ModelInstance(space);
        spaceInstance.transform.scale(10,10,10);

        for (int i = 0; i < 100; i++) {
            debrisModel = loader.loadModel(Gdx.files.internal("textures/Nuka_Cola_Fridge.obj"));
            casketInstance.add(new ModelInstance(debrisModel));
        }

        for (Placemark pm : debris) {
            Random rand = new Random();
            debrisModel = modelBuilder.createSphere(3f, 3f, 3f, 4, 4,
                    new Material(ColorAttribute.createDiffuse(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat())),
                    VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal | VertexAttributes.Usage.TextureCoordinates);
            ModelInstance mi = new ModelInstance(debrisModel);
            Coordinate coordinate = pm.getNextCoordinate(100f);
            mi.transform.translate((float) coordinate.x, (float) coordinate.y, (float) coordinate.z);
            debrisInstance.add(mi);
        }
        camController = new CameraInputController(cam);
        Gdx.input.setInputProcessor(camController);
    }
 
开发者ID:mkostin,项目名称:NASAChallengeDebris,代码行数:57,代码来源:MyGDXSattelite.java

示例7: create

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
@Override
public void create () {
	Gdx.input.setInputProcessor(this);
	
	modelBatch = new ModelBatch();
	
	spriteBatch = new SpriteBatch();
	
	font = new BitmapFont();
	
	ModelBuilder modelBuilder = new ModelBuilder();
	
	float gameArea = 16.5f*2f;
	
	snakeModel = modelBuilder.createSphere(4,4,4,
			6, 6,
			new Material(ColorAttribute.createDiffuse(Color.GREEN)),
			Usage.Position | Usage.Normal);
	candyModel = modelBuilder.createSphere(3, 3, 3,
			4, 4,
			new Material(ColorAttribute.createDiffuse(Color.RED)),
			Usage.Position | Usage.Normal);
	
	planes[0] = modelBuilder.createBox(gameArea, 0.1f, gameArea,
			new Material(ColorAttribute.createDiffuse(Color.MAROON)),
			Usage.Position | Usage.Normal);
	
	planes[1] = modelBuilder.createBox(gameArea, 0.1f, gameArea,
			new Material(ColorAttribute.createDiffuse(new Color(0.2f,1f,0.4f,0.4f))),
			Usage.Position | Usage.Normal);
	
	planes[2] = modelBuilder.createBox(gameArea, 4f*1.5f*2f, 0.1f,
			new Material(ColorAttribute.createDiffuse(Color.BLUE)),
			Usage.Position | Usage.Normal);
	
	planes[3] = modelBuilder.createBox(0.1f, 4f*1.5f*2f, gameArea,
			new Material(ColorAttribute.createDiffuse(Color.BLUE)),
			Usage.Position | Usage.Normal);
	
	planes[1].materials.get(0).set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
	
	cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	cam.position.set(20f, 28f, 26f);
	cam.lookAt(0,0,0);
	cam.near = 1f;
	cam.far = 300f;
	cam.update();
	
	environment = new Environment();
	environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
	environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
	
	//TODO read highscore
	
	//gameplay = new GameplayManager(this);
}
 
开发者ID:programistagd,项目名称:Snake3d,代码行数:57,代码来源:Snake.java


注:本文中的com.badlogic.gdx.graphics.g3d.utils.ModelBuilder.createSphere方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。