PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Several objects

Hello,

I'm trying to load several objects, but it doesn't work like I want. I explain myself:

If an object is inside another one, they seem that they are superposed. For example, I have two objects in format 3ds. A cup and a spoon. The spoon is inside the cup. If I load both objects with 3D studio, is correctly. But when I load them with the EDGELIB functions it seems that the spoon is outside the cup.

How can I do to get this effect?
Have I explained myself well? I must apologize for my English. I'm sorry.:oops:

Thanks a lot. :lol:
Hi Meiline,

Can you tell me which method you use for rendering the 3D objects?

If you're using the EDGELIB internal renderer, it's currently not possible to do proper object sorting when drawing multiple objects. The best way to solve it is to merge the objects before rendering.
Hi!

First of all, thanks for the answer.

My code is like this:
In OnDisplayInit
Code:


if (display->CreateSurface(∪, "cup.3ds") != E_OK)
return(E_ERROR);
if (display->CreateSurface(&spoon;, "spoon.3ds") != E_OK)
return(E_ERROR);



And then I draw the models
Code:


display->Render(∪);
display->Render(&spoon;);



I'm learning with the samples and the tutorials.

I'll try to merge the objects before rendering.

I suppose one solution could be having only one object, for example "CupSpoon.3ds" But I need the objects separated. I'd like to animate the spoon like stiring the sugar into the coffee ;-).

Thanks a lot.
Hi again!

I have tried to merge the objects, but I don't achieve my purpose.

I have read: "Setting up the OpenGL ES display is handled by the Edge SDK, enabling developers to start outputting 3D models right away. In addition, Edge's existing E3DSurface interface can be used in combination with the 3D Studio Max 3DS loader to easily load 3D models in OpenGL ES powered applications."

So my question now is: If I load my 3ds object in E3DSurface, ¿how can I render it with OpenGL ES? ¿Is it possible?

Thanks a lot of. Best regards.
Im no expect on the subject so could be way off here but, wouldn't you have to first move the spoon surface inside the 3d space of the cup?

Without first moving the spoon it would appear in front of the cup but if you moved the spoons z axis to be in the range of the cups it would give the effect it is inside it.

Or maybe it is because you are rendering the cup and THEN the spoon?

Just a guess...
Hi Rye,

Thanks for your guess.

If I render the cup and then the spoon, the effect is "the spoon is in front of the cup". If I render the spoon first, the result is "spoon is behind the cup"
I'd like to have the effect "the spoon is inside the cup" That means: if you see the scene in one part the cup cover the spoon, but in another part, the spoon cover the cup

Thanks anyway!! :)
napoleondynamite · 18 May 2007, 13:36 UTC
There is no spoon.

Sorry, I couldn't resist! No idea how to fix your problem, though :wink:
Hi Meiline,

To enable OpenGL ES, you can define EGL_USEGL before including edgemain.h and link the necessary libraries. It may be needed to download an SDK, for example PowerVR or Rasteroid.

For more information look at the View3D and Animate3D samples or read our tutorial here: http://www.edgelib.com/index.php?node=1093
meiline wrote:If I render the cup and then the spoon, the effect is "the spoon is in front of the cup". If I render the spoon first, the result is "spoon is behind the cup".


This sounds more like a depth problem, i.e. under OpenGLES, if I choose a configuration which doesn't have a depth buffer, then the output depends on the drawing order (last drawn object is on top). Choosing a depth buffer enabled configuration gives me the right result, independent of the order I draw my objects in.

I don't know much about E3DSurfaces but I assume that they must have a concept of depth as well.

HTH
Well, actually it's a problem with depth sorting in the internal EDGELIB renderer (which isn't based on OpenGL and doesn't have a z-buffer). The internal EDGELIB renderer is used when OpenGL isn't enabled.

Both objects are rendered by z-sorting the polygons. Because the first object is already drawn before the second object, the second object will be rendered on top of that without looking at the rotation or position of the objects. The only solution for this would be to draw both objects in one render call. Of course, this only applies when using the internal EDGELIB renderer instead of using OpenGL.

