Questions from new user

All topics about ZGameEditor goes here.

Moderator: Moderators

fracteed
Posts: 43
Joined: Wed Apr 30, 2014 1:14 am
Location: Sydney

Questions from new user

Post by fracteed »

Having a lot of fun creating a little game with ZgameEditor! It has a very logical and well thought out workflow, which has enabled me to not run into too many issues. A couple that I have run into that I would like some clarification on..

- The 3ds import tab has a checkbox for vertex colors, but I can't get it to work. I don't think 3ds even supports vertex colors, so what am I missing here? I am exporting meshes from Blender, so is there any way of getting that data in? Btw would love to see native import of .blend files :D

- Does the music component work on Android? I have it working fine on Windows, but in Android it is playing back the notes at random speeds, but in the right order. What are people using for music on Android...I know there is the Bass and Sunvox libraries, but I was hoping to keep it simple for my first project. Does the Bass one even work in Android?

- I started my project on a Win8 pc and then upon continuing it on a Win7 pc, it seems none of my materials with any blend alpha options seem to work. These materials are just flat colors/no maps, but won't render with any of the alpha options in the "blend" pulldown . Works fine in Win8/AMD card but not on Win7/Nvidia. Is this a known issue? Btw, have tried it in 3.0 and 3.1 beta.

cheers...
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Re: Questions from new user

Post by Kjell »

Hi fracteed,
fracteed wrote:The 3ds import tab has a checkbox for vertex colors, but I can't get it to work. I don't think 3ds even supports vertex colors, so what am I missing here?
You're right, the 3DS file format doesn't support true vertex colors ( nor true normals by the way ). It does however supports per-face materials .. so i always assumed it would pull the colors from that data. Never tried it though.
fracteed wrote:I am exporting meshes from Blender, so is there any way of getting that data in?
Unfortunately only 3DS files are supported at the moment. There are some other importers floating around on this forum, but they don't work with the Mesh component, so you lose that convenience.
fracteed wrote:Btw would love to see native import of .blend files.
I think a more generic format ( such as COLLADA or FBX ) would benefit more users .. not everybody uses Blender you know ;)
fracteed wrote:Does the music component work on Android? I have it working fine on Windows, but in Android it is playing back the notes at random speeds, but in the right order.
I don't think anybody ever uses the music component ( it should be overhauled in my opinion ) ..
fracteed wrote:What are people using for music on Android...I know there is the Bass and Sunvox libraries, but I was hoping to keep it simple for my first project. Does the Bass one even work in Android?
A library that plays MP3 or OGG files is probably the easiest option. But in case you want to use BASS on Android, check this thread.
fracteed wrote:I started my project on a Win8 pc and then upon continuing it on a Win7 pc, it seems none of my materials with any blend alpha options seem to work. These materials are just flat colors/no maps, but won't render with any of the alpha options in the "blend" pulldown . Works fine in Win8/AMD card but not on Win7/Nvidia. Is this a known issue? Btw, have tried it in 3.0 and 3.1 beta.
Hmm, sounds very peculiar. Would it be possible to post a example project that behaves like this on your system?

Welcome to the club ~

K
fracteed
Posts: 43
Joined: Wed Apr 30, 2014 1:14 am
Location: Sydney

Post by fracteed »

Hi Kjell...thanks for your reply.

The main reason I suggested .blend import was that it was an open format, which would gel nicely with a project like ZGE. I actually make my living using C4D, and have used most 3d apps in the past. Even though I have noodled with Blender for years, I still struggle with it.

I am actually forcing myself to use Blender on this project to learn it better. It actually some nifty things for vertex colours like baking the AO or diffuse map into them, which would result in some very light and sexy models that I was hoping to use in ZGE. No worries though, I will just use some low res map with the 3ds exports.

Collada seems to be a dying and generally problematic format , with even the Blender devs abondoning it. Fbx, being tied to the Autoborg has its own set of issues as well, but of course is the standard in the game industry. Blender having a much better fbx importer/exporter now could possibly be re-used by ZGE? OBJ native would be good and easy option.

Another possibility would be to use a translator like assimp. There is a dev working on this for the Godot Engine , which curently only imports collada: http://www.godotengine.org/forum/viewto ... ?f=8&t=525
A library that plays MP3 or OGG files is probably the easiest option
Any links to how this works? I can see the sample import component, but can't get it to work yet, even though I have converted to a RAW wave. How do you import/play an mp3/ogg?

Also, I am not really sure what the sample import is for. Can I actually import a wavetable and use it with the sound component instead of using the oscillators?

