------

[ AD ] Port Monitor ( Try to use a Best WebSite Monitoring Tool )

------

메인 소스
public class CanvasLissajous extends Activity {


	CanvasView mCanvasView;
	private TextView mTextView;
	
	Random mRandom;
	
	//int A=13;
	//int B=19;
	
	
	
	//private int A=10000;
	//private int B=20000;
    Timer mTimer = new Timer();
    TimerTask mTimerTask = new TimerTask() {

		@Override
		public void run() {
			// TODO Auto-generated method stub
			mCanvasView.A = mRandom.nextInt(Def.RANGE);
			if (mCanvasView.A == 0) mCanvasView.A =1;
			
			mCanvasView.B = mRandom.nextInt(Def.RANGE);
			if ( mCanvasView.B == 0) mCanvasView.B =1 ;
			/*
			mCanvasView.A++;
			if ( mCanvasView.A > 500) mCanvasView.A=1 ;
			mCanvasView.B++;
			if ( mCanvasView.B > 500) mCanvasView.B=1;
			*/
		}
    };

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        //CanvasView 
        //mCanvasView = new CanvasView(this);
        //setContentView(mCanvasView ); //R.layout.main);
        setContentView(R.layout.main);
        
        mCanvasView = (CanvasView)findViewById(R.id.canvasview);
        mTextView = (TextView)findViewById(R.id.textview);
        mCanvasView.setTextView(mTextView);
		mTimer.schedule(mTimerTask, Def.INTERVAL, Def.INTERVAL);
		mRandom = new Random();

    }


}

CanvasView 소스
public class CanvasView extends View {
	
	Context mContext;
	private TextView mTextView;
	
	public CanvasView(Context context, AttributeSet attrs) {
		super(context, attrs);
		mContext = context;
		
		
		
		// TODO Auto-generated constructor stub
		mHandler.sendEmptyMessageDelayed(0, Def.INTERVAL);
	}
	int w,h;
	int A=1,B=1;
	Canvas mCanvas;
	
	private int CenterX,CenterY;

	/*
	public CanvasView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		
	}
	*/
	Handler mHandler = new Handler() {

		@Override
		public void handleMessage( Message msg ) {
			// TODO Auto-generated method stub
			//super.handleMessage(msg);
			drawCurve(mCanvas);
			invalidate();
			mHandler.sendEmptyMessageDelayed(0, Def.INTERVAL);
		}
		
	};
	void drawCurve(Canvas canvas) {
		w = getWidth();
		h = getHeight();
		
		CenterX = w/2;
		CenterY = h/2;
		
		int x1 = CenterX*2;
		int y1 = CenterY;
		
		Paint paint = new Paint();
		canvas.drawColor(Color.WHITE);
		
		paint.setColor(Color.BLUE);
		paint.setTextSize(24);
		
		//canvas.drawText("A:"+ A + " B: "+B, 10, 30, paint);
		getTextView().setText("A:"+ A + " B: "+B);
		
		for(float r=0; r<= Math.PI*3; r += 0.01) {
			int x2 = (int)(CenterX + Math.cos(r*A) * CenterX );
			int y2 = (int)(CenterY - Math.sin(r*B) * CenterY );
			canvas.drawLine(x1, y1, x2, y2, paint);
			//try { Thread.sleep(100); } catch (InterruptedException e) {;}
			x1 = x2 ;
			y1 = y2 ;
		}
	}
	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		
		mCanvas = canvas;
		
		drawCurve(canvas);
		
		//super.onDraw(canvas);
	}
	public void setTextView(TextView mTextView) {
		this.mTextView = mTextView;
	}
	public TextView getTextView() {
		return mTextView;
	}

}



'0.일반개발' 카테고리의 다른 글

HTML 제거하기  (0) 2010.09.28
ECMA 262 Brief History  (0) 2010.09.28
JNI ffmpeg  (0) 2010.09.28
삼각함수 trigonometric function 기초  (0) 2010.09.28
아날로그 시계  (0) 2010.09.27

2010/07/09

android / ffmpeg dynamic module, JNI simple wrapper

On production device, we can't use "executable file ".

we need to build "dynamic, SO module" for ffmpeg/ ffserver.

This post explain how to build SO module and simple JNI interface  for ffmpeg.

1) change ffmpeg.c

a) add JNI part.


////////////////////////////////////////////////////////////////////////////////////////////////////////////


// KKS ...

#include

