Can I display a Sprite3D object at 2 places in the world?

本文探讨了在Sony Ericsson的3D图形API中如何有效复用Sprite3D对象以节省内存。讨论了通过变换矩阵在不同位置显示同一个Sprite3D实例的方法,以及这种方法对于性能的影响。

FW: http://developer.sonyericsson.com/thread.jspa?threadID=30521&tstart=180


Permlink Replies: 6 - Pages: 1 - Last Post: Jul 29, 2006 10:18 AM by: Xmas Threads: [ Previous | Next ]
arbixy

Posts: 33
Registered: 7/21/06
 Can I display a Sprite3D object at 2 places in the world? :S
Posted: Jul 25, 2006 11:14 AM
 
 Click to reply to this thread Reply

Hello again!

Still looking for ways to save memory :) I'm sorry to post two threads at once, but the two subjects are definitely different and cant be joined in one thread only.
So mister moderator, please excuse me, it wont happen again :)

Back to my question:

I am displaying Sprite3D elements under the text of my menu in a 3D rendered scene.

Lets imagine I have 5 choices in my main menu: 4 of them are not currently selected, one is.
I'd like to display one special Sprite3D behind these 4 choices, and another one behind the choice currently selected.

Do I have to load 4 different Sprite3D objects to diplay the same image 4 times? Thats what I'm doing at the moment. It sure works, but it looks like a lot of memory wasted here.

So my question is pretty simple: can i create a Sprite3D object, and diplay it at 2 (at least :p) different places in my world space?

I tried already but a Sprite3D object can have one parent node only.
I also tried to use the duplicate() method to avoid re-creating my Sprite3D object, but wouldnt it be exacty the same as the System migt create the duplicate objects in memory?

punkedge  


Posts: 162
Registered: 11/15/04
 Re: Can I display a Sprite3D object at 2 places in the world? :S
Posted: Jul 26, 2006 2:04 AM   in response to: arbixy
Helpful
 Click to reply to this thread Reply

its easy to do tht
say u hav a sprite3d sp use the render command

g3d.render(sp,transform);
g3d.render(sp,transform2);

also the duplicate method is the same thing ...its jus keeps the same object wid separate transforms so there are no separate objects created in memory.
so u can use both the ways to do wht u want to.

cheers !

Xmas

Posts: 47
Registered: 2/21/06
 Re: Can I display a Sprite3D object at 2 places in the world? :S
Posted: Jul 26, 2006 6:09 AM   in response to: punkedge
Very Helpful
 Click to reply to this thread Reply

> also the duplicate method is the same thing ...its
> jus keeps the same object wid separate transforms so
> there are no separate objects created in memory.
> so u can use both the ways to do wht u want to.

Not true, the duplicate method will create a completely new object with most of the fields set to the same data (except for some of those belonging to Node). It is not possible to just keep the same object with separate transforms.


Trying to save memory is a good thing, however I would recommend to not overdo it. If it is easy to save an object or two somewhere and doesn't impact readability of your code, by all means, do it. But you should only optimize where it really makes a difference (and only optimize once the code is running). It just doesn't pay off to chase every last byte, even on very limited mobile devices.

The minimum amount of memory used for a Sprite3D object should be around 176 bytes (12 for Object3D, 104 for Transformable, 32 for Node, 28 for Sprite3D). An implementation might of course use more than that internally, however this is still not excessively large if you only have five of them. In all likelyhood it is still much less memory than the Image2D for the sprites needs.

arbixy

Posts: 33
Registered: 7/21/06
 Re: Can I display a Sprite3D object at 2 places in the world? :S
Posted: Jul 28, 2006 7:18 AM   in response to: Xmas
 
 Click to reply to this thread Reply

Well okay, there's no way to do it by sticking to retained mode. I'm gonna have to mix retained and immediate mode if i wanna use only one Sprite3D object instead of, actually, 6.

On the other hand, what Xmas says is quite true, I'm not sure I wanna get my code complicated that much to save a few bytes. I might give it a try though.