With regards to the alpha/material issue I am having ,I will test out on some other computers first before I post a file.

cheers...
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi fracteed,
fracteed wrote:The main reason I suggested .blend import was that it was an open format, which would gel nicely with a project like ZGE.
Understood, i'm just not a fan of forcing people to use a certain program. But you're free to disagree of course.
fracteed wrote:OBJ native would be good and easy option.
Yea, this would have been a better choice than 3DS ( imo ) .. even though OBJ doesn't support vertex colors either ;)
fracteed wrote:How do you import/play an mp3/ogg?
You can use DLL's with ZGameEditor. A super simple example of MP3 playback on Windows can be downloaded here.
fracteed wrote:Also, I am not really sure what the sample import is for.
The sample component basically represents a waveform .. either imported or procedurally generated. In order to use it you need a Sound component with its Sample property set to the sample you want to use.

K
Attachments
Sample.png
Sample.png (12.64 KiB) Viewed 14864 times
fracteed
Posts: 43
Joined: Wed Apr 30, 2014 1:14 am
Location: Sydney

Post by fracteed »

Thanks for the project file Kjell. Is there any library extension like this that can be used with Android?

Still haven't been able to get the sample import to work on Android. I have converted to a raw wav. file with Audacity, but I will keep playing around with it with some other converters.

My first game using ZGE will probably be sfx only at this stage, but that's cool. As a longtime muso, I dig having access to the inbuilt synth for crazy old school sfx. Would be great to be able to use a wavetable instead of the oscillators. Maybe you can?

Btw, I did see your tute on creating FM sounds, so I will have to dig into that as well 8)
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi fracteed,
fracteed wrote:Is there any library extension like this that can be used with Android?
No idea. Thing is, Android has support for many audio formats build-in, so most engines use those features directly.
fracteed wrote:Still haven't been able to get the sample import to work on Android. I have converted to a raw wav. file with Audacity, but I will keep playing around with it with some other converters.
Audacity is fine. Simply use the "Other uncompressed files" option when exporting your sample, and make sure the header is set to RAW ( using the Options button ).

Attached is a simple 3 sample + 1 synth example project ( tested on Android 4.4 ).

K
Attachments
Samples.zgeproj
(23.68 KiB) Downloaded 502 times
fracteed
Posts: 43
Joined: Wed Apr 30, 2014 1:14 am
Location: Sydney

Post by fracteed »

Thanks for the project file, that cleared up a few things for me. Looks like I will have to dig into the the Sunvox library at some stage to achieve what I am after.

Hope you don't mind the barrage of questions...I have plenty more :)

In my project, I am using the CollideWith command to determine properties of the model my bullets have hit. It is all working fine, just wondering if there is a more elegant solution for what I have.

When a bullet hits an enemy, it explodes into fragments (which is another model spawned many times). The trick is that I am trying to get the material of the model hit so that I can use it on the fragments.

Currently I am using a switch command based on the Model ClassId, and it is working well...for example...

Code: Select all


model m = CurrentModel;         // itself
model c = m.CollidedWith;        // what it collides with

switch(c.ClassId)                     // pick material
{
  case 2:
    render_fragment_mat.Material = asteroid_mat;
    break;

  case 3:
    render_fragment_mat.Material = cubenemy_mat;
    break;
}
But when there are 20 or so different enemies this is somewhat clunky. Just wondering if there is a way of getting the material property that is used in a "Use Material" component via a models' Class.Id? If I understand correctly I can only access the model properties and not it's children?
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi fracteed,
fracteed wrote:Hope you don't mind the barrage of questions...I have plenty more :)
No problem, keep 'em coming :wink:
fracteed wrote:Looks like I will have to dig into the the Sunvox library at some stage to achieve what I am after.
SunVox can't play MP3 / OGG files though ( it's a synth based tracker ). Anyway, i'm pretty sure there are Android libraries with MP3 / OGG playback capabilities .. i've just have never looked for / used them.
fracteed wrote:Just wondering if there is a way of getting the material property that is used in a "Use Material" component via a models' Class.Id? If I understand correctly I can only access the model properties and not it's children?
You can only access model definitions from outside the model. However, any component used in a Model can be accessed from the model itself. So what you want to do is to put the model that explodes in charge of spawning the fragments ( instead of the bullet ). Attached is a example.

K
Attachments
Fragments.zgeproj
(2.9 KiB) Downloaded 520 times
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

I'd like to add that when you do a switch on classId's, it is safest (and more readable) to use comparisons with the model.classId like this:

Code: Select all

