Tech Forums > General Discussion

porting from demoniak3d


Hi all,

I ported my minigame from demoniak3d.
Cloning function is missing, not listed in api doc and program crashes on `HYP_Object.Clone` call.
Switched from `HYP_Object.Clone` to `HYP_Model.Load` is that good practice ?
Physix is working ok.
I have polygons that are visible now and they was transparent in demoniak3d with alpha.
Also models not rendering when in some particular position/camera distance.


Nice news Alex!
Don't hesitate to post some screenshots (or send me them).

For what do you use HYP_Object.Clone()? for Model? 

In GeeXLab, transparent surfaces have a material with an opacity < 1.0. That was not necessary in Demoniak3D.
So check this detail and let me know.

I will release this evening an update that includes a bugfix for mode bounding volumes. Maybe that will solve your problem.

The minigame has elements:
 - object movement. Done by `HYP_PhysX.AddSphereActorToScene`
 - shooting.
    - laser effect with `HYP_Primitive.CreateLine`
    - sound effect
    - and if there is target a particle effect on hit position

a screenshot:

Particle effect is working as expected, could not find doc about it in api reference.

Laser effect is not working. `HYP_Primitive.CreateLine` does return valid id (id > 0) but is not rendered, here is code :

--- Code: --- line = HYP_Primitive.CreateLine('dzebana')
log('laser created : '.. line)
HYP_Primitive.SetLineVertexPosition(line, 0, pos.x, pos.y, pos.z)
HYP_Primitive.SetLineVertexPosition(line, 1, target.x, target.y, target.z)
HYP_Primitive.SetLineVertexColor(line, 0, 1, 0, 0, 0.7)
HYP_Primitive.SetLineVertexColor(line, 1, 1, 0, 0, 0.7)

--- End code ---

For every sound effect (when ship fires you can hear 'zaap') I use load so user can hear effects overlapping :

--- Code: --- local effect = HYP_Sound.Load('data/sound/zap.wav', 0)
HYP_Sound.SetSourcePosition(effect, pos.x, pos.y, pos.z)

--- End code ---
I do not know whether to always create a new sound.

For collision detection I use `HYP_Scene.CastRay`. To better the detection model has sort of bounding box around it, with material that has alpha == 0 and white color. Somehow that material is not loaded properly or was lost during export from google sketchup to 3ds.
Maybe if I add boundingbox mesh manualy to model and set its material in script ..

Ideally, I would calculate collision with physix actors but I didn`t found the way to do it.

I like to define model in xml and then use it as template for instancing objects with the same model. In this case clone function comes handy. And I don`t know if it is good to use `HYP_Model.Load`every time when new element is inserted in scene.

Also there is another model far to the right but is not visible somehow.


The new update of GeeXLab should solve some of your problems:

I added 3 new examples:

1 - sound phaser: for your sound effect "zaap". Just load once all audio files you need, depending on the type of sound, set the play and loop params. As soon you need to produce a sound, just call HYP_Sound.Play(). Look at the demo. If you press the SPACE key, you'll heard the phaser for around 1 second.

2 - Draw line: there are two demos that draw a line. The first demo draws a line using a primitive line as you did. That works and it's simple. But I recommend you to use the second technique: immediate mode. In this mode you talk directly with the renderer and then you have a full control over what's going on.

3 - Cloning model: there was a bug in mesh cloning code so cloning a model was impossible. Now it's ok. But if your models are simple (one sub mesh only), I recommend you to use mesh instancing to manage huge amount of instances. Just remove the sub mesh from the model hierarchy (see this code sample) and use mesh instancing techniques like in this code sample.
I added in GeeXLab 0.1.10 one useful function for instances management:

--- Code: ---HYP_Mesh.SetInstanceRenderState(instanceIndex, state)

--- End code ---



[0] Message Index

Go to full version