int m_argc = 0;

int M_MAX_ARGC = 30;

char *m_pargv [30];

int dynamic_ffpmeg_main (int argc, char **argv);

jint JNICALL Java_com_ccmedia_codec_ffmpeg_mod_1run ( JNIEnv *, jclass, jstring, jstring );



jint JNICALL Java_com_ccmedia_codec_ffmpeg_mod_1run ( JNIEnv *env, jclass class, jstring pj1, jstring pj2) {

jint ji;

jboolean ic;



char sz_temp [1024];

char seps [] = " ";

char *psztoken, *pszdata;

int i = 0;



const char *pszname;

pszname = (*env)->GetStringUTFChars(env, pj1, &ic);



sprintf ( sz_temp, "ffmpeg %s ", pszname );



if ( ic == JNI_TRUE ) (*env)->ReleaseStringUTFChars(env, pj1, pszname);

// strcpy ( sz_temp, "ffmpeg -i /sdcard/arm_and/bin/tv_dump.mpg http://localhost:8090/feed1.ffm " );



printf ( "[DEBUG] %s\n", sz_temp );



psztoken = strtok ( sz_temp, seps );

while ( psztoken != NULL ) {



m_pargv [ m_argc] = ( char *)malloc ( strlen ( psztoken));

strcpy ( m_pargv [ m_argc], psztoken );

m_argc++;

psztoken = strtok ( NULL, seps);

}



for ( i = 0; i < m_argc; i++ ) {

printf ( "argc[%d] = %s\n", i, m_pargv[i]);

}



dynamic_ffpmeg_main ( m_argc, m_pargv );



ji = 0;



return ji;



}

b) change main function
original  --> int   main (int argc, char **argv )

new  --> int dynamic_ffpmeg_main (int argc, char **argv )

c) add  " new main function "

int main(int argc, char **argv)


{


dynamic_ffpmeg_main ( argc, argv );


return 0;

}

2)  build ffmpeg .


- on preivious post, you can find "configure" option to build ffmpeg.


http://demo860.blogspot.com/2010/06/ffmpeg-libx264-build-for-android.html

3) build ffmpeg SO module using following command.

i use NDK r4 , /export/home/android/ndk/


/export/home/android/ndk/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-gcc \


-nostdlib -Wl,-soname,libffmpeg.so -Wl,-shared,-Bsymbolic \

cmdutils.o ffmpeg.o \

-Wl,--no-whole-archive -Wl,--whole-archive \

/export/home/android/android-ndk-r4/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/libgcc.a \

/export/home/android/ndk/build/platforms/android-8/arch-arm/usr/lib/libc.so \

/export/home/android/ndk/build/platforms/android-8/arch-arm/usr/lib/libstdc++.so \

/export/home/android/ndk/build/platforms/android-8/arch-arm/usr/lib/libm.so \

/export/home/android/ndk/build/platforms/android-8/arch-arm/usr/lib/libz.so \

/export/home/android/ndk/build/platforms/android-8/arch-arm/usr/lib/libdl.so \

-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-rpath-link=/export/home/android/ndk/build/platforms/android-8/arch-arm/usr/lib \

./libavutil/libavutil.a \

./libavcodec/libavcodec.a \

./libavfilter/libavfilter.a \

./libavformat/libavformat.a \

./libswscale/libswscale.a \

./libavdevice/libavdevice.a \

-o libffmpeg.so


4) now you can use using following ffmpeg wrapper.

public class ffmpeg implements Runnable {




static boolean m_bret = false;


static String m_szconfig = " -i /sdcard/file.mpg -vcodec mpeg4 aaa.mpg";


public native String unimplementedStringFromJNI();

static {



try {



System.out.println ( "[AdDBCache] Module load try ffmpeg : " + System.getProperty("java.library.path"));

// System.load("/sdcard/arm_and/bin/libffmpeg.so");

System.loadLibrary("ffmpeg");

System.out.println ( "[AdDBCache] Module load success");

}

catch ( Exception e ) {

System.out.println ( "[AdDBCache] Module load err : " + System.getProperty("java.library.path"));

}

}



private static synchronized final native int mod_run (String name, String sztoken );



public void set_config ( String sz_config ) {

m_szconfig = sz_config;

}



public void run_core ( String sz_file, String sz_token ) {

int n_stat;

m_bret = false;

n_stat = mod_run ( m_szconfig, sz_token );

m_bret = true;

}



public void run () {

run_core ( "", "");

}

}