When OpenGL is enabled, it will render properly because OpenGL has a z-buffer. This buffer is automatically enabled in the OpenGL configuration.
edge wrote:
To enable OpenGL ES, you can define EGL_USEGL before including edgemain.h and link the necessary libraries. It may be needed to download an SDK, for example PowerVR or Rasteroid.

For more information look at the View3D and Animate3D samples or read our tutorial here: http://www.edgelib.com/index.php?node=1093


Hello Edge

Thanks a lot for your answer.

I knew to use OpenGL I must to define EGL_USEGL. But by question was how can I render an object if I load it with EDGELIB. I mean: I have my objects in E3DSurface.

I suppose that the render isn't:

Code:
display->Render(∪);
Hi Meiline,

Actually, the call to display->Render(∪) will have the ability to render to OpenGL. If OpenGL is enabled, first call display->Perspective3D before calling display->Render(). For an example, please look at the view3D sample, bundled with the SDK.
edge wrote:
Actually, the call to display->Render(∪) will have the ability to render to OpenGL. If OpenGL is enabled, first call display->Perspective3D before calling display->Render(). For an example, please look at the view3D sample, bundled with the SDK.


Hi Edge,

Thanks very much for your patience and your answers.

I've got a new question. I have looked the View3D sample and it's clear, but when I try to following it, I have some doubts. My problem is related to #define EGL_USEGL

The example says:
Code:

//Use a GL library if an implementation has been defined in the workspace
#if defined(EGL_PC) || defined(EGL_SYMBIAN) || defined(EGL_RASTEROID) || defined(EGL_POWERVR)
#define EGL_USEGL
#if !defined(EGL_PC)
#define EGL_USEGLES
#endif
#endif

//Include Edge
#include "edgemain.h"

//Link the Edge static library
#pragma comment(lib, "edge.lib")

//Include headers and link OpenGL libraries
#if defined(EGL_USEGL)
#if defined(EGL_USEGLES)
#include "GLES\\gl.h"
#include "GLES\\egl.h"
#else
#include "GL\\gl.h"
#endif
#if defined(DEVICE_WIN32)
#if defined(EGL_PC)
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "plugingl.lib")
#elif defined(EGL_POWERVR)
#pragma comment(lib, "libgles_cl.lib")
#pragma comment(lib, "pluginpowervr.lib")
#elif defined(EGL_RASTEROID)
#pragma comment(lib, "libEGL.lib")
#pragma comment(lib, "libGLES_CM_NoE.lib")
#pragma comment(lib, "pluginrasteroid.lib")
#endif
#endif
#endif


If I use the #define EGL_USEGL, I've got the following error: "Couldn't open the display device".

My application is for a pocket PC.

If I remove this and I only use #define EGL_USEGLES, It is ok, but the render is like the internal EDGELIB renderer. I can't solve my problem.

Thanks again.
Hi Meiline,

Can you tell me which OpenGL ES implementation you're using? Would you like to recompile the View3D sample and try to run it on your device? Does it generate an error message?

If the problem only occurs with your project we recommend adding an EGL_POWERVR or EGL_RASTEROID definition to your Embedded Visual C++ project. If you're using the Edge IDE you can see this definition when editing the project file with a text editor.
edge wrote:Hi Meiline,
If the problem only occurs with your project we recommend adding an EGL_POWERVR or EGL_RASTEROID definition to your Embedded Visual C++ project. If you're using the Edge IDE you can see this definition when editing the project file with a text editor.


Hi edge. Thanks for your help.

The problem happens when I don't use either PowerVR or Rasteroid, and also when I try to use Rasteroid. If I use PowerVR this error doesn't happen.
But if I use PowerVR, the objects don't appear on the screen. Even the background isn't showed.
Hi,

Can you tell me more about the device you're targetting? Also, would you like to build the View3D sample with the EdgeIDE and tell me the results?

Thanks.
edge wrote:Hi,

Can you tell me more about the device you're targetting? Also, would you like to build the View3D sample with the EdgeIDE and tell me the results?

Thanks.


Hi edge,

My device is an old Pocket PC Toshiba e800. I'm going to change it in a few weeks, but for the moment...

I tried to build the View3D sample with the EdgeIDE. I get the following error:

Can't execute command '"C:\Program Files\Microsoft eMbedded C++ 4.0\Common\EVC\Bin\rc"

That is because I don't have Microsoft eMbedded in this path. Can I change the path to build it?
meiline wrote:
Can't execute command '"C:\Program Files\Microsoft eMbedded C++ 4.0\Common\EVC\Bin\rc"

That is because I don't have Microsoft eMbedded in this path. Can I change the path to build it?


Ok, I have edited file: winmobile-ppc_2003.ini and other files.
the result is:
---------------- Building: view3d - WM Pocket PC (2003) Release ----------------
view3d.ico
view3d.res
view3d.cpp
LINK : warning LNK4089: all references to 'WS2.dll' discarded by /OPT:REF

view3d.exe


If I want to run it on my device, what have I do?
I have tried to copy the files to my device, but it said: "Cannot find 'View3d' (or one of its components) Make sure the path and filename are correct and all the required libraries are available"

It could be because of the warning LNK4089?
Well, I have used the setup file to execute the View3D in my device. It runs properly.

I have tried to make a setup of my program with EdgeIDE (Build -> build setup) but it doesn't work.

Could you help me to make a setup file?

thanks.
Hi Meiline,

Your application probably doesn't run on the device because it's missing a DLL file.

If you're using rasteroid, you need to copy libEGL.dll and libGLES_CM_NoE.dll to your device along with your program executable. If you're using PowerVR, the device must have 3D hardware and drivers installed.

Building .CAB setups is currently not possible with the EdgeIDE yet. An example on how to create a setup file can be seen in the View3D/setup folder. It contains cabwiz, the tool for creating .CAB files. It also contains an .inf file and batch file for building the setup file.
Hi Edge

Thanks for your help :)

I can run my application on my device. However, I'm using rasteroid, but the render is the same without it. I thought my problem with several objects would be solved using OpenGL render...
Hello again

I'm sorry for being so annoying :oops:

I think the render is the same because actually, my program doesn't use rasteroid.

I have:

Code:

#if !defined(__EDGEIDE__)
#define EGL_RASTEROID
#endif

#if defined(EGL_PC) || defined(EGL_SYMBIAN) || defined(EGL_RASTEROID) || defined(EGL_POWERVR)
#define EGL_USEGL
#if !defined(EGL_PC)
#define EGL_USEGLES
#endif
#endif


I have tried to do my render like here:

Code:

#if defined(EGL_USEGL)
display->BindTexture(&tex;);
display->SetShading(rendertype_shading[rendertype]);
display->Render(∪);
#endif


And the object isn't rendered. So I suppose the EGL_USEGL isn't defined... right? :wink:

Now, I have:

Code:

#define EGL_RASTEROID
#define EGL_USEGL
#define EGL_USEGLES

#include "GLES\\gl.h"
#include "GLES\\egl.h"

#pragma comment(lib, "libEGL.lib")
#pragma comment(lib, "libGLES_CM_NoE.lib")
#pragma comment(lib, "pluginrasteroid.lib")


But when I execute my program the screen is white.
The object doesn't appear.
Hi Meiline,

Can you tell me if you're defining the symbols before including edgemain.h? Because the EGL_USEGL definition only takes effect when defining it before including edgemain.h.
Hello Edge,

Yes, I'm defining the symbols before including edgemain.h

Code:

#define EGL_RASTEROID
#define EGL_USEGL
#define EGL_USEGLES


// Include and link the library

//Include Edge
#include "edgemain.h"

//Link the Edge static library
#pragma comment(lib, "edge.lib")

#include "GLES\\gl.h"
#include "GLES\\egl.h"

#pragma comment(lib, "libEGL.lib")
#pragma comment(lib, "libGLES_CM_NoE.lib")
#pragma comment(lib, "pluginrasteroid.lib")

Hi Meiline,

Perhaps you can attach your project workspace and source files? I think we're able to help you better if we see the source.

You can also mail it to support "at" edgelib "dot" com.

Thanks.
Hello Edge!

I have solved my problem starting with one of the examples and changing the code. :D

I don't know what was wrong with my code, I had all the paths, includes, etc. like now... :roll:

Thanks again for your help.

Best Regards