Comments (9)
The 1.18.8 release solves some Material issues and brings a Video Texture sample
Release 1.18.8 - Video Texture + SceneView Background
from sceneform-android.
@suryanadiminti99
give me your mail id will sent
from sceneform-android.
@aseemiboson Thankyou very much.
from sceneform-android.
@aseemiboson did you got any solution ?
from sceneform-android.
@suryanadiminti99
private fun loadVideo() {
runOnUiThread {
val uri = Uri.parse(arData!!.arContent[0].arProperty[2].propertyValue)
val player = MediaPlayer.create(this@MainActivity,uri)
val externalTexture = ExternalTexture()
player.setSurface(externalTexture.surface)
player.setAudioStreamType(AudioManager.STREAM_MUSIC)
player.setScreenOnWhilePlaying(true)
player.isLooping = true
//player.start();
Material.builder().setSource(this@MainActivity,R.raw.augmented_video_material).build().thenAccept { material: Material? ->
Log.d(TAG,"loadVideo: $uri")
val playerNode = Node()
Log.d(TAG,"loadVideo: Aspect Ratio = ${player.videoWidth}x${player.videoHeight}")
val gcd = gcd(player.videoWidth.toLong(),player.videoHeight.toLong())
val widthAspect = (player.videoWidth/gcd).toFloat()
val heightAspect = (player.videoHeight/gcd).toFloat()
val videoScreen = ShapeFactory.makeCube(Vector3(widthAspect,heightAspect,0.0001f),Vector3.zero(),material)
videoScreen.isShadowCaster = true
videoScreen.material.setExternalTexture("videoTexture",externalTexture)
// cube.material.setFloat3("keyColor",CHROMA_KEY_COLOR);
playerNode.renderable = videoScreen
// (playerNode.renderable as ModelRenderable).material.setFloat4("keyColor",CHROMA_KEY_COLOR);
val boundingBox = videoScreen.collisionShape as Box?
if (boundingBox != null) {
val boundingBoxSize = boundingBox.size
val maxExtent = Math.max(boundingBoxSize.x,Math.max(boundingBoxSize.y,boundingBoxSize.z))
val targetSize = 0.2f // Whatever size you want.
val scale = targetSize / maxExtent
val scaleVector3 = Vector3.one().scaled(scale)
playerNode.localScale = scaleVector3
Log.d(TAG,"loadVideo: Scale ${Vector3.one().scaled(scale).toString()}")
}
cube!!.addChild(playerNode)
player.start()
}
}
}
this is currently i am using but this is support in Scenceform 1.16.0 Official SDK, in this repo its crashing, to do chroma keying use croma keying material and put keyColor
from sceneform-android.
@aseemiboson will you please share your material file ? or can we use chromakey material ?
from sceneform-android.
@aseemiboson [email protected]
from sceneform-android.
@aseemiboson It's working in previous scene form module.
from sceneform-android.
@ThomasGorisse Hi , You really did a great job .
This is the code for android users to show video using cube.
`runOnUiThread(new Runnable() {
@OverRide
public void run() {
// Create Media Player
mediaPlayer = MediaPlayer.create(ArActivity.this,Uri.fromFile(new File(videoUrl)));
ExternalTexture externalTexture = new ExternalTexture();
mediaPlayer.setSurface(externalTexture.getSurface());
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setScreenOnWhilePlaying(true);
mediaPlayer.setLooping(true);
Material.builder().setSource(ArActivity.this,R.raw.chroma_key_material).build().thenAccept(material -> {
ModelRenderable renderable = ShapeFactory.makeCube(new Vector3(Float.parseFloat(scalex),0.0001f,Float.parseFloat(scaley)),Vector3.zero(),material);
renderable.getMaterial().setExternalTexture("videoTexture", externalTexture);
renderable.getMaterial().setFloat4("keyColor", CHROMA_KEY_COLOR);
AnchorNode anchorNode = new AnchorNode(anchor);
// Create a node to render the video and add it to the anchor.
Node videoNode = new Node();
anchorNode.setParent(arFragment.getArSceneView().getScene());
videoNode.setParent(anchorNode);
// Vector3 vectorScale = new Vector3(Float.parseFloat(scalex), 0.0001f, Float.parseFloat(scaley));
Vector3 vectorPos = new Vector3(Float.parseFloat(posx), Float.parseFloat(posy),(Float.parseFloat(posz)));
Vector3 vectorScale = new Vector3(Float.parseFloat(scalex), Float.parseFloat(scaley),(Float.parseFloat(scalez)));
Quaternion rx = Quaternion.eulerAngles(new Vector3(Float.parseFloat(rotatex), 0.0f, 0.0f));
Quaternion ry = Quaternion.eulerAngles(new Vector3(0.0f, Float.parseFloat(rotatey), Float.parseFloat(rotatez)));
// Set Scaling
// videoNode.setLocalScale(vectorScale);
// Set Position
videoNode.setLocalPosition(vectorPos);
// Set Rotation
videoNode.setLocalRotation(Quaternion.multiply(rx,ry));
// Set Scaling values
videoNode.setLocalScale(vectorScale);
// Start playing the video when the first node is placed.
if (!mediaPlayer.isPlaying()) {
mediaPlayer.start();
externalTexture.getSurfaceTexture().setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
@Override
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
videoNode.setRenderable(renderable);
externalTexture.getSurfaceTexture().setOnFrameAvailableListener(null);
}
});
} else {
videoNode.setRenderable(renderable);
}
});
}
});`
@ThomasGorisse Please look on this issue. Why it is not working in current repository .
from sceneform-android.
Related Issues (20)
- Issue with Face Model HOT 5
- Issue With Skybox HOT 1
- Issue with centered node HOT 2
- Shadow position is not correct, shadow appears at the middle of the object. HOT 2
- VideoNode Size Problem HOT 3
- Unauthorized Access Error for Sceneform Dependency Version 1.22.0 HOT 2
- What is Engine and how to use it? HOT 1
- How To Change Texture Images HOT 2
- Color of model on scene doesn't match color of texture (warm white instead of white) HOT 2
- Failed to create arsession HOT 4
- How to combine multiple node into one HOT 2
- java.lang.IllegalStateException: Calling method on destroyed View when i have scene inside horizontalpager
- Camera doesn't open and crashes when Proguard is enabled (R8) in Sceneform. HOT 1
- measure with camera HOT 2
- Scan Qr code using sceneform HOT 2
- Crash on App Start: NoSuchMethodError for acquireEnvironmentalHdrCubeMap HOT 1
- sceneform AugmentedFaceNode performance
- Scan Human Skin
- how to get a image in portrait mode
- Support for Compose Multiplatform
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sceneform-android.