Thanx for answering guyz, and for being that clear. ;)

venkat512

Posts: 9
Registered: 3/16/06
 Re: Can I display a Sprite3D object at 2 places in the world? :S
Posted: Jul 28, 2006 11:55 PM   in response to: punkedge
 
 Click to reply to this thread Reply

Hi,
A small question......

g3d.render(sp,transform);
g3d.render(sp,transform1);

how to declare transform here.....when i want to place 50 trees...i have to geive 50 transforms here....The transform is a 4*4 identity matrix.So it wil take more memory than the Sprite3D objects..i think......It's correct are not....

tel me how to declare trnasforms here....

Thank's in advance...

arbixy

Posts: 33
Registered: 7/21/06
 Re: Can I display a Sprite3D object at 2 places in the world? :S
Posted: Jul 29, 2006 3:33 AM   in response to: venkat512
 
 Click to reply to this thread Reply

This is a very interesting question u have here.

The way I do it is the following:

//this is a global (an attribute) used everywhere
Transform rmp = new Transform();

//when i need a transform:
tmp.setIdentity();
tmp.postTranslate( ... );
tmp.postScale( ... );
...
g3d.render( sp1, tmp );
//then do it again for the next sprite
tmp.setIdentity();
tmp.postTranslate( ... );
tmp.postScale( ... );
...
g3d.render( sp2, tmp );


I'm suddenly wondering if it's the right way to do it. I'm gonna check the JSR184 doc to see if a call to render copies the Transform object or just makes a reference to it. In the latter, I think I'm screwed and gonna have to change some pieces of code.

Thx for making me focus on that anyway! Gonna check this and get back to this thread.

Cheers!

Xmas

Posts: 47
Registered: 2/21/06
 Re: Can I display a Sprite3D object at 2 places in the world? :S
Posted: Jul 29, 2006 10:18 AM   in response to: arbixy
 
 Click to reply to this thread Reply

> w to declare transform here.....when i want to place
> 50 trees...i have to geive 50 transforms here....The
> transform is a 4*4 identity matrix.So it wil take
> more memory than the Sprite3D objects..i
> think......It's correct are not....
The 50 Transforms together will need more memory than one Sprite3D, but a Sprite3D object requires more memory than a Transform, since it's a subclass of Transformable.


> I'm suddenly wondering if it's the right way to do
> it. I'm gonna check the JSR184 doc to see if a call
> to render copies the Transform object or just makes a
> reference to it. In the latter, I think I'm screwed
> and gonna have to change some pieces of code.
Don't worry. A call to render will always act as using the Transform object in its state at the point of the method call, regardless of whether it performs the actual rendering immediately or not.
 

基于数据驱动的 Koopman 算子的递归神经网络模型线性化,用于纳米定位系统的预测控制研究(Matlab代码实现)内容概要:本文围绕“基于数据驱动的Koopman算子的递归神经网络模型线性化”展开,旨在研究纳米定位系统的预测控制方法。通过结合数据驱动技术与Koopman算子理论,将非线性系统动态近似为高维线性系统,进而利用递归神经网络(RNN)建模并实现系统行为的精确预测。文中详细阐述了模型构建流程、线性化策略及在预测控制中的集成应用,并提供了完整的Matlab代码实现,便于科研人员复现实验、优化算法并拓展至其他精密控制系统。该方法有效提升了纳米级定位系统的控制精度与动态响应性能。; 适合人群:具备自动控制、机器学习或信号处理背景,熟悉Matlab编程,从事精密仪器控制、智能制造或先进控制算法研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①实现非线性动态系统的数据驱动线性化建模;②提升纳米定位平台的轨迹跟踪与预测控制性能;③为高精度控制系统提供可复现的Koopman-RNN融合解决方案; 阅读建议:建议结合Matlab代码逐段理解算法实现细节,重点关注Koopman观测矩阵构造、RNN训练流程与模型预测控制器(MPC)的集成方式,鼓励在实际硬件平台上验证并调整参数以适应具体应用场景。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值