5) ffmpeg / ffserver,
 
  - i made both  , dynamic module and run it.
  - the speed is ok but it's use CPU so much.

'0.일반개발' 카테고리의 다른 글

ECMA 262 Brief History  (0) 2010.09.28
Lissajous 리사쥬  (0) 2010.09.28
삼각함수 trigonometric function 기초  (0) 2010.09.28
아날로그 시계  (0) 2010.09.27
버튼 이미지 / 둥근 버튼  (0) 2010.09.27


중심점 : cx,cy 일때

기준선 : 수평선 일때

[점 x,y]수평선 기준으로 반시계방향으로 θ 만큼 회전한 원주 위의 점 x,y



x = cx + cos(θ) * r
y = cy + sin(θ) * r  <----> y= cy - sin(θ) * r  ( 컴퓨터와 수학의 y축은 반대 )

[8방향 계산] θ를 45도 단위로 증가 시키면 8방향 좌표가 계산 됨

[각도->라디안]삼각함수에서 사용하는 각도는 모두 라디안이므로 각도를 라디안으로 변경
               rad = deg * π / 180
               
    (int) ( cx + Math.cos( i*45* Math.PI/180 ) * r ) 
    (int) ( cy - Math.sin( i*45* Math.PI/180 ) * r ) 
               




[ 라디안 ???? ]
원점 O(0,0)이 중심이고, 반지름이 1인 원을 생각하자.

이 원 위의 점 P(1, 0)에서 출발하여 원 위를 따라 반시계 방향으로 호 PQ의 길이가 t가 되도록 걸어가자.
이 때, 각 QOP를 t 라디안(radian)이라 부르고, t (rad)라고 쓴다.
P에서 호의 길이가 π이도록 걸어가면, 중심각이 180°임은 명백하므로




'0.일반개발' 카테고리의 다른 글

