|
|
Pages: [1]
|
 |
|
Author
|
Sprite3D (Read 234 times)
|
prasad.madu
New user

Posts: 10
|
 |
Sprite3D
« on: July 27, 2010, 04:55:46 pm » |
|
Dear all,
I have an image of a person. when I create it, I simply cut the person and insert it in to a transparent background. Now person is in the image and its surrounding is transparent. I converted it to 3D Sprite object. But when I render it to my 3D world, its transparent background is also rendered with shading color around (kind of deformation).
here is the code sample:
Image2D texImage = null; Appearance myAppearance = new Appearance(); texImage = (Image2D) Loader.load("/GameWorld/Umpire/umpair back .png")[0]; sprite = new Sprite3D(true, texImage, myAppearance); sprite.setCrop(0, 0, 64, 128); sprite.setTranslation(-0.6f, 0.65f, 0.0f); sprite.setScale(0.6f, 1.2f, 0f); sprite.setOrientation(90, 0f, 0.1f, 0f); sprite.postRotate(-270, 0.1f, 0f, 0f); groundWorld.addChild(sprite);
I render the world in my game loop. But when I draw it as a sprite on top of a another image, transparency is there. What should I do? Pls help.
|
|
|
|
|
Logged
|
|
|
|
|
|
prasad.madu
New user

Posts: 10
|
Here is the screen shot. Surrounding of the umpire should be transparent to see the environment clearly. But see the deformation. Can i fix this through the code or what should i do?
|
err.jpg (21.4 KB - downloaded 27 times.)
|
|
|
Logged
|
|
|
|
|
|
prasad.madu
New user

Posts: 10
|
Yep, But I changed code to this way
Appearance app = new Appearance(); Image2D img = (Image2D) Loader.load("/GameWorld/Umpire/four.png")[0]; // Texture2D tex = new Texture2D(img); // tex.setBlending(Texture2D.FUNC_MODULATE); //replace for faster drawing CompositingMode compMode = new CompositingMode(); compMode.setBlending(CompositingMode.ALPHA); // set the texture to use the alpha component compMode.setAlphaThreshold(0.1f); app.setLayer(63); //draw the 2D billboards last so the transparency is not fucked up app.setCompositingMode(compMode); // app.setTexture(0, tex); sprite = new Sprite3D(true, img, app); sprite.setCrop(cropX, 0, img.getWidth(), img.getHeight()); sprite.setTranslation(-0.4f, 0.65f, 0.0f); sprite.setScale(1.4f, 2.0f, 0f); groundWorld.addChild(sprite);
After commenting tex, it works fine with transparency. To get transparecy only needs compMode.setBlending(CompositingMode.ALPHA); When i used tex.setBlending(Texture2D.FUNC_MODULATE); or another func, game world is not loading. But wht is dat setLayer(63) thing means. Anyhow my problem was solved. Now as no polygons there will not huge affect on performance. Thank You very much again . You are the best
|
|
|
|
|
Logged
|
|
|
|
|
|
prasad.madu
New user

Posts: 10
|
3D sprites can't be rotated inverse like by inverting values of setScale method (to convert same image from right hand to left hand batsman) as I did in mesh objects and ball tends to less visible when it goes far from camera. how can i avoid that getting small thing when going far from camera and achieve first issue?
|
|
|
|
|
Logged
|
|
|
|
|
|
prasad.madu
New user

Posts: 10
|
yep, You are correct. but when ball is thrown by the bowler it gets smaller and when it is moving towards to a fielder in phone ball is not shown. But in emulator it works fine. This happens when scaling is on. When it is off ball becomes large when it is moving out from the camera and in the view of fielding scene. I can't think the reason. Do you have any suggestions?
|
|
|
|
|
Logged
|
|
|
|
|
|
prasad.madu
New user

Posts: 10
|
If so I have to use ball mesh for that coz it is ok in both emulator and phone. Thanks for your help so far. really admire it.
|
|
|
|
|
Logged
|
|
|
|
|
Pages: [1]
|
|
|
|
|