forum.boolean.name

forum.boolean.name (http://forum.boolean.name/index.php)
-   C++ (http://forum.boolean.name/forumdisplay.php?f=22)
-   -   Havok (http://forum.boolean.name/showthread.php?t=1753)

haedim 21.10.2006 15:38

Havok
 
http://necromanthus.com/Games/ShockW...FPS_Havok.html
Вот нашел туториал по Havok'у. Может это как - нибудь пригодится в C++ - прогинге (вопрос к спецам)? Если да, то это было бы ОЧЕНЬ полезно.

haedim 21.10.2006 15:44

Re: Havok
 
Еще хочу напомнить, что Havok изпользовался в такиз проектах как Half-Life 2 и Oblivion в качестве физического движка.

jimon 21.10.2006 18:35

Re: Havok
 
Havok стоит кучу денег :) большую кучу
да даже демку высылают - надо вводить телефоны и где живеш
так что практическая разработка под него не светит вообще
лутче уж юзать PhysX - возможности теже

Raiter 21.10.2006 19:50

Re: Havok
 
лучше писать свой и на блице :)

haedim 21.10.2006 20:25

Re: Havok
 
Ну, посмотрим. А насчет Физикса ты правильно заметил, Jimon - от тоже профессиональный.

jimon 21.10.2006 20:39

Re: Havok
 
1) написание своего физ. двига сравнимо по сложности с написанием своей операционки

2) physx в отличии от havok можно хотя бы скачать без особых проблем
и без особых проблем его юзать в простых проектах

haedim 17.11.2006 22:48

Re: Havok
 
Вот некоторые возможности Хавока:
http://www.youtube.com/watch?v=7f33GYOC2as
http://www.youtube.com/watch?v=sPqD0oe9lAM.
P. S. Марио жалко :) .

Render 19.11.2006 12:44

Re: Havok
 
Всё это легко реализовать на Физиксе. Посмотрел почти все ролики и в одном нашол коэчто интересное, оказывается Хавок по стабильности сочлений не уступает Физиксу, видимо алгоритмы похожие :). Там в самом конце кирпич при ударе отскакивает с линии сочления. в Физиксе такое намного стабильнее работает :)
http://www.youtube.com/watch?v=iHLwO...elated&search=

jimon 19.11.2006 15:24

Re: Havok
 
интересно а havok есть fluids ?
судя по сорсу хл2 немогу определить
там в модуле vphysics есть physics_fluid.cpp

вот header
Код:

//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================

#ifndef PHYSICS_FLUID_H
#define PHYSICS_FLUID_H
#pragma once

#include "vphysics_interface.h"

class IVP_Compact_Surface;
class IVP_Environment;
class IVP_Listener_Phantom;
class CBuoyancyAttacher;
class IVP_Liquid_Surface_Descriptor_Simple;
class CPhysicsObject;
class CPhysicsObject;

class CPhysicsFluidController : public IPhysicsFluidController
{
public:
        CPhysicsFluidController( CBuoyancyAttacher *pBuoy, IVP_Liquid_Surface_Descriptor_Simple *pLiquid, CPhysicsObject *pObject );
        ~CPhysicsFluidController( void );

        void SetGameData( void *pGameData );
        void *GetGameData( void ) const;

        void GetSurfacePlane( Vector *pNormal, float *pDist );

        class IVP_Real_Object *GetIVPObject();
        float GetDensity();

private:
        CBuoyancyAttacher                                        *m_pBuoyancy;
        IVP_Liquid_Surface_Descriptor_Simple *m_pLiquidSurface;
        CPhysicsObject                                                *m_pObject;
        void *m_pGameData;
};

extern CPhysicsFluidController *CreateFluidController( IVP_Environment *pEnvironment, CPhysicsObject *pFluidObject, fluidparams_t *pParams );


#endif // PHYSICS_FLUID_H

вот cpp
Код:

#include "vphysics_interface.h"
#include "physics_fluid.h"
#include "physics_object.h"
#include "physics_material.h"
#include "convert.h"

#include <stdio.h>

#include "ivp_physics.hxx"
#include "ivp_core.hxx"
#include "ivp_compact_surface.hxx"
#include "ivp_surman_polygon.hxx"
#include "ivp_templates.hxx"
#include "ivp_phantom.hxx"
#include "ivp_controller_buoyancy.hxx"
#include "ivp_liquid_surface_descript.hxx"

// NOTE: This is auto-deleted by the phantom controller
class CBuoyancyAttacher : public IVP_Attacher_To_Cores_Buoyancy
{
public:
    virtual IVP_Template_Buoyancy *get_parameters_per_core( IVP_Core *pCore );
    CBuoyancyAttacher(IVP_Template_Buoyancy &templ, IVP_U_Set_Active<IVP_Core> *set_of_cores_, IVP_Liquid_Surface_Descriptor *liquid_surface_descriptor_);

        float m_density;
};

CPhysicsFluidController::CPhysicsFluidController( CBuoyancyAttacher *pBuoy, IVP_Liquid_Surface_Descriptor_Simple *pLiquid, CPhysicsObject *pObject )
{
        m_pBuoyancy = pBuoy;
        m_pLiquidSurface = pLiquid;
        m_pObject = pObject;
}

