Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
nftpro
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
胡尚
nftpro
Commits
487c54f8
提交
487c54f8
authored
5月 16, 2023
作者:
cbd
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1、网络加载dae文件
上级
f9e6587c
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
204 行增加
和
33 行删除
+204
-33
SceneLoader.java
...he3deer/android_3d_model_engine/services/SceneLoader.java
+1
-1
ModelRenderer.java
.../the3deer/android_3d_model_engine/view/ModelRenderer.java
+2
-1
ModelSurfaceView.java
...e3deer/android_3d_model_engine/view/ModelSurfaceView.java
+1
-1
build.gradle
provide_tool/build.gradle
+4
-0
AndroidManifest.xml
widget/src/main/AndroidManifest.xml
+2
-1
App.kt
widget/src/main/java/com/orange/widget/app/App.kt
+20
-1
ModelActivity.java
widget/src/main/java/com/orange/widget/ui/ModelActivity.java
+146
-28
NoEtagFileDownloadUrlConnection.java
...m/orange/widget/util/NoEtagFileDownloadUrlConnection.java
+28
-0
没有找到文件。
engine/src/main/java/org/the3deer/android_3d_model_engine/services/SceneLoader.java
浏览文件 @
487c54f8
...
@@ -409,7 +409,7 @@ public class SceneLoader implements LoadListener, EventListener {
...
@@ -409,7 +409,7 @@ public class SceneLoader implements LoadListener, EventListener {
public
final
void
toggleLighting
()
{
public
final
void
toggleLighting
()
{
if
(
this
.
drawLighting
&&
this
.
rotatingLight
)
{
if
(
this
.
drawLighting
&&
this
.
rotatingLight
)
{
this
.
rotatingLight
=
false
;
this
.
rotatingLight
=
false
;
makeToastText
(
"Light stopped"
,
Toast
.
LENGTH_SHORT
);
//+
makeToastText("Light stopped", Toast.LENGTH_SHORT);
}
else
if
(
this
.
drawLighting
&&
!
this
.
rotatingLight
)
{
}
else
if
(
this
.
drawLighting
&&
!
this
.
rotatingLight
)
{
this
.
drawLighting
=
false
;
this
.
drawLighting
=
false
;
makeToastText
(
"Lights off"
,
Toast
.
LENGTH_SHORT
);
makeToastText
(
"Lights off"
,
Toast
.
LENGTH_SHORT
);
...
...
engine/src/main/java/org/the3deer/android_3d_model_engine/view/ModelRenderer.java
浏览文件 @
487c54f8
...
@@ -198,10 +198,11 @@ public class ModelRenderer implements GLSurfaceView.Renderer {
...
@@ -198,10 +198,11 @@ public class ModelRenderer implements GLSurfaceView.Renderer {
}
}
public
ModelRenderer
(
Activity
parent
,
ModelSurfaceView
modelSurfaceView
){
public
ModelRenderer
(
Activity
parent
,
ModelSurfaceView
modelSurfaceView
,
float
[]
backgroundColor
){
this
.
main
=
modelSurfaceView
;
this
.
main
=
modelSurfaceView
;
try
{
try
{
this
.
drawer
=
new
RendererFactory
(
parent
);
this
.
drawer
=
new
RendererFactory
(
parent
);
this
.
backgroundColor
=
backgroundColor
;
}
catch
(
IllegalAccessException
e
)
{
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
...
engine/src/main/java/org/the3deer/android_3d_model_engine/view/ModelSurfaceView.java
浏览文件 @
487c54f8
...
@@ -58,7 +58,7 @@ public class ModelSurfaceView extends GLSurfaceView implements EventListener {
...
@@ -58,7 +58,7 @@ public class ModelSurfaceView extends GLSurfaceView implements EventListener {
super
(
context
,
attrs
);
super
(
context
,
attrs
);
Log
.
i
(
"ModelSurfaceView"
,
"Loading [OpenGL 2] ModelSurfaceView..........."
);
Log
.
i
(
"ModelSurfaceView"
,
"Loading [OpenGL 2] ModelSurfaceView..........."
);
setEGLContextClientVersion
(
2
);
setEGLContextClientVersion
(
2
);
mRenderer
=
new
ModelRenderer
((
Activity
)
context
,
this
);
mRenderer
=
new
ModelRenderer
((
Activity
)
context
,
this
,
backgroundColor
);
mRenderer
.
addListener
(
this
);
mRenderer
.
addListener
(
this
);
setRenderer
(
mRenderer
);
setRenderer
(
mRenderer
);
}
}
...
...
provide_tool/build.gradle
浏览文件 @
487c54f8
...
@@ -77,4 +77,7 @@ dependencies {
...
@@ -77,4 +77,7 @@ dependencies {
api
'com.github.SherlockGougou:BigImageViewPager:androidx-7.1.4'
api
'com.github.SherlockGougou:BigImageViewPager:androidx-7.1.4'
api
'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.10'
api
'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.10'
//文件downloader
api
'com.liulishuo.filedownloader:library:1.7.5'
}
}
\ No newline at end of file
widget/src/main/AndroidManifest.xml
浏览文件 @
487c54f8
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
package=
"com.orange.widget"
>
package=
"com.orange.widget"
>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<application
<application
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
android:supportsRtl=
"true"
android:supportsRtl=
"true"
android:theme=
"@style/Theme.Look"
android:theme=
"@style/Theme.Look"
android:usesCleartextTraffic=
"true"
android:usesCleartextTraffic=
"true"
android:requestLegacyExternalStorage=
"true"
android:name=
"com.orange.widget.app.App"
>
android:name=
"com.orange.widget.app.App"
>
<!-- <activity-->
<!-- <activity-->
<!-- android:name="com.orange.widget.MainActivity"-->
<!-- android:name="com.orange.widget.MainActivity"-->
...
...
widget/src/main/java/com/orange/widget/app/App.kt
浏览文件 @
487c54f8
package
com.orange.widget.app
package
com.orange.widget.app
import
android.app.Application
import
android.app.Application
import
android.util.Log
import
com.alibaba.android.arouter.launcher.ARouter
import
com.alibaba.android.arouter.launcher.ARouter
import
com.liulishuo.filedownloader.FileDownloader
import
com.liulishuo.filedownloader.connection.FileDownloadConnection
import
com.liulishuo.filedownloader.connection.FileDownloadUrlConnection
import
com.orange.net.net.NetHelper
import
com.orange.net.net.NetHelper
import
com.orange.tool.app.AppUrl
import
com.orange.tool.app.AppUrl
import
com.orange.tool.app.IApp
import
com.orange.tool.app.IApp
import
com.orange.widget.util.NoEtagFileDownloadUrlConnection
import
xyz.doikki.videoplayer.util.PlayerUtils.getApplication
import
java.io.IOException
class
App
:
IApp
(){
class
App
:
IApp
(){
...
@@ -28,6 +34,19 @@ class App : IApp(){
...
@@ -28,6 +34,19 @@ class App : IApp(){
ARouter
.
openLog
()
ARouter
.
openLog
()
ARouter
.
openDebug
()
ARouter
.
openDebug
()
ARouter
.
init
(
app
)
ARouter
.
init
(
app
)
// FileDownloader.setupOnApplicationOnCreate(getApplication())
FileDownloader
.
setupOnApplicationOnCreate
(
getApplication
())
.
connectionCreator
(
object
:
FileDownloadUrlConnection
.
Creator
(
FileDownloadUrlConnection
.
Configuration
()
.
connectTimeout
(
15000
)
// set connection timeout.
.
readTimeout
(
15000
)
// set read timeout.
)
{
@Throws
(
IOException
::
class
)
override
fun
create
(
originUrl
:
String
):
FileDownloadConnection
{
return
NoEtagFileDownloadUrlConnection
(
originUrl
)
}
})
.
commit
()
}
}
override
fun
init
(
app
:
Application
,
applicationFlag
:
Boolean
)
{
override
fun
init
(
app
:
Application
,
applicationFlag
:
Boolean
)
{
...
...
widget/src/main/java/com/orange/widget/ui/ModelActivity.java
浏览文件 @
487c54f8
...
@@ -11,6 +11,7 @@ import android.hardware.SensorManager;
...
@@ -11,6 +11,7 @@ import android.hardware.SensorManager;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.MotionEvent
;
import
android.view.MotionEvent
;
...
@@ -25,6 +26,9 @@ import com.bumptech.glide.load.DataSource;
...
@@ -25,6 +26,9 @@ import com.bumptech.glide.load.DataSource;
import
com.bumptech.glide.load.engine.GlideException
;
import
com.bumptech.glide.load.engine.GlideException
;
import
com.bumptech.glide.request.RequestListener
;
import
com.bumptech.glide.request.RequestListener
;
import
com.bumptech.glide.request.target.Target
;
import
com.bumptech.glide.request.target.Target
;
import
com.liulishuo.filedownloader.BaseDownloadTask
;
import
com.liulishuo.filedownloader.FileDownloadListener
;
import
com.liulishuo.filedownloader.FileDownloader
;
import
com.orange.widget.R
;
import
com.orange.widget.R
;
import
com.orange.widget.util.ModelViewerGUI
;
import
com.orange.widget.util.ModelViewerGUI
;
import
org.the3deer.android_3d_model_engine.camera.CameraController
;
import
org.the3deer.android_3d_model_engine.camera.CameraController
;
...
@@ -118,12 +122,22 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
...
@@ -118,12 +122,22 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
}
}
}
}
setContentView
(
R
.
layout
.
activity_model
);
glView
=
findViewById
(
R
.
id
.
surfaceView
);
handler
=
new
Handler
(
getMainLooper
());
handler
=
new
Handler
(
getMainLooper
());
// Create our 3D scenario
// Create our 3D scenario
datas
.
add
(
"https://appmanage.youcai168.cn/villain/villain_obj.obj"
);
/*
datas.add("https://appmanage.youcai168.cn/villain/villain_obj.obj");
datas.add("https://appmanage.youcai168.cn/villain/villain_mtl");
datas.add("https://appmanage.youcai168.cn/villain/villain_mtl");
datas.add("https://appmanage.youcai168.cn/villain/villain_d.png");
datas.add("https://appmanage.youcai168.cn/villain/villain_d.png");
datas
.
add
(
"https://appmanage.youcai168.cn/villain/villain_n.png"
);
datas.add("https://appmanage.youcai168.cn/villain/villain_n.png");*/
datas
.
add
(
"https://appmanage.youcai168.cn/androidtest/sj.dae"
);
datas
.
add
(
"https://appmanage.youcai168.cn/androidtest/sj01.jpg"
);
datas
.
add
(
"https://appmanage.youcai168.cn/androidtest/sj02.jpg"
);
// datas.add("https://appmanage.youcai168.cn/androidtest/33.dae");
//datas.add("https://appmanage.youcai168.cn/androidtest/cgaxis_models_77_19_01.jpg");
// datas.add("https://appmanage.youcai168.cn/androidtest/cgaxis_models_77_19_02.jpg");
// datas.add("https://appmanage.youcai168.cn/androidtest/cgaxis_models_77_19_02_bump.jpg");
load3dModel
();
load3dModel
();
}
}
...
@@ -219,11 +233,15 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
...
@@ -219,11 +233,15 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
@Override
@Override
public
boolean
onEvent
(
EventObject
event
)
{
public
boolean
onEvent
(
EventObject
event
)
{
if
(
event
instanceof
FPSEvent
){
if
(
event
instanceof
FPSEvent
){
if
(
gui
!=
null
)
{
gui
.
onEvent
(
event
);
gui
.
onEvent
(
event
);
}
}
}
else
if
(
event
instanceof
SelectedObjectEvent
){
else
if
(
event
instanceof
SelectedObjectEvent
){
if
(
gui
!=
null
)
{
gui
.
onEvent
(
event
);
gui
.
onEvent
(
event
);
}
}
}
else
if
(
event
.
getSource
()
instanceof
MotionEvent
){
else
if
(
event
.
getSource
()
instanceof
MotionEvent
){
// event coming from glview
// event coming from glview
touchController
.
onMotionEvent
((
MotionEvent
)
event
.
getSource
());
touchController
.
onMotionEvent
((
MotionEvent
)
event
.
getSource
());
...
@@ -281,6 +299,7 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
...
@@ -281,6 +299,7 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
for
(
String
url
:
datas
)
{
for
(
String
url
:
datas
)
{
String
fileName
=
url
.
substring
(
url
.
lastIndexOf
(
'/'
)
+
1
);
String
fileName
=
url
.
substring
(
url
.
lastIndexOf
(
'/'
)
+
1
);
File
destFile
=
new
File
(
this
.
getExternalFilesDir
(
"3dModel"
).
toString
(),
fileName
);
File
destFile
=
new
File
(
this
.
getExternalFilesDir
(
"3dModel"
).
toString
(),
fileName
);
// File destFile = new File(Environment.getExternalStorageDirectory()+File.separator+"3dModel",fileName);
if
(
url
.
contains
(
"obj"
)){
if
(
url
.
contains
(
"obj"
)){
objName
=
url
.
substring
(
url
.
lastIndexOf
(
'/'
)
+
1
);
objName
=
url
.
substring
(
url
.
lastIndexOf
(
'/'
)
+
1
);
}
else
if
(
url
.
contains
(
"mtl"
)){
}
else
if
(
url
.
contains
(
"mtl"
)){
...
@@ -292,14 +311,23 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
...
@@ -292,14 +311,23 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
downloadCount
+=
1
;
downloadCount
+=
1
;
}
}
}
}
Log
.
e
(
"downloaded
file= "
,
"objName= "
+
objName
+
" mtlName= "
+
mtlName
+
" downloadCount= "
+
downloadCount
);
Log
.
i
(
"ModelActivity
file= "
,
"objName= "
+
objName
+
" mtlName= "
+
mtlName
+
" downloadCount= "
+
downloadCount
);
if
(
downloadCount
==
datas
.
size
()){
if
(
downloadCount
==
datas
.
size
()){
//已经存在了,直接加载
//已经存在了,直接加载
// parseMtlmappic(0x0000ff,objName,mtlName);
// parseMtlmappic(0x0000ff,objName,mtlName);
File
objFile
=
new
File
(
this
.
getExternalFilesDir
(
"3dModel"
).
toString
(),
objName
);
File
destFile
=
new
File
(
this
.
getExternalFilesDir
(
"3dModel"
).
toString
(),
objName
);
if
(
objFile
.
isFile
()
&&
objFile
.
exists
()){
// File destFile = new File(Environment.getExternalStorageDirectory()+File.separator+"3dModel",objName);
Uri
uri
=
Uri
.
parse
(
"file://"
+
objFile
.
getAbsolutePath
());
if
(
destFile
.
isFile
()
&&
destFile
.
exists
()){
initScene
(
uri
);
// 0 = obj, 1 = stl, 2 = dae,3 = gtlf
int
type
=
0
;
if
(
destFile
.
getAbsolutePath
().
contains
(
".obj"
)){
type
=
0
;
}
else
if
(
destFile
.
getAbsolutePath
().
contains
(
".dae"
)){
type
=
2
;
}
ContentUtils
.
setCurrentDir
(
destFile
.
getParentFile
());
Uri
uri
=
Uri
.
parse
(
"file://"
+
destFile
.
getAbsolutePath
());
initScene
(
uri
,
type
);
}
}
}
else
{
}
else
{
//下载并保存
//下载并保存
...
@@ -307,7 +335,7 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
...
@@ -307,7 +335,7 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
}
}
}
}
private
void
initScene
(
Uri
uri
)
{
private
void
initScene
(
Uri
uri
,
int
type
)
{
Log
.
i
(
"ModelActivity"
,
"Loading Scene..."
);
Log
.
i
(
"ModelActivity"
,
"Loading Scene..."
);
try
{
try
{
this
.
paramUri
=
URI
.
create
(
uri
.
toString
());
this
.
paramUri
=
URI
.
create
(
uri
.
toString
());
...
@@ -320,30 +348,29 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
...
@@ -320,30 +348,29 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
return
;
return
;
}
}
}
}
paramType
=
type
;
scene
=
new
SceneLoader
(
this
,
this
.
paramUri
,
paramType
);
scene
=
new
SceneLoader
(
this
,
this
.
paramUri
,
paramType
);
scene
.
addListener
(
this
);
scene
.
addListener
(
this
);
//默认正常光
scene
.
toggleLighting
();
if
(
paramUri
==
null
)
{
if
(
paramUri
==
null
)
{
// final LoaderTask task = new DemoLoaderTask(this, null, scene);
// final LoaderTask task = new DemoLoaderTask(this, null, scene);
// task.execute();
// task.execute();
}
}
try
{
try
{
Log
.
i
(
"ModelActivity"
,
"Loading GLSurfaceView..."
);
Log
.
i
(
"ModelActivity"
,
"Loading GLSurfaceView..."
);
setContentView
(
R
.
layout
.
activity_model
);
//
setContentView(R.layout.activity_model);
glView
=
findViewById
(
R
.
id
.
surfaceView
);
//
glView= findViewById(R.id.surfaceView);
glView
.
setBackgroundColor
(
backgroundColor
);
glView
.
setBackgroundColor
(
backgroundColor
);
glView
.
setScene
(
scene
);
glView
.
setScene
(
scene
);
glView
.
addListener
(
this
);
glView
.
addListener
(
this
);
glView
.
setCanTouch
(
canTouch
);
glView
.
setCanTouch
(
canTouch
);
// mRenderer = new ModelRenderer(this, glView, backgroundColor, this.scene);
// mRenderer.addListener(this);
// glView.setRenderer(mRenderer);
// glView = new ModelSurfaceView(this, backgroundColor, this.scene);
// glView = new ModelSurfaceView(this, backgroundColor, this.scene);
// glView.addListener(this);
// glView.addListener(this);
// setContentView(glView);
// setContentView(glView);
// scene.setView(glView);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
e
(
"ModelActivity"
,
e
.
getMessage
(),
e
);
Log
.
i
(
"ModelActivity"
,
e
.
getMessage
(),
e
);
Toast
.
makeText
(
this
,
"Error loading OpenGL view:\n"
+
e
.
getMessage
(),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
this
,
"Error loading OpenGL view:\n"
+
e
.
getMessage
(),
Toast
.
LENGTH_LONG
).
show
();
}
}
try
{
try
{
...
@@ -355,7 +382,7 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
...
@@ -355,7 +382,7 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
}
}
//touchController.addListener(glView);
//touchController.addListener(glView);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
e
(
"ModelActivity"
,
e
.
getMessage
(),
e
);
Log
.
i
(
"ModelActivity"
,
e
.
getMessage
(),
e
);
Toast
.
makeText
(
this
,
"Error loading TouchController:\n"
+
e
.
getMessage
(),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
this
,
"Error loading TouchController:\n"
+
e
.
getMessage
(),
Toast
.
LENGTH_LONG
).
show
();
}
}
try
{
try
{
...
@@ -365,7 +392,7 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
...
@@ -365,7 +392,7 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
//touchController.addListener(collisionController);
//touchController.addListener(collisionController);
//touchController.addListener(scene);
//touchController.addListener(scene);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
e
(
"ModelActivity"
,
e
.
getMessage
(),
e
);
Log
.
i
(
"ModelActivity"
,
e
.
getMessage
(),
e
);
Toast
.
makeText
(
this
,
"Error loading CollisionController\n"
+
e
.
getMessage
(),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
this
,
"Error loading CollisionController\n"
+
e
.
getMessage
(),
Toast
.
LENGTH_LONG
).
show
();
}
}
...
@@ -375,30 +402,31 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
...
@@ -375,30 +402,31 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
//glView.getModelRenderer().addListener(cameraController);
//glView.getModelRenderer().addListener(cameraController);
//touchController.addListener(cameraController);
//touchController.addListener(cameraController);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
e
(
"ModelActivity"
,
e
.
getMessage
(),
e
);
Log
.
i
(
"ModelActivity"
,
e
.
getMessage
(),
e
);
Toast
.
makeText
(
this
,
"Error loading CameraController"
+
e
.
getMessage
(),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
this
,
"Error loading CameraController"
+
e
.
getMessage
(),
Toast
.
LENGTH_LONG
).
show
();
}
}
try
{
try
{
// TODO: finish UI implementation
// TODO: finish UI implementation
Log
.
i
(
"ModelActivity"
,
"Loading GUI..."
);
Log
.
i
(
"ModelActivity"
,
"Loading GUI..."
);
gui
=
new
ModelViewerGUI
(
glView
,
scene
);
//
gui = new ModelViewerGUI(glView, scene);
touchController
.
addListener
(
gui
);
//
touchController.addListener(gui);
glView
.
addListener
(
gui
);
//
glView.addListener(gui);
//去调sufaceview表面添加的东西
//去调sufaceview表面添加的东西
// scene.addGUIObject(gui);
// scene.addGUIObject(gui);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
e
(
"ModelActivity"
,
e
.
getMessage
(),
e
);
Log
.
i
(
"ModelActivity"
,
e
.
getMessage
(),
e
);
Toast
.
makeText
(
this
,
"Error loading GUI"
+
e
.
getMessage
(),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
this
,
"Error loading GUI"
+
e
.
getMessage
(),
Toast
.
LENGTH_LONG
).
show
();
}
}
scene
.
init
();
scene
.
init
();
Log
.
i
(
"ModelActivity"
,
"Finished loading"
);
Log
.
i
(
"ModelActivity"
,
"Finished loading"
);
}
}
private
void
save3dModelResourceToLocal
(
List
<
String
>
datas
)
{
/*
private void save3dModelResourceToLocal(List<String> datas) {
//// 发起多个请求
//// 发起多个请求
for (String url : datas) {
for (String url : datas) {
String fileName = url.substring(url.lastIndexOf('/') + 1);
String fileName = url.substring(url.lastIndexOf('/') + 1);
File
destFile
=
new
File
(
this
.
getExternalFilesDir
(
"3dModel"
).
toString
(),
fileName
);
// File destFile = new File(this.getExternalFilesDir("3dModel").toString(), fileName);
File destFile = new File(Environment.getExternalStorageDirectory()+File.separator+"3dModel",fileName);
if(destFile.exists()){
if(destFile.exists()){
continue;
continue;
}
}
...
@@ -417,7 +445,8 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
...
@@ -417,7 +445,8 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
public boolean onResourceReady(File resource, Object model, Target<File> target, DataSource dataSource, boolean isFirstResource) {
public boolean onResourceReady(File resource, Object model, Target<File> target, DataSource dataSource, boolean isFirstResource) {
// Toast.makeText(context, "下载成功", Toast.LENGTH_SHORT).show();
// Toast.makeText(context, "下载成功", Toast.LENGTH_SHORT).show();
String fileName = url.substring(url.lastIndexOf('/') + 1);
String fileName = url.substring(url.lastIndexOf('/') + 1);
File
destFile
=
new
File
(
ModelActivity
.
this
.
getExternalFilesDir
(
"3dModel"
).
toString
(),
fileName
);
// File destFile = new File(ModelActivity.this.getExternalFilesDir("3dModel").toString(), fileName);
File destFile = new File(Environment.getExternalStorageDirectory()+File.separator+"3dModel",fileName);
FileUtils.copy(resource, destFile);
FileUtils.copy(resource, destFile);
// 这里可以执行某些逻辑,如记录日志等
// 这里可以执行某些逻辑,如记录日志等
counter++;
counter++;
...
@@ -429,14 +458,22 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
...
@@ -429,14 +458,22 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
}else if(url.contains(".dae")){
}else if(url.contains(".dae")){
objName = url.substring(url.lastIndexOf('/') + 1);
objName = url.substring(url.lastIndexOf('/') + 1);
}
}
Log
.
e
(
"file= "
,
"objName= "
+
objName
+
" mtlName= "
+
mtlName
+
" counter= "
+
counter
);
Log.
i
("file= ", "objName= "+objName+" mtlName= " + mtlName +" counter= "+counter);
if (counter == datas.size()) { // 所有请求都完成了
if (counter == datas.size()) { // 所有请求都完成了
// 在这里执行处理逻辑
// 在这里执行处理逻辑
// parseMtlmappic(0x0000ff,objName,mtlName);
// parseMtlmappic(0x0000ff,objName,mtlName);
File
objFile
=
new
File
(
ModelActivity
.
this
.
getExternalFilesDir
(
"3dModel"
).
toString
(),
objName
);
// File objFile =
File objFile = new File(Environment.getExternalStorageDirectory(),objName);
if(objFile.isFile() && objFile.exists()){
if(objFile.isFile() && objFile.exists()){
// 0 = obj, 1 = stl, 2 = dae,3 = gtlf
int type = 0;
if(objFile.getAbsolutePath().contains(".obj")){
type = 0;
}else if(objFile.getAbsolutePath().contains(".dae")){
type = 2;
}
Uri uri = Uri.parse("file://" + objFile.getAbsolutePath());
Uri uri = Uri.parse("file://" + objFile.getAbsolutePath());
initScene
(
uri
);
initScene(uri
,type
);
}
}
}
}
return false;
return false;
...
@@ -444,5 +481,85 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
...
@@ -444,5 +481,85 @@ public class ModelActivity extends AppCompatActivity implements EventListener {
})
})
.preload();
.preload();
}
}
}*/
private
void
save3dModelResourceToLocal
(
List
<
String
>
datas
)
{
//// 发起多个请求
for
(
String
url
:
datas
)
{
String
fileName
=
url
.
substring
(
url
.
lastIndexOf
(
'/'
)
+
1
);
File
destFile
=
new
File
(
this
.
getExternalFilesDir
(
"3dModel"
).
toString
(),
fileName
);
//File destFile = new File(Environment.getExternalStorageDirectory()+File.separator+"3dModel",fileName);
if
(
destFile
.
exists
()){
continue
;
}
FileDownloader
.
getImpl
().
create
(
url
)
.
setPath
(
destFile
.
getAbsolutePath
())
.
setForceReDownload
(
true
)
.
setListener
(
new
FileDownloadListener
()
{
@Override
protected
void
pending
(
BaseDownloadTask
task
,
int
soFarBytes
,
int
totalBytes
)
{
}
@Override
protected
void
progress
(
BaseDownloadTask
task
,
int
soFarytes
,
int
totalytes
)
{
Log
.
e
(
"progress"
,
" progress= "
+(
int
)
((
long
)
soFarytes
*
100
/
(
long
)
totalytes
));
}
@Override
protected
void
started
(
BaseDownloadTask
task
)
{
super
.
started
(
task
);
Log
.
e
(
"started"
,
" started "
);
}
@Override
protected
void
paused
(
BaseDownloadTask
task
,
int
soFarBytes
,
int
totalBytes
)
{
}
@Override
protected
void
completed
(
BaseDownloadTask
task
)
{
// 这里可以执行某些逻辑,如记录日志等
counter
++;
Log
.
e
(
"completed file= "
,
"url= "
+
url
+
" fileName= "
+
fileName
);
if
(
url
.
contains
(
".obj"
)){
objName
=
url
.
substring
(
url
.
lastIndexOf
(
'/'
)
+
1
);
}
else
if
(
url
.
contains
(
".mtl"
)){
mtlName
=
url
.
substring
(
url
.
lastIndexOf
(
'/'
)
+
1
);
}
else
if
(
url
.
contains
(
".dae"
)){
objName
=
url
.
substring
(
url
.
lastIndexOf
(
'/'
)
+
1
);
}
Log
.
i
(
"file= "
,
"objName= "
+
objName
+
" mtlName= "
+
mtlName
+
" counter= "
+
counter
);
if
(
counter
==
datas
.
size
())
{
// 所有请求都完成了
// 在这里执行处理逻辑
// parseMtlmappic(0x0000ff,objName,mtlName);
File
objFile
=
new
File
(
ModelActivity
.
this
.
getExternalFilesDir
(
"3dModel"
).
toString
(),
objName
);
// File objFile = new File(Environment.getExternalStorageDirectory()+File.separator+"3dModel",objName);
if
(
objFile
.
isFile
()
&&
objFile
.
exists
()){
// 0 = obj, 1 = stl, 2 = dae,3 = gtlf
int
type
=
0
;
if
(
objFile
.
getAbsolutePath
().
contains
(
".obj"
)){
type
=
0
;
}
else
if
(
objFile
.
getAbsolutePath
().
contains
(
".dae"
)){
type
=
2
;
}
ContentUtils
.
setCurrentDir
(
objFile
.
getParentFile
());
Uri
uri
=
Uri
.
parse
(
"file://"
+
objFile
.
getAbsolutePath
());
initScene
(
uri
,
type
);
}
}
}
@Override
protected
void
error
(
BaseDownloadTask
task
,
Throwable
e
)
{
Log
.
e
(
"error download file "
,
e
.
toString
());
}
@Override
protected
void
warn
(
BaseDownloadTask
task
)
{
}
}).
start
();
}
}
}
}
}
\ No newline at end of file
widget/src/main/java/com/orange/widget/util/NoEtagFileDownloadUrlConnection.java
0 → 100644
浏览文件 @
487c54f8
package
com
.
orange
.
widget
.
util
;
import
com.liulishuo.filedownloader.connection.FileDownloadUrlConnection
;
import
java.io.IOException
;
import
java.net.URL
;
public
class
NoEtagFileDownloadUrlConnection
extends
FileDownloadUrlConnection
{
public
NoEtagFileDownloadUrlConnection
(
String
originUrl
,
Configuration
configuration
)
throws
IOException
{
super
(
originUrl
,
configuration
);
}
public
NoEtagFileDownloadUrlConnection
(
URL
url
,
Configuration
configuration
)
throws
IOException
{
super
(
url
,
configuration
);
}
public
NoEtagFileDownloadUrlConnection
(
String
originUrl
)
throws
IOException
{
super
(
originUrl
);
}
@Override
public
void
addHeader
(
String
name
,
String
value
)
{
if
(
"If-Match"
.
equals
(
name
))
{
return
;
}
super
.
addHeader
(
name
,
value
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论