Multiple rendering of one Object3D

Started by ElKornacio, August 12, 2012, 01:30:29 AM

Previous topic - Next topic

ElKornacio

Hi.

Firstly, sorry for my awful english, I'm from Russia =)

I want to make game for Android. And in my game there are a lot of buildings - same models, that placed in different locations.
So. I want to load .3ds one time. I want to create one object3d, that will store mesh from .3ds. But I want to render it multiple times in different places. How can I do it?

I would be very grateful to you for your answer =)

EgonOlsen

You can't render one object multiple times per frame, but you can create clones of an Object3D and make them use the same mesh. To do this, do


Object3D obj2=new Object3D(obj1, true);
obj2.shareCompiledData(obj1);
obj2.shareTextureData(obj1);


The last two lines can be left out, but that will reduce performance and increase memory usage. As long as the clones are 100% clones of the first object, you should use them.

ElKornacio

Okay, thank you, that's really will help me.

And more one question: I saw your RPG project. That's really great. But I want to ask: how are you texturing terrain?
Trying to be more understandable: for example: I have map, that covered by grass. But in some places it covered by asphalt. Is it really to make one Object3D (mesh) and make it.. multitexturing?)

Asking, because I saw something like I want in your project =)

EgonOlsen

Yes, basically. The rpg's terrain uses four texture layers. One contains the tiled grass, one the tiled rocks, one the tiled sand and one a streched rgb-image that defines the texture splatting at each location. So at a given point of the terrain, a shader reads the color value at that point from all three textures (plus a darkened version of sand for roads) and mixes them based on the rgb-color of that point in the splatting texture.