Lissajous 리사쥬  (0) 2010.09.28
JNI ffmpeg  (0) 2010.09.28
아날로그 시계  (0) 2010.09.27
버튼 이미지 / 둥근 버튼  (0) 2010.09.27
Matching game in javasacript  (0) 2010.09.27
        setContentView(new ClockView(this) ) ;//R.layout.main);
        
    }
    
    protected class ClockView extends View {
    	Canvas mCanvas;
    	private Bitmap mClock;
    	private Bitmap mPin[] = new Bitmap[3];
		public ClockView(Context context) {
			super(context);
			// TODO Auto-generated constructor stub
			mHandler.sendEmptyMessageDelayed(0, 1000);
		}
		Handler mHandler = new Handler() {

			@Override
			public void handleMessage(Message msg) {
				// TODO Auto-generated method stub
				//super.handleMessage(msg);
				drawClock(mCanvas);
				invalidate();
				mHandler.sendEmptyMessageDelayed(0, 1000);
			}
			
		};
		@Override
		protected void onDraw(Canvas canvas) {
			// TODO Auto-generated method stub
			//super.onDraw(canvas);
			mCanvas = canvas;
			
			mClock = 
				BitmapFactory.decodeResource(this.getResources(), R.drawable.dial);
			
			mPin[0] = 
				BitmapFactory.decodeResource(this.getResources(), R.drawable.pin_1);
			mPin[1] = 
				BitmapFactory.decodeResource(this.getResources(), R.drawable.pin_2);
			mPin[2] = 
				BitmapFactory.decodeResource(this.getResources(), R.drawable.pin_3);
			
			drawClock(canvas);
		}
		private void drawClock(Canvas canvas) {
			// TODO Auto-generated method stub
			
			GregorianCalendar mCalendar = 
				new GregorianCalendar();
			int hour = mCalendar.get(Calendar.HOUR);
			int min = mCalendar.get(Calendar.MINUTE);
			int sec = mCalendar.get(Calendar.SECOND);
			
			float rSec = sec *6 ; // 360도 / 60초 = 6도/초
			float rMin = min*6 + rSec/60; //
			float rHour = hour * 30 + rMin /12 ;
			
			int w = mClock.getWidth()/2; // 반폭
			int h = mClock.getHeight()/2;
			
			int w1=mPin[0].getWidth()/2;
			int h1=mPin[0].getHeight()-15;
			
			int cx = getWidth()/2;
			int cy = getHeight()/2;
			
			//canvas.drawBitmap(mClock, left, top, paint);
			canvas.drawBitmap(mClock, cx-w, cy-h, null);
			
			canvas.rotate(rHour,cx,cy);
			canvas.drawBitmap(mPin[2],cx-w1,cy-h1,null); //시침 맨아래
			
			canvas.rotate(rMin-rHour,cx,cy);
			canvas.drawBitmap(mPin[1],cx-w1,cy-h1,null);

			canvas.rotate(rSec-rMin,cx,cy);
			canvas.drawBitmap(mPin[0],cx-w1,cy-h1,null); //초침 맨위에
			
			
			canvas.rotate(-rSec,cx,cy);
			/*
			Paint paint = new Paint();
			paint.setColor(Color.WHITE);
			paint.setTextSize(30);
			canvas.rotate(-rSec,cx,cy);
			canvas.drawText(String.format("%2d:%2d:%d",hour,min,sec),
					cx-70, cy+w+50, paint);
					*/ 

		}

..

버튼 이미지 / 둥근 버튼


1. 이미지 준비 및 복사

- 기본 이미지 / 포커스 된 이미지 / 클릭된 이미지

- res/drawable-hdpi 등으로 복사
 button_normal
 button_focused
button_pressed

2. main.xml에 둥근 버튼으로 쓸 ImageView   추가 ( Button/ImageButton은 사각형이라 안되요~~~)

- Clickable = true

- Focusable = true


3. 속성 XML 만들기

- res/drawable 밑에 button_attr.xml











4.ImageView와 속성XML 연결
- Properties :
src
- 소스상
ImageView iv = (ImageView)this.findViewById(R.id.ImageView01);
iv.setImageResource(R.drawable.button_click);


크롬의 개발자 도구를 활용해서 0에서부터 라이브 코딩으로 파티클 시스템을 만드는 것을 시연함.

HTML 5 CANVAS
< LIVE_CODING_PRACTICE />

A SIMPLE PARTICLE SYSTEM - seung joon choi

Developer Tools http://www.chromium.org/devtools


canvas = document.createElement('canvas')
ctx = canva.getContext('2d')

document.body.appendChild(canvas)
canvas.width = 400
canvas.height=400

ctx.fillRect(0,0,400,400)
Ptcl = new function() {}

Object() {
x=0
y=0
vx=0
vy=0
r=0
dt=0.1
}



[김기준] 지하철에서 키우는 애완동물 ‘QT 펫’
QT펫은 애완동물키우기 게임이다.
예전에 잠깐 유행했던 다마고치와 비슷하다.
여러 동물 중에 하나를 선택해 이름을 지어주고 나만의 애완동물로 성장시키는 것이다.

이용자가 지하철역 1km안에 있어야만 동물을 훈련시킬 수 있다.

역마다 능력치가 다른 것이 특징이다.
서울대입구역에 가면 지능이 향상되고 강남역에 가면 주량이 높아진다.
 수색역에서 훈련하면 전투력이 향상되는 방식이다.
나처럼 잠실과 강남만 왔다갔다하면 애완동물이 주량만 늘기 때문에
다른 곳에 친구를 만들어야 한다.

지하철역 특성에 맞게 애완동물을 키울 수 있는 육성 게임으로 친구를 사귈 수 있는
SNS서비스를 결합한 것이 특징이다.

부산 해운대에 살고 있는 친구가 전철역에서 잠시 열어두면 친구를 맺어 거기서 훈련하면 된다.
이런 방법으로 친구를 만들어 인맥도 넓히는 게임이다.
곧 앱스토어에 올라갈 예정이다.

상 받은 앱이라 마크라도 하나 달아줄까 살짝 기대했는데 그런건 없어 조금 아쉽다. 

'People in' 카테고리의 다른 글

SNG 단상 2010 09  (0) 2010.09.30
『2010 서울 SNG게임 제작지원 사업』 공모  (1) 2010.09.29
맘마 미아 / Mamma Mia  (0) 2010.09.27
바닥 희망 성과  (0) 2010.09.27
물가정보 서울특별시  (0) 2010.09.27

mammabia_01_honey_honey.jpg
mammamia_02_money_money_money.jpg
mammamia_03_mamma_mia.jpg
mammamia_04_dancing_queen.jpg
mammamia_05_our_last_summer.jpg
mammamia_06_lay_all_your_love_on_me.jpg
mammamia_07_super_trouper.jpg
mammamia_08_gimme_gimme_gimme.jpg
mammamia_09_the_name_of_the_game.jpg

mammamia_10_voulez_vous.jpg
mammamia_11_sos.jpg
mammamia_12_does_your_mother_know.jpg
mammamia_13_slipping_through_my_fingers.jpg
mammamia_14_the_winner_takes_it_all.jpg
mammamia_15_when_all_is_said_and_done.jpg
mammamia_16_take_a_chance_on_me.jpg
mammamia_17_have_a_dream.jpg
mammamia_18_thank_you_for_the_music.jpg

'People in' 카테고리의 다른 글

『2010 서울 SNG게임 제작지원 사업』 공모  (1) 2010.09.29
QT펫은 애완동물키우기 게임이다  (0) 2010.09.27
바닥 희망 성과  (0) 2010.09.27
물가정보 서울특별시  (0) 2010.09.27
유가 정보 서비스  (0) 2010.09.27

Introduction to some of the network features of Rocket Engine. Built by and for professional game developers, Rocket Engine is the only fully integrated solution for plugin-free browser game development. Read more at http://rocketpack.fi/engine/ ! Follow us on Twitter: http://twitter.com/rocketpackgames


 

Supports IE8, iDevices, Android...

Works in every major browser

Flash doesn't run on the iPhone or the iPad.
The browser with the largest market share doesn't support the HTML5 Canvas element.
Don't panic.
The Rocket Pack Engine runs smoothly in every major browser, no plugins required.

  • Works in every major browser
  • No plugin or installation required
  • No Canvas tag support required
  • Built-in Web Application support
  • Can be packaged as a native application

Everything You Need to Get Started

Wide selection of bundled components

Have a great game idea?
With the bundled components,
you'll have the first prototype running the same afternoon.

  • Animated sprites
  • Orthographic and isometric tile rendering
  • Audio playback
  • Collision detection
  • Pathfinding
  • AI state machines
  • ...and many many more

Professional Editing Tools

Real-time multi-user editing

With Rocket Builder, you can easily edit your game on-the-fly,
wherever you are, no coding required.
Need to tweak some viral activities while fishing in the Mediterranean?
Now you can.

  • Level editor with live preview
  • Integrated source and asset editing
  • Real-time multi-user support
  • No installation required
  • Edit anywhere (works on your desktop browser, phone, etc.)

 



Rocket Network
Scalable MMO services

Developing an MMO or a multiplayer game?
Rocket Network takes care of your server-side troubles.

  • Identity handling
  • Socially connected (Facebook, Twitter...)
  • Common services required by MMOs
  • MMO-grade scaling
  • Virtual currencies
  • Tracking and reporting for custom metrics
  • In-depth analytics for all RPN services

Modern Extendable Architecture

  • Component-based
  • Focus on rapid development and deployment
  • Design based on years of experience working
    with professional game development tools


Future-proof

When the glorious day arrives when HTML5 is widely supported,
you can literally just plug in a Canvas-based renderer and enjoy the results.

  • Canvas support
  • WebGL support


 

Transparent Client-Server Model

  • Supports multiple fallback transports
  • Run the same code on both client and server
  • Transparent RPCs and reflection


Easy Deployment

  • Per-user sandboxes
  • Deployment to cloud services
  • Support for multiple concurrent versions
  • Easy A/B testing




 

Feature Comparison

  Rocket Engine HTML5 Flash Unity3D
No plugin required X X    
No canvas support required X   X X
Designer & Artist Tools X   X X
Transparent Client-server Integration X     *
Deployment as Web App X X    
Hardware accelerated 3D ** **   X
Built-in Cloud Deployment X      
Built-in Analytics X      
Source Available X X    
Server-side Services for Social Apps X      

* Partial (non-MMO) support  
** Coming with WebGL support




Note: Higher quality version on Vimeo: http://vimeo.com/6691519

Are you interested in HTML 5 and what's coming down the pipeline but haven't had time to read any articles yet?

Brad Neuberg has put together an educational Introduction to HTML 5 video that goes over many of the major aspects of this new standard, including:

* Web vector graphics with the Canvas tag and Scalable Vector Graphics (SVG)
* The Geolocation API
* HTML 5 Video
* The HTML 5 Database and Application Cache
* Web workers

In the video we also crack open the HTML 5 YouTube Video prototype to show you some of the new HTML 5 tags,
such as nav, article, etc.
 
It's chock full of demos and sample source code.

+ Recent posts