switch(c.ClassId)                     // pick material
{
  case AsteroidModel.ClassId:  ...
  case PlayerModel.ClassId:  ...
If you compare against constants like 2, 3 etc it might change depending on the models position in the project tree.
fracteed
Posts: 43
Joined: Wed Apr 30, 2014 1:14 am
Location: Sydney

Post by fracteed »

Hi Kjell, I am somewhat familiar with Sunvox and have used it before, but I find the tracker interface does my head in! I do love the modular synth section of Sunvox though and I may export my midi files from Reaper into Sunvox. I want to get the game to a nearly finished state first, music would just be icing on the cake.

Thanks for your project file. Funnily enough I was originally using this approach of having the fragments within the model itself. What I was missing was your approach of the Zlibrary. I had no idea that you could create functions in ZGE, so this will be very useful!

One thing that has thrown me is this line:

Code: Select all

model m = i & 1 ? Red : Blue;
How does that work...is the question mark a c thing or is that native to ZGE?

And Ville, thanks for that code tip, it is much better like that.
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi fracteed,
fracteed wrote:I had no idea that you could create functions in ZGE, so this will be very useful!
You don't necessarily need to use a function ( although i do think it's the best choice for the situation ). A alternative solution would be to set the fragment material directly from the exploding model, and execute a script that spawns the fragments. Attached is same example as before, but using this approach.
fracteed wrote:Is the question mark a c thing or is that native to ZGE?
It's a C thing. It's called a conditional operator, which is basically a if-statement and assignment-operator combined. So, the following code would give the same result.

Code: Select all

model m;

if(i & 1)
{
	m = Red;
}
else
{
	m = Blue;
}
That part of the example isn't important though. All it does is spawn 4 Red and 4 Blue clones ;)

K
Attachments
Fragments.zgeproj
(2.97 KiB) Downloaded 431 times
fracteed
Posts: 43
Joined: Wed Apr 30, 2014 1:14 am
Location: Sydney

Post by fracteed »

Great explanation! I know python a lot better than I know C, so there are a lot of gaps in my knowledge. More of a scripter/artist than coder :)

I will dig into your other project when I have a chance....cheers for that.

Ok, my next problem is trying to get variables defined in the Definitions event of a model. I have attached a define variable component called "points" to one enemy model and then in the On Spawn event I have allocated the variable a value. Now this all works fine.

But when I try and do that with another model , of course I can't call the variable points because all components must have a unique name. How do I go about giving all models there own points value, without resorting to global variables.

I am getting that defined var mismatch error, and have read the documentation, but am stumped...
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

That's a problem in current ZGE, you need unique names.

So you have to name them Enemy1Points, Enemy2Points etc.

And then test by class id:

if(m.ClassId==Enemy1Model.ClassId)
m.Enemy1Points=42;
else if(m.ClassId==Enemy2Model.ClassId)
m.Enemy2Points=42;

etc.

This is something that needs addressing in future updates of ZGE.
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi fracteed,
fracteed wrote:More of a scripter/artist than coder :)
Same here ;)
fracteed wrote:How do I go about giving all models there own points value, without resorting to global variables.
This can be a bit of a problem / challenge yes ( not being able to use definitions that use the same name ). There are two primary solutions.

- If the models that you'd like to use the same variable name for are similar enough, it's worth considering using a single Model with multiple ModelStates instead of multiple Models.

- In case using ModelStates doesn't make much sense, use individual Models with unique Definition variables, but try to limit the amount of Definitions you're going to communicate with from outside the model.

Not exactly sure what you're working on, but i suspect you could use a single Model ( with perhaps a couple of ModelStates ) for your bullets. Then once a enemy is hit by a bullet, let the enemy check what kind of bullet it is / how much damage it causes, instead of the other way around.

K
Last edited by Kjell on Sat May 10, 2014 1:05 pm, edited 1 time in total.
fracteed
Posts: 43
Joined: Wed Apr 30, 2014 1:14 am
Location: Sydney

Post by fracteed »

Cheers Kjell, some good ideas there. I ended up going back to just using a global variable for points, and updating it at the same time the material for the fragments was being evaluated. Works fine, I was probably overcomplicatng it!

I do like your idea of multiple models in model states, and will keep that in mind for future use. lots of interesting ways to twist ZGE.

A few more questions, if you don't mind.

- What is the advantage of meshes under model definitions? I noticed some of the sample projects did that.

- The console displays the total number of models when a project is run, but is there any way of seeing the total number of triangles? Would be very useful for optimising.

- Is there any way of saving out components/hierarchies for use in another project...for instance reusing a sound or mesh component that I have created?

cheers :)
Post Reply