001/** 002 * Copyright (c) 2008-2014 Ardor Labs, Inc. 003 * 004 * This file is part of Ardor3D. 005 * 006 * Ardor3D is free software: you can redistribute it and/or modify it 007 * under the terms of its license which may be found in the accompanying 008 * LICENSE file or at <http://www.ardor3d.com/LICENSE>. 009 */ 010 011package com.ardor3d.example.benchmark.ball; 012 013import com.ardor3d.renderer.queue.RenderBucketType; 014import com.ardor3d.scenegraph.hint.CullHint; 015import com.ardor3d.scenegraph.shape.Quad; 016 017class BallSprite extends Quad { 018 019 private final Ball _ball; 020 private final int _areaWidth; 021 private final int _areaHeight; 022 023 public BallSprite(final String name, final double width, final double height, final int areaWidth, 024 final int areaHeight) { 025 super(name, width, height); 026 _areaWidth = areaWidth; 027 _areaHeight = areaHeight; 028 _ball = new Ball(); 029 _ball.setRandomPositionIn(_areaWidth, _areaHeight); 030 setTranslation(_ball._x + Ball.radius, _ball._y + Ball.radius, 0); 031 getSceneHints().setRenderBucketType(RenderBucketType.Ortho); 032 setModelBound(null); 033 getSceneHints().setCullHint(CullHint.Never); 034 } 035 036 @Override 037 public void updateGeometricState(final double time, final boolean initiator) { 038 super.updateGeometricState(time, initiator); 039 _ball.move(_areaWidth, _areaHeight); 040 setTranslation(_ball._x + Ball.radius, _ball._y + Ball.radius, 0); 041 } 042 043 public Ball getBall() { 044 return _ball; 045 } 046}