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

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.
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
城市应急指挥系统是智慧城市建设的重要组成部分,旨在提高城市对突发事件的预防和处置能力。系统背景源于自然灾害和事故灾难频发,如汶川地震和日本大地震等,这些事件造成了巨大的人员伤亡和财产损失。随着城市化进程的加快,应急信息化建设面临信息资源分散、管理标准不统一等问题,需要通过统筹管理和技术创新来解决。 系统的设计思路是通过先进的技术手段,如物联网、射频识别、卫星定位等,构建一个具有强大信息感知和通信能力的网络和平台。这将促进不同部门和层次之间的信息共享、交流和整合,提高城市资源的利用效率,满足城市对各种信息的获取和使用需求。在“十二五”期间,应急信息化工作将依托这些技术,实现动态监控、风险管理、预警以及统一指挥调度。 应急指挥系统的建设目标是实现快速有效的应对各种突发事件,保障人民生命财产安全,减少社会危害和经济损失。系统将包括预测预警、模拟演练、辅助决策、态势分析等功能,以及应急值守、预案管理、GIS应用等基本应用。此外,还包括支撑平台的建设,如接警中心、视频会议、统一通信等基础设施。 系统的实施将涉及到应急网络建设、应急指挥、视频监控、卫星通信等多个方面。通过高度集成的系统,建立统一的信息接收和处理平台,实现多渠道接入和融合指挥调度。此外,还包括应急指挥中心基础平台建设、固定和移动应急指挥通信系统建设,以及应急队伍建设,确保能够迅速响应并有效处置各类突发事件。 项目的意义在于,它不仅是提升灾害监测预报水平和预警能力的重要科技支撑,也是实现预防和减轻重大灾害和事故损失的关键。通过实施城市应急指挥系统,可以加强社会管理和公共服务,构建和谐社会,为打造平安城市提供坚实的基础。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值