CPhysicsFluidController::~CPhysicsFluidController( void )
{
        delete m_pLiquidSurface;
}

void CPhysicsFluidController::SetGameData( void *pGameData )
{
        m_pGameData = pGameData;
}

void *CPhysicsFluidController::GetGameData( void ) const
{
        return m_pGameData;
}

void CPhysicsFluidController::GetSurfacePlane( Vector *pNormal, float *pDist )
{
        ConvertPlaneToHL( m_pLiquidSurface->surface, pNormal, pDist );
        if ( pNormal )
        {
                *pNormal *= -1;
        }
        if ( pDist )
        {
                *pDist *= -1;
        }
}

IVP_Real_Object *CPhysicsFluidController::GetIVPObject()
{
        return m_pObject->GetObject();
}

float CPhysicsFluidController::GetDensity()
{
        return m_pBuoyancy->m_density;
}


IVP_Template_Buoyancy *CBuoyancyAttacher::get_parameters_per_core( IVP_Core *pCore )
{
        if ( pCore )
        {
                IVP_Real_Object *pivp = pCore->objects.element_at(0);
                CPhysicsObject *pPhys = static_cast<CPhysicsObject *>(pivp->client_data);

                // This ratio is for objects whose mass / (collision model) volume is not equal to their density.
                // Keep the fluid pressure/friction solution for the volume, but scale the buoyant force calculations
                // to be in line with the object's real density.  This is accompilshed by changing the fluid's density
                // on a per-object basis.
                float ratio = pPhys->GetBuoyancyRatio();

                if ( pPhys->GetShadowController() || !(pPhys->GetCallbackFlags() & CALLBACK_DO_FLUID_SIMULATION) )
                {
                        // NOTE: don't do buoyancy on these guys for now!
                        template_buoyancy.medium_density = 0;
                }
                else
                {
                        template_buoyancy.medium_density = m_density * ratio;
                }
        }
        else
        {
                template_buoyancy.medium_density = m_density;
        }

        return &template_buoyancy;
}

CBuoyancyAttacher::CBuoyancyAttacher(IVP_Template_Buoyancy &templ, IVP_U_Set_Active<IVP_Core> *set_of_cores_, IVP_Liquid_Surface_Descriptor *liquid_surface_descriptor_)
        :IVP_Attacher_To_Cores_Buoyancy(templ, set_of_cores_, liquid_surface_descriptor_)
{
        m_density = templ.medium_density;
}


CPhysicsFluidController *CreateFluidController( IVP_Environment *pEnvironment, CPhysicsObject *pFluidObject, fluidparams_t *pParams )
{
        pFluidObject->BecomeTrigger();

        IVP_Controller_Phantom *pPhantom = pFluidObject->GetObject()->get_controller_phantom();
        if ( !pPhantom )
                return NULL;

    // ------------------------------------
    // first initialize the water's surface
    // ------------------------------------
    // note that this surface is an infinite plane!
        for ( int i = 0; i < 4; i++ )
        {
                pParams->surfacePlane[i] = -pParams->surfacePlane[i];
        }

    IVP_U_Float_Hesse water_surface;
        ConvertPlaneToIVP( pParams->surfacePlane.AsVector3D(), pParams->surfacePlane[3], water_surface );
       
    IVP_U_Float_Point abs_speed_of_current_ws;
        ConvertPositionToIVP( pParams->currentVelocity, abs_speed_of_current_ws );

    IVP_Liquid_Surface_Descriptor_Simple *lsd = new IVP_Liquid_Surface_Descriptor_Simple(&water_surface, &abs_speed_of_current_ws);

    // ---------------------------------------------
    // create parameter template for Buoyancy_Solver
    // ---------------------------------------------
        // UNDONE: Expose these other parameters
    IVP_Template_Buoyancy buoyancy_input;
    buoyancy_input.medium_density                        = ConvertDensityToIVP(pParams->density); // density of water (unit: kg/m^3)
    buoyancy_input.pressure_damp_factor    = pParams->damping;
    buoyancy_input.viscosity_factor      = 0.0f;
    buoyancy_input.torque_factor          = 0.01f;
    buoyancy_input.viscosity_input_factor = 0.1f;
    // -------------------------------------------------------------------------------
    // create "water" (i.e. buoyancy solver) and attach a dynamic list of object cores
    // -------------------------------------------------------------------------------
    CBuoyancyAttacher *attacher_to_cores_buoyancy = new CBuoyancyAttacher( buoyancy_input, pPhantom->get_intruding_cores(), lsd );

        CPhysicsFluidController *pFluid = new CPhysicsFluidController( attacher_to_cores_buoyancy, lsd, pFluidObject );
        pFluid->SetGameData( pParams->pGameData );
        pPhantom->client_data = static_cast<void *>(pFluid);

        return pFluid;
}



bool SavePhysicsFluidController( const physsaveparams_t &params, CPhysicsFluidController *pFluidObject )
{
        return false;
}

bool RestorePhysicsFluidController( const physrestoreparams_t &params, CPhysicsFluidController **ppFluidObject )
{
        return false;
}

но именно предназначение его не понятно :)

ps. сорс хл2 такой большой - 172 метра
а выдрать нечего :)
разве что систему материалов ... и гуи


Часовой пояс GMT +4, время: 18:02.

vBulletin® Version 3.6.5.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot