Jump to content

Shard

Members
  • Posts

    293
  • Joined

  • Last visited

Posts posted by Shard

  1. It's a custom User Control which deeply use the C# wrapper classes. However the source is free available on the Google Code space (you should use a SVN client like TortoiseSVN to download the branch: /trunk/Leadwerks.Controls).

     

    EDIT: I'm writing some tutorials on C# in the C# Programming section of tutorials, more coming next.

     

    RE-EDIT: the thing you're speaking about (adjusting controls on a form when something happens on the LE's control) should be simple in C#, I would try something later since I need a kind of little editor too.

     

    Yes, the system would be useful in many ways.

    Altho I am resistant to learn C#, I think it would definitely be helpful to further my horizons and have another language under my belt.

  2. I may be confused here as to what you are asking. Anyway. I doubt the render control can easily be ported to C++ with all the GUI libraries around. I would strongly urge you not too use C++ for creating a GUI-heavy application anyway because C# is far better at it. It basically is just drag-and-drop.

     

    I do not have a sample lying around though, sorry :)

     

    Yea but its also drag and drop in C++ in a Windows Form application.

    The reason I'm stressing for C++ is because I want to get this product out rather than learn C#.

    And I do know that they are similar, but they are not the same and this will slow me down.

     

    Edit: Is the render controller source avaliable so that I can try to port it myself?

    I really need a Windows Forms app instead of something like CEGUI.

     

    Edit: Can someone outline the process of creating a Windows Forms Application with Leadwerks in C#(maybe a tutorial?)

    Again the basic idea is that in the center of the screen there is the Leadwerks window which runs all the time. On the left and right are context menus that display information based off of the item selected on screen be able able to transmit data and check data in boxes, etc.

    For example, if I click on the planet on the Leadwerks window, on the right bar, all the relevant boxes will come up and then in the right box, I can set the mass to be 100. Then I can click apply and the mass of the planet becomes 100 in the Leadwerks game.

  3. With C# you can create a Windows Form application and then "draw it" drag&dropping components from a huge list (and the C# community has released a NET control to render LE inside it, thanks to klepto).

     

    But if you want to code in C++ then Pixel Perfect has published a showcase some days ago for its own navArea editor in which he has the scene rendered in an area of the window (may be you need GL commands), may be he can help.

     

     

    I've asked Pixel to take a look at this thread.

     

    Is it possible for someone to post a sample project in C# so that I can take a look at how its setup.

     

    Also, would it be possible to port the wrapper to C++?

  4. I would suggest to do it in C# if you can, for anything UI related I think C# is much more simpler than C++ and we already have a render control that you can add in a .NET Windows Form.

     

    Could you explain this a bit more as I have not done much C# and I don't know anything about the render controls or .NET.

    Also, I'm far more proficient in C++ and I would much rather code this sim in C++. Is there anyway to do this in C++?

  5. Is it possible to use windows forms with Leadwerks?

     

    The basic setup I'm trying to do is have buttons and value boxes on the bars on the sides of the main window with a Leadwerks window rendering things in the center.

     

    The reason I need this is because I'm looking to do a fairly complicated UI with multiple options and settings but I don't need the UI to be run on top of Leadwerks, since this is not for a game (for that, I'll be using CEGUI) and instead for a sim.

     

    Is this possible?

  6. You don't need to use 2D drawing, but you can use 3D lines to connect real vertices with lines:

    http://leadwerks.com/werkspace/index.php?/page/resources/_/programming/cpp/using-opengl-for-drawing-r19

     

     

    Just glancing at it, this seems a little bit complicated. But alas, I do need it so I'll have to put some time into learning how to do it.

    I suppose I'll just make a wrapper of sorts and tie it in with my sim initialization/drawing methods.

  7. Glancing over the code in that tutorial it may be fairly complicated although it has a far wider use. A perhaps somewhat easier solution would be to simply render a plane with a transparent texture that has an opaque circle on it and then scaling the plane to represent the correct orbit.

     

    This doesn't quite work.

     

    Because the orbits are based off of the gravitational pulls from the planets around it and the user will have the ability to move planets around, the orbit could be a perfect circle, an oval or not a shape at all and instead just a line.

  8. Just reviving this thread as I didn't get an answer last time but Josh showed us all a video of Newton doing some destructible objects way back in December.

     

    We haven't heard about this since then and I'm just wondering what happened to it.

     

    Currently I am only looking for destructibility on primitives (mostly spheres) for my solar system simulator (so that when planetary collisions happen or tidal forces tear a planet apart).

     

     

    Anyone know anything about this?

  9. This is a fairly complicated question so I hope I present it correctly.

     

    I am looking to draw the orbit of planets for my solar system simulation and I'm not sure how to go about it.

     

    Last time I tried this (with DarkGDK) I drew several spheres to show the line of the orbit, which then looked correct when viewed from a distance, but was very inefficient.

     

    As far as the orbit code goes, I will figure that out using code (which in theory will give me a mathematical function) for what the orbit is. I am hoping I can use this in some way so that I can draw the orbit of the planets using 2D drawing to the screen.

     

     

    Does anyone have any suggestions of how to do this?

  10. It is, the R5/R6 etc is not official versioning, but the community makes up those microversions since 2.32 has been updated several times. 6 times so far, thus R6 now. Josh should really use the industrial standard notation like 0.0.0.0 versions, so it would be 2.3.2.6 now :lol:

     

    Please, this would be so much nicer for tracking of versions.

  11. What is the proper method for loading water?

     

    We had water working in our project a while ago, but since then I have been testing it with water turned off. Now that I turn it back on, water doesn't show up properly.

     

    The current problem is that the water is always at 1 for its height, no matter how I set it in the editor.

     

     

    What is the proper method for loading water? What files need to be included so that it loads properly?

     

     

    Thanks.

  12. So it seems that something is wrong with my Media class because I can play the video when I put your code into my main and run it but when I try to run it through my media class, it always crashes at the same location, the CreateClip function T_T

     

     

    Please take a look at my media class and tell me what I'm doing wrong with it.

     

    // Header File

    #pragma once
    
    #pragma comment(lib,"libtheoraplayer.lib")
    #pragma comment(lib,"opengl32.lib")
    #pragma comment(lib,"openal32.lib")
    
    #include "Include.h"
    
    #include <windows.h>
    #include "engine.h"
    #include <gl/gl.h>
    #include "TheoraVideoManager.h"
    #include "TheoraVideoFrame.h"
    #include "OpenAL_AudioInterface.h"
    
    
    class Media
    {
    
    private:
    int nextPow2(int x);
    
    TheoraVideoClip *clip;
    TheoraVideoManager *manager;
    OpenAL_AudioInterfaceFactory *iface_factory;
    
    float w;
    float h;
    
    float tw;
    float th;
    
    TBuffer testbuffer;
    TTexture testtexture;
    TMaterial testmaterial;
    
    public:
    
    bool eax;
    Framework *frameWork;
    
    
    Media();
    
    void PlaySoundFile(string &nonAbstractFileName, bool loop = false, float volume = 10);
    void PlaySoundFile(TSound &sound, float volume = 10, bool loop = false);
    void PlaySoundSource(TSource &source, float volume = 10, bool loop = false);
    
    TSource LoadSoundFile(string fileName);
    
    void PlayVideo(string &nonAbstractFileName, bool autoRestart = false,  bool skippable = true);
    void PlayVideo(TheoraVideoClip *clip, bool skippable = true);
    
    TheoraVideoClip* LoadVideo(string &fileName, bool autoRestart = false);
    
    void Update();
    void Initialize();
    };

     

     

     

    //CPP

    #include "Media.h"
    
    
    Media::Media()
    {
    clip = NULL;
    manager = NULL;
    
    }
    
    void Media::PlaySoundFile(string &nonAbstractFileName, bool loop, float volume)
    {
    nonAbstractFileName = "abstract::" + nonAbstractFileName;
    TSound sound = LoadSound(str(nonAbstractFileName.c_str()));
    PlaySoundFile(sound,loop,volume);
    }
    
    void Media::PlayVideo(string &nonAbstractFileName, bool autoRestart, bool skippable)
    {
    nonAbstractFileName = "abstract::" + nonAbstractFileName;
    nonAbstractFileName = AbstractPath(str(nonAbstractFileName.c_str()));
    
    this->clip = LoadVideo(nonAbstractFileName,autoRestart);
    PlayVideo(this->clip,skippable);
    }
    
    TheoraVideoClip* Media::LoadVideo(string &fileName, bool autoRestart)
    {
    TheoraVideoClip *clip = manager->createVideoClip(fileName, TH_RGB, 0, 1);
    clip->setAutoRestart(autoRestart);
    
    return clip;
    }
    
    void Media::PlayVideo(TheoraVideoClip *clip, bool skippable)
    {
    
    float w = clip->getWidth();
    float h = clip->getHeight();
    
    float tw = nextPow2(w);
    float th = nextPow2(h);
    
    TTexture videotexture = CreateTexture( tw, th, TEXTURE_RGB );
    
    TheoraVideoFrame* f = clip->getNextFrame();
    
    unsigned long time = GetTickCount();
    unsigned long t = time;
    
    bool exitVideo = true;
    
    while(f || exitVideo == true)
    {
    	TheoraVideoFrame *f = clip->getNextFrame();
    
    	if(f)
    	{
    		BindTexture(videotexture);
    		glTexImage2D( GL_TEXTURE_2D,0, GL_RGB, w-1, h-1, 0, GL_RGB, GL_UNSIGNED_BYTE, f->getBuffer() );
    		clip->popFrame();
    	}
    
    	t=GetTickCount();
    	float diff=(t-time)/1000.0f; 
    	if (diff > 0.25f) diff=0.05f; // prevent spikes (usually happen on app load)                                
    	manager->update(diff);
    	time=t;
    
    	// Update timing and world
    	UpdateAppTime();
    	UpdateWorld(AppSpeed()) ;
    
    	// Render
    	frameWork->Update();
    	frameWork->Render();
    
    
    	DrawImage(videotexture,0,0,GraphicsWidth(),GraphicsHeight() );
    
    	// Send to screen
    	Flip(0) ;
    
    
    }
    }
    
    void Media::PlaySoundFile(TSound &sound, float volume, bool loop)
    {
    TSource source;
    
    if(!loop) source = CreateSource(sound);
    else source = CreateSource(sound,SOURCE_LOOP);
    
    PlaySoundSource(source);
    }
    
    void Media::PlaySoundSource(TSource &source, float volume, bool loop)
    {
    volume = Clamp(volume,0,10);
    
    PlaySource(source);
    SetSourceVolume(source,volume);
    
    FreeSource(source);
    }
    
    TSource Media::LoadSoundFile(string fileName)
    {
    fileName = "abstract::" + fileName;
    
    TSound sound = LoadSound(str(fileName.c_str()));
    TSource source = CreateSource(sound);
    
    return source;
    }
    
    void Media::Update()
    {
    
    }
    
    int Media::nextPow2(int x)
    {
    int y;
    for (y=1;y<x;y*=2);
    return y;
    }
    
    void Media::Initialize()
    {
    manager = new TheoraVideoManager();
    this->iface_factory = new OpenAL_AudioInterfaceFactory();
    
    manager->setAudioInterfaceFactory(iface_factory);
    manager->setDefaultNumPrecachedFrames(32);
    
    }

     

     

    //Usage

    Media *media = new Media;
    
    media->Initialize();
    media->frameWork = [frameWork Reference];
    
    string vid = "bunny.ogg";
    media->PlayVideo(vid);
    
    

     

     

    //This Works Fine

    //	====================================================================
    //	This file was generated by Leadwerks C++/LEO/BlitzMax Project Wizard
    //	Written by Rimfrost Software
    //	http://www.rimfrost.com 
    //	====================================================================
    #pragma comment(lib,"libtheoraplayer.lib")
    #pragma comment(lib,"opengl32.lib")
    #pragma comment(lib,"openal32.lib")
    
    #include <windows.h>
    #include "engine.h"
    #include <gl/gl.h>
    #include "TheoraVideoManager.h"
    #include "TheoraVideoFrame.h"
    #include "OpenAL_AudioInterface.h"
    
    int nextPow2(int x)
    {
    int y;
    for (y=1;y<x;y*=2);
    return y;
    }
    
    int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) 
    {
    
    Initialize() ;
    SetAppTitle( "hello_video" ) ;
    Graphics( 1024, 600 ) ;
    
    TWorld	world;
    TBuffer gbuffer;
    TCamera camera;
    
    world = CreateWorld() ;
    gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);
    camera=CreateCamera();
    
    
    // THEORA SETUP THEORA SETUP THEORA SETUP THEORA SETUP
    // THEORA SETUP THEORA SETUP THEORA SETUP THEORA SETUP
    // THEORA SETUP THEORA SETUP THEORA SETUP THEORA SETUP
    // THEORA SETUP THEORA SETUP THEORA SETUP THEORA SETUP
    TheoraVideoManager *mgr = new TheoraVideoManager();
    OpenAL_AudioInterfaceFactory *iface_factory=new OpenAL_AudioInterfaceFactory();
    mgr->setAudioInterfaceFactory(iface_factory);
    mgr->setDefaultNumPrecachedFrames(32);
    
    //TheoraVideoClip *clip = mgr->createVideoClip( "bunny.ogg",TH_RGB,0,1);
    TheoraVideoClip *clip = mgr->createVideoClip( "bunny.ogg",TH_RGB,0,1);
    clip->setAutoRestart(1);
    float w = clip->getWidth();
    float h = clip->getHeight();
    float tw = nextPow2(w);
    float th = nextPow2(h);
    
    TTexture videotexture = CreateTexture( tw, th, TEXTURE_RGB );
    // THEORA SETUP THEORA SETUP THEORA SETUP THEORA SETUP
    // THEORA SETUP THEORA SETUP THEORA SETUP THEORA SETUP
    
     unsigned long time=GetTickCount();                
     unsigned long t=time;
    
    // Game loop
    while( !KeyHit() && !AppTerminate() )
    {
    	if( !AppSuspended() ) // We are not in focus!
    	{		
    
    		// THEORA CODE UPDATE TEXTURE 
    		// THEORA CODE UPDATE TEXTURE  
    		TheoraVideoFrame *f = clip->getNextFrame();
    		if(f)
    		{
    			BindTexture(videotexture);
    			glTexImage2D( GL_TEXTURE_2D,0, GL_RGB, w-1, h-1, 0, GL_RGB, GL_UNSIGNED_BYTE, f->getBuffer() );
    			clip->popFrame();
    		}
    		//mgr->update(AppSpeed());
    		// THEORA CODE UPDATE TEXTURE
    
    		t=GetTickCount();
    		float diff=(t-time)/1000.0f; 
    		if (diff > 0.25f) diff=0.05f; // prevent spikes (usually happen on app load)                                
    		mgr->update(diff);
    		time=t;
    
    
    		// Update timing and world
    		UpdateAppTime();
    		UpdateWorld(AppSpeed()) ;
    
    		// Render
    		SetBuffer(gbuffer);
    		RenderWorld();
    		SetBuffer(BackBuffer());
    		RenderLights(gbuffer);
    
    		// THEORA "PLAYBACK" 
    		// THEORA "PLAYBACK" 
    		DrawImage(videotexture,0,0,GraphicsWidth(),GraphicsHeight() );
    
    		// Send to screen
    		Flip(0) ;
    	}
    }
    
    // Done
    return Terminate() ;
    }
    

     

    Why isn't it working D:<

     

    Edit: The release version doesn't run at all if the Initialize function is allowed to happen. But I think this occurs in VS2010 and works fine in 2008 but the results are not consistent.

     

    Anyone know how to remedy this?

  13. Hmm sound works for me - in bunny.ogg and my own transcoded file, don't know if this will help but I attached a screenshot from the settings I used in SUPER

     

     

    Thanks, changing the bitrate to 128 fixed the problem but created a new one. (of course >,>)

     

    The audio files we have play at 96kbps so when the this->iface_factory = new OpenAL_AudioInterfaceFactory(); is set it plays the audio files faster to compensate for the speed.

     

    Is there some way to set the playback speed of video files? The other options for me would be to increase the audio files to 128 or set and unset the iface every time I play and finish a video.

  14. possibly... but i do not know if Josh considers it a bug... his description of it basically is this is when the pick structure is first being created...

     

    Still did it in Release Mode.

     

     

     

    I tried it with the sample crawler model and now it does not appear anymore on the Model Viewer (I already posted a comment reporting it) but still visible when loaded by code, didn't tried on the Editor, really I didn't noticed any difference in the picking delay.

     

    So... what do we do to fix the problem?

  15. what youve never noticed this forum?

     

    Nope, I usually just click the C++ shortcut on the Werkspace page. Plus its a hidden from view unless I scroll down.

     

     

     

    possibly... but i do not know if Josh considers it a bug... his description of it basically is this is when the pick structure is first being created...

     

    Hrm, only in debug mode. I haven't tested this, but if thats the case then I can live with cause as long as Release works its all good.

  16. there are alot of posts about this... and actually Josh created a model optimizer to help with this...

     

    But it also happens with the terrain.

     

     

    btw, why do you put all of your posts in GD? there are obviously better places for your programming/modeling questions... :blink:

     

    Seemed appropriate in this case as this involves everyone, not just coders. I post in the C++ threads when its just about code and Editor when its just about Editor. There isn't an overall engine discussion thread except General Discussion which is the general discussion of the engine WerkSpace> Leadwerks Engine> General Discussion

  17. When using EntityPick, I've noticed that my game stalls for a few seconds and then continues to run as normal. This happens the first time a pick happens at a high poly surface or at least it seems like that.

     

    At first I thought this was because of DOF, but I turned that off because it became a large enough problem. But now when our character shoots, it does a pick to see what it hit and it freezes up just the same.

     

    I'm just checking to see if anyone else has had this problem and how they fixed it. If not, I'll create a basic program and upload to bug tracker.

  18. I basically use the same settings, .. you'll have to create a power of 2 texture (you already used niosop's code for that in your example) and the code to prevent 'spikes' ..

     

     

    Thanks for that. The video is showing now, but there is no sound. What do I do about that? The sound works fine in VLC.

     

    Heres the code:

     

    //	====================================================================
    //	This file was generated by Leadwerks C++/LEO/BlitzMax Project Wizard
    //	Written by Rimfrost Software
    //	http://www.rimfrost.com 
    //	====================================================================
    #pragma comment(lib,"libtheoraplayer.lib")
    #pragma comment(lib,"opengl32.lib")
    #pragma comment(lib,"openal32.lib")
    
    #include <windows.h>
    #include "engine.h"
    #include <gl/gl.h>
    #include "TheoraVideoManager.h"
    #include "TheoraVideoFrame.h"
    #include "OpenAL_AudioInterface.h"
    
    int nextPow2(int x)
    {
    int y;
    for (y=1;y<x;y*=2);
    return y;
    }
    
    int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) 
    {
    
    Initialize() ;
    SetAppTitle( "hello_video" ) ;
    Graphics( 1024, 600 ) ;
    
    TWorld	world;
    TBuffer gbuffer;
    TCamera camera;
    
    world = CreateWorld() ;
    gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);
    camera=CreateCamera();
    
    
    // THEORA SETUP THEORA SETUP THEORA SETUP THEORA SETUP
    // THEORA SETUP THEORA SETUP THEORA SETUP THEORA SETUP
    // THEORA SETUP THEORA SETUP THEORA SETUP THEORA SETUP
    // THEORA SETUP THEORA SETUP THEORA SETUP THEORA SETUP
    TheoraVideoManager *mgr = new TheoraVideoManager();
    OpenAL_AudioInterfaceFactory *iface_factory=new OpenAL_AudioInterfaceFactory();
    mgr->setAudioInterfaceFactory(iface_factory);
    mgr->setDefaultNumPrecachedFrames(32);
    
    //TheoraVideoClip *clip = mgr->createVideoClip( "bunny.ogg",TH_RGB,0,1);
    TheoraVideoClip *clip = mgr->createVideoClip( "bunny.ogg",TH_RGB,0,1);
    clip->setAutoRestart(1);
    float w=clip->getWidth();
    float h=clip->getHeight();
    float tw = nextPow2(w),th=nextPow2(h);
    
    TTexture videotexture = CreateTexture( tw, th, TEXTURE_RGB );
    // THEORA SETUP THEORA SETUP THEORA SETUP THEORA SETUP
    // THEORA SETUP THEORA SETUP THEORA SETUP THEORA SETUP
    
     unsigned long time=GetTickCount();                
     unsigned long t=time;
    
    // Game loop
    while( !KeyHit() && !AppTerminate() )
    {
    	if( !AppSuspended() ) // We are not in focus!
    	{		
    
    		// THEORA CODE UPDATE TEXTURE 
    		// THEORA CODE UPDATE TEXTURE  
    		TheoraVideoFrame *f = clip->getNextFrame();
    		if(f)
    		{
    			BindTexture(videotexture);
    			glTexImage2D( GL_TEXTURE_2D,0, GL_RGB, w-1, h-1, 0, GL_RGB, GL_UNSIGNED_BYTE, f->getBuffer() );
    			clip->popFrame();
    		}
    		//mgr->update(AppSpeed());
    		// THEORA CODE UPDATE TEXTURE
    
    		t=GetTickCount();
    		float diff=(t-time)/1000.0f; 
    		if (diff > 0.25f) diff=0.05f; // prevent spikes (usually happen on app load)                                
    		mgr->update(diff);
    		time=t;
    
    
    		// Update timing and world
    		UpdateAppTime();
    		UpdateWorld(AppSpeed()) ;
    
    		// Render
    		SetBuffer(gbuffer);
    		RenderWorld();
    		SetBuffer(BackBuffer());
    		RenderLights(gbuffer);
    
    		// THEORA "PLAYBACK" 
    		// THEORA "PLAYBACK" 
    		DrawImage(videotexture,0,0,GraphicsWidth(),GraphicsHeight() );
    
    		// Send to screen
    		Flip(0) ;
    	}
    }
    
    // Done
    return Terminate() ;
    }
    

  19. Are there any plans for soft body collisions?

     

    Also, is there a way to set different collision values on different parts of an object? Like for a tree, where the trunk is 100% resistive and the low branches and leaves are only 20% resistive so that if the player keeps pushing, they will eventually make it through.

×
×
